Device Tree SODIMM 105, SODIMM 107, SODIMM 129 and SPI CS 1, spidev1

With regards to my GPIO problem you solved earlier (GPIO configuration on IMX.6 - #12 by lucas_a.tx),

I tried to enable some other GPIOs, using the same technique as you taught. Some seem to work but with others I experienced some problems. I think it worked for all the pins 113, 115, 117,119, 123, 125, and 127

I can’t seem to figure out the right soultion for the SODIMM 105, 107 and 129…
For SODIMM 105 I can’t even figure out what the name of the PAD should be. Says GPIO2_IO23 in the datasheet, should it be MX6QDL_PAD_EIM_CS0__GPIO2_IO23 ?

I am also trying to add a CS line for spidev1

imx6dl-colibri-eval.dts


&ecspi4 {
	status = "okay";

	mcp251x0: mcp251x@0 {
		compatible = "microchip,mcp2515";
		reg = <0>;
		clocks = <&clk16m>;
		interrupt-parent = <&gpio3>;
		interrupts = <27 0x2>;
		spi-max-frequency = <10000000>;
		status = "disabled";
	};

	/* To keep the CAN controller enabled by default,  */
	/*  disable conflicting spidev. This spidev device */
	/*  enables with the devicetree overlay.           */
	/*                                                 */

	spidev0: spidev@0 {
		compatible = "toradex,evalspi";
		reg = <0>;
		spi-max-frequency = <23000000>;
		status = "okay";
	};

    /* the following added June 13th according to Renato */ 
	spidev1: spidev@1 {
		compatible = "toradex,evalspi";
		reg = <1>;
		spi-max-frequency = <23000000>;
		status = "okay";
	}; 

};

.
.
.


&iomuxc {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_gpio_custom>;
    pinctrl_gpio_custom: gpiocustom {
        fsl,pins = <

    /*         MX6QDL_PAD_EIM_CS0_GPIO2_IO23                                           /* ARM_OE -    SODIMM 105 */
            MX6QDL_PAD_EIM_CS1__GPIO2_IO24      0x1b0b0  /* DOUT_FAULT- SODIMM 107 */
            MX6QDL_PAD_EIM_DA1__GPIO3_IO01      0x1b0b0  /* DOUT1 -     SODIMM 113 */
            MX6QDL_PAD_EIM_DA2__GPIO3_IO02      0x1b0b0  /* DOUT2 -     SODIMM 115 */
            MX6QDL_PAD_EIM_DA3__GPIO3_IO03      0x1b0b0  /* DOUT3 -     SODIMM 117 */
            MX6QDL_PAD_EIM_DA4__GPIO3_IO04      0x1b0b0  /* DOUT4 -     SODIMM 119 */
            MX6QDL_PAD_EIM_DA5__GPIO3_IO05      0x1b0b0  /* DIN3 -      SODIMM 121 */
            MX6QDL_PAD_EIM_DA6__GPIO3_IO06      0x1b0b0  /* DIN1 -      SODIMM 123 */
            MX6QDL_PAD_EIM_DA7__GPIO3_IO07      0x1b0b0  /* DIN4 -      SODIMM 125 */
            MX6QDL_PAD_EIM_DA8__GPIO3_IO08      0x1b0b0  /* DIN2 -      SODIMM 127 */
            MX6QDL_PAD_EIM_D31__GPIO3_IO31      0x1b0b0  /* AO_FAULT -  SODIMM 129 */

        >;

    };

};

for the CS pin for my SPI bus so I added this:

imx6qdl-colibri.dtsi

pinctrl_ecspi4: ecspi4grp {
        fsl,pins = <
            MX6QDL_PAD_EIM_D22__ECSPI4_MISO 0x100b1
            MX6QDL_PAD_EIM_D28__ECSPI4_MOSI 0x100b1
            MX6QDL_PAD_EIM_D21__ECSPI4_SCLK 0x100b1
            /* SPI CS */
            MX6QDL_PAD_EIM_A25__GPIO5_IO02  0x000b1  /* Emera DAC */
            MX6QDL_PAD_EIM_D24__GPIO3_IO24  0x000b1  /* Emera DSP  - added additional chip select line June 13th according to Renato's file CS.txt  */
        >;
    };

and also here (in the same file)

&ecspi4 {
    fsl,spi-num-chipselects = <2>;
    cs-gpios = <&gpio5 2 GPIO_ACTIVE_HIGH>, <&gpio3 24 GPIO_ACTIVE_HIGH>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_ecspi4>;
    status = "okay";

    spidev0: spidev@0 {
        compatible = "toradex,evalspi";
        reg = <0>;
        spi-max-frequency = <23000000>;
    };

    spidev1: spidev@1 {
        compatible = "toradex,evalspi";
        reg = <0>;
        spi-max-frequency = <23000000>;
    };
};

but I get these error messages on bootup:


[    0.054033] debugfs: Directory 'dummy-iomuxc-gpr@20e0000' with parent 'regmap' already present!
[    0.084185] imx6dl-pinctrl 20e0000.iomuxc: pin MX6DL_PAD_EIM_D31 already requested by 20e0000.iomuxc; cannot claim for regulator-usb-host-vbus
[    0.084217] imx6dl-pinctrl 20e0000.iomuxc: pin-96 (regulator-usb-host-vbus) status -22
[    0.084238] imx6dl-pinctrl 20e0000.iomuxc: could not request pin 96 (MX6DL_PAD_EIM_D31) from group gpioregusbhpwrgrp  on device 20e0000.iomuxc
[    0.084260] reg-fixed-voltage regulator-usb-host-vbus: Error applying setting, reverse things back
[    1.617448] imx6dl-pinctrl 20e0000.iomuxc: pin MX6DL_PAD_EIM_D24 already requested by 2020000.serial; cannot claim for 2014000.spi
[    1.629267] imx6dl-pinctrl 20e0000.iomuxc: pin-89 (2014000.spi) status -22
[    1.636187] imx6dl-pinctrl 20e0000.iomuxc: could not request pin 89 (MX6DL_PAD_EIM_D24) from group ecspi4grp  on device 20e0000.iomuxc
[    1.648302] spi_imx 2014000.spi: Error applying setting, reverse things back

Hi @leighjboyd,

The error messages in the boot sequence indicate that pins MX6QDL_PAD_EIM_D31 and MX6QDL_PAD_EIM_D24 are already in use by other peripherals, namely regulator-usb-host-vbus and serial (UART A).

Looking at the Device Tree we can confirm these two are indeed being used:

[...]
	reg_usb_host_vbus: regulator-usb-host-vbus {
        [...]
		pinctrl-0 = <&pinctrl_regulator_usbh_pwr>;
        [...]
	};
[...]
	pinctrl_regulator_usbh_pwr: gpioregusbhpwrgrp {
		fsl,pins = <
			/* USBH_EN */
			MX6QDL_PAD_EIM_D31__GPIO3_IO31	0x0f058
		>;
	};
[...]
/* Colibri UART_A */
&uart1 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart1_dte &pinctrl_uart1_ctrl>;
	fsl,dte-mode;
	uart-has-rtscts;
	status = "disabled";
};
[...]
	/* Additional DTR, DSR, DCD */
	pinctrl_uart1_ctrl: uart1ctrlgrp {
		fsl,pins = <
			MX6QDL_PAD_EIM_D23__UART1_DCD_B 0x1b0b0
			MX6QDL_PAD_EIM_D24__UART1_DTR_B 0x1b0b0
			MX6QDL_PAD_EIM_D25__UART1_DSR_B 0x1b0b0
		>;
	};
