SPI device not showing up in /dev/ on imx7d

Hi,
We are trying to get our accelerometer working on our TorizonOS image however there seems to be an issue with the spi device not binding to the spidev driver. For sake of backwards compatibility with our application we want to use spidev instead of an higher level interface.

The device does show up under spi/devices/:

torizon@colibri-imx7-emmc-15002892:/sys/bus/spi/devices$ ls
spi3.0

But not in /dev/

torizon@colibri-imx7-emmc-15002892:/sys/bus/spi/devices/spi2.0$ ls /dev/ | grep spi 
*nothing*

I’ve attached the relevant part of our device tree, please let me know if you need more information.

#include "imx7d-colibri-emmc.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>

&ecspi4 {
	cs-gpios = <&gpio3 3 GPIO_ACTIVE_HIGH>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi4 &pinctrl_ecspi4_cs>;
	status="okay";
	
	spidev0: spidev@0 {
		compatible = "toradex,evalspi";
		reg = <0>;
		spi-max-frequency = <10000000>;
		status = "okay";
	};
};

/* because of MX7D_PAD_SD1_DATA2 (SODIMM 51) - to be used by ecspi4 (for IMU) */
&usdhc1 {
	status = "disabled";
};

/* because of MX7D_PAD_SD1_WP (SODIMM 71) - to be used by ecspi4 (for IMU) */
&backlight {
	status = "disabled";
};

/* because of MX7D_PAD_LCD_VSYNC (SODIMM 82) - to be used by ecspi4 (for IMU) */
&lcdif {
	status = "disabled";
};

&iomuxc {

	pinctrl_ecspi4: ecspi4-grp {
		fsl,pins = <
			MX7D_PAD_SD1_CD_B__ECSPI4_MISO		0x2 /* SODIMM 69 - SPI_4_MASTER_MISO */
			MX7D_PAD_SD1_WP__ECSPI4_MOSI		0x2 /* SODIMM 71 - SPI_4_MASTER_MOSI */
			MX7D_PAD_SD1_RESET_B__ECSPI4_SCLK	0x2 /* SODIMM 73 - SPI_4_MASTER_SCLK */
			MX7D_PAD_SD1_DATA2__ECSPI4_RDY		0x2 /* SODIMM 51 - SPI_4_MASTER_RDY  */
		>;
	};

	pinctrl_ecspi4_cs: ecspi4-cs-grp {
		fsl,pins = <
			MX7D_PAD_LCD_VSYNC__GPIO3_IO3		0x14 /* SODIMM 82 - SPI_4_MASTER_CS0 */
		>;
	};
}

dmesg shows the following:

torizon@colibri-imx7-emmc-15002892:/sys/bus/spi/devices$ dmesg | grep spi
[    1.692094] spidev@0 enforce active low on chipselect handle

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

Did you like my answer?

:+1: :-1:


Based on the context provided, it seems like the SPI device is not appearing in the /dev directory, which indicates that the spidev interface might not be properly bound to the SPI device. Here are a few things to check and try:

  1. Device Tree Configuration: Ensure that the device tree configuration is correct. The compatible property for the spidev node should be "spidev", not "toradex,evalspi". Update the device tree as follows:

    spidev0: spidev@0 {
        compatible = "spidev";
        reg = <0>;
        spi-max-frequency = <10000000>;
        status = "okay";
    };
    
  2. Kernel Configuration: Make sure that the spidev driver is enabled in the kernel configuration. You can check this by ensuring that CONFIG_SPI_SPIDEV is set to y or m in your kernel configuration.

  3. Device Tree Overlays: If you are using device tree overlays, ensure that the overlay is correctly applied and that it does not conflict with other configurations.

  4. Check dmesg Logs: The dmesg log you provided shows a message about enforcing active low on chipselect handle. This might not be directly related to the issue, but ensure there are no other error messages related to SPI or spidev in the dmesg logs.

  5. Reboot the System: After making changes to the device tree, ensure that the system is rebooted to apply the changes.

If after these checks the issue persists, it might be necessary to further investigate the kernel logs or the device tree configuration for any other potential misconfigurations.

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

SPI demo not working Apalis imx6.

Hello @Casper,

Which version of Torizon OS are you using?

If you are using Torizon OS 6, the following would be applicable:

In our overlay which enables the spidev interface in ecspi3 for the Colibri iMX7 we add the rohm,dh2228fv compatible string:

/dts-v1/;
/plugin/;

/ {
	compatible = "toradex,colibri-imx7d",
		     "toradex,colibri-imx7d-emmc",
		     "toradex,colibri-imx7s";
};

/* Colibri SPI */
&ecspi3 {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	spidev@0 {
		/* Use compatible "rohm,dh2228fv" to bind spidev driver */
		compatible = "rohm,dh2228fv";
		reg = <0>;
		spi-max-frequency = <10000000>;
	};
};

Can you try to do that?

Best Regards,
Bruno

That worked!

1 Like