Skip to content

Commit

Permalink
enables spidev interfaces (#181)
Browse files Browse the repository at this point in the history
by patching the dtb as closely as possible to raspbian, only difference
the gpio ports start with an offset of 458

Co-authored-by: Andreas Schubert <as@burgeins.de>
  • Loading branch information
schubter and Andreas Schubert committed Apr 19, 2020
1 parent 365bffc commit f686f39
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
61 changes: 61 additions & 0 deletions 0201-enable-spidev.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
index e1abe8c73..3d4baaeee 100644
--- a/arch/arm/boot/dts/bcm283x.dtsi
+++ b/arch/arm/boot/dts/bcm283x.dtsi
@@ -297,6 +297,14 @@ uart1_ctsrts_gpio42: uart1_ctsrts_gpio42 {
brcm,pins = <42 43>;
brcm,function = <BCM2835_FSEL_ALT5>;
};
+ spi0_pins: spi0_pins {
+ brcm,pins = <9 10 11>;
+ brcm,function = <BCM2835_FSEL_ALT0>;
+ };
+ spi0_cs_pins: spi0_cs_pins {
+ brcm,pins = <8 7>;
+ brcm,function = <BCM2835_FSEL_GPIO_OUT>;
+ };
};

uart0: serial@7e201000 {
@@ -331,7 +339,28 @@ spi: spi@7e204000 {
clocks = <&clocks BCM2835_CLOCK_VPU>;
#address-cells = <1>;
#size-cells = <0>;
- status = "disabled";
+ status = "okay";
+ dmas = <&dma 6>, <&dma 7>;
+ dma-names = "tx", "rx";
+ cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
+
+ spidev0: spidev@0 {
+ compatible = "brcm,bcm2835-spi";
+ spi-max-frequency = <125000000>;
+ reg = <0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
+
+ spidev1: spidev@1 {
+ compatible = "brcm,bcm2835-spi";
+ spi-max-frequency = <125000000>;
+ reg = <1>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
};

i2c0: i2c@7e205000 {
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 2ab6e782f..a426d5474 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -675,6 +675,7 @@ static const struct of_device_id spidev_dt_ids[] = {
{ .compatible = "lwn,bk4" },
{ .compatible = "dh,dhcom-board" },
{ .compatible = "menlo,m53cpld" },
+ { .compatible = "brcm,bcm2835-spi" },
{},
};
MODULE_DEVICE_TABLE(of, spidev_dt_ids);
Binary file modified bcm2710-rpi-3-b-plus.dtb
Binary file not shown.
Binary file modified bcm2710-rpi-3-b.dtb
Binary file not shown.
Binary file modified bcm2711-rpi-4-b.dtb
Binary file not shown.
4 changes: 4 additions & 0 deletions cmd/gokr-build-kernel/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ CONFIG_FUSE_FS=y
# For periph.io:
CONFIG_GPIO_SYSFS=y
CONFIG_SPI_SPIDEV=y
CONFIG_SPI_GPIO=y
CONFIG_GPIOLIB=y
CONFIG_GPIOLIB_IRQCHIP=y
# TODO: trim the settings below to the minimum set that works (taken from debian)
##
Expand Down
2 changes: 2 additions & 0 deletions cmd/gokr-rebuild-kernel/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ var patchFiles = []string{
"0101-expose-UART0-ttyAMA0-on-GPIO-14-15-disable-UART1-tty.patch",
"0102-expose-UART0-ttyAMA0-on-GPIO-14-15-disable-UART1-tty.patch",
"0103-expose-UART0-ttyAMA0-on-GPIO-14-15-disable-UART1-tty.patch",
// spi
"0201-enable-spidev.patch",
}

func copyFile(dest, src string) error {
Expand Down

0 comments on commit f686f39

Please sign in to comment.