iMX8MM GPIO Overlay

Hi,

I am using a verdin iMX8MM with the development kit.

I am trying to set SODIMM 210 as GPIO 3 and then set high by default.

I have followed the following tutorial on the website - Customize Device Trees

My custom device tree overlay is as follows

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
#include "imx8mm-pinfunc.h"

/{
    compatible = "toradex,verdin-imx8mm-wifi-dev",
    	"toradex,verdin-imx8mm-wifi",
    	"toradex,verdin-imx8mm",
    	"fsl,imx8mm";
};

&{/} {
    leds {
        compatible = "gpio-leds";

        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_my_led>;

        myled_sodimm_210 {
            label = "myled_sodimm_210";
            gpios = <&gpio5 26 GPIO_ACTIVE_HIGH>;
            default-state = "on";
        };
    };
};

&iomuxc {	

	pinctrl_my_led: myledgrp {
        fsl,pins =
            <MX8MM_IOMUXC_UART3_RXD_GPIO5_IO26 0x104>; // SODIMM 210 // pull-down enabled and drive strength X2
    };
};

This successfully downloads to the development board however the overlay is not successfully applied. I have run the ‘dmesg’ command checked the output. I have noticed the following errors

[    0.933983] imx8mm-pinctrl 30330000.pinctrl: pin MX8MM_IOMUXC_UART3_RXD already requested by 30330000.pinctrl; cannot claim for leds
[    0.933997] imx8mm-pinctrl 30330000.pinctrl: pin-145 (leds) status -22
[    0.934005] imx8mm-pinctrl 30330000.pinctrl: could not request pin 145 (MX8MM_IOMUXC_UART3_RXD) from group myledgrp  on device 30330000.pinctrl
[    0.934013] leds-gpio leds: Error applying setting, reverse things back

Any pointers and help would be greatly appreciated.

Thanks in advance.

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

The error message you’re encountering indicates that the pin MX8MM_IOMUXC_UART3_RXD (SODIMM 210) is already being used by another function in the system, which prevents your device tree overlay from claiming it for GPIO use. This is a common issue when multiple functionalities are assigned to the same pin without proper reconfiguration.

To resolve this issue, you need to ensure that the pin is not being used by another driver or function. This typically involves modifying the device tree to disable the conflicting function before you can use the pin as a GPIO. Here’s how you can approach this:

  1. Identify the conflicting function: Based on the error, the UART3_RXD function is currently claiming the pin. You’ll need to locate where this pin is defined in the device tree for its original purpose (in this case, as part of UART3) and make the necessary adjustments.

  2. Disable the conflicting function: If UART3 is not needed for your application, you can disable it in the device tree to free up the pin. This can be done by setting the status of UART3 to “disabled”. For example:

&uart3 {
    status = "disabled";
};
  1. Apply your overlay: After ensuring that the pin is no longer claimed by another function, your overlay should be able to apply without errors. Make sure your overlay is correctly formatted and applied according to the Torizon or Yocto Project documentation for device tree overlays.

  2. Verify the changes: After applying the overlay, use the dmesg command again to check for any errors and ensure that the pin configuration has been applied successfully. You can also use tools like gpioinfo or gpioset from the libgpiod package to verify the pin’s state and control it from userspace.

Remember, modifying the device tree and working with overlays requires a careful approach to avoid conflicts and ensure that all hardware components function as expected. Always backup your original device tree files before making changes.

Best regards,
Toradex AI Assistant

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

How to Write Device Tree Overlays | Toradex Developer Center.

Hello @DAH,

Welcome to the Toradex Community!

The SODIMM 210 pin is already requested on pinctrl_gpio3, as you can see here: imx8mm-verdin.dtsi « freescale « dts « boot « arm64 « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

You need to remove it from the iomuxc pinctrl and reconfigure it to use it as an LED.

The following device tree overlay will do what you want here:

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
#include "imx8mm-pinfunc.h"

/{
    compatible = "toradex,verdin-imx8mm-wifi-dev",
    	"toradex,verdin-imx8mm-wifi",
    	"toradex,verdin-imx8mm",
    	"fsl,imx8mm";
};

&{/} {
    leds {
        compatible = "gpio-leds";

        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_gpio3>;

        myled_sodimm_210 {
            label = "myled_sodimm_210";
            gpios = <&gpio5 26 GPIO_ACTIVE_HIGH>;
            default-state = "on";
        };
    };
};

&iomuxc {
	pinctrl-0 = <&pinctrl_gpio1>, <&pinctrl_gpio2>,
		        <&pinctrl_gpio4>, <&pinctrl_gpio7>,
                <&pinctrl_gpio8>, <&pinctrl_gpio_hog1>,
                <&pinctrl_gpio_hog2>, <&pinctrl_gpio_hog3>,
		    <&pinctrl_pmic_tpm_ena>;
};

&pinctrl_gpio3 {
    fsl,pins =
        <MX8MM_IOMUXC_UART3_RXD_GPIO5_IO26 0x104>; // SODIMM 210 // pull-down enabled and drive strength X2
};

Best Regards,
Bruno

Hi Bruno,

Thank you very much for your reply.

I have copied the overlay you created and everything is working correctly now. Thank you very much for your help.

Kind Regards

DAH