AM62: gpiod pin identification

Thanks for your response.

Please remember to tick the “Solution” checkbox below if my response solves your question. If you have follow-up questions, just continue to tag me using @ToradexAI in your new posts.

Did you like my answer? :+1: :-1:


Hello!

That’s a great, in-depth follow-up—and your scenario is common when customizing GPIO usage on the Verdin AM62 platform.

You’re correct:

  • SODIMM_217 is not exported as a GPIO by default.
  • When you configure it in the device tree as GPIO0_91, the mapping to gpiochip/line is not immediately obvious, especially since the AM62’s gpiochips do not line up 1:1 with GPIO bank numbers like on i.MX8M-Plus.

Here’s how you can proceed:


1. Update the Device Tree to Enable SODIMM_217 as GPIO

First, you must create a custom device tree (or overlay) that muxes SODIMM_217 as GPIO0_91.
For guidance:

The general approach:

/* Example: enable SODIMM_217 as GPIO0_91 */

&main_pmx0 {
    custom_gpio0_91_pins: custom-gpio0-91-pins {
        pinctrl-single,pins = <
            /* OFFSET/MUX: adjust to your SoC's pinmux options */
            AM62X_IOPAD(SODIMM_217_PAD, PIN_INPUT_PULLUP, MUX_MODE_GPIO)
        >;
    };
};

&gpio0 {
    pinctrl-names = "default";
    pinctrl-0 = <&custom_gpio0_91_pins>;
    /* Optionally add gpio-line-names here, see below */
};

The specifics will depend on the AM62 device tree binding and pad naming. Use this as a template.


2. Add a gpio-line-names Entry (Highly Recommended!)

To make the pin easily discoverable with gpiod tools, add a gpio-line-names property and include SODIMM_217 at the correct position—index 91 for GPIO0_91.

Example:

&gpio0 {
    gpio-line-names = /* ... upto 91 entries ... */, "SODIMM_217", /* ... */;
};

See: Colibri iMX8QXP is missing GPIO line names in the device tree


3. Deploy, Reboot, and Locate Your Pin

Once your device tree is built and deployed:

  • Reboot your board.
  • Now use libgpiod tools:
gpiofind SODIMM_217
# or, view all named lines and find "SODIMM_217":
gpioinfo | grep SODIMM_217

This will tell you the chip (e.g., /dev/gpiochip2) and the line number (which should match 91 if in gpiochip2, for example).


4. Why Can’t You Predict the chip/line Mapping?

The mapping from (e.g.) GPIO0_91 to a specific /dev/gpiochipN and line may not match AM62 datasheet GPIO0/91 directly:

  • The kernel assigns gpiochip numbers in driver probe order.
  • Some chips may be reserved for special or internal functions.
  • Banks may be grouped or split at the driver’s discretion.

Thus, you can’t always statically predict that GPIO0_91 is necessarily at gpiochip0, line 91! That’s why using gpio-line-names (and thus SODIMM/x names) is robust.


5. Without gpio-line-names?

If you do not add a gpio-line-names property, you’ll have to manually check:

  • Which gpiochipN has the expected number of lines (often, the largest chip is the main bank).
  • Which physical pins respond when you toggle a candidate line.
  • Or, cross-reference the device tree pinmux with the output of gpioinfo and trial/error.

But adding gpio-line-names for each user-accessible GPIO you configure is strongly recommended.


Key References


Summary:
Configure the pin as a GPIO in your device tree, include a recognisable gpio-line-names entry, and then use gpiofind or gpioinfo to programmatically (and portably) identify the actual gpiochip/line for the pin.

If you need an explicit example based on your actual device tree, let me know what Toradex BSP version you’re using and your device’s full DTB setup.

Best regards,
Toradex AI Assistant