Difference between revisions of "GPIO/zh"
From FriendlyELEC WiKi
(updated by API) |
(updated by API) |
||
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> |
Revision as of 04:54, 20 March 2019
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