SPI not working on Colibri-imx7

I am working on a custom carrier board based on “colibri-imx7-emmc” module. There are thre SPI chips (LS7366R) that I have connected to SPI0, 1 and 2 of the SOM. While ECSPI3 works, the remaining SPIs do not work ECSPI2 and ECSPI1. They do not generate SCLK pulse when checked with an oscilloscope. The following is my software configuration:

$ sudo tdx-info

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           6.1.83-rt28-6.6.0-devel+git.c88639fef1f2 #1-TorizonCore SMP PREEMPT_RT Wed Mar 13 13:37:44 UTC 2024
Kernel command line:      root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.1/torizon/1ce1ac205eaf2736193966875a35e0ec6a3a6e3c4fb3100a05db3c0600d0bf5c/0
Distro name:              NAME="TorizonCore Upstream with PREEMPT_RT"
Distro version:           VERSION_ID=6.6.0-devel-20250207123230-build.0
Distro variant:           VARIANT="Minimal"
Hostname:                 colibri-imx7-emmc-15048509
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Colibri iMX7D 1GB (eMMC) on Teckinsoft Evaluation Board
Toradex version:          0039 V1.1B
Serial number:            15048509
Processor arch:           armv7l
------------------------------------------------------------

The following are the relevant snippets from device tree:-

&iomuxc {
--------------------------
	pinctrl_ecspi3: ecspi3grp {
		fsl,pins = <
			MX7D_PAD_I2C1_SCL__ECSPI3_MISO		0x2 /* SODIMM 90 */
			MX7D_PAD_I2C1_SDA__ECSPI3_MOSI		0x2 /* SODIMM 92 */
			MX7D_PAD_I2C2_SCL__ECSPI3_SCLK		0x2 /* SODIMM 88 */
		>;
	};

	pinctrl_ecspi3_cs: ecspi3csgrp {
		fsl,pins = <
			//MX7D_PAD_I2C2_SDA__ECSPI3_SS0		0x14 /* SODIMM 86 */
			MX7D_PAD_I2C2_SDA__GPIO4_IO11			0x14 /* SODIMM 86 */
		>;
	};

	pinctrl_ecspi1: ecspi1grp {
		fsl,pins = <
			MX7D_PAD_ECSPI1_MISO__ECSPI1_MISO		0x2 /* SODIMM 79 */
			MX7D_PAD_ECSPI1_MOSI__ECSPI1_MOSI		0x2 /* SODIMM 103 */
			MX7D_PAD_ECSPI1_SCLK__ECSPI1_SCLK		0x2 /* SODIMM 101 */
		>;
	};

	pinctrl_ecspi1_cs: ecspi1csgrp {
		fsl,pins = <
			//MX7D_PAD_ECSPI1_SS0__ECSPI1_SS0		0x14 /* SODIMM 97 */
			MX7D_PAD_ECSPI1_SS0__GPIO4_IO19			0x14 /* SODIMM 97 */
		>;
	};

	pinctrl_ecspi2: ecspi2grp {
		fsl,pins = <
			MX7D_PAD_ECSPI2_MISO__ECSPI2_MISO			0x2 /* SODIMM 85 */
			MX7D_PAD_ENET1_RGMII_RD3__ECSPI2_MOSI		0x2 /* SODIMM 55 */
			MX7D_PAD_ENET1_RGMII_RD2__ECSPI2_SCLK		0x2 /* SODIMM 63 */
		>;
	};

	pinctrl_ecspi2_cs: ecspi2csgrp {
		fsl,pins = <
			//MX7D_PAD_ENET1_RGMII_TD3__ECSPI2_SS0		0x14 /* SODIMM 194 */
			MX7D_PAD_ENET1_RGMII_TD3__GPIO7_IO9		0x14 /* SODIMM 194 */
		>;
	};
---------------------------------------
};

/* SPI 1 */
&ecspi3 {
	cs-gpios = <&gpio4 11 GPIO_ACTIVE_LOW>; /* SODIMM 86 */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi3 &pinctrl_ecspi3_cs>;
	status = "okay";

	encoder1: encoder@0 {
		compatible = "lsi,ls7366r";
		reg = <0>;
		spi-max-frequency = <1000000>;
		status = "okay";
	};
};

/* SPI 2 */
&ecspi1 {
	cs-gpios = <&gpio4 19 GPIO_ACTIVE_LOW>; /* SODIMM 97 */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi1 &pinctrl_ecspi1_cs>;
	status = "okay";

	encoder2: encoder@0 {
		compatible = "lsi,ls7366r";
		reg = <0>;
		spi-max-frequency = <1000000>;
		status = "okay";
	};
};

/* SPI 3 */
&ecspi2 {
	cs-gpios = <&gpio7 9 GPIO_ACTIVE_LOW>; /* SODIMM 194 */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi2 &pinctrl_ecspi2_cs>;
	status = "okay";

	encoder3: encoder@0 {
		compatible = "lsi,ls7366r";
		reg = <0>;
		spi-max-frequency = <1000000>;
		status = "okay";
	};
};

The driver is recognised the SPI devices do get created.

[    0.779799] ls7366r spi0.0: LS7366R driver probed and sysfs created
[    0.780126] ls7366r spi1.0: LS7366R driver probed and sysfs created
[    0.780421] ls7366r spi2.0: LS7366R driver probed and sysfs created
ls /sys/class/spi_master
spi0  spi1  spi2

But only spi2 (ecspi3) works, not the others. Please help.

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

It seems you’re encountering issues with ECSPI1 and ECSPI2 on your Colibri iMX7 module, where these interfaces are not generating SCLK pulses. Let’s go through some steps to help troubleshoot and resolve the issue:

  1. Device Tree Configuration:

    • Double-check the pin multiplexing settings in your device tree for ECSPI1 and ECSPI2. Ensure that the pins are correctly configured for SPI functionality and not being used by another peripheral.
    • Verify that the status property for both ECSPI1 and ECSPI2 is set to “okay” in the device tree.
  2. Kernel Logs:

    • Check the kernel logs (dmesg) for any errors or warnings related to SPI. This can provide clues if there are issues with the SPI driver or hardware initialization.
  3. Testing SPI Communication:

    • Use user-space tools like spidev_test to manually test SPI communication. This can help verify if the issue is with the SPI configuration or the specific devices connected.
  4. Driver and Overlay Configuration:

    • Ensure that there are no conflicting device tree overlays or kernel modules that might be affecting SPI operation.

By following these steps, you should be able to identify and resolve the issue with ECSPI1 and ECSPI2. If the problem persists, consider reviewing your software configuration to ensure all settings align with your intended setup.

Best regards,
Toradex AI Assistant

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

Enable 2nd SPI controller on Colibri imx7d.