Colibri iMX6ULL GPIO with Device Tree

I have problems getting the gpio’s working.

Device Tree (I also included some other stuff than the gpio_additional node and the iomux because the problem may be elsewhere. please ask if you need other stuff e.g. regulator,clocks,display,pwm,audio…)

/ {
        /*   some other stuff    */
        gpio_additional {
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_additionalgpio>;
                status = "okay";
        };
};

/* UART <A> */
&uart1 {
        status = "okay";
        /delete-property/uart-has-rtscts;
};

/* UART <B> */
&uart2 {
        status = "okay";
        ///delete-property/uart-has-rtscts;
};

/* UART <C> */
&uart5 {
        status = "disabled";
};

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

        imx6ull-colibri {
                pinctrl_gpiotouch: touchgpios {
                        fsl,pins = <
                                MX6UL_PAD_NAND_DQS__GPIO4_IO16          0x74
                                MX6UL_PAD_ENET1_TX_EN__GPIO2_IO05       0x14
                        >;
                };

                pinctrl_audmux: audmuxgrp {
                        fsl,pins = <
                                MX6UL_PAD_SD1_CLK__SAI2_MCLK            0x130b1
                                MX6UL_PAD_JTAG_TDI__SAI2_TX_BCLK        0x130b0
                                MX6UL_PAD_JTAG_TRST_B__SAI2_TX_DATA     0x130b0
                                MX6UL_PAD_SD1_DATA0__SAI2_TX_SYNC       0x130b1
                        >;
                };

                pinctrl_additionalgpio: additionalgpios {
                        fsl,pins = <
                                MX6UL_PAD_UART1_RTS_B__GPIO1_IO19       0x130b0
                                MX6UL_PAD_SD1_DATA1__GPIO2_IO19         0x30
                                MX6UL_PAD_SD1_DATA3__GPIO2_IO21         0x30
                                MX6UL_PAD_ENET1_RX_DATA0__GPIO2_IO00    0x30   
                                MX6UL_PAD_ENET1_RX_DATA1__GPIO2_IO01    0x30   
                                MX6UL_PAD_CSI_DATA07__GPIO4_IO28        0x30
                                MX6UL_PAD_ENET1_TX_CLK__GPIO2_IO06      0x30 
                                MX6UL_PAD_CSI_DATA04__GPIO4_IO25        0x30
                                MX6UL_PAD_JTAG_TDO__GPIO1_IO12          0x30
                                MX6UL_PAD_CSI_MCLK__GPIO4_IO17          0x30
                                MX6UL_PAD_CSI_DATA02__GPIO4_IO23        0x10000
                                MX6UL_PAD_CSI_VSYNC__GPIO4_IO19         0xB000
                                MX6UL_PAD_CSI_DATA06__GPIO4_IO27        0xB000
                                MX6UL_PAD_GPIO1_IO03__GPIO1_IO03        0xB000
                                MX6UL_PAD_CSI_DATA03__GPIO4_IO24        0xB000 
                        >;
                };
        };
};

Testing gpio 19 by measuring pin 19 on the Toradex Evaluation Board (Rev 3.2)

echo 19 > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio19/direction
echo 1 > /sys/class/gpio/gpio19/value
echo 0 > /sys/class/gpio/gpio19/value

nothing…

cat /sys/kernel/debug/gpio

prior to exporting gpio dosent show gpio 19, after exporting and set direction it shows up in /sys/kernel/debug/gpio and even the value changes after setting 0 or 1… but no 3.3V on the pin.

Dear @codeshredder726b,

Greetings from Toradex Community!

The SODIMM pin 19 on the X1 bank of the Colibri Evaluation board is GPIO1_IO04 (Datasheet Page number 21). That can be translated to GPIO pin number → 4, according to the calculation here. And so, you need to export 4 and not 19.

The GPIOs are enabled by default and when you export the pin correctly, it should work automatically (without any device tree changes). You can refer the following links for more info on GPIO:

Best Regards,
Janani

Hi @saijanani.tx
Thank you

Isn’t it the other way, MX6UL_PAD_UART1_RTS_B__GPIO1_IO19 is X1 pin 27?

i.MX6ULLBall Name: UART1_RTS

used as ALT5: gpio1.IO[19]

X1 Pin: 27

Kind regards

Hello @codeshredder726b ,

Yes, you are right, if we are talking about the MX6UL_PAD_UART1_RTS_B__GPIO1_IO19. It was not clear to me before.

Could you get that working now?

Best Regards,
Janani

Hi,

I do not know how to link this to another question that was answered so if you look for

GPIO - Device tree no effect

You will see i had a similar issue and explain how i fixed this and some additional useful information

maybe this one , https://www.toradex.com/community/questions/54729/gpio-device-tree-no-effect.html?childToView=54841#answer-54841 ?

Hi @saijanani.tx
We got it working. Problem was the pins were already defined before our dtsi was included.

//&flexcan1 {
//      pinctrl-names = "default";
//      pinctrl-0 = <&pinctrl_flexcan1>;
//      status = "disabled";
//};

//&flexcan2 {
//      pinctrl-names = "default";
//      pinctrl-0 = <&pinctrl_flexcan2>;
//      status = "disabled";
//};

and in &iomuxc delete the nodes did the trick

                /delete-node/flexcan1-grp;
                /delete-node/flexcan2-grp;
                /delete-node/gpio2-grp;
                /delete-node/gpio4-grp;
                /delete-node/gpio6-grp;
                /delete-node/gpio7-grp;
                /delete-node/usdhc2-grp;
                /delete-node/uart1-ctrl1-grp;

Hi @codeshredder726b,

You shouldn’t delete pin groups, but instead disable unused peripherals with status=“disabled”. In your first post you have additionalgpios defined, but it hasn’t any effect until you reference it from some peripheral which is enabled and will activate your pin group. iomuxc it self can reference some pingroups via pinctrl-0. These pingroups are initialized along with iomuxc. This is what we have in imx6ull-colibri-nonwifi.dtsi:

&iomuxc {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_gpio1 &pinctrl_gpio2 &pinctrl_gpio3
		&pinctrl_gpio4 &pinctrl_gpio5 &pinctrl_gpio6 &pinctrl_gpio7>;
};

So what you have commented out in your first message was quite right, but you shouldn’t disable all other pinctrl_gpioN groups replacing pinctrl-0 with only your group, but ether a) add it to the list of other pin groups, perhaps they are needed for something or b) replace pinctrl_gpio1 so that it will include your GPIO1_IO19, do the same for other required gpios from different pinctrl_gpioN’s.

Hi @codeshredder726b

Perfect that your issue is solved. @Edward is right, you should not delete pin groups but disable the nodes where these pins are used.

Best regards,
Jaski