GPIO

From FriendlyELEC WiKi
Revision as of 04:54, 20 March 2019 by Tzs (Talk | contribs) (updated by API)

Jump to: navigation, search

查看中文

1 S5P4418/S5P6818 GPIO pin definition

See pin definition, total GPIOA ~ GPIOD 4 group,
Use the following command to see the GPIO pins.

#/bin/sh
cd /sys/class/gpio
for i in gpiochip* ; do echo `cat $i/label`: `cat $i/base` ; done

Output on 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

Each label represents a group, and the above shows 6 groups.
Then the corresponding is:

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

The difference between each group is 32, which is checked by the cat gpiochip0/ngpio command.

2 RK3399 GPIO pin definition

Use the following command to see the GPIO pins.

cat /sys/kernel/debug/gpio

Output on 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

Take GPIO4_C6 as an example, since gpio4 is 128, According to:
a = 1
b = 2
c = 3
d = 4
So GPIO4_C6 is 128 + (3-1)*8 + 6 = 128+16+6 = 150。
Some examples of conversion of pin index numbers:

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