[...]

These nodes are then activated in the dts file for the eval board:

&reg_usb_host_vbus {
	status = "okay";
};

&uart1 {
	status = "okay";
};

You can set status = "disabled"; on both nodes in your Device Tree to make the pins available; that should solve the error messages. However, please be aware that:

  • Disabling reg_usb_host_vbus will disable the USB Host function on your module;
  • uart1 is for this SoM the standard debug interface used in TorizonCore and in our reference images. If you disable it you won’t be able to see the terminal output in the serial connection after loading the Device Tree, although SSH connection should work as usual.

You can also try removing pinctrl_uart1_ctrl from pinctrl-0 in uart1 instead of disabling it and see if serial output still works.

As for SODIMM pins 105 and 107 not working, that’s strange. Just to confirm, did you disable weim in your Device Tree before setting them as GPIO? I’ll do some tests to see if I can make them work.

Let me know if that helps you.

Best regards,
Lucas Akira

1 Like

Hi @leighjboyd,

I just realized I forgot to answer your question at the beginning: Yes, SODIMM 105 as GPIO is defined as MX6QDL_PAD_EIM_CS0__GPIO2_IO23. You can check all pin names for the Colibri iMX6DL in this header file.

I was able to successfully enable SODIMM pins 105, 107 and 129 as GPIO. To do that I added the following to imx6dl-colibri-eval-v3.dts:

  • Disabled weim if it isn’t already:
