Difference between revisions of "GPIO/zh"
From FriendlyELEC WiKi
(updated by API) |
|||
(One intermediate revision by one other user not shown) | |||
Line 29: | Line 29: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
每一组之间差32,是通过cat gpiochip0/ngpio查看的 | 每一组之间差32,是通过cat gpiochip0/ngpio查看的 | ||
+ | |||
+ | ===RK3399下计算Linux gpio索引号的方法=== | ||
+ | 用以下命令看GPIO针脚<br/> | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | cat /sys/kernel/debug/gpio | ||
+ | </syntaxhighlight> | ||
+ | T4下的输出如下所示: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | GPIOs 0-31, platform/pinctrl, gpio0: | ||
+ | gpio-1 ( |vcc_sd ) out lo | ||
+ | gpio-4 ( |bt_default_wake_host) out hi | ||
+ | gpio-5 ( |GPIO Key Power ) in hi | ||
+ | gpio-9 ( |bt_default_reset ) out hi | ||
+ | gpio-10 ( |reset ) out hi | ||
+ | gpio-13 ( |? ) out hi | ||
+ | GPIOs 32-63, platform/pinctrl, gpio1: | ||
+ | gpio-34 ( |int-n ) in hi | ||
+ | gpio-46 ( |vsel ) out lo | ||
+ | gpio-49 ( |vsel ) out lo | ||
+ | GPIOs 64-95, platform/pinctrl, gpio2: | ||
+ | gpio-83 ( |bt_default_rts ) out lo | ||
+ | gpio-90 ( |bt_default_wake ) out hi | ||
+ | GPIOs 96-127, platform/pinctrl, gpio3: | ||
+ | gpio-111 ( |mdio-reset ) out hi | ||
+ | GPIOs 128-159, platform/pinctrl, gpio4: | ||
+ | gpio-154 ( |vbus-5v ) out lo | ||
+ | gpio-156 ( |Headphone detection ) in lo | ||
+ | gpio-157 ( |enable ) out lo | ||
+ | gpio-158 ( |vcc_lcd ) out hi | ||
+ | </syntaxhighlight> | ||
+ | 以计算 GPIO4_C6 为例,由于 gpio4是 128,再者,<br/> | ||
+ | a = 1<br/> | ||
+ | b = 2<br/> | ||
+ | c = 3<br/> | ||
+ | d = 4<br/> | ||
+ | 所以GPIO4_C6就是 128 + (3-1)*8 + 6 = 128+16+6 = 150。<br/> | ||
+ | 一些引脚索引号的换算示例: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | GPIO4_C6 128+(3-1)*8+6 = 150 | ||
+ | GPIO4_C1 128+(3-1)*8+1 = 145 | ||
+ | GPIO4_C0 128+(3-1)*8+0 = 144 | ||
+ | GPIO1_C2 32+(3-1)*8+2 = 50 | ||
+ | GPIO1_C7 32+(3-1)*8+7 = 55 | ||
+ | GPIO3_D4 96+(4-1)*8+4 = 124 | ||
+ | GPIO3_D5 96+(4-1)*8+5 = 125 | ||
+ | GPIO3_D6 96+(4-1)*8+6 = 126 | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ===全志 H3 / H5 计算 Linux gpio 索引号的方法=== | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ cat /sys/kernel/debug/pinctrl/*/pins | ||
+ | registered pins: 94 | ||
+ | pin 0 (PA0) | ||
+ | pin 1 (PA1) | ||
+ | pin 2 (PA2) | ||
+ | pin 3 (PA3) | ||
+ | pin 4 (PA4) | ||
+ | pin 5 (PA5) | ||
+ | pin 6 (PA6) | ||
+ | pin 7 (PA7) | ||
+ | pin 8 (PA8) | ||
+ | pin 9 (PA9) | ||
+ | pin 10 (PA10) | ||
+ | pin 11 (PA11) | ||
+ | pin 12 (PA12) | ||
+ | pin 13 (PA13) | ||
+ | pin 14 (PA14) | ||
+ | pin 15 (PA15) | ||
+ | pin 16 (PA16) | ||
+ | pin 17 (PA17) | ||
+ | pin 18 (PA18) | ||
+ | pin 19 (PA19) | ||
+ | pin 20 (PA20) | ||
+ | pin 21 (PA21) | ||
+ | pin 64 (PC0) | ||
+ | pin 65 (PC1) | ||
+ | pin 66 (PC2) | ||
+ | pin 67 (PC3) | ||
+ | pin 68 (PC4) | ||
+ | pin 69 (PC5) | ||
+ | pin 70 (PC6) | ||
+ | pin 71 (PC7) | ||
+ | pin 72 (PC8) | ||
+ | pin 73 (PC9) | ||
+ | pin 74 (PC10) | ||
+ | pin 75 (PC11) | ||
+ | pin 76 (PC12) | ||
+ | pin 77 (PC13) | ||
+ | pin 78 (PC14) | ||
+ | pin 79 (PC15) | ||
+ | pin 80 (PC16) | ||
+ | pin 96 (PD0) | ||
+ | pin 97 (PD1) | ||
+ | pin 98 (PD2) | ||
+ | pin 99 (PD3) | ||
+ | pin 100 (PD4) | ||
+ | pin 101 (PD5) | ||
+ | pin 102 (PD6) | ||
+ | pin 103 (PD7) | ||
+ | pin 104 (PD8) | ||
+ | pin 105 (PD9) | ||
+ | pin 106 (PD10) | ||
+ | pin 107 (PD11) | ||
+ | pin 108 (PD12) | ||
+ | pin 109 (PD13) | ||
+ | pin 110 (PD14) | ||
+ | pin 111 (PD15) | ||
+ | pin 112 (PD16) | ||
+ | pin 113 (PD17) | ||
+ | pin 128 (PE0) | ||
+ | pin 129 (PE1) | ||
+ | pin 130 (PE2) | ||
+ | pin 131 (PE3) | ||
+ | pin 132 (PE4) | ||
+ | pin 133 (PE5) | ||
+ | pin 134 (PE6) | ||
+ | pin 135 (PE7) | ||
+ | pin 136 (PE8) | ||
+ | pin 137 (PE9) | ||
+ | pin 138 (PE10) | ||
+ | pin 139 (PE11) | ||
+ | pin 140 (PE12) | ||
+ | pin 141 (PE13) | ||
+ | pin 142 (PE14) | ||
+ | pin 143 (PE15) | ||
+ | pin 160 (PF0) | ||
+ | pin 161 (PF1) | ||
+ | pin 162 (PF2) | ||
+ | pin 163 (PF3) | ||
+ | pin 164 (PF4) | ||
+ | pin 165 (PF5) | ||
+ | pin 166 (PF6) | ||
+ | pin 192 (PG0) | ||
+ | pin 193 (PG1) | ||
+ | pin 194 (PG2) | ||
+ | pin 195 (PG3) | ||
+ | pin 196 (PG4) | ||
+ | pin 197 (PG5) | ||
+ | pin 198 (PG6) | ||
+ | pin 199 (PG7) | ||
+ | pin 200 (PG8) | ||
+ | pin 201 (PG9) | ||
+ | pin 202 (PG10) | ||
+ | pin 203 (PG11) | ||
+ | pin 204 (PG12) | ||
+ | pin 205 (PG13) | ||
+ | registered pins: 12 | ||
+ | pin 352 (PL0) | ||
+ | pin 353 (PL1) | ||
+ | pin 354 (PL2) | ||
+ | pin 355 (PL3) | ||
+ | pin 356 (PL4) | ||
+ | pin 357 (PL5) | ||
+ | pin 358 (PL6) | ||
+ | pin 359 (PL7) | ||
+ | pin 360 (PL8) | ||
+ | pin 361 (PL9) | ||
+ | pin 362 (PL10) | ||
+ | pin 363 (PL11) | ||
+ | </syntaxhighlight> |
Latest revision as of 03:25, 11 May 2021
1 S5P4418/S5P6818下计算Linux gpio索引号的方法
看管脚定义,共有GPIOA ~ GPIOD 4 组,
用以下命令看GPIO针脚
#/bin/sh cd /sys/class/gpio for i in gpiochip* ; do echo `cat $i/label`: `cat $i/base` ; done
在T2上输出
nxp-gpio.0: 0 nxp-gpio.4: 128 nxp-gpio.5: 160 nxp-gpio.1: 32 nxp-gpio.2: 64 nxp-gpio.3: 96
每一个label表示一组,上面是显示6组,
那么,对应的就是
nxp-gpio.0: 0 -> GPIOA nxp-gpio.4: 128 -> GPIOE ->AliveGPIO3 nxp-gpio.5: 160 -> GPIOF ->AliveGPIO5 nxp-gpio.1: 32 -> GPIOB nxp-gpio.2: 64 -> GPIOC nxp-gpio.3: 96 -> GPIOD
每一组之间差32,是通过cat gpiochip0/ngpio查看的
2 RK3399下计算Linux gpio索引号的方法
用以下命令看GPIO针脚
cat /sys/kernel/debug/gpio
T4下的输出如下所示:
GPIOs 0-31, platform/pinctrl, gpio0: gpio-1 ( |vcc_sd ) out lo gpio-4 ( |bt_default_wake_host) out hi gpio-5 ( |GPIO Key Power ) in hi gpio-9 ( |bt_default_reset ) out hi gpio-10 ( |reset ) out hi gpio-13 ( |? ) out hi GPIOs 32-63, platform/pinctrl, gpio1: gpio-34 ( |int-n ) in hi gpio-46 ( |vsel ) out lo gpio-49 ( |vsel ) out lo GPIOs 64-95, platform/pinctrl, gpio2: gpio-83 ( |bt_default_rts ) out lo gpio-90 ( |bt_default_wake ) out hi GPIOs 96-127, platform/pinctrl, gpio3: gpio-111 ( |mdio-reset ) out hi GPIOs 128-159, platform/pinctrl, gpio4: gpio-154 ( |vbus-5v ) out lo gpio-156 ( |Headphone detection ) in lo gpio-157 ( |enable ) out lo gpio-158 ( |vcc_lcd ) out hi
以计算 GPIO4_C6 为例,由于 gpio4是 128,再者,
a = 1
b = 2
c = 3
d = 4
所以GPIO4_C6就是 128 + (3-1)*8 + 6 = 128+16+6 = 150。
一些引脚索引号的换算示例:
GPIO4_C6 128+(3-1)*8+6 = 150 GPIO4_C1 128+(3-1)*8+1 = 145 GPIO4_C0 128+(3-1)*8+0 = 144 GPIO1_C2 32+(3-1)*8+2 = 50 GPIO1_C7 32+(3-1)*8+7 = 55 GPIO3_D4 96+(4-1)*8+4 = 124 GPIO3_D5 96+(4-1)*8+5 = 125 GPIO3_D6 96+(4-1)*8+6 = 126
3 全志 H3 / H5 计算 Linux gpio 索引号的方法
$ cat /sys/kernel/debug/pinctrl/*/pins registered pins: 94 pin 0 (PA0) pin 1 (PA1) pin 2 (PA2) pin 3 (PA3) pin 4 (PA4) pin 5 (PA5) pin 6 (PA6) pin 7 (PA7) pin 8 (PA8) pin 9 (PA9) pin 10 (PA10) pin 11 (PA11) pin 12 (PA12) pin 13 (PA13) pin 14 (PA14) pin 15 (PA15) pin 16 (PA16) pin 17 (PA17) pin 18 (PA18) pin 19 (PA19) pin 20 (PA20) pin 21 (PA21) pin 64 (PC0) pin 65 (PC1) pin 66 (PC2) pin 67 (PC3) pin 68 (PC4) pin 69 (PC5) pin 70 (PC6) pin 71 (PC7) pin 72 (PC8) pin 73 (PC9) pin 74 (PC10) pin 75 (PC11) pin 76 (PC12) pin 77 (PC13) pin 78 (PC14) pin 79 (PC15) pin 80 (PC16) pin 96 (PD0) pin 97 (PD1) pin 98 (PD2) pin 99 (PD3) pin 100 (PD4) pin 101 (PD5) pin 102 (PD6) pin 103 (PD7) pin 104 (PD8) pin 105 (PD9) pin 106 (PD10) pin 107 (PD11) pin 108 (PD12) pin 109 (PD13) pin 110 (PD14) pin 111 (PD15) pin 112 (PD16) pin 113 (PD17) pin 128 (PE0) pin 129 (PE1) pin 130 (PE2) pin 131 (PE3) pin 132 (PE4) pin 133 (PE5) pin 134 (PE6) pin 135 (PE7) pin 136 (PE8) pin 137 (PE9) pin 138 (PE10) pin 139 (PE11) pin 140 (PE12) pin 141 (PE13) pin 142 (PE14) pin 143 (PE15) pin 160 (PF0) pin 161 (PF1) pin 162 (PF2) pin 163 (PF3) pin 164 (PF4) pin 165 (PF5) pin 166 (PF6) pin 192 (PG0) pin 193 (PG1) pin 194 (PG2) pin 195 (PG3) pin 196 (PG4) pin 197 (PG5) pin 198 (PG6) pin 199 (PG7) pin 200 (PG8) pin 201 (PG9) pin 202 (PG10) pin 203 (PG11) pin 204 (PG12) pin 205 (PG13) registered pins: 12 pin 352 (PL0) pin 353 (PL1) pin 354 (PL2) pin 355 (PL3) pin 356 (PL4) pin 357 (PL5) pin 358 (PL6) pin 359 (PL7) pin 360 (PL8) pin 361 (PL9) pin 362 (PL10) pin 363 (PL11)