Set GPIO output in Device Tree

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

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


Hello Tim,

Thanks for providing all the details and device tree snippet. Let’s go step by step to address your goal: setting SODIMM 222 (GPIO4_IO01, Linux GPIO 97) high at boot on a Verdin iMX8MP using a device tree overlay.

Analysis and Guidance

1. Device Tree Overlay Structure

Your overlay is mostly correct, but there are a few subtle issues:

  • The compatible string in the overlay should be as generic as possible or match your board’s base device tree.
  • Including dtsi and pinfunc headers is typically not required in overlays (the base device tree already includes them).
  • The pinmux setting (0x105) should match your electrical requirements, but 0x1b0b0 is more commonly used for GPIO (see below).

2. Pinmux configuration

The key to making the hog work is setting the correct pad control and ensuring no other DTS node claims the pin in parallel.

Here’s a simplified and corrected example you can use as your overlay:

/dts-v1/;
/plugin/;

/ {
    compatible = "toradex,verdin-imx8mp";
};

&iomuxc {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_sodimm222>;

    pinctrl_sodimm222: sodimm222grp {
        fsl,pins = <
            MX8MP_IOMUXC_SAI1_RXC__GPIO4_IO01 0x1b0b0
        >;
    };
};

&gpio4 {
    sodimm222_hog: sodimm222_hog {
        gpio-hog;
        gpios = <1 GPIO_ACTIVE_HIGH>;
        output-high;
        line-name = "sodimm-222";
    };
};

Key points:

  • Use 0x1b0b0 as the pad setting for a generic, strong-pull-up, fast slew GPIO.
  • Make sure the pin isn’t being used anywhere else (check your base device tree, verify it’s not used for SAI1 or any other peripheral).
  • The gpio-hog will set the pin as output and drive it high.

3. Make Sure There are No Conflicts

  • In /sys/kernel/debug/gpio, you should see gpio-97 as “sodimm-222” and OUT HI.
  • In /sys/kernel/debug/pinctrl/30330000.pinctrl/, check that MX8MP_IOMUXC_SAI1_RXC is assigned to your hog (not unclaimed).
  • If still “GPIO UNCLAIMED,” it’s possible another DTS fragment is conflicting. Double-check the base device tree and overlays that SAI1_RXC is not assigned to any SAI1 function.

Details here:

4. Deploy and Test

  1. Deploy the overlay as described in the Toradex documentation.
  2. Reboot and check:
    • cat /sys/kernel/debug/gpio to confirm the hog.
    • cat /sys/kernel/debug/pinctrl/30330000.pinctrl for pin assignment.

5. Troubleshooting

  • If the pin still isn’t claimed by the hog, try removing any unneeded overlay includes and keep the compatible entry short, as shown above.
  • If a conflict persists, search your base device tree and overlays for any occurrences of sai1 or the pin in question (SAI1_RXC or GPIO4_IO01) and comment those sections out if not needed.

Let me know if this overlay and these steps solve your issue or if you see further problems!

Best regards,
Toradex AI Assistant.

Reference: