GPIO trouble with device tree overlays

Hello,

I created an overlay for my device tree 2-3 months ago and it worked fine.

I have some trouble using some GPIO that should already be accessible without modifiying the device tree :
I am using gpiod to try to switch on and off some GPIO with the imx8m-mini non wifi SoM.

Here the gpio that i can’t set :
SODIMM_206, SODIMM_208, SODIMM_210, SODIMM_212, SODIMM_216

I use the command on for exemple SODIMM_206:2. 3.

gpiofind SODIMM_206 //gpiochip2, line 4
gpioget 2 4 // the output is 0 for me
gpioset 2 4=1
gpioget 2 4 // output is still 0 for me 

if i do the same commands on : SODIMM_ : 218, 220, 222, 17, 21, 30 it works
i modified SODIMM_: 17, 21 and 30 on my overlay to have them working.

Here is my custom overlay :

/dts-v1/;
/plugin/;

#include "../dts-arm64/imx8mm-pinfunc.h"


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

&sai2 {
    status="disabled";
};





&iomuxc {
	pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_gpio3>, <&pinctrl_gpio4>, <&pinctrl_gpio7>,
		    <&pinctrl_gpio8>, <&pinctrl_gpio_hog1>,
		    <&pinctrl_gpio_hog2>, <&pinctrl_gpio_hog3>,
		    <&pinctrl_sai5>, <&pinctrl_pmic_tpm_ena>, <&pinctrl_my_gpios>;
    
     pinctrl_my_gpios: my_example_grp {
            fsl,pins = <
                MX8MM_IOMUXC_SAI2_TXC_GPIO4_IO25      0x184     /* SODIMM_30 */

                MX8MM_IOMUXC_NAND_RE_B_GPIO3_IO15     0x184     /* SODIMM_17 */
                
                MX8MM_IOMUXC_NAND_CE2_B_GPIO3_IO3     0x184     /* SODIMM_21 */
            >;
        };
    pinctrl_pwm_4: pwm4grp {
		fsl,pins = <
			MX8MM_IOMUXC_GPIO1_IO15_PWM4_OUT			0x6	/* SODIMM 187 */
		>;
	};
};

I have many question :

  1. I can’t remember what the “0x184” or “0x6” are for ?
  2. How can i know if i have an conflict and i need to disable something ? like the sai2 that i disabled ?
  3. Does you have a documentation for writing a device tree ? i also can’t remember the usage of the file : “…/dts-arm64/imx8mm-pinfunc.h”

here are my overlays :

ls /proc/device-tree/chosen/overlays/
name  verdin-imx8mm_disable_can1.dtbo  verdin-imx8mm_extra_gpios_overlay.dtbo  verdin-imx8mm_spidev_overlay.dtbo

Thank you for the answer !

Dear @autolab,

Thank you for contacting us. I will answer you questions further below. Before hand I would like to discuss the usage of the gpiod functionalities. First off you are using the functions correctly here:

However using the get or set function switches the IO state. This means that if you try reading a gpio output with gpioget it switches the pin to an input, which subsequently overwrites the previously set output value. Should you want to measure your output of a specific pin you will have to physically measure it externally.

1.)

These Hex numbers are the socalled pad control, which defines specific functionalities, such as drive strength, pull up/down, etc., for the defined pin. You can find the tables to calculate the numbers in the reference manual for the used SoC.

2.)

To check if the desired pins and functionalities are available, I suggest using our pinout generator, which checks what components can possibly be configured for your specific module. You can also consult the reference manual of both the module and the SoC. For checking the device tree itself I can recommend the following tool called find-in-devicetree.

3.)

the pinfunc.h file is necessary for the makros defined within it. These macros define how the specified pins should act, when defined as a pinctrl.

Best regards
Collin

1 Like

Hello,

thank you for the answer, really helpfull !! :slight_smile:

I tried to measure my GPIO outputs and it’s working.

I have an other question:

I added 2 GPIOS to my device tree overlay

  1. SODIMM_20
  2. SODIMM_22
/dts-v1/;
/plugin/;

#include "../dts-arm64/imx8mm-pinfunc.h"


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

&sai2 {
    status="disabled";
};

&ecspi3{
    status="disabled";
};

&iomuxc {
	pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_gpio3>, <&pinctrl_gpio4>, <&pinctrl_gpio7>,
		    <&pinctrl_gpio8>, <&pinctrl_gpio_hog1>,
		    <&pinctrl_gpio_hog2>, <&pinctrl_gpio_hog3>,
		    <&pinctrl_pmic_tpm_ena>, <&pinctrl_my_gpios>;
    
     pinctrl_my_gpios: my_example_grp {
            fsl,pins = <
                MX8MM_IOMUXC_SAI2_TXC_GPIO4_IO25      0x184     /* SODIMM_30 GPIO_2_P */

                MX8MM_IOMUXC_NAND_RE_B_GPIO3_IO15     0x184     /* SODIMM_17 GPIO_1_P */
                
                MX8MM_IOMUXC_NAND_CE2_B_GPIO3_IO3     0x184     /* SODIMM_21 GPIO_1_N */

                MX8MM_IOMUXC_UART2_RXD_GPIO5_IO24     0x184     /* SODIMM_20 GPIO_R_1 */

                MX8MM_IOMUXC_UART1_RXD_GPIO5_IO22     0X184     /* SODIMM_22 GPIO_R_2 */
            >;
        };
    pinctrl_pwm_4: pwm4grp {
		fsl,pins = <
			MX8MM_IOMUXC_GPIO1_IO15_PWM4_OUT			0x6	/* SODIMM 187 */
		>;
	};
};

my problem is that there aren’t listed in the “gpioinfo” list so i can’t use the command :

gpiofind SODIMM_20
//and
gpiofind SODIMM_22

Do i need to add them somewhere in my overlay or something ?

Thank you

Best regards

Dear @autolab,

I am glad to hear that the outputs are working.
For SODIMM_20 and SODIMM_22 to even be gpio options you will need to check if your module has a can interface or not. If you module HAS a can-bus interface you will NOT be able to use these pins as gpios as mentioned on our datasheet:

If you are not using a module with can-bus interface we should be able to see the gpios under bank 5, line 24 for SODIMM_20 and line 22 for SODIMM_22.

Therefore you should be able create a node in your overlay and for gpio5 in this fashion:

&gpio5 {
        gpio-line-names = "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "SODIMM_22",
                          "",
                          "SODIMM_20",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "";
};

Could you please also share your output of gpioinfo?
Please let me know how you fare with this.

Best regards
Collin

1 Like

Hi,

Thank you a lot for the answer, it worked !!

my gpioinfo now list all my SODIMM including SODIMM_22 & SODIMM_20.

Thank you again for the help :smile:

Best regards