Mainline Kernel , Colibri T30 and SPI

Dear all / @marcel.tx
I am using ColibriT30 module version 1.1A on Iris carrier board v1.1A. I have successfully compiled mainline kernel 4.18.11 and I am quite happy with the result as I have everything working as I expected.

I need to connect a NRF24L01+ radio module using the SPI exactly similar to what I have addressed in this post: HERE for Apalis T30

I see /dev/spidev0.1 on my device list and I have connected my SPI module to physical pin numbers:

 Physical pin: 8 --> (X1 pin 88) CLK  ==> Y02 --> GPIO 194
 Physical pin:  9 --> (X1 pin 86) CS  ==> Y03 --> GPIO 195
 Physical pin: 10 --> (X1 pin 90) MISO ==> Y01 --> GPIO 193
 Physical pin:   11 --> (X1 pin 92) MOSI ==> Y00 --> GPIO 192

However, it seems that the device is not responding.
May I kindly ask you to advise if PIN numbers on X16 header are correct to connect the SPI module?
Am I missing something and do I need to do anything else on mainline device tree inside “tegra30-colibri-eval-v3.dtb” to be able to get it working? as I mentioned, /dev/spidev0.1 is already available in user space!

I appreciate your help…

For your info, here is the node in device tree:

/* SPI1: Colibri SSP */
spi@7000d400 {
        status = "okay";
        spi-max-frequency = <25000000>;
        can0: can@0 {
                compatible = "microchip,mcp2515";
                reg = <0>;
                clocks = <&clk16m>;
                interrupt-parent = <&gpio>;
                interrupts = <TEGRA_GPIO(S, 0) IRQ_TYPE_EDGE_RISING>;
                spi-max-frequency = <10000000>;
        };
        spidev0: spi@1 {
                compatible = "spidev";
                reg = <1>;
                spi-max-frequency = <25000000>;
        };
};

