BCM2835: SPI on Linux 5.10

Stefan Wahren stefan.wahren at i2se.com
Sat May 1 11:52:20 BST 2021


Hi Deniz,

Am 29.04.21 um 14:10 schrieb Deniz Uğur:
> Hi Stefan,
>
>> so you actual problem is that there is no /dev/spidevX.X?
> Yes, that’s correct.
>
>> the upstream DTS doesn't contain the spidev.
> Just to be sure, the following line is present in my kernel tree as you pointed out. Inside spidev.c
> { .compatible = "spidev,loopback” }

i think, you didn't get what was i trying to say. This issues isn't
about the kernel, it's about the device tree. In the upstream device
tree SPI is completely disabled, because there is no solution available
yet which fits all setups. The Raspberry Pi kernel has a lot of
downstream changes (incl. the overlay DT) which is very practical. But
in upstream the situation is bit complicated.

Let me give a quick and dirty "solution" (produce a ugly strace trace,
but should work), which should give you a spidev for SPI0 using CS0 (not
tested with a real SPI setup):

diff --git a/arch/arm/boot/dts/bcm2835-rpi.dtsi
b/arch/arm/boot/dts/bcm2835-rpi.dtsi
index d94357b..7fa9f61 100644
--- a/arch/arm/boot/dts/bcm2835-rpi.dtsi
+++ b/arch/arm/boot/dts/bcm2835-rpi.dtsi
@@ -44,7 +44,7 @@
     };
 
     alt0: alt0 {
-        brcm,pins = <4 5 7 8 9 10 11>;
+        brcm,pins = <4 5>;
         brcm,function = <BCM2835_FSEL_ALT0>;
     };
 };
@@ -63,6 +63,18 @@
     clock-frequency = <100000>;
 };
 
+&spi {
+    pinctrl-names = "default";
+    pinctrl-0 = <&spi0_gpio7>;
+    status = "okay";
+
+    spidev at 0 {
+        reg = <0>;
+        compatible = "spidev";
+        spi-max-frequency = <10000000>;
+    };
+};
+
 &usb {
     power-domains = <&power RPI_POWER_DOMAIN_USB>;
 };





More information about the linux-rpi-kernel mailing list