&weim {
	status = "disabled";
};
  • Disabled reg_usb_host_vbus in order to make SODIMM 129 available:
&reg_usb_host_vbus {
	status = "disabled";
};

USB ports on the eval board didn’t work after doing this.

  • Changed uart1 so that it doesn’t use pin MX6QDL_PAD_EIM_D24:
&uart1 {
	pinctrl-0 = <&pinctrl_uart1_dte>;
};

Fortunately I could still see terminal output through serial as usual. This should solve the problem with the SPI.

  • Added these SODIMM pins as GPIO through pinctrl-0 in iomuxc:
&iomuxc {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_gpio_custom>;

	pinctrl_gpio_custom: gpiocustom {
		fsl,pins = <
			MX6QDL_PAD_EIM_CS0__GPIO2_IO23		0x1b0b0  /*             SODIMM 105 */
            MX6QDL_PAD_EIM_CS1__GPIO2_IO24      0x1b0b0  /* DOUT        SODIMM 107 */
            MX6QDL_PAD_EIM_DA1__GPIO3_IO01      0x1b0b0  /* DOUT1 -     SODIMM 113 */
            MX6QDL_PAD_EIM_DA2__GPIO3_IO02      0x1b0b0  /* DOUT2 -     SODIMM 115 */
            MX6QDL_PAD_EIM_DA3__GPIO3_IO03      0x1b0b0  /* DOUT3 -     SODIMM 117 */
            MX6QDL_PAD_EIM_DA4__GPIO3_IO04      0x1b0b0  /* DOUT4 -     SODIMM 119 */
            MX6QDL_PAD_EIM_DA5__GPIO3_IO05      0x1b0b0  /* DIN3 -      SODIMM 121 */
            MX6QDL_PAD_EIM_DA6__GPIO3_IO06      0x1b0b0  /* DIN1 -      SODIMM 123 */
            MX6QDL_PAD_EIM_DA7__GPIO3_IO07      0x1b0b0  /* DIN4 -      SODIMM 125 */
            MX6QDL_PAD_EIM_DA8__GPIO3_IO08      0x1b0b0  /* DIN2 -      SODIMM 127 */
            MX6QDL_PAD_EIM_D31__GPIO3_IO31      0x1b0b0  /* AO   -      SODIMM 129 */

		>;
	};
};

Using gpioset all pins listed above function as they should.

I’ve attached the final .dts file with all these additions if you need to verify the result. This is the exact file that I used for the tests.

Let me know if this solves your problem.

Best regards,
Lucas Akira

imx6dl-colibri-eval-v3-more-gpio-custom.dts (5.6 KB)

1 Like

Wow, yes that was a big help, and the serial port seems to still do its job!

