f526a1573c5858877a6ad78371466e9e55b4e819
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.10 / 950-0420-Add-overlay-for-Seeed-Studio-CAN-BUS-FD-HAT-4034.patch
1 From 0f49536b413a81aedb9635c7b2613ca5a8d554c4 Mon Sep 17 00:00:00 2001
2 From: menschel <menschel.p@posteo.de>
3 Date: Wed, 30 Dec 2020 21:55:34 +0100
4 Subject: [PATCH] Add overlay for Seeed Studio CAN BUS FD HAT (#4034)
5
6 This patch adds the overlay for the Seeed Studio CAN BUS FD HAT
7 with two CAN FD Channels and an RTC.
8 https://www.seeedstudio.com/CAN-BUS-FD-HAT-for-Raspberry-Pi-p-4742.html
9
10 The overlay was generated by
11 ovmerge -c mcp251xfd-overlay.dts,spi0-0,interrupt=25 \
12 mcp251xfd-overlay.dts,spi0-1,interrupt=24 \
13 i2c-rtc-overlay.dts,pcf85063
14
15
16 Also, add description on how to generate overlays
17
18 Signed-off-by: Patrick Menschel <menschel.p@posteo.de>
19 ---
20 arch/arm/boot/dts/overlays/Makefile | 1 +
21 arch/arm/boot/dts/overlays/README | 46 +++++++
22 .../dts/overlays/seeed-can-fd-hat-overlay.dts | 117 ++++++++++++++++++
23 3 files changed, 164 insertions(+)
24 create mode 100644 arch/arm/boot/dts/overlays/seeed-can-fd-hat-overlay.dts
25
26 --- a/arch/arm/boot/dts/overlays/Makefile
27 +++ b/arch/arm/boot/dts/overlays/Makefile
28 @@ -161,6 +161,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
29 sc16is752-spi1.dtbo \
30 sdhost.dtbo \
31 sdio.dtbo \
32 + seeed-can-fd-hat.dtbo \
33 sh1106-spi.dtbo \
34 smi.dtbo \
35 smi-dev.dtbo \
36 --- a/arch/arm/boot/dts/overlays/README
37 +++ b/arch/arm/boot/dts/overlays/README
38 @@ -81,6 +81,44 @@ Parameters usually have default values,
39 mandatory. See the list of overlays below for a description of the parameters
40 and their defaults.
41
42 +Making new Overlays based on existing Overlays
43 +==============================================
44 +
45 +Recent overlays have been designed in a more general way, so that they can be
46 +adapted to hardware by changing their parameters. When you have additional
47 +hardware with more than one device of a kind, you end up using the same overlay
48 +multiple times with other parameters, e.g.
49 +
50 + # 2 CAN FD interfaces on spi but with different pins
51 + dtoverlay=mcp251xfd,spi0-0,interrupt=25
52 + dtoverlay=mcp251xfd,spi0-1,interrupt=24
53 +
54 + # a realtime clock on i2c
55 + dtoverlay=i2c-rtc,pcf85063
56 +
57 +While this approach does work, it requires knowledge about the hardware design.
58 +It is more feasible to simplify things for the end user by providing a single
59 +overlay as it is done the traditional way.
60 +
61 +A new overlay can be generated by using ovmerge utility.
62 +https://github.com/raspberrypi/utils/blob/master/ovmerge/ovmerge
63 +
64 +To generate an overlay for the above configuration we pass the configuration
65 +to ovmerge and add the -c flag.
66 +
67 + ovmerge -c mcp251xfd-overlay.dts,spi0-0,interrupt=25 \
68 + mcp251xfd-overlay.dts,spi0-1,interrupt=24 \
69 + i2c-rtc-overlay.dts,pcf85063 \
70 + >> merged-overlay.dts
71 +
72 +The -c option writes the command above as a comment into the overlay as
73 +a marker that this overlay is generated and how it was generated.
74 +After compiling the overlay it can be loaded in a single line.
75 +
76 + dtoverlay=merged
77 +
78 +It does the same as the original configuration but without parameters.
79 +
80 The Overlay and Parameter Reference
81 ===================================
82
83 @@ -2466,6 +2504,14 @@ Info: This overlay is now deprecated.
84 Load: <Deprecated>
85
86
87 +Name: seeed-can-fd-hat
88 +Info: Overlay for Seeed Studio CAN BUS FD HAT with two CAN FD channels and an
89 + RTC.
90 + https://www.seeedstudio.com/CAN-BUS-FD-HAT-for-Raspberry-Pi-p-4742.html
91 +Load: dtoverlay=seeed-can-fd-hat
92 +Params: <None>
93 +
94 +
95 Name: sh1106-spi
96 Info: Overlay for SH1106 OLED via SPI using fbtft staging driver.
97 Load: dtoverlay=sh1106-spi,<param>=<val>
98 --- /dev/null
99 +++ b/arch/arm/boot/dts/overlays/seeed-can-fd-hat-overlay.dts
100 @@ -0,0 +1,117 @@
101 +// redo: ovmerge -c mcp251xfd-overlay.dts,spi0-0,interrupt=25 mcp251xfd-overlay.dts,spi0-1,interrupt=24 i2c-rtc-overlay.dts,pcf85063
102 +
103 +// Device tree overlay for https://www.seeedstudio.com/CAN-BUS-FD-HAT-for-Raspberry-Pi-p-4742.html
104 +
105 +/dts-v1/;
106 +/plugin/;
107 +
108 +#include <dt-bindings/gpio/gpio.h>
109 +#include <dt-bindings/interrupt-controller/irq.h>
110 +#include <dt-bindings/pinctrl/bcm2835.h>
111 +
112 +/ {
113 + compatible = "brcm,bcm2835";
114 + fragment@0 {
115 + target = <&spidev0>;
116 + __overlay__ {
117 + status = "disabled";
118 + };
119 + };
120 + fragment@1 {
121 + target = <&gpio>;
122 + __overlay__ {
123 + mcp251xfd_pins: mcp251xfd_spi0_0_pins {
124 + brcm,pins = <25>;
125 + brcm,function = <BCM2835_FSEL_GPIO_IN>;
126 + };
127 + };
128 + };
129 + fragment@2 {
130 + target-path = "/clocks";
131 + __overlay__ {
132 + clk_mcp251xfd_osc: mcp251xfd-spi0-0-osc {
133 + #clock-cells = <0>;
134 + compatible = "fixed-clock";
135 + clock-frequency = <40000000>;
136 + };
137 + };
138 + };
139 + fragment@3 {
140 + target = <&spi0>;
141 + __overlay__ {
142 + status = "okay";
143 + #address-cells = <1>;
144 + #size-cells = <0>;
145 + mcp251xfd@0 {
146 + compatible = "microchip,mcp251xfd";
147 + reg = <0>;
148 + pinctrl-names = "default";
149 + pinctrl-0 = <&mcp251xfd_pins>;
150 + spi-max-frequency = <20000000>;
151 + interrupt-parent = <&gpio>;
152 + interrupts = <25 IRQ_TYPE_LEVEL_LOW>;
153 + clocks = <&clk_mcp251xfd_osc>;
154 + };
155 + };
156 + };
157 + fragment@4 {
158 + target = <&spidev1>;
159 + __overlay__ {
160 + status = "disabled";
161 + };
162 + };
163 + fragment@5 {
164 + target = <&gpio>;
165 + __overlay__ {
166 + mcp251xfd_pins_1: mcp251xfd_spi0_1_pins {
167 + brcm,pins = <24>;
168 + brcm,function = <BCM2835_FSEL_GPIO_IN>;
169 + };
170 + };
171 + };
172 + fragment@6 {
173 + target-path = "/clocks";
174 + __overlay__ {
175 + clk_mcp251xfd_osc_1: mcp251xfd-spi0-1-osc {
176 + #clock-cells = <0>;
177 + compatible = "fixed-clock";
178 + clock-frequency = <40000000>;
179 + };
180 + };
181 + };
182 + fragment@7 {
183 + target = <&spi0>;
184 + __overlay__ {
185 + status = "okay";
186 + #address-cells = <1>;
187 + #size-cells = <0>;
188 + mcp251xfd@1 {
189 + compatible = "microchip,mcp251xfd";
190 + reg = <1>;
191 + pinctrl-names = "default";
192 + pinctrl-0 = <&mcp251xfd_pins_1>;
193 + spi-max-frequency = <20000000>;
194 + interrupt-parent = <&gpio>;
195 + interrupts = <24 IRQ_TYPE_LEVEL_LOW>;
196 + clocks = <&clk_mcp251xfd_osc_1>;
197 + };
198 + };
199 + };
200 + fragment@8 {
201 + target = <&i2cbus>;
202 + __overlay__ {
203 + #address-cells = <1>;
204 + #size-cells = <0>;
205 + pcf85063@51 {
206 + compatible = "nxp,pcf85063";
207 + reg = <0x51>;
208 + };
209 + };
210 + };
211 + fragment@9 {
212 + target = <&i2c_arm>;
213 + i2cbus: __overlay__ {
214 + status = "okay";
215 + };
216 + };
217 +};