Only one SPIDEV shows up in '/dev'. Need help with device tree

I am trying to turn on SPI_2, which is ECSPI1, and then do some pin muxing to use the ALT pins from IPU1 for ECSPI1; I have disabled IPU1. We are running the OS headless. I am able to turn “on” the default spidev node that I saw on ECSPI4 and I can see it show up in /dev as SPIDEV3.0, but when I do the same for ECSPI1 it doesn’t show up. I feel like I might be missing something basic to get it up and running. My device tree code is below. The pin mux is at the end. I am decompiling the .dtb to .dts to make these changes so I had to enter the pinmux hex values by hand Thank you for any help.

spi@2008000 {
					#address-cells = <0x01>;
					#size-cells = <0x00>;
					compatible = "fsl,imx6q-ecspi\0fsl,imx51-ecspi";
					reg = <0x2008000 0x4000>;
					interrupts = <0x00 0x1f 0x04>;
					clocks = <0x04 0x70 0x04 0x70>;
					clock-names = "ipg\0per";
					dmas = <0x0d 0x03 0x07 0x01 0x0d 0x04 0x07 0x02>;
					dma-names = "rx\0tx";
					status = "okay";
					fsl,spi-num-chipselects = <1>;
					pinctrl-names = "default";
					pinctrl-0 = <0xfa>;
					phandle = <0x93>;
					
					spidev@1 {
						compatible = "toradex,evalspi";
						reg = <0x0>;
						spi-max-frequency = <0x15ef3c0>;
						status = "okay";
					};
					
					mcp251x@1 {
						compatible = "microchip,mcp2515";
						reg = <0x01>;
						clocks = <0x13>;
						interrupt-parent = <0x14>;
						interrupts = <0x1b 0x02>;
						spi-max-frequency = <0x989680>;
						status = "disabled";
					};
				};

				spi@200c000 {
					#address-cells = <0x01>;
					#size-cells = <0x00>;
					compatible = "fsl,imx6q-ecspi\0fsl,imx51-ecspi";
					reg = <0x200c000 0x4000>;
					interrupts = <0x00 0x20 0x04>;
					clocks = <0x04 0x71 0x04 0x71>;
					clock-names = "ipg\0per";
					dmas = <0x0d 0x05 0x07 0x01 0x0d 0x06 0x07 0x02>;
					dma-names = "rx\0tx";
					status = "okay";
					phandle = <0x94>;
				};

				spi@2010000 {
					#address-cells = <0x01>;
					#size-cells = <0x00>;
					compatible = "fsl,imx6q-ecspi\0fsl,imx51-ecspi";
					reg = <0x2010000 0x4000>;
					interrupts = <0x00 0x21 0x04>;
					clocks = <0x04 0x72 0x04 0x72>;
					clock-names = "ipg\0per";
					dmas = <0x0d 0x07 0x07 0x01 0x0d 0x08 0x07 0x02>;
					dma-names = "rx\0tx";
					status = "okay";
					phandle = <0x95>;
				};

				spi@2014000 {
					#address-cells = <0x01>;
					#size-cells = <0x00>;
					compatible = "fsl,imx6q-ecspi\0fsl,imx51-ecspi";
					reg = <0x2014000 0x4000>;
					interrupts = <0x00 0x22 0x04>;
					clocks = <0x04 0x73 0x04 0x73>;
					clock-names = "ipg\0per";
					dmas = <0x0d 0x09 0x07 0x01 0x0d 0x0a 0x07 0x02>;
					dma-names = "rx\0tx";
					status = "okay";
					cs-gpios = <0x11 0x02 0x00>;
					pinctrl-names = "default";
					pinctrl-0 = <0x12>;
					phandle = <0x96>;
					
					spidev@0 {
						compatible = "toradex,evalspi";
						reg = <0x00>;
						spi-max-frequency = <0x15ef3c0>;
						status = "okay";
						phandle = <0x97>;
					};
					
					mcp251x@0 {
						compatible = "microchip,mcp2515";
						reg = <0x00>;
						clocks = <0x13>;
						interrupt-parent = <0x14>;
						interrupts = <0x1b 0x02>;
						spi-max-frequency = <0x989680>;
						status = "disabled";
						phandle = <0x98>;
					};
				};

               ecspi1grp {
						fsl,pins = <
						0x0ec 0x400 0x7dc 0x2 0x1 0x100b1 0x0e8 0x3fc 0x7e0 0x2 0x1 0x100b1 0x0e4 0x3f8 0x7d8 0x2 0x1 0x100b1 0x0f0 0x404 0x7e4 0x2 0x1 0xb1
						>;
						phandle = <0xfa>;
					};

					ecspi4grp {
						fsl,pins = <0x15c 0x52c 0x00 0x01 0x00 0x100b1 0x174 0x544 0x00 0x02 0x00 0x100b1 0x158 0x528 0x00 0x01 0x00 0x100b1 0x134 0x504 0x00 0x05 0x00 0xb1>;
						phandle = <0x12>;
					};

