Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

...

  1. Export GPIO5_IO00:

    Code Block
    / # echo 640 > /sys/class/gpio/export
  2. Make sure the value of GPIO5_IO00 is 1 when the USER BUTTON is untouched (due to the internal PULL-UP being enabled):

    Code Block
    / # cat /sys/class/gpio/gpio640/value1value
    1
  3. Press and hold the USER BUTTON and make sure the GPIO5_IO00 value has changed to 0:

    Code Block
    / # cat /sys/class/gpio/gpio640/value
    0

...