BCM2835: SPI on Linux 5.10

Deniz Uğur deniz343 at gmail.com
Sat May 1 12:15:55 BST 2021


Hi Stefan,

Yes, I think I didn’t understand what you meant while writing my reply. Later that evening I figured it though. In the end, I’ve used downstream RPi linux as a reference [1] to add the required spidev nodes to both bcm283x.dtb (SPI0) and bcm2711.dtb (SPI3-6). I’ve tested this on RPi 3B and spidev0.X is working as expected.

Thank you for pointing me in the right direction.

Have a pleasent weekend.
Deniz.

[1] - https://github.com/raspberrypi/linux/blob/96110e96f1a82e236afb9a248258f1ef917766e9/arch/arm/boot/dts/bcm2711-rpi-4-b.dts#L383

> On 1 May 2021, at 13:52, Stefan Wahren <stefan.wahren at i2se.com> wrote:
> 
> 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