AM625: Ensuring Consistent GPIO Numbering with Removable I2C Expansion Module

Part Number: AM625

Tool/software:

On our Customer board, there is an I2C expansion IO module. When this module is connected, the IO numbering is as follows, and five gpiochips are detected. Among them, gpiochip2 to gpiochip4 represent mcu_gpio0, main_gpio0, and main_gpio1, respectively.

When the I2C module is removed, only four gpiochips remain. In this case, gpiochip1 to gpiochip3 represent mcu_gpio0, main_gpio0, and main_gpio1.

It can be observed that the starting GPIO numbers of mcu_gpio0, main_gpio0, and main_gpio1 have changed, which directly impacts the usage of our application.

How can we configure the system to ensure that the starting GPIO numbers for mcu_gpio0, main_gpio0, and main_gpio1 remain unchanged when the I2C expansion module is removed?


When the module is connected:

root@User:~# cat /sys/kernel/debug/gpio
gpiochip4: GPIOs 334-385, parent: platform/601000.gpio, 601000.gpio:
gpiochip3: GPIOs 386-477, parent: platform/600000.gpio, 600000.gpio:
gpiochip2: GPIOs 478-501, parent: platform/4201000.gpio, 4201000.gpio:
gpiochip1: GPIOs 502-509, parent: i2c/0-0020, 0-0020, can sleep:
gpiochip0: GPIOs 510-511, parent: platform/3b000000.memory-controller, omap-gpmc:

When the module is removed:

root@User:~# cat /sys/kernel/debug/gpio
gpiochip3: GPIOs 342-393, parent: platform/601000.gpio, 601000.gpio:
gpiochip2: GPIOs 394-485, parent: platform/600000.gpio, 600000.gpio:
gpiochip1: GPIOs 486-509, parent: platform/4201000.gpio, 4201000.gpio:
gpiochip0: GPIOs 510-511, parent: platform/3b000000.memory-controller, omap-gpmc:
  • Hi Stephen,

    You application should not rely on the gpiochip name. The properly implementation is to give unique names (in the devicetree) to the GPIO pins, then your application query the gpiochip name using the GPIO pin name as the parameter.