I can now confirm at least that the following GPIOs are working for me:

            MX6QDL_PAD_EIM_CS0__GPIO2_IO23      0x1b0b0  /*              SODIMM 105 */
            MX6QDL_PAD_EIM_CS1__GPIO2_IO24      0x1b0b0  /* DOUT        SODIMM 107 */
            MX6QDL_PAD_EIM_DA1__GPIO3_IO01      0x1b0b0  /* DOUT1 -     SODIMM 113 */
            MX6QDL_PAD_EIM_DA2__GPIO3_IO02      0x1b0b0  /* DOUT2 -     SODIMM 115 */
            MX6QDL_PAD_EIM_DA3__GPIO3_IO03      0x1b0b0  /* DOUT3 -     SODIMM 117 */
            MX6QDL_PAD_EIM_DA4__GPIO3_IO04      0x1b0b0  /* DOUT4 -     SODIMM 119 */
            MX6QDL_PAD_EIM_DA5__GPIO3_IO05      0x1b0b0  /* DIN3 -      SODIMM 121 */
            MX6QDL_PAD_EIM_DA6__GPIO3_IO06      0x1b0b0  /* DIN1 -      SODIMM 123 */
            MX6QDL_PAD_EIM_DA7__GPIO3_IO07      0x1b0b0  /* DIN4 -      SODIMM 125 */
            MX6QDL_PAD_EIM_DA8__GPIO3_IO08      0x1b0b0  /* DIN2 -      SODIMM 127 */

I am curious about what 0x1b0b0 means though…

However
MX6QDL_PAD_EIM_DA8__GPIO3_IO08 0x1b0b0 /* DIN2 - SODIMM 127 */

does not work yet. Even though I have disabled reg_usb_host_vbus in imx6dl-colibri-eval-v3.dts:

/* Should be disabled in order to use SODIMM 129 as GPIO */
&reg_usb_host_vbus {
status = "disabled";
};

but If I disable this, can I still use the uSD card? is that not something which requires USB host?

Still not certain if I have spidev1 CS set up correctly… I assume not. Post more tomorrow…

But when booting I get the message


Starting kernel ...

[    0.054196] debugfs: Directory 'dummy-iomuxc-gpr@20e0000' with parent 'regmap' already present!
[    1.581077] spi_imx 2014000.spi: chipselect 0 already in use
[    1.586805] spi_master spi3: spi_device register error /soc/aips-bus@2000000/spba-bus@2000000/spi@2014000/spidev@1

The relevant sections of imx6dl-colibri-eval-v3.dts look like this:


/* Colibri SSP */
&ecspi4 {
	status = "okay";

	mcp251x0: mcp251x@0 {
		compatible = "microchip,mcp2515";
		reg = <0>;
		clocks = <&clk16m>;
		interrupt-parent = <&gpio3>;
		interrupts = <27 0x2>;
		spi-max-frequency = <10000000>;
		status = "disabled";
	};

	spidev0: spidev@0 {
		compatible = "toradex,evalspi";
		reg = <0>;
		spi-max-frequency = <23000000>;
		status = "okay";
	};
};

/*
 * Colibri I2C: I2C3_SDA/SCL on SODIMM 194/196 (e.g. RTC on carrier board)
 */
&i2c3 {
	status = "okay";  /* Renato thinks we should disable this, to stop using the RTC on the Colibri Evaluation Carrier board, and instead use it for I2C chip select */

	/* M41T0M6 real time clock on carrier board */
	rtc_i2c: rtc@68 {
		compatible = "st,m41t0";
		reg = <0x68>;
	};
};

and in imx6qdl-colibri.dtsi I have:


	pinctrl_ecspi4: ecspi4grp {
		fsl,pins = <
			MX6QDL_PAD_EIM_D22__ECSPI4_MISO	0x100b1
			MX6QDL_PAD_EIM_D28__ECSPI4_MOSI	0x100b1
			MX6QDL_PAD_EIM_D21__ECSPI4_SCLK 0x100b1
			/* SPI CS */
			MX6QDL_PAD_EIM_A25__GPIO5_IO02	0x000b1  /* Emera DAC */
			MX6QDL_PAD_EIM_D24__GPIO3_IO24  0x000b1  /* Emera DSP  - added additional chip select line June 13th according to Renato's file CS.txt  */
		>;
	};

[...]
* Added June 13th accoring to Renato Dutra file cs.txt */
/* Colibri SSP */
&ecspi4 {
	
	fsl,spi-num-chipselects = <2>;
	cs-gpios = <&gpio5 2 GPIO_ACTIVE_HIGH>, <&gpio3 24 GPIO_ACTIVE_HIGH>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi4>;
	status = "okay";
	
	spidev0: spidev@0 {
		compatible = "toradex,evalspi";
		reg = <0>;
		spi-max-frequency = <23000000>;
	};
	
	spidev1: spidev@1 {
		compatible = "toradex,evalspi";
		reg = <0>;
		spi-max-frequency = <23000000>;
	};
};

