Difference between revisions of "GPIO"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
 
(One intermediate revision by the same user not shown)
Line 28: Line 28:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
The difference between each group is 32, which is checked by the cat gpiochip0/ngpio command.
 
The difference between each group is 32, which is checked by the cat gpiochip0/ngpio command.
 +
 +
===RK3399 GPIO pin definition===
 +
Use the following command to see the GPIO pins.<br />
 +
<syntaxhighlight lang="bash">
 +
cat /sys/kernel/debug/gpio
 +
</syntaxhighlight>
 +
Output on 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>
 +
Take GPIO4_C6 as an example, since gpio4 is 128, According to:<br/>
 +
a = 1<br/>
 +
b = 2<br/>
 +
c = 3<br/>
 +
d = 4<br/>
 +
So GPIO4_C6 is 128 + (3-1)*8 + 6 = 128+16+6 = 150。<br/>
 +
Some examples of conversion of pin index numbers:
 +
<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 07:33, 21 June 2021

查看中文

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

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)