Add an SPI device to colibri imx6

We have 2 SPI slave devices connected to the same colibri standard SPI bus with different chip_selects on our custom carrier board. We are able to communicate with the 1st SPI device using the default SPI driver from the kernel. But what do we do to make the driver work for 2nd one? By reading posts on the forum, my understanding is to add the 2nd device to board device tree file (imx6dl_colibri_eval_v3.dts). So the SPI session of the file looks like this:
/* Colibri SPI */
&ecspi4 {
status = “okay”;

spidev0: spidev@1 {
    compatible = "spidev";
    reg = <0>;
    spi-max-frequency = <23000000>;
spidev1: spidev@2 {
    compatible = "spidev";
    reg = <1>;
    spi-max-frequency = <23000000>;


Then compile and copy the the DTB file to a SD card, which is then used to update target device tree (run update_fdt at uboot prompt). However that did not work for me. I did not see a 2nd SPI device appear under /dev folder (first SPI device appears as spidev3.0).

What am I missing here? Please help. Thanks

For two SPI slave devices, one would also require two chip selects. Freescale ECSPI driver uses the device node property fsl,spi-num-chipselects to specify the number of chip selects and cs-gpios to specify the GPIO’s to be used as chip selects. Please have a look here at the device tree binding documentation.

An appropriate change would be as below.

diff --git a/arch/arm/boot/dts/imx6dl-colibri-eval-v3.dts b/arch/arm/boot/dts/imx6dl-colibri-eval-v3.dts
index 3a2121e..5b292e0 100644
--- a/arch/arm/boot/dts/imx6dl-colibri-eval-v3.dts
+++ b/arch/arm/boot/dts/imx6dl-colibri-eval-v3.dts
@@ -119,6 +119,12 @@
                reg = <0>;
                spi-max-frequency = <23000000>;
+       spidev1: spidev@2 {
+               compatible = "spidev";
+               reg = <1>;
+               spi-max-frequency = <23000000>;
+       };
 &hdmi_audio {
diff --git a/arch/arm/boot/dts/imx6qdl-colibri.dtsi b/arch/arm/boot/dts/imx6qdl-colibri.dtsi
index 7eea47e..95ab6b2 100644
--- a/arch/arm/boot/dts/imx6qdl-colibri.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-colibri.dtsi
@@ -172,8 +172,8 @@
 /* Colibri SPI */
 &ecspi4 {
-       fsl,spi-num-chipselects = <1>;
-       cs-gpios = <&gpio5 2 0>;
+       fsl,spi-num-chipselects = <2>;
+       cs-gpios = <&gpio5 2 0>, <&gpio1 2 0>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_ecspi4 &pinctrl_spi_cs1>;
        status = "disabled";
@@ -552,7 +552,8 @@
                pinctrl_spi_cs1: spi_cs1 {
                        fsl,pins = <
-                               MX6QDL_PAD_EIM_A25__GPIO5_IO02          PAD_CTRL_NO     /* SPI cs */
+                               MX6QDL_PAD_EIM_A25__GPIO5_IO02          PAD_CTRL_NO     /* SPI cs 1 */
+                               MX6QDL_PAD_GPIO_2__GPIO1_IO02           PAD_CTRL_NO     /* SPI cs 2 */
                pinctrl_touch_int_1: touch_int-1 {
@@ -881,7 +882,6 @@
                                MX6QDL_PAD_CSI0_PIXCLK__GPIO5_IO18 PAD_CTRL_HYS_PU
                                MX6QDL_PAD_GPIO_4__GPIO1_IO04      PAD_CTRL_HYS_PU
                                MX6QDL_PAD_GPIO_5__GPIO1_IO05      PAD_CTRL_HYS_PU
-                               MX6QDL_PAD_GPIO_2__GPIO1_IO02      PAD_CTRL_HYS_PU
                /* DQM[0:3]  used as GPIO */

Note that the choice of second GPIO for chipselect would be as per one’s pin multiplexing requirements for a custom carrier board or testing. The above is just an example, a custom carrier board dts file would be more apt. Please also have a look at our Device Tree Customization article.

With the above change in place and a device tree update, two spidev nodes would be seen as below.

root@colibri-imx6:~# uname -a
Linux colibri-imx6 3.14.52-v2.6b2+g9ace52b #1 SMP Thu May 26 06:31:06 CEST 2016 armv7l GNU/Linux
root@colibri-imx6:~# ls /dev | grep -i "spidev"

I did not test the functioning of two spidev’s but the above should work as expected.

I made my own patch file based the example shown above.It worked just as expected.
Thank you very much!

Do I need to to modify anything in the SPIDEV driver if I connect the Microcontroller over SPI?

It would be recommended to open a new topic for questions unrelated to the current topic. spidev should not require any modification for communicating with any spi device microcontroller or otherwise.