which I can see already doesn’t match up very well.

I had /dev/spidev3.0 working earlier in the year, but have not checked on its status since working with CAN and GPIOs…

But a consultant said I should add these parts added here with spidev0 and spidev1 were not present earlier when things WERE working… Not sure but it seems odd that I am using spidev3.0 and the consultant says I should ad spidev0 and spidev1…

I am curious about what 0x1b0b0 means though…

This value is a bit configuration field. It passes additional information to the pin registers on how to further configure the field. Each SoC has different values, so “0x1b0b0” on the i.MX6 is not the same as “0x1b0b0” on the i.MX8. In order to know what these values mean and other options for values you’d need to consult the SoC specific reference manual from NXP.

However
MX6QDL_PAD_EIM_DA8__GPIO3_IO08 0x1b0b0 /* DIN2 - SODIMM 127 */
does not work yet. Even though I have disabled reg_usb_host_vbus in imx6dl-colibri-eval-v3.dts:

I thought you said in your original post that you were able to use 127 correctly? Also disabling reg_usb_host_vbus was to free up pin 129 not 127. Are you perhaps mixing the pin numbers up?

but If I disable this, can I still use the uSD card? is that not something which requires USB host?

The SD/MMC interface should be different than the USB host. Why is your SD/MMC interface not working anymore?

Regarding your SPI changes, one immediate issue I see is that you have spidev0 and spidev1, configured to use the same chip-select. Which is determined by the reg field which you have set to 0 for both of these. Meaning they’re both using the first chip select.

Which is why on boot you get the message spi_imx 2014000.spi: chipselect 0 already in use.

Best Regards,
Jeremias

Okay, so not in the iMX6 Colibri datasheet then?

Yes, sorry SODIMM 127 is working, SODIMM 129 is not.

I have not checked, I just did a google search on USB host mode, and made that assumption.
So disabling USB host might mean for example I can’t use the mouse then?

Thanks for spotting that. I will fix it now.

Okay, so not in the iMX6 Colibri datasheet then?

No, this information is specific to the SoC itself which comes from NXP.

Yes, sorry SODIMM 127 is working, SODIMM 129 is not.

Hmm strange as long as reg_usb_host_vbus is disabled, SODIMM 129 appears to work on my setup. How are you confirming that it doesn’t work on your side?

I have not checked, I just did a google search on USB host mode, and made that assumption.
So disabling USB host might mean for example I can’t use the mouse then?

Well the modification as it is now specifically disables reg_usb_host_vbus which controls and enables the power to the USB host interface. You can still use USB but you’ll need to substitute another GPIO in SODIMM 129’s place.

Best Regards,
Jeremias

Hi again,

Okay, so I test the GPIOs with this code:

	while (1) {

		sleep(1);
		
		line_value = !line_value;

		for (bank = 0; bank <8; bank++){

		//	snprintf(chip, sizeof(chip), "gpiochip%d",DOUT1_BANK);
		//	printf("Setting %s to %d\n",chip, line_value);

			
			for (offset =0; offset <32; offset++){
			
					OutputGPIO(bank, offset, line_value);  // reset all outputs

					if ((bank == 2 ) && (offset == 31)){
						printf("Setting %s line %d to %d\n",bank, offset, line_value);
					}
				
			} 

		

		}


	
	//	input = InputGPIO(DIN1_BANK, DIN1_LINE);
	//	printf("Input: %d\n", input);

	}


int OutputGPIO(int bank, unsigned int line, int value ){

	char chip[32];

	snprintf(chip, sizeof(chip), "gpiochip%d",bank);

	gpiod_ctxless_set_value(chip, line, value, false,"EmeraOutput",NULL,NULL);

}

The problem was with the “32” in the code, I had 31 (which meant it only went up to line 30!)
duh…

Thanks again… now the IO is working, along with debug mode as you had!

Glad we managed to help you!

Best regards,
Lucas Akira