Difference between revisions of "How to use GPIO RK3568"
From ESS-WIKI
Yunjin.jiang (talk | contribs) |
Yunjin.jiang (talk | contribs) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | |||
= Configuration = | = Configuration = | ||
− | The RK3568 bank/bit notation for GPIOs must be formed as "GPIO | + | The RK3568 bank/bit notation for GPIOs must be formed as "GPIO<GPIO_bank>_<gpio_bit>" |
The numeric value of GPIO is calculated as follows: | The numeric value of GPIO is calculated as follows: | ||
Line 11: | Line 12: | ||
E.g. GPIO3_A0 becomes 96 | E.g. GPIO3_A0 becomes 96 | ||
− | == RSB-4810 | + | == RSB-4810 == |
− | {| | + | {| border="1" cellpadding="1" cellspacing="1" |
|- | |- | ||
| GPIO Number | | GPIO Number | ||
Line 19: | Line 20: | ||
| Numeric Representation | | Numeric Representation | ||
|- | |- | ||
− | | GPIO1 | + | | GPIO1 |
− | | GPIO3_A0 | + | | GPIO3_A0 |
| 96 | | 96 | ||
|- | |- | ||
− | | GPIO2 | + | | GPIO2 |
− | | GPIO3_A2 | + | | GPIO3_A2 |
+ | | 98 | ||
+ | |- | ||
+ | | GPIO3 | ||
+ | | GPIO3_A3 | ||
+ | | 99 | ||
+ | |- | ||
+ | | GPIO4 | ||
+ | | GPIO3_A4 | ||
+ | | 100 | ||
+ | |- | ||
+ | | GPIO5 | ||
+ | | GPIO3_A5 | ||
+ | | 101 | ||
+ | |- | ||
+ | | GPIO6 | ||
+ | | GPIO3_A6 | ||
+ | | 102 | ||
+ | |} | ||
+ | |||
+ | == AFE-E630 == | ||
+ | |||
+ | {| border="1" cellpadding="1" cellspacing="1" | ||
+ | |- | ||
+ | | GPIO Number | ||
+ | | GPIO formed | ||
+ | | Numeric Representation | ||
+ | |- | ||
+ | | GPIO1 | ||
+ | | GPIO0_B0 | ||
+ | | 8 | ||
+ | |- | ||
+ | | GPIO2 | ||
+ | | GPIO3_A2 | ||
| 98 | | 98 | ||
|- | |- | ||
− | | GPIO3 | + | | GPIO3 |
− | | GPIO3_A3 | + | | GPIO3_A3 |
| 99 | | 99 | ||
|- | |- | ||
− | | GPIO4 | + | | GPIO4 |
− | | GPIO3_A4 | + | | GPIO3_A4 |
| 100 | | 100 | ||
|- | |- | ||
− | | GPIO5 | + | | GPIO5 |
− | | GPIO3_A5 | + | | GPIO3_A5 |
| 101 | | 101 | ||
|- | |- | ||
− | | GPIO6 | + | | GPIO6 |
− | | GPIO3_A6 | + | | GPIO3_A6 |
| 102 | | 102 | ||
+ | |- | ||
+ | | UIO_GPIO2 | ||
+ | | GPIO0_B3 | ||
+ | | 11 | ||
+ | |- | ||
+ | | UIO_GPIO4 | ||
+ | | GPIO0_B4 | ||
+ | | 12 | ||
+ | |- | ||
+ | | UIO_GPIO5 | ||
+ | | GPIO0_B5 | ||
+ | | 13 | ||
+ | |- | ||
+ | | UIO_GPIO6 | ||
+ | | GPIO0_B6 | ||
+ | | 14 | ||
+ | |- | ||
+ | | UIO_GPIO7 | ||
+ | | GPIO0_C5 | ||
+ | | 21 | ||
+ | |- | ||
+ | | UIO_GPIO8 | ||
+ | | GPIO0_C6 | ||
+ | | 22 | ||
+ | |- | ||
+ | | UIO_GPIO9 | ||
+ | | GPIO4_C3 | ||
+ | | 147 | ||
+ | |- | ||
+ | | UIO_GPIO10 | ||
+ | | GPIO4_C2 | ||
+ | | 146 | ||
+ | |- | ||
+ | | UIO_GPIO11 | ||
+ | | IIC_GPIO_P0 | ||
+ | | 503 | ||
+ | |- | ||
+ | | UIO_GPIO12 | ||
+ | | IIC_GPIO_P1 | ||
+ | | 504 | ||
|} | |} | ||
Line 103: | Line 177: | ||
== EBC-RB07 == | == EBC-RB07 == | ||
− | {| | + | {| border="1" cellpadding="1" cellspacing="1" |
|- | |- | ||
| GPIO Number | | GPIO Number | ||
Line 109: | Line 183: | ||
| Numeric Representation | | Numeric Representation | ||
|- | |- | ||
− | | GPIO1 | + | | GPIO1 |
− | | GPIO3_A0 | + | | GPIO3_A0 |
| 96 | | 96 | ||
|- | |- | ||
− | | GPIO2 | + | | GPIO2 |
− | | GPIO3_A2 | + | | GPIO3_A2 |
| 98 | | 98 | ||
|- | |- | ||
− | | GPIO3 | + | | GPIO3 |
− | | GPIO3_A3 | + | | GPIO3_A3 |
| 99 | | 99 | ||
|- | |- | ||
− | | GPIO4 | + | | GPIO4 |
− | | GPIO3_A4 | + | | GPIO3_A4 |
| 100 | | 100 | ||
|- | |- | ||
− | | GPIO5 | + | | GPIO5 |
− | | GPIO3_A5 | + | | GPIO3_A5 |
| 101 | | 101 | ||
|- | |- | ||
− | | GPIO6 | + | | GPIO6 |
− | | GPIO3_A6 | + | | GPIO3_A6 |
| 102 | | 102 | ||
|} | |} |
Latest revision as of 07:18, 19 September 2024
Configuration
The RK3568 bank/bit notation for GPIOs must be formed as "GPIO<GPIO_bank>_<gpio_bit>"
The numeric value of GPIO is calculated as follows:
32 x (gpio_bank) + gpio_bit
gpio_bit : A0~A7 0-7 B0~B7 8-15 C0~C7 16-23 D0~D7 24-31
E.g. GPIO3_A0 becomes 96
RSB-4810
GPIO Number | GPIO formed | Numeric Representation |
GPIO1 | GPIO3_A0 | 96 |
GPIO2 | GPIO3_A2 | 98 |
GPIO3 | GPIO3_A3 | 99 |
GPIO4 | GPIO3_A4 | 100 |
GPIO5 | GPIO3_A5 | 101 |
GPIO6 | GPIO3_A6 | 102 |
AFE-E630
GPIO Number | GPIO formed | Numeric Representation |
GPIO1 | GPIO0_B0 | 8 |
GPIO2 | GPIO3_A2 | 98 |
GPIO3 | GPIO3_A3 | 99 |
GPIO4 | GPIO3_A4 | 100 |
GPIO5 | GPIO3_A5 | 101 |
GPIO6 | GPIO3_A6 | 102 |
UIO_GPIO2 | GPIO0_B3 | 11 |
UIO_GPIO4 | GPIO0_B4 | 12 |
UIO_GPIO5 | GPIO0_B5 | 13 |
UIO_GPIO6 | GPIO0_B6 | 14 |
UIO_GPIO7 | GPIO0_C5 | 21 |
UIO_GPIO8 | GPIO0_C6 | 22 |
UIO_GPIO9 | GPIO4_C3 | 147 |
UIO_GPIO10 | GPIO4_C2 | 146 |
UIO_GPIO11 | IIC_GPIO_P0 | 503 |
UIO_GPIO12 | IIC_GPIO_P1 | 504 |
ROM-5880
GPIO Number | GPIO formed | Numeric Representation |
GPIO0 | GPIO2_D0 | 88 |
GPIO1 | GPIO2_D1 | 89 |
GPIO2 | GPIO2_D2 | 90 |
GPIO3 | GPIO2_D3 | 91 |
GPIO4 | GPIO2_C6 | 86 |
GPIO5 | GPIO3_A1 | 97 |
GPIO6 | GPIO3_A7 | 103 |
GPIO7 | GPIO3_B0 | 104 |
GPIO8 | GPIO3_B1 | 105 |
GPIO9 | GPIO3_B2 | 106 |
GPIO10 | GPIO3_B3 | 107 |
GPIO11 | GPIO3_B4 | 108 |
EBC-RB07
GPIO Number | GPIO formed | Numeric Representation |
GPIO1 | GPIO3_A0 | 96 |
GPIO2 | GPIO3_A2 | 98 |
GPIO3 | GPIO3_A3 | 99 |
GPIO4 | GPIO3_A4 | 100 |
GPIO5 | GPIO3_A5 | 101 |
GPIO6 | GPIO3_A6 | 102 |
Test
Here we take GPIO1 of 4810 as an example.
Export GPIO then you can use control GPIO from userr space through sysfs
Export GPIO1
# echo 96 > /sys/class/gpio/export
Set GPIO direction to in/out
# echo "out" > /sys/class/gpio/gpio96/direction
Set GPIO value 0/1 if GPIO pin define is output
# echo 1 > /sys/class/gpio/gpio96/value
Used as IRQ signal
Note:You have to configure GPIO to input
# echo "rising" > /sys/class/gpio/gpio96/edge
- rising: Trigger on rising edge
- falling: Trigger on falling edge
- both: Trigger on both edges
- none: Disable interrupt on both edges
Unexport GPIO1
# echo 96 > /sys/class/gpio/unexport
Test
GPIO1 and GPIO2 are taken as an example:
- Connect GPIO1 and GPIO2
- Export GPIO1 and GPIO2
# echo 96 > /sys/class/gpio/export # echo 98 > /sys/class/gpio/export
- Set GPIO 1 to output
# echo "out" > /sys/class/gpio/gpio96/direction
- Set GPIO 2 to input
# echo "in" > /sys/class/gpio/gpio98/direction
- Change GPIO1 to 1 and read GPIO2value
# echo 1 > /sys/class/gpio/gpio96/value # cat /sys/class/gpio/gpio98/value 1
- Change GPIO1 to 0 and read GPIO2 value
# echo 0 > /sys/class/gpio/gpio96/value # cat /sys/class/gpio/gpio98/value 0