Hi @SterlingA!

Can you provide more information?

Which BSP version are you using?

Also, it is very time-consuming to analyze the hexadecimal values on the device tree you shared. Please share the device tree with the names defined on the headers (gpio.h, imx6dl-pinfunc.h, etc).

I just added an answer I’m not sure if it’s still on here. It looks like it dissapeared. Can you see it?

Hey, sorry for the late response.

I hacve BSP version 5, and I’m using the tdx-reference-minimal-image found in this tutorial:Build a Reference Image with Yocto Project/OpenEmbedded | Toradex Developer Center

The definitions of the pins in the imx6dl-pinfunc.h is as follows:

   #define MX6QDL_PAD_DISP0_DAT22__ECSPI1_MISO         0x0ec 0x400 0x7dc 0x2 0x1
    #define MX6QDL_PAD_DISP0_DAT21__ECSPI1_MOSI         0x0e8 0x3fc 0x7e0 0x2 0x1
    #define MX6QDL_PAD_DISP0_DAT20__ECSPI1_SCLK         0x0e4 0x3f8 0x7d8 0x2 0x1
    #define MX6QDL_PAD_DISP0_DAT23__ECSPI1_SS0          0x0f0 0x404 0x7e4 0x2 0x1

Do you want the entire file? It’s pretty big. But those are the definitions I used to select my pins. I copy pasted the hext values into my device tree.

I’m not sure what other information you might need but please don’t hesitate to ask I will provide what I can.

Sorry for the late reply.

I’m using BSP 5, tdx-reference-minimal-image from this tutorial: BSP Layers and Reference Images for Yocto Project Software | Toradex Developer Center. We have made our own custom motherboard for the imx6.

These are the specific definitions in the imx6dl-pinfunc.h that are defined in:

