Apalix iMX6 spidev

I am trying to use spidev driver on Apalis iMX6. According to the device tree file found here, the SPI device should already be enabled. However, I cannot find it under /dev, so is there more configuration that needs done?

Could you please provide more details about image you are using? “Toradex BSP 4.0” is ambiguous.

The image being used is a custom image based on Toradex BSP 4.0 and Yocto Zeus 3.0. The main additions to the image are a few libraries that were necessary for use with our peripherals. However, none of the changes should have impacted the SPI driver.

Please note that the Linux Kernel branch toradex_4.14-2.0.x-imx is deprecated and no longer supported as such.

You may want to have a look at the following articles on our developer website:

https://developer.toradex.com/knowledge-base/build-u-boot-and-linux-kernel-from-source-code

https://developer.toradex.com/knowledge-base/spi-(linux)

According to the Source Code version tables, toradex_4.14-2.0.x-imx is the most up-to-date branch. What branch is currently being supported?

Also, reproduced below is the actual device tree file used in the custom image. It seems like the SPI devices are enabled.

ecspi@02008000 {
					#address-cells = <0x1>;
					#size-cells = <0x0>;
					compatible = "fsl,imx6q-ecspi", "fsl,imx51-ecspi";
					reg = <0x2008000 0x4000>;
					interrupts = <0x0 0x1f 0x4>;
					clocks = <0x2 0x70 0x2 0x70>;
					clock-names = "ipg", "per";
					dmas = <0xe 0x3 0x7 0x1 0xe 0x4 0x7 0x2>;
					dma-names = "rx", "tx";
					status = "okay";
					cs-gpios = <0x11 0x19 0x0>;
					pinctrl-names = "default";
					pinctrl-0 = <0x12>;

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

				ecspi@0200c000 {
					#address-cells = <0x1>;
					#size-cells = <0x0>;
					compatible = "fsl,imx6q-ecspi", "fsl,imx51-ecspi";
					reg = <0x200c000 0x4000>;
					interrupts = <0x0 0x20 0x4>;
					clocks = <0x2 0x71 0x2 0x71>;
					clock-names = "ipg", "per";
					dmas = <0xe 0x5 0x7 0x1 0xe 0x6 0x7 0x2>;
					dma-names = "rx", "tx";
					status = "okay";
					cs-gpios = <0x13 0x1a 0x0>;
					pinctrl-names = "default";
					pinctrl-0 = <0x14>;

					spidev@2 {
						compatible = "toradex,evalspi";
						reg = <0x0>;
						spi-max-frequency = <0x112a880>;
					};
				};

				ecspi@02010000 {
					#address-cells = <0x1>;
					#size-cells = <0x0>;
					compatible = "fsl,imx6q-ecspi", "fsl,imx51-ecspi";
					reg = <0x2010000 0x4000>;
					interrupts = <0x0 0x21 0x4>;
					clocks = <0x2 0x72 0x2 0x72>;
					clock-names = "ipg", "per";
					dmas = <0xe 0x7 0x7 0x1 0xe 0x8 0x7 0x2>;
					dma-names = "rx", "tx";
					status = "disabled";
				};

				ecspi@02014000 {
					#address-cells = <0x1>;
					#size-cells = <0x0>;
					compatible = "fsl,imx6q-ecspi", "fsl,imx51-ecspi";
					reg = <0x2014000 0x4000>;
					interrupts = <0x0 0x22 0x4>;
					clocks = <0x2 0x73 0x2 0x73>;
					clock-names = "ipg", "per";
					dmas = <0xe 0x9 0x7 0x1 0xe 0xa 0x7 0x2>;
					dma-names = "rx", "tx";
					status = "disabled";
				};

Sorry, I just realised that only the i.MX 8 series based module’s information got updated so far:

https://developer.toradex.com/knowledge-base/build-u-boot-and-linux-kernel-from-source-code#imx88x8mm

BTW: What exact Linux kernel configuration are you using? Do you have CONFIG_SPI_SPIDEV enabled at all?

http://git.toradex.com/cgit/linux-toradex.git/commit/?h=toradex_4.14-2.3.x-imx&id=3bd9a79b31d6b94399a5d71747ea2cf7e5c6a15f

Yes, I have CONFIG_SPI_SPIDEV enabled.

Could you please provide the full boot log attached as a textual file? Thanks!

Hi my company has renewed interest in setting up SPI communication. Attached is the full boot log.link text

Toradex provided Linux Reference Minimal Downstream SoC vendor based kernel 5.2.0+build.7 image supports spidev interface out of box. It’s based on toradex_5.4-2.3.x-imx git branch. Please use it as a base for your image. Please note that upstream kernel doesn’t support it.

Okay thank you. We were trying to avoid updating the kernel to minimize development and testing efforts. I was looking at older versions of SPI documentations from Toradex, and it seemed like it should be enabled. Documentation only mentioned Colibri not having it enabled by default, and we are using Ixora, so I thought it should be working.

Also, how do I specify this version in Yocto?

You can specify it by setting DISTRO variable in local.conf to tdx-xwayland (default value).

So we already have our own custom distro, can I just use the updated kernel? If so, how do I specify that kernel version used?

Since I’m not familiar with your custom Yocto setup I don’t know where a kernel version is defined. To enable a spidev you just need to set SPI_SPIDEV at your config and either add { .compatible = "toradex,evalspi" }, to the drivers/spi/spidev.c as it done here or use an existing names from drivers spidev_dt_ids[] list at your device tree.

This is why I am confused about it not working on my image. I understand we are using a deprecated kernel branch, but I have already made those changes. Yet, spidev device never appears under /dev.

Have you added { .compatible = "toradex,evalspi" }, to the drivers/spi/spidev.c ?

When I went into the kernel-source directory and looked at the SPI driver files, this line was already part of spidev.c.

So it should work. At least you should see a /dev/spidev* nodes. Could you attach a dmesg output as a simple test file?

Yeah I do not know why the nodes do not appear. I found a spidev entry in sys/class, but no nodes listed under it either. Attached is the log. link text