This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PHYTC-3P-PHYCORE-AM335X: GPIOD Chip Number Enumeration Logic

Part Number: PHYTC-3P-PHYCORE-AM335X

Hi all,

We recently added GPMC support to our board and now gpiod added an extra gpiochip.

However, my C application is broken because I had everything starting at gpiochip0, but the gpmc gpio is now chip 0.

What is the logic behind the enumeration in gpiod? Do I need to rearrange things in the DTS file so that GPMC is enabled last?

I would like the actual gpios to be labeled as gpiochip0-3, and the GPMC gpios to be gpiochip4.

I tried searching around for this but couldn't find anything.

Or, is there a way for me in C to reference the name, like gpio-0-31 rather than the enumerated field?

Before enabling GPMC:

root@am335x:~# gpiodetect
gpiochip0 [gpio-0-31] (32 lines)
gpiochip1 [gpio-32-63] (32 lines)
gpiochip2 [gpio-64-95] (32 lines)
gpiochip3 [gpio-96-127] (32 lines)

After enabling GPMC:

root@am335x:~# gpiodetect
gpiochip0 [omap-gpmc] (2 lines)
gpiochip1 [gpio-0-31] (32 lines)
gpiochip2 [gpio-32-63] (32 lines)
gpiochip3 [gpio-64-95] (32 lines)
gpiochip4 [gpio-96-127] (32 lines)

  • I was able to change my C code to obtain chips based on label instead of chip number.

    Instead of an array of chip numbers, I used an array of labels (gpio-0-31, gpio-32-63...) and then called gpiod_chip_open_by_label instead of gpiod_chip_open_by_name.