...
Code Block |
---|
gpio = chip_base + pin
|
Kernel allocates the base numbers for GPIO chips dynamically, in 6.6.x the 512 offset is applied to all numbers, refer to include/linux/gpio.h
in the Linux kernel sources:
...
Code Block |
---|
(chip_instance - 1) * 32 + 512
|
So the resultant formula for the GPIO number is:
Code Block |
---|
gpio = (chip_instance - 1) * 32 + 512 + pin
|
For example:
gpio number for
GPIO01.IO09
will be (1 – 1) * 32 + 512 + 9 = 521.gpio number for
GPIO05.IO00
will be (5 – 1) * 32 + 512 + 0 = 640.
...
Export
GPIO5_IO00
:Code Block / # echo 640 > /sys/class/gpio/export
Make sure the value of
GPIO5_IO00
is 1 when theUSER BUTTON
is untouched (due to the internal PULL-UP being enabled):Code Block / # cat /sys/class/gpio/gpio640/value1value 1
Press and hold the
USER BUTTON
and make sure theGPIO5_IO00
value has changed to 0:Code Block / # cat /sys/class/gpio/gpio640/value 0
...