SPI CS issue on Colibri imx 6

I am using imx6 module. I want to have a total of 5 SPI slaves. I having the organization as (4+1) 4 SPI Slaves controlled by one line and the other slave by different SPI line. I can see the different SPI devices in Linux using the command ’ ls /dev | grep “spidev” '. I am facing problem when I test the SPI lines using a Oscilloscope. I can see the MISO, MOSI and SCLK working but not the CS line.

The CS line never goes high or low.
Here is the SPI definition in the device tree files

imx6qdl-colibri.dtsi

&ecspi4 {
                  fsl,spi-num-chipselects = <4>;
                  cs-gpio = <0>;
                  pinctrl-names = "default";
                  pinctrl-0 = <&pinctrl_ecspi4 &pinctrl_spi_cs1 &pinctrl_spi_cs0 &pinctrl_spi_cs2 &pinctrl_spi_cs3>;
                  status = "okay";
                  };
&ecspi1 {
                  fsl,spi-num-chipselects = <1>;
                  cs-gpio = <0>;
                  pinctrl-names = "default";
                  pinctrl-0 = <&pinctrl_ecspi1 &pinctrl_spi1_cs1 >;
                  status = "okay";
                  };

pinctrl_spi_cs1: spi_cs1 {
                  fsl,pins = <
                                    MX6QDL_PAD_EIM_A25__ECSPI4_SS1 PAD_CTRL_NO /* SPI 4 cs 1*/
                                    >;
                  };
pinctrl_spi_cs0: spi_cs0 {
                   fsl,pins = <
                                    MX6QDL_PAD_EIM_D20__ECSPI4_SS0 PAD_CTRL_HYS_PD /* SPI 4 cs 0*/ 
                                    >;
                  };
pinctrl_spi_cs2: spi_cs2 {
                  fsl,pins = <
                                    MX6QDL_PAD_EIM_D24__ECSPI4_SS2 PAD_CTRL_HYS_PD /* SPI 4 cs 2*/ 
                                    >;
                  };
pinctrl_spi_cs3: spi_cs3 {
                  fsl,pins = <
                                   MX6QDL_PAD_EIM_D25__ECSPI4_SS3 PAD_CTRL_HYS_PD /* SPI 4 cs 3*/ 
                                    >;
                  };

pinctrl_spi1_cs1: spi1_cs1 {
                  fsl,pins = <
                                    MX6QDL_PAD_DISP0_DAT23__ECSPI1_SS0 PAD_CTRL_NO /* SPI 1 cs 0*/ 
                                    >;
                  };

Carrier Board Level device tree

>   /* Colibri SPI */ &ecspi4 {
>                   status = "okay";
>                   mcp258x0: mcp258x@1 {
>                                        compatible = "microchip,mcp2515";
>                                        reg = <0>;
>                                        clocks = <&clk16m>;
>                                        interrupt-parent = <&gpio3>;
>                                        interrupts = <27 0x2>;
>                                        spi-max-frequency = <10000000>;
>                                        status = "disabled";
>                                        };
>    
>                   spidev0: spidev@1 {
>                                        compatible = "spidev";
>                                        reg = <0>;
>                                        spi-max-frequency = <23000000>;
>                                        };
>                    spidev1: spidev@2 {
>                                        compatible = "spidev";
>                                        reg = <1>;
>                                        spi-max-frequency = <23000000>;
>                                        };
>                   spidev2: spidev@3 {
>                                        compatible = "spidev";
>                                        reg = <2>;
>                                        spi-max-frequency = <23000000>;
>                                        };
>                    spidev3: spidev@4 {
>                                        compatible = "spidev";
>                                        reg = <3>;
>                                        spi-max-frequency = <23000000>;
>                                        }; }; 
>          &ecspi1 {
>                    status = "okay";
>                   spidev4: spidev@5 {
>                                          compatible = "spidev";
>                                        reg = <4>;
>                                        spi-max-frequency = <23000000>;
>                                        }; };

I am using spidev_test.c from linux documentation to test the SPI lines. Can someone let me know why I can’t have SPI CS line active?

I am testing spidev3.1 as of now.

Thanks in advance.

The usage of cs-gpios property is wrong. It should specify the gpio being used as chip select. For example, see here. In case of four GPIO’s being used as chip select, it should correspondingly specify four GPIO’s.

I am using the native SPI CS lines so I don’t have to do a manual gpio chip select. This is why I have used <0> in the cs-gpio property.

Please correct me if I am wrong.

The spi-imx driver primarily uses gpios for chipselect. See here. Did the SPI driver get correctly probed in your scenario? Can you check dmesg logs?. I believe we did not test the use of native CS lines at our end. It should also be easily possible to specify the GPIO pinmux for the native CS lines and then use them.

I active the native SPI CS on Apalis i.MX6. The method should be similar. Modify imx6qdl-apalis.dtsi file.

&ecspi1 {
	fsl,spi-num-chipselects = <1>;
	cs-gpios = <0>;
	/* cs-gpios = <&gpio5 25 0>; */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi1 &pinctrl_spi_cs1>;
	status = "disabled";
};

configure pintrl for spi cs

pinctrl_spi_cs1: spi_cs1 {
	fsl,pins = <
		MX6QDL_PAD_CSI0_DAT7__ECSPI1_SS0    PAD_CTRL_NO /* Native SPI1 CS*/
		/* MX6QDL_PAD_CSI0_DAT7__GPIO5_IO25	PAD_CTRL_NO	 SPI1 cs */
		>;
};

Here you need use the right pin for Colibri i.MX6.