Apalis I.MX6 Device Tree Overlay pinmux for GPIO

Dear all,
After succesfully config UART2 as simple uart without rts and cts, we are changing the functionality of several peripherals to be GPIOs.
As can be seen in the device tree overlay we have disbled many modules. We have several issues with the gpios, because we can manage a few but many are not changing their state.
The module LCD is disabled and we manage pin 251, 253, but we are not able to manage pin 255,257,259,261.
The module MMC1 is disabled and we are not able to manage any pins, in particulary we focus in pin 152,156,158
The Device Tree overlay file is compiled correctly and also is load by the uboot. The pins are managed by the gpioset command, like gpioset 1 2=0. The command is accept and any message is shown, but the state of the pin is not changed.

Please could you give some advice to get those GPIOs availables?

Thank you

Our hardware is:
Apalis iMX6D 1GB IT
Custom board base in Apalis Eval Board v1.1
Linux apalis-imx6-10806407 6.1.22-6.2.0 (Reference image Apalis-iMX6_Reference-Multimedia-Image-upstream)

/dts-v1/;
/plugin/; //Indicates a Device Tree Overlay

// Header file with pin definitions
#include <imx6dl-pinfunc.h>

/ {
    compatible = "toradex,apalis_imx6q";// Set hardware compatibility

    backlight: backlight {
        status = "disabled";
    };

    lcd_display: disp0 {
        status = "disabled";
    };

    panel_dpi: panel-dpi {
        status = "disabled";
    };

    panel_lvds: panel-lvds {
        status = "disabled";
    };      
       
};

&audmux {
    status = "disabled";
};    
    
&can1 {
    status = "disabled";
};

&can2 {
    status = "disabled";
};

&pcie{
    status = "disabled";
};

&ipu1_csi1  {
    status = "disabled";
};

&ldb     {
    status = "disabled";
};
 
&mipi_csi {
    status = "disabled";
};

&mipi_dsi {
    status = "disabled";
};

&pwm1 {
    status = "disabled";
};

&pwm2 {
    status = "disabled";
};

&pwm3 {
    status = "disabled";
};

&pwm4 {
    status = "disabled";
};

&sata {
	status = "disabled";
};

&sound_spdif  {
    status = "disabled";
};

&spdif   {
    status = "disabled";
};

&usdhc1   {
    status = "disabled";
};
 
&usdhc2   {
    status = "disabled";
};

&ssi1     {
    status = "disabled";
};


&iomuxc {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_gpio_custom>;  // Pin group available in userspace i.e. as GPIO

    pinctrl_gpio_custom: gpiocustom {
        fsl,pins = <
            MX6QDL_PAD_GPIO_9__GPIO1_IO09       0x130b0  /* SODIMM  2 */
            MX6QDL_PAD_GPIO_1__GPIO1_IO01       0x130b0  /* SODIMM  4 */
            MX6QDL_PAD_SD4_DAT1__GPIO2_IO09     0x130b0  /* SODIMM  6 */
            MX6QDL_PAD_SD4_DAT2__GPIO2_IO10     0x130b0  /* SODIMM  8 */

            MX6QDL_PAD_SD4_DAT5__GPIO2_IO13		0x130b0  /* SODIMM  128  */
            MX6QDL_PAD_SD4_DAT6__GPIO2_IO14     0x130b0  /* SODIMM  130 */

           /* MX6QDL_PAD_NANDF_D0__GPIO2_IO00     0x130b0  /* SODIMM  148 */     
            MX6QDL_PAD_NANDF_D1__GPIO2_IO01     0x130b0  /* SODIMM  152 */     
            MX6QDL_PAD_NANDF_D2__GPIO2_IO02     0x130b0  /* SODIMM  156 */     
            MX6QDL_PAD_NANDF_D3__GPIO2_IO03     0x130b0  /* SODIMM  158 */     
          /*  MX6QDL_PAD_DI0_PIN4__GPIO4_IO20     0x130b0  /* SODIMM  164 */ 

            MX6QDL_PAD_EIM_A21__GPIO2_IO17      0x130b0  /* SODIMM  251  */     
            MX6QDL_PAD_EIM_A23__GPIO6_IO06      0x130b0  /* SODIMM  255  */     
            MX6QDL_PAD_EIM_D31__GPIO3_IO31      0x130b0  /* SODIMM  259  */     

            MX6QDL_PAD_EIM_A22__GPIO2_IO16      0x130b0  /* SODIMM  253  */     
            MX6QDL_PAD_EIM_A24__GPIO5_IO04      0x130b0  /* SODIMM  257  */     
            MX6QDL_PAD_EIM_D30__GPIO3_IO30      0x130b0  /* SODIMM  261  */  


            MX6QDL_PAD_KEY_ROW4__GPIO4_IO15     0x130b0  /* SODIMM  16 */
            MX6QDL_PAD_KEY_COL4__GPIO4_IO14     0x130b0  /* SODIMM  18 */

            MX6QDL_PAD_EIM_D20__GPIO3_IO20      0x130b0  /* SODIMM  114 */
            MX6QDL_PAD_EIM_D23__GPIO3_IO23      0x130b0  /* SODIMM  124 */
            MX6QDL_PAD_EIM_D23__GPIO3_IO23      0x130b0  /* SODIMM  122 */

            MX6QDL_PAD_EIM_D23__GPIO3_IO23      0x130b0  /* SODIMM  191 */
            MX6QDL_PAD_NANDF_CS2__GPIO6_IO15    0x130b0  /* SODIMM  193 */
            MX6QDL_PAD_CSI0_VSYNC__GPIO5_IO21   0x130b0  /* SODIMM  195 */

         /*   MX6QDL_PAD_CSI0_DAT12__GPIO5_IO30   0x130b0  /* SODIMM  187 */
         /*   MX6QDL_PAD_CSI0_DAT13__GPIO5_IO31   0x130b0  /* SODIMM  185 */
         /*   MX6QDL_PAD_CSI0_DAT14__GPIO6_IO00   0x130b0  /* SODIMM  183 */
          /*   MX6QDL_PAD_CSI0_DAT15__GPIO6_IO01   0x130b0  /* SODIMM  181 */
          /*  MX6QDL_PAD_CSI0_DAT16__GPIO6_IO02   0x130b0  /* SODIMM  179 */
          /*  MX6QDL_PAD_CSI0_DAT17__GPIO6_IO03   0x130b0  /* SODIMM  177 */
          /*  MX6QDL_PAD_CSI0_DAT18__GPIO6_IO04   0x130b0  /* SODIMM  175 */
           /* MX6QDL_PAD_CSI0_DAT19__GPIO6_IO05   0x130b0  /* SODIMM  173 */

        >;
    };
};



Hi @aarribas ,

In your overlay I’ve noticed that you referenced some nodes inside the root node of the overlay, like backlight, lcd_display, panel_dpi and panel_lvds. I think these should be outside the root node and referenced with & like you did for the others e.g.

/dts-v1/;
/plugin/; //Indicates a Device Tree Overlay

// Header file with pin definitions
#include <imx6dl-pinfunc.h>

/ {
    compatible = "toradex,apalis_imx6q";// Set hardware compatibility
};

&backlight {
        status = "disabled";
};

&lcd_display {
        status = "disabled";
};

&panel_dpi {
        status = "disabled";
};

&panel_lvds {
        status = "disabled";
};

&audmux {
    status = "disabled";
};  

[...]

To help narrow down the issue I would also try creating a simpler overlay that only sets some pins as GPIOs, like two or three pins in a pinctrl group, maybe also including some of the default GPIO pins set on the Apalis iMX6 Device Tree just to be sure they’re still working.

Best regards,
Lucas Akira

Hi @lucas_a.tx,
We have done as you said and moved the nodes from / to individual notes outside. We were able to manage several pins from CAM module, but not all. Then we realiazed that the GPIOs not working were comment in the overlay file, so we uncomment them. At this point we can mange those GPIOs (191,193,195,187,185,183,181,179,177,175,173) but we then discover that the ethernet eth0 had gone. If we comment those pins again the eth0 appears again.
By the way LCD module GPIOs were unmanagebles. There is no error when we trying to command the change of their state, but no changes detected.
The MMC module also had its GPIOs uncontrollables.
All the GPIOs defined as GPIO1,2,3,4,5,6,7,8 (Pins 1,3,5,7,11,13,15,17) are full controlables. The GPIOs 16,18,2,4,6,8,128 are also ok, and we can command/read the state as they are defined in the overlay file

Last thing if we uncomment pin 148 and 164 the module gets blocked with the message “Starting Kernel …”

Could you give us any advice to proceed and test?

This is our Device Tree Overlay file right now,