Yes, you will have to make sure you are using the proper SPI chip select signal. Your device tree as shown above does use the MCP2515 on chip select 0 (e.g. the can@0 and reg = <0>; and spidev on chip select 1 (e.g. spi@1 and reg = <1>;). However, most likely you want spidev on chip select 0 which corresponds to the actual SSPFRM pin in question.

Please note that the use of spidev in the device tree is deprecated and one should use user space driven driver binding via sysfs instead. Therefore I also removed the same in mainline here.

Dear @marcel.tx ,
Thank for your time and your explanation.
I tried to recompile the device tree with just these:

spi@7000d400 {
             status = "okay";
             spi-max-frequency = <25000000>;
             spidev0: spi@0 {
                     compatible = "spidev";
                     reg = <0>;
                     spi-max-frequency = <25000000>;
             };
     };

I see the spidev has changed to /dev/spidev0.0 now.
However, I still cannot get the response from my SPI module.

Can you please assist and see if my device tree node is correct to use the SSPFRM as you mentioned above?

Many thanks…

This should really work. I quickly tried 4.20.0-rc3 with the following SPI specific changes:

diff --git a/arch/arm/boot/dts/tegra30-colibri-eval-v3.dts b/arch/arm/boot/dts/tegra30-colibri-eval-v3.dts
index 5965150ecdd2..ecbcf0b83571 100644
--- a/arch/arm/boot/dts/tegra30-colibri-eval-v3.dts
+++ b/arch/arm/boot/dts/tegra30-colibri-eval-v3.dts
@@ -82,19 +82,22 @@
        /* SPI1: Colibri SSP */
        spi@7000d400 {
                status = "okay";
-               spi-max-frequency = <25000000>;
-
-               can@0 {
-                       compatible = "microchip,mcp2515";
-                       reg = <0>;
-                       clocks = <&clk16m>;
-                       interrupt-parent = <&gpio>;
-                       /* CAN_INT */
-                       interrupts = <TEGRA_GPIO(S, 0) IRQ_TYPE_EDGE_FALLING>;
-                       spi-max-frequency = <10000000>;
-                       vdd-supply = <&reg_3v3>;
-                       xceiver-supply = <&reg_5v0>;
+
+#if 1
+               spidev0: spidev0@0 {
+                       compatible = "spidev";
+                       reg = <0>;
+                       spi-max-frequency = <25000000>;
+               };
+#else
+               flash: sst@0 {
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       compatible = "sst,sst25vf016b", "jedec,spi-nor";
+                       reg = <0>;
+                       spi-max-frequency = <25000000>;
                };
+#endif
        };
 
        /* SD/MMC */
diff --git a/arch/arm/configs/tegra_defconfig b/arch/arm/configs/tegra_defconfig
index c7b99ebf5fcf..9de5067a6623 100644
--- a/arch/arm/configs/tegra_defconfig
+++ b/arch/arm/configs/tegra_defconfig
@@ -133,6 +133,7 @@ CONFIG_SPI=y
 CONFIG_SPI_TEGRA114=y
 CONFIG_SPI_TEGRA20_SFLASH=y
 CONFIG_SPI_TEGRA20_SLINK=y
+CONFIG_SPI_SPIDEV=y
 CONFIG_PINCTRL_AS3722=y
 CONFIG_PINCTRL_PALMAS=y
 CONFIG_GPIO_SYSFS=y

I hooked up a Microchip SST25VF016B-50 to an Iris as per your suggested pin connection table. First, I ran it with the proper spi-nor binding (e.g. #else case) and dumped the whole contents doing e.g. cat /dev/mtd0ro > m25p80.dump. Then, I enabled spidev support in the configuration and run it with the following test program giving me the expected output as per Microchip datasheet:

root@colibri-t30:~# ./spitest
Reading from SPI can controller
SPI mode: 3
bits per word: 8
max speed: 1000000 Hz (1000 kHz)
after initialisation of array rx:
00 00 00 00 

after read of kernel buffer, rx:
00 BF 25 41

Any help on this please!!!

Dear @marcel.tx

I did the exact same thing as yours.
Here is the spitest output…

Stupid question as you have not read the datasheet but as general, does it looks ok to you .
I think NO as I disconnect the device I see the same result!

Reading from SPI can controller
SPI mode: 3
bits per word: 8
max speed: 1000000 Hz (1000 kHz)
after initialisation of array rx:
00 00 00 00 

after read of kernel buffer, rx:
FF FF FF FF

(The app I have does not communicate as the same method I used on Apalis T30.
It was working fine there but same thing here does not !!!)

Appreciate your help…

F.Y.I: I also tried with another different SPI module and the result is same and the output of spitest is exactly same with last line of FF FF FF FF

Yes, all FF indicates the communication not working at all. Either your setup is still flawed or your hardware does not work. Did you try it with the exact same 4.20.0-rc3 with my patch as given above?

Actually not, I am still using 4.18.11.
But to be sure we are in same page, I’ll try doing that with 4.20.0-rc3 and see how it goes.
Will post the result here…

Thanks @marcel.tx spending time finding this issue. I am sure everyone else can find this post useful if we resolve the problem.

Many thanks…

Dear @marcel.tx ,
With 4.20.0-rc3. it seems I get some response:

Reading from SPI can controller
SPI mode: 3
bits per word: 8
max speed: 1000000 Hz (1000 kHz)
after initialisation of array rx:
00 00 00 00 

after read of kernel buffer, rx:
1C 00 00 00 

However, my app still cannot communicate with the module as it does on Apalis T30.
I do the same thing and it works fine on Apalis T30, exact same thing here in Colibri T30, no luck…

With 4.20.0-rc3. it seems I get some response.

There you go, then it may have to do with some of the clean-up I did of late.

However, my app still cannot communicate with the module as it does on Apalis T30. I do the same thing and it works fine on Apalis T30, exact same thing here in Colibri T30, no luck…

I suspect some configuration still is amiss.

So do you think you can fix/find the issue then?

The app is a mid interface. You only give it the correspondent GPIO pins on X16 header and it should communicate.
Exact same thing on Apalis T30. the only difference are the GPIO pin numbers as I expect which make seance as the headers are different so the GPIOs.
The rest are same.
I did the same thing on other SBCs and all responding but not on Colibri. That’s why it make me curios what is going on and interested to get it working.

So do you think you can fix/find the issue then?

I’m not sure what issue you are talking about. SPI works just fine.

The app is a mid interface. You only give it the correspondent GPIO pins on X16 header and it should communicate. Exact same thing on Apalis T30. the only difference are the GPIO pin numbers as I expect which make seance as the headers are different so the GPIOs. The rest are same. I did the same thing on other SBCs and all responding but not on Colibri. That’s why it make me curios what is going on and interested to get it working.

We were there before. I don’t think it makes any sense to talk about GPIOs if all you want is to communicate by SPI, sorry.

You told me the exact same thing on Apalis T30 post which I had sent before. So just before I gave up, I found the answer myself.
May I kindly ask you to have a look at that post and see what will be the same in here for Colibri.

I posted the answer there for others to look so I did the same here for Colibri and I need to get it done…
if you have a look there you will find out what I am talking about.

@marcel.tx ,
Found the issue.

Need to set the CE pin in my app as well. Was pointing to wrong GPIO.
However, it all works only on 4.20.0-rc3 though. Before that it was not communicating at all.

So Thanks a lot Marcel. For time and effort you put to help me.

You are very welcome.