"ecspi1grp { fsl,pins = $(function () {
setupComments($(‘#question-container-64354’), true, false, croles, “full”, true)

Hi @SterlingA

Sorry for taking so long to reply. This question had some problems to be displayed and reviewed, but now this problem was solved.

The device tree file you shared is hard to analyze because it is using hexadecimal values instead of the macro constants defined on the includes (e.g. the imx6dl-pinfunc.h, as you pointed out).

What I asked you is to share your device tree, but using the macro constants instead of hexadecimal values.

To illustrate, you can take a look at lines 408 and 409 from here for example:

interrupts = <0 31 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6QDL_CLK_ECSPI1>,
         <&clks IMX6QDL_CLK_ECSPI1>;

And comparing with yours:

interrupts = <0x00 0x1f 0x04>;
clocks = <0x04 0x70 0x04 0x70>;

It’s better to analyze when using the macro constants from the headers.

Hi, yes I noticed I couldn’t reply to the thread anymore. Glad it’s fixed.

I’ve changed what I had here. I used “phandle = <0x96>;” to refer to the pinmux in “iomuxc-gpr@20e0000”. This is the SPI I’m trying to modify:

spi@2008000 {
					#address-cells = <0x01>;
					#size-cells = <0x00>;
					compatible = "fsl,imx6q-ecspi\0fsl,imx51-ecspi";
					reg = <0x2008000 0x4000>;
					interrupts = <0x00 0x1f 0x04>;
					clocks = <0x04 0x70 0x04 0x70>;
					clock-names = "ipg\0per";
					dmas = <0x0d 0x03 0x07 0x01 0x0d 0x04 0x07 0x02>;
					dma-names = "rx\0tx";
					status = "okay";
					fsl,spi-num-chipselects = <1>;
					pinctrl-names = "default";
					pinctrl-0 = <0xfa>;
					phandle = <0x93>;
					
					spidev@1 {
						compatible = "toradex,evalspi";
						reg = <0x0>;
						spi-max-frequency = <0x15ef3c0>;
						status = "okay";
					};
					
					mcp251x@1 {
						compatible = "microchip,mcp2515";
						reg = <0x01>;
						clocks = <0x13>;
						interrupt-parent = <0x14>;
						interrupts = <0x1b 0x02>;
						spi-max-frequency = <0x989680>;
						status = "disabled";
					};
				};

This is the pinmux I chose with the marco constants:

ecspi1grp {
						fsl,pins = <
						MX6QDL_PAD_DISP0_DAT22__ECSPI1_MISO 0x100b1 
						MX6QDL_PAD_DISP0_DAT21__ECSPI1_MOSI 0x100b1 
						MX6QDL_PAD_DISP0_DAT20__ECSPI1_SCLK 0x100b1 
						MX6QDL_PAD_DISP0_DAT23__ECSPI1_SS0 0xb1
						>;
						phandle = <0xfa>;
					};

My previous comment disappeared, but I think I may have put it into the “asnwer” box instead. I had re-written the device tree with the macros you were talking about. Not sure if you can recover it or if you’re still able to see it on your end.

I took a look at the log when the kernel booted and found this error which might help:

[ 1.145026] imx6dl-pinctrl 20e0000.iomuxc: pin MX6DL_PAD_DISP0_DAT22 already requested by 20e0000.iomuxc; cannot claim for 2008000.spi
[ 1.157199] imx6dl-pinctrl 20e0000.iomuxc: pin-59 (2008000.spi) status -22
[ 1.164093] imx6dl-pinctrl 20e0000.iomuxc: could not request pin 59 (MX6DL_PAD_DISP0_DAT22) from group ecspi1grp on device 20e0000.iomuxc
[ 1.176561] spi_imx 2008000.spi: Error applying setting, reverse things back
[ 1.183669] spi_imx: probe of 2008000.spi failed with error -22

Here’s the device tree with the mod I put in there instead of the hex values. I couldn’t find the name of the definition you posted in the pinfunc.h file you mentioned, was that just an example?

Device tree:

spi@2008000 {
					#address-cells = <0x01>;
					#size-cells = <0x00>;
					compatible = "fsl,imx6q-ecspi\0fsl,imx51-ecspi";
					reg = <0x2008000 0x4000>;
					interrupts = <0x00 0x1f 0x04>;
					clocks = <0x04 0x70 0x04 0x70>;
					clock-names = "ipg\0per";
					dmas = <0x0d 0x03 0x07 0x01 0x0d 0x04 0x07 0x02>;
					dma-names = "rx\0tx";
					status = "okay";
					fsl,spi-num-chipselects = <1>;
					pinctrl-names = "default";
					pinctrl-0 = <&pinctrl_ecspi1>;
					phandle = <0x93>;
					
					spidev@1 {
						compatible = "toradex,evalspi";
						reg = <0x0>;
						spi-max-frequency = <0x15ef3c0>;
						status = "okay";
					};
					
					mcp251x@1 {
						compatible = "microchip,mcp2515";
						reg = <0x01>;
						clocks = <0x13>;
						interrupt-parent = <0x14>;
						interrupts = <0x1b 0x02>;
						spi-max-frequency = <0x989680>;
						status = "disabled";
					};
				};

pinmux:

pinctrl_ecspi1: ecspi1grp {
						fsl,pins = <
						MX6QDL_PAD_DISP0_DAT22__ECSPI1_MISO 0x100b1 
						MX6QDL_PAD_DISP0_DAT21__ECSPI1_MOSI 0x100b1 
						MX6QDL_PAD_DISP0_DAT20__ECSPI1_SCLK 0x100b1 
						MX6QDL_PAD_DISP0_DAT23__ECSPI1_SS0 0xb1
						>;
						//phandle = <0xfa>;
					};

I just posted the new code for device tree and pinmux and it dissapeared again. I dunno what’s going on.

Hi @SterlingA.

Again, it’s really hard to analyze your device tree source file because you’re using hexadecimal values instead of the constant macros.

If I understand correctly, you’re decompiling a Device Tree Blob (dtb) into a Device Tree Source (dts) and then you’re modifying it. Although this process could work, I really think this is not a good way to perform modifications on a Device Tree.

For example, you should get the sources from linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules and then start modifying from there. This way you’ll see how a usual Device Tree source is expected to look like. Also, helping you to solve your problem will be easier.

These articles can help you with some guidance:
Device Tree Customization
Build U-Boot and Linux Kernel from Source Code

Also, be aware that BSP 5 supports Device Tree Overlays:
Device Tree Overlays (Linux)

And, last, but not least, by the error you got

 [ 1.145026] imx6dl-pinctrl 20e0000.iomuxc: pin MX6DL_PAD_DISP0_DAT22 already requested by 20e0000.iomuxc; cannot claim for 2008000.spi

Your pinctrl-0 property is pointing to a pin that is already captured by another node ( iomuxc , in this case), so it can’t be used by another node.