Urgent help needed gpio device tree overlay

Hi there,

I am trying to get on my mallow carrier and verdin IMX8MP to have extra GPIO’s. I am needing pins 3&4 on the X19 header to be GPIO:
3 SPI_1_MOSI 200 O +1.8V SPI Master Output, Slave Input
4 SPI_1_CS 202 O +1.8V SPI Slave Select

Here is my dts file currently:
/dts-v1/;
/plugin/;

#include “imx8mp-pinfunc.h”

/ {
compatible = “toradex,verdin-imx8mp”;

fragment@0 {
    target = <&iomuxc>;
    __overlay__ {
        pinctrl_gpio: gpio_pins {
            fsl,pins = <
                MX8MP_IOMUXC_NAND_WP_B__GPIO3_IO18 0x19  /* SODIMM 200: SPI_1_MOSI as GPIO */
                MX8MP_IOMUXC_NAND_READY_B__GPIO3_IO07 0x19 /* SODIMM 202: SPI_1_CS as GPIO */
            >;
        };
    };
};

fragment@1 {
    target = <&gpio3>;
    __overlay__ {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_gpio>;

        spi1_mosi_hog: gpio-hog@18 {
            gpios = <&gpio3 18 GPIO_ACTIVE_LOW>;
            output-low;
            line-name = "SPI_1_MOSI";
            status = "okay";
        };

        spi1_cs_hog: gpio-hog@7 {
            gpios = <&gpio3 7 GPIO_ACTIVE_LOW>;
            output-low;
            line-name = "SPI_1_CS";
            status = "okay";
        };
    };
};

};
I have the imx8mp-pinfunc.h in the same folder when compiling.
I have been trying for ages and I have read all of the instructions!

PLEASE HELP!

/dts-v1/;
/plugin/;

#include “imx8mp-pinfunc.h”

/ {
compatible = “toradex,verdin-imx8mp”;

fragment@0 {
    target = <&iomuxc>;
    __overlay__ {
        pinctrl_gpio: gpio_pins {
            fsl,pins = <
                MX8MP_IOMUXC_NAND_WP_B__GPIO3_IO18 0x19  /* SODIMM 200: SPI_1_MOSI as GPIO */
                MX8MP_IOMUXC_NAND_READY_B__GPIO3_IO07 0x19 /* SODIMM 202: SPI_1_CS as GPIO */
            >;
        };
    };
};

fragment@1 {
    target = <&gpio3>;
    __overlay__ {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_gpio>;

        spi1_mosi_hog: gpio-hog@18 {
            gpios = <&gpio3 18 GPIO_ACTIVE_LOW>;
            output-low;
            line-name = "SPI_1_MOSI";
            status = "okay";
        };

        spi1_cs_hog: gpio-hog@7 {
            gpios = <&gpio3 7 GPIO_ACTIVE_LOW>;
            output-low;
            line-name = "SPI_1_CS";
            status = "okay";
        };
    };
};

};

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

To configure pins 3 and 4 on the X19 header of your Mallow carrier with the Verdin iMX8MP as GPIOs, let’s ensure your DTS file is correctly set up.

  1. Verify Pin Definitions: Double-check that the pin definitions in your DTS file are correct. For the Verdin iMX8MP:

    • MX8MP_IOMUXC_NAND_WP_B__GPIO3_IO18 should map to pin 3 (SPI_1_MOSI).
    • MX8MP_IOMUXC_NAND_READY_B__GPIO3_IO07 should map to pin 4 (SPI_1_CS).
  2. Check Pin Control Settings: Ensure the pinctrl_gpio fragment correctly maps these pins to GPIO functionality. Verify the fsl,pins settings against the hardware documentation.

  3. Review GPIO-Hog Configuration: Your gpio-hog settings seem correct, setting the pins to output low. Ensure the status is “okay” and the gpios property uses the correct GPIO controller and pin numbers.

  4. Compile and Deploy: After adjustments, recompile your device tree overlay and deploy it to your device:

    • Compile with: dtc -I dts -O dtb -o <output>.dtbo <input>.dts
    • Place the compiled overlay in /boot/overlays/ on your device.
  5. Load the Overlay: Ensure your overlay loads at boot by adding it to the overlays.txt file or using the appropriate bootloader commands.

  6. Test the GPIOs: After rebooting, test the GPIOs using sysfs or libgpiod to confirm they function as expected.

If these steps do not resolve the issue, ensure there are no conflicts with other peripherals using the same pins. This should help you successfully configure the GPIOs on your setup.

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

Enable 10.1" LVDS display on Mallow carrier board.

Hi Benedict, I need more information to address the problem.

  1. Is the OS Torizon or Linux BSP running on the Verdin iMX8MP?
  2. What is the OS version?
  3. What device tree is currently loaded?
  4. Are there any other overlays loaded besides your device tree overlays?

Hi Benjamin,

  1. Torizon OS
  2. The OS version is 6.8.0 torizon-core-docker.
  3. No device tree is currently loaded I believe.
  4. No other overlays loaded

Hi Benedict, usually the default device tree and overlays are loaded. You could double check with the tdxinfo tool on Torizon v6.8.0.

sudo tdx-info --all

Hi Benedict, there is a verdin-imx8mp_spidev_overlay.dtbo loaded by default where SODIMM 200 and 202 are configured as the SPI interface. An easy way to disable it is by deleting it from overlays.txt as described here. Your custom device tree overlays could also be added.