/dts-v1/;
/plugin/; //Indicates a Device Tree Overlay

// Header file with pin definitions
#include <imx6dl-pinfunc.h>

/ {
    compatible = "toradex,apalis_imx6q";// Set hardware compatibility
};

&backlight {
    status = "disabled";
};

&lcd_display {
    status = "disabled";
};

&panel_dpi {
    status = "disabled";
};

&panel_lvds {
    status = "disabled";
};      

&audmux {
    status = "disabled";
};    
    
&can1 {
    status = "disabled";
};

&can2 {
    status = "disabled";
};

&pcie{
    status = "disabled";
};

&ipu1_csi1  {
    status = "disabled";
};

&ldb     {
    status = "disabled";
};
 
&mipi_csi {
    status = "disabled";
};

&mipi_dsi {
    status = "disabled";
};

&pwm1 {
    status = "disabled";
};

&pwm2 {
    status = "disabled";
};

&pwm3 {
    status = "disabled";
};

&pwm4 {
    status = "disabled";
};

&sata {
	status = "disabled";
};

&sound_spdif  {
    status = "disabled";
};

&spdif   {
    status = "disabled";
};


&ssi1     {
    status = "disabled";
};


&iomuxc {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_gpio_custom>;  // Pin group available in userspace i.e. as GPIO

    pinctrl_gpio_custom: gpiocustom {
        fsl,pins = <
            MX6QDL_PAD_GPIO_9__GPIO1_IO09       0x130b0  /* SODIMM  2 AUDIO_PWM_uC   */
            MX6QDL_PAD_GPIO_1__GPIO1_IO01       0x130b0  /* SODIMM  4 RELAY1_CONTROL */
            MX6QDL_PAD_SD4_DAT1__GPIO2_IO09     0x130b0  /* SODIMM  6 RELAY2_CONTROL */
            MX6QDL_PAD_SD4_DAT2__GPIO2_IO10     0x130b0  /* SODIMM  8 DISPLAY_PWM_uC */

            MX6QDL_PAD_SD4_DAT5__GPIO2_IO13		0x130b0  /* SODIMM  128  UART2_TXDEN */
            MX6QDL_PAD_SD4_DAT6__GPIO2_IO14     0x130b0  /* SODIMM  130 POWER_FAIL   */

           /* MX6QDL_PAD_NANDF_D0__GPIO2_IO00     0x130b0  /* SODIMM  148 I2C_EN1 */     
            MX6QDL_PAD_NANDF_D1__GPIO2_IO01     0x130b0  /* SODIMM  152 UART_EN1 */     
            MX6QDL_PAD_NANDF_D2__GPIO2_IO02     0x130b0  /* SODIMM  156 UART_EN2 */     
            MX6QDL_PAD_NANDF_D3__GPIO2_IO03     0x130b0  /* SODIMM  158 UART_EN3 */     
          /*  MX6QDL_PAD_DI0_PIN4__GPIO4_IO20     0x130b0  /* SODIMM  164 I2C_EN2 */ 

            MX6QDL_PAD_EIM_A21__GPIO2_IO17      0x130b0  /* SODIMM  251 ONOFF 1 */     
            MX6QDL_PAD_EIM_A23__GPIO6_IO06      0x130b0  /* SODIMM  255 ONOFF 2 */     
            MX6QDL_PAD_EIM_D31__GPIO3_IO31      0x130b0  /* SODIMM  259 ONOFF 3 */     

            MX6QDL_PAD_EIM_A22__GPIO2_IO16      0x130b0  /* SODIMM  253 MUTE 1 */     
            MX6QDL_PAD_EIM_A24__GPIO5_IO04      0x130b0  /* SODIMM  257 MUTE 2 */     
            MX6QDL_PAD_EIM_D30__GPIO3_IO30      0x130b0  /* SODIMM  261 MUTE 3 */  


            MX6QDL_PAD_KEY_ROW4__GPIO4_IO15     0x130b0  /* SODIMM  16 ONOFF_HPA*/
            MX6QDL_PAD_KEY_COL4__GPIO4_IO14     0x130b0  /* SODIMM  18 ONOFF_MUTE*/

         /*   MX6QDL_PAD_EIM_D20__GPIO3_IO20      0x130b0  /* SODIMM  114 RCU_ENABLE*/
            MX6QDL_PAD_EIM_D23__GPIO3_IO23      0x130b0  /* SODIMM  124 MUTE_EXT*/
         /*   MX6QDL_PAD_EIM_EB3__GPIO2_IO31      0x130b0  /* SODIMM  122 TFT_INT_MCU*/

            MX6QDL_PAD_CSI0_PIXCLK__GPIO5_IO18  0x130b0  /* SODIMM  191 ALARM_1*/
            MX6QDL_PAD_NANDF_CS2__GPIO6_IO15    0x130b0  /* SODIMM  193 ALARM_2*/
            MX6QDL_PAD_CSI0_VSYNC__GPIO5_IO21   0x130b0  /* SODIMM  195 ALARM_3*/

          /*  MX6QDL_PAD_CSI0_DAT12__GPIO5_IO30   0x130b0  /* SODIMM  187 SW4_IND2_mcu*/
          /*  MX6QDL_PAD_CSI0_DAT13__GPIO5_IO31   0x130b0  /* SODIMM  185 SW4_IND1_mcu*/
          /*  MX6QDL_PAD_CSI0_DAT14__GPIO6_IO00   0x130b0  /* SODIMM  183 SW3_IND2_mcu*/
          /*  MX6QDL_PAD_CSI0_DAT15__GPIO6_IO01   0x130b0  /* SODIMM  181 SW3_IND1_mcu*/
          /*  MX6QDL_PAD_CSI0_DAT16__GPIO6_IO02   0x130b0  /* SODIMM  179 SW2_IND2_mcu*/
          /*  MX6QDL_PAD_CSI0_DAT17__GPIO6_IO03   0x130b0  /* SODIMM  177 SW2_IND1_mcu*/
          /*  MX6QDL_PAD_CSI0_DAT18__GPIO6_IO04   0x130b0  /* SODIMM  175 SW1_IND2_mcu*/
          /*  MX6QDL_PAD_CSI0_DAT19__GPIO6_IO05   0x130b0  /* SODIMM  173 SW1_IND1_mcu*/

        >;
    };
};

Hi @aarribas ,

At this point we can mange those GPIOs (191,193,195,187,185,183,181,179,177,175,173) but we then discover that the ethernet eth0 had gone. If we comment those pins again the eth0 appears again.

That’s very strange, the pins you mentioned shouldn’t have anything to do with ethernet.

By the way LCD module GPIOs were unmanagebles. There is no error when we trying to command the change of their state, but no changes detected.

The gpioset command doesn’t really give much info if a pin is correctly muxed as GPIO or not. When the command doesn’t seem to work for a pin it usually means that something in the device tree is not configured correctly for it.

Last thing if we uncomment pin 148 and 164 the module gets blocked with the message “Starting Kernel …”

This happens during boot right? This can happen when something wrong happened when applying an overlay to your device tree blob. It usually means that the overlay is incorrect somehow.

If you got stuck at the “Starting kernel…” message you can tell the bootloader (called U-Boot) to temporarily ignore any overlays: In a serial connection to the module, if you press any key during the initial seconds of the boot process it will stop and give you the U-Boot command line interface instead. After that just type these two commands on U-Boot, as explained here: Device Tree Overlays (Linux) | Toradex Developer Center

setenv skip_fdt_overlays 1
boot

I noticed in your overlay that you included the iMX6DL pin macros. While you are using an Apalis iMX6D, I think that we use the iMX6Q pin macros (imx6q-pinfunc.h) for Apalis iMX6Q and Apalis iMX6D.

Can you check if changing the pin macros to imx6q-pinfunc.h helps? Just changing the #include line at the beginning should be enough. I’ll try to do some tests on my side as well to see if I can reproduce what you’re seeing with some pins.

Best regards,
Lucas Akira

Hi @lucas_a.tx,
We think you have found the problem. We have change the pinfunc library to imx6q-pinfunc.h and every GPIO is working. By the way, from the Toradex info, we understood that the Pin Definitions Header File was imx6dl-pinfunc.h, we could have understood wrong.
We continue testing our custom board with your help
Thank you very much.

Hi @aarribas ,

Glad I was able to help!

By the way, from the Toradex info, we understood that the Pin Definitions Header File was imx6dl-pinfunc.h, we could have understood wrong.

You haven’t understood wrong, and I think the information on that article is, in fact, inaccurate: It should be imx6q-pinfunc.h for the Apalis iMX6D.

I’ll contact the team to correct the table in the article. Sorry for the confusion, and thank you for reporting!

Best regards,
Lucas Akira