How to use spi with rpi-4
Laurentiu-Cristian Duca
laurentiu.duca at gmail.com
Tue Nov 10 09:03:34 EST 2020
Hi,
I have done it with arch/arm/boot/dts/bcm2835-rpi.dtsi as the following:
/ {
aliases {
spi0 = &spi0;
};
leds {
compatible = "gpio-leds";
act {
label = "ACT";
default-state = "keep";
linux,default-trigger = "heartbeat";
};
};
soc {
spi0: spi at 7e204000 {
/* Add label */
dmas = <&dma 6>, <&dma 7>;
dma-names = "tx", "rx";
};
firmware: firmware {
compatible = "raspberrypi,bcm2835-firmware", "simple-mfd";
#address-cells = <1>;
#size-cells = <1>;
mboxes = <&mailbox>;
dma-ranges;
};
power: power {
compatible = "raspberrypi,bcm2835-power";
firmware = <&firmware>;
#power-domain-cells = <1>;
};
vchiq: mailbox at 7e00b840 {
compatible = "brcm,bcm2835-vchiq";
reg = <0x7e00b840 0x3c>;
interrupts = <0 2>;
};
};
};
&gpio {
pinctrl-names = "default";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
//brcm,function = <4>; /* alt0 */
brcm,function = <BCM2835_FSEL_ALT0>;
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
gpioout: gpioout {
brcm,pins = <6>;
brcm,function = <BCM2835_FSEL_GPIO_OUT>;
};
alt0: alt0 {
//brcm,pins = <4 5 7 8 9 10 11>;
brcm,pins = <4 5>;
brcm,function = <BCM2835_FSEL_ALT0>;
};
};
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c0_gpio0>;
status = "okay";
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_gpio2>;
status = "okay";
clock-frequency = <100000>;
};
&usb {
power-domains = <&power RPI_POWER_DOMAIN_USB>;
};
&vec {
power-domains = <&power RPI_POWER_DOMAIN_VEC>;
status = "okay";
};
&dsi0 {
power-domains = <&power RPI_POWER_DOMAIN_DSI0>;
};
&dsi1 {
power-domains = <&power RPI_POWER_DOMAIN_DSI1>;
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
spidev0: spidev at 0{
compatible = "spidev";
reg = <0>; // CE0
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
status = "okay";
};
spidev1: spidev at 1{
compatible = "spidev";
reg = <1>; // CE1
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
status = "okay";
};
};
On 11/10/20, Laurentiu-Cristian Duca <laurentiu.duca at gmail.com> wrote:
> Dear friends,
>
> I am trying to test spi on raspberry pi 4.
> I have set dtparam=spi=on in config.txt
> After I boot the rpi-4, I enter the following commands:
> modprobe spi-bcm2835
> modprobe spi-bcm2835-aux
> modprobe spidev
> Even so, the /dev/ is not populated with spidev0.0 or spidev0.1 or
> spidev1.0 ...
>
> I have compiled the dtb with the command:
> make ARCH=arm64 bcm2711-rpi-4-b.dtb
> Also, the kernel is compiled for ARCH=arm64.
>
> Any ideas on how to have /dev populated?
>
> Thank you very much,
> L-C.
>
More information about the linux-rpi-kernel
mailing list