1 From 4d19be9132ca10cf582450a86dcb2c41f227f589 Mon Sep 17 00:00:00 2001
2 From: Ed Spiridonov <edo.rus@gmail.com>
3 Date: Tue, 10 Dec 2019 22:45:04 +0300
4 Subject: [PATCH] Add universal device tree overlay for SPI devices
6 Just specify the SPI address and device name ("compatible" property).
7 This overlay lacks any device-specific parameter support!
8 (some of them could be added later)
11 1. SPI NOR flash on spi0.1, maximum SPI clock frequency 45MHz:
12 dtoverlay=anyspi:spi0-1,dev="jedec,spi-nor",speed=45000000
13 2. MCP3204 ADC on spi1.2, maximum SPI clock frequency 500kHz:
14 dtoverlay=anyspi:spi1-2,dev="microchip,mcp3204"
16 Signed-off-by: Ed Spiridonov <edo.rus@gmail.com>
18 arch/arm/boot/dts/overlays/Makefile | 1 +
19 arch/arm/boot/dts/overlays/README | 23 ++
20 arch/arm/boot/dts/overlays/anyspi-overlay.dts | 205 ++++++++++++++++++
21 3 files changed, 229 insertions(+)
22 create mode 100755 arch/arm/boot/dts/overlays/anyspi-overlay.dts
24 --- a/arch/arm/boot/dts/overlays/Makefile
25 +++ b/arch/arm/boot/dts/overlays/Makefile
26 @@ -15,6 +15,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
27 allo-katana-dac-audio.dtbo \
28 allo-piano-dac-pcm512x-audio.dtbo \
29 allo-piano-dac-plus-pcm512x-audio.dtbo \
34 --- a/arch/arm/boot/dts/overlays/README
35 +++ b/arch/arm/boot/dts/overlays/README
36 @@ -441,6 +441,29 @@ Params: 24db_digital_gain Allow ga
37 better voice quality. (default Off)
41 +Info: Universal device tree overlay for SPI devices
43 + Just specify the SPI address and device name ("compatible" property).
44 + This overlay lacks any device-specific parameter support!
46 + For devices on spi1 or spi2, the interfaces should be enabled
47 + with one of the spi1-1/2/3cs and/or spi2-1/2/3cs overlays.
50 + 1. SPI NOR flash on spi0.1, maximum SPI clock frequency 45MHz:
51 + dtoverlay=anyspi:spi0-1,dev="jedec,spi-nor",speed=45000000
52 + 2. MCP3204 ADC on spi1.2, maximum SPI clock frequency 500kHz:
53 + dtoverlay=anyspi:spi1-2,dev="microchip,mcp3204"
54 +Load: dtoverlay=anyspi,<param>=<val>
55 +Params: spi<n>-<m> Configure device at spi<n>, cs<m>
57 + dev Set device name to search compatible module
59 + speed Set SPI clock frequency in Hz
60 + (integer, optional, default 500000)
64 Info: Configures the AVAGO APDS9960 digital proximity, ambient light, RGB and
67 +++ b/arch/arm/boot/dts/overlays/anyspi-overlay.dts
70 + * Universal device tree overlay for SPI devices
77 + compatible = "brcm,bcm2835";
80 + target = <&spidev0>;
82 + status = "disabled";
87 + target = <&spidev1>;
89 + status = "disabled";
94 + target-path = "spi1/spidev@0";
96 + status = "disabled";
101 + target-path = "spi1/spidev@1";
103 + status = "disabled";
108 + target-path = "spi1/spidev@2";
110 + status = "disabled";
115 + target-path = "spi2/spidev@0";
117 + status = "disabled";
122 + target-path = "spi2/spidev@1";
124 + status = "disabled";
129 + target-path = "spi2/spidev@2";
131 + status = "disabled";
139 + #address-cells = <1>;
142 + anyspi_00: anyspi@0 {
144 + spi-max-frequency = <500000>;
153 + #address-cells = <1>;
156 + anyspi_01: anyspi@1 {
158 + spi-max-frequency = <500000>;
167 + #address-cells = <1>;
170 + anyspi_10: anyspi@0 {
172 + spi-max-frequency = <500000>;
181 + #address-cells = <1>;
184 + anyspi_11: anyspi@1 {
186 + spi-max-frequency = <500000>;
195 + #address-cells = <1>;
198 + anyspi_12: anyspi@2 {
200 + spi-max-frequency = <500000>;
209 + #address-cells = <1>;
212 + anyspi_20: anyspi@0 {
214 + spi-max-frequency = <500000>;
223 + #address-cells = <1>;
226 + anyspi_21: anyspi@1 {
228 + spi-max-frequency = <500000>;
237 + #address-cells = <1>;
240 + anyspi_22: anyspi@2 {
242 + spi-max-frequency = <500000>;
248 + spi0-0 = <0>, "+0+8";
249 + spi0-1 = <0>, "+1+9";
250 + spi1-0 = <0>, "+2+10";
251 + spi1-1 = <0>, "+3+11";
252 + spi1-2 = <0>, "+4+12";
253 + spi2-0 = <0>, "+5+13";
254 + spi2-1 = <0>, "+6+14";
255 + spi2-2 = <0>, "+7+15";
256 + dev = <&anyspi_00>,"compatible",
257 + <&anyspi_01>,"compatible",
258 + <&anyspi_10>,"compatible",
259 + <&anyspi_11>,"compatible",
260 + <&anyspi_12>,"compatible",
261 + <&anyspi_20>,"compatible",
262 + <&anyspi_21>,"compatible",
263 + <&anyspi_22>,"compatible";
264 + speed = <&anyspi_00>, "spi-max-frequency:0",
265 + <&anyspi_01>, "spi-max-frequency:0",
266 + <&anyspi_10>, "spi-max-frequency:0",
267 + <&anyspi_11>, "spi-max-frequency:0",
268 + <&anyspi_12>, "spi-max-frequency:0",
269 + <&anyspi_20>, "spi-max-frequency:0",
270 + <&anyspi_21>, "spi-max-frequency:0",
271 + <&anyspi_22>, "spi-max-frequency:0";