bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0796-overlays-Add-overlay-for-MIPI-DBI-displays.patch
1 From bf5020c3cbf3e799379c661e2f653ac572175d67 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
3 Date: Mon, 7 Mar 2022 17:05:49 +0100
4 Subject: [PATCH] overlays: Add overlay for MIPI DBI displays
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Add an overlay that can be used with all displays that have a
10 MIPI DBI compatible controller (pixels over SPI).
11
12 Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
13 ---
14 arch/arm/boot/dts/overlays/Makefile | 1 +
15 arch/arm/boot/dts/overlays/README | 67 +++++++
16 .../dts/overlays/mipi-dbi-spi-overlay.dts | 172 ++++++++++++++++++
17 3 files changed, 240 insertions(+)
18 create mode 100644 arch/arm/boot/dts/overlays/mipi-dbi-spi-overlay.dts
19
20 --- a/arch/arm/boot/dts/overlays/Makefile
21 +++ b/arch/arm/boot/dts/overlays/Makefile
22 @@ -135,6 +135,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
23 midi-uart5.dtbo \
24 minipitft13.dtbo \
25 miniuart-bt.dtbo \
26 + mipi-dbi-spi.dtbo \
27 mlx90640.dtbo \
28 mmc.dtbo \
29 mpu6050.dtbo \
30 --- a/arch/arm/boot/dts/overlays/README
31 +++ b/arch/arm/boot/dts/overlays/README
32 @@ -2386,6 +2386,73 @@ Params: krnbt Set to "
33 driver without need of hciattach/btattach
34
35
36 +Name: mipi-dbi-spi
37 +Info: Overlay for SPI-connected MIPI DBI displays using the panel-mipi-dbi
38 + driver. The driver will load a file /lib/firmware/panel.bin containing
39 + the initialisation commands.
40 +
41 + Example:
42 + dtoverlay=mipi-dbi-spi,spi0-0,speed=70000000
43 + dtparam=width=320,height=240
44 + dtparam=reset-gpio=23,dc-gpio=24
45 + dtparam=backlight-gpio=18
46 +
47 + Compared to fbtft panel-mipi-dbi runs pixel data at spi-max-frequency
48 + and init commands at 10MHz. This makes it possible to push the envelope
49 + without messing up the controller configuration due to command
50 + transmission errors.
51 +
52 + For devices on spi1 or spi2, the interfaces should be enabled
53 + with one of the spi1-1/2/3cs and/or spi2-1/2/3cs overlays.
54 +
55 + See https://github.com/notro/panel-mipi-dbi/wiki for more info.
56 +
57 +Load: dtoverlay=mipi-dbi-spi,<param>=<val>
58 +Params:
59 + compatible Set the compatible string to load a different
60 + firmware file. Both the panel compatible value
61 + used to load the firmware file and the value
62 + used to load the driver has to be set having a
63 + NUL (\0) separator between them.
64 + Example:
65 + dtparam=compatible=mypanel\0panel-mipi-dbi-spi
66 + spi<n>-<m> Configure device at spi<n>, cs<m>
67 + (boolean, required)
68 + speed SPI bus speed in Hz (default 32000000)
69 + cpha Shifted SPI clock phase (CPHA) mode
70 + cpol Inverse SPI clock polarity (CPOL) mode
71 + write-only Controller is not readable
72 + (ie. MISO is not wired up).
73 +
74 + width Panel width in pixels (required)
75 + height Panel height in pixels (required)
76 + width-mm Panel width in mm
77 + height-mm Panel height in mm
78 + x-offset Panel x-offset in controller RAM
79 + y-offset Panel y-offset in controller RAM
80 +
81 + clock-frequency Panel clock frequency in Hz
82 + (optional, just informational).
83 +
84 + reset-gpio GPIO pin to be used for RESET
85 + dc-gpio GPIO pin to be used for D/C
86 +
87 + backlight-gpio GPIO pin to be used for backlight control
88 + (default of none).
89 + backlight-pwm PWM channel to be used for backlight control
90 + (default of none). NB Disables audio headphone
91 + output as that also uses PWM.
92 + backlight-pwm-chan Choose channel on &pwm node for backlight
93 + control (default 0).
94 + backlight-pwm-gpio GPIO pin to be used for the PWM backlight. See
95 + pwm-2chan for valid options (default 18).
96 + backlight-pwm-func Pin function of GPIO used for the PWM backlight.
97 + See pwm-2chan for valid options (default 2).
98 + backlight-def-brightness
99 + Set the default brightness. Normal range 1-16.
100 + (default 16).
101 +
102 +
103 Name: mlx90640
104 Info: Overlay for i2c connected mlx90640 thermal camera
105 Load: dtoverlay=mlx90640
106 --- /dev/null
107 +++ b/arch/arm/boot/dts/overlays/mipi-dbi-spi-overlay.dts
108 @@ -0,0 +1,172 @@
109 +/*
110 + * mipi-dbi-spi-overlay.dts
111 + */
112 +
113 +#include <dt-bindings/gpio/gpio.h>
114 +
115 +/dts-v1/;
116 +/plugin/;
117 +
118 +/ {
119 + compatible = "brcm,bcm2835";
120 +
121 + spidev_fragment: fragment@0 {
122 + target-path = "spi0/spidev@0";
123 + __overlay__ {
124 + status = "disabled";
125 + };
126 + };
127 +
128 + panel_fragment: fragment@1 {
129 + target = <&spi0>;
130 + __overlay__ {
131 + /* needed to avoid dtc warning */
132 + #address-cells = <1>;
133 + #size-cells = <0>;
134 +
135 + status = "okay";
136 +
137 + panel: panel@0 {
138 + compatible = "panel", "panel-mipi-dbi-spi";
139 + reg = <0>;
140 + spi-max-frequency = <32000000>;
141 +
142 + timing: panel-timing {
143 + hactive = <320>;
144 + vactive = <240>;
145 + hback-porch = <0>;
146 + vback-porch = <0>;
147 +
148 + clock-frequency = <0>;
149 + hfront-porch = <0>;
150 + hsync-len = <0>;
151 + vfront-porch = <0>;
152 + vsync-len = <0>;
153 + };
154 + };
155 + };
156 + };
157 +
158 + fragment@10 {
159 + target = <&panel>;
160 + __dormant__ {
161 + backlight = <&backlight_gpio>;
162 + };
163 + };
164 +
165 + fragment@11 {
166 + target-path = "/";
167 + __dormant__ {
168 + backlight_gpio: backlight_gpio {
169 + compatible = "gpio-backlight";
170 + gpios = <&gpio 255 GPIO_ACTIVE_HIGH>;
171 + };
172 + };
173 + };
174 +
175 + fragment@20 {
176 + target = <&panel>;
177 + __dormant__ {
178 + backlight = <&backlight_pwm>;
179 + };
180 + };
181 +
182 + fragment@21 {
183 + target-path = "/";
184 + __dormant__ {
185 + backlight_pwm: backlight_pwm {
186 + compatible = "pwm-backlight";
187 + brightness-levels = <0 6 8 12 16 24 32 40 48 64 96 128 160 192 224 255>;
188 + default-brightness-level = <16>;
189 + pwms = <&pwm 0 200000>;
190 + };
191 + };
192 + };
193 +
194 + fragment@22 {
195 + target = <&pwm>;
196 + __dormant__ {
197 + pinctrl-names = "default";
198 + pinctrl-0 = <&pwm_pins>;
199 + assigned-clock-rates = <1000000>;
200 + status = "okay";
201 + };
202 + };
203 +
204 + fragment@23 {
205 + target = <&gpio>;
206 + __dormant__ {
207 + pwm_pins: pwm_pins {
208 + brcm,pins = <18>;
209 + brcm,function = <2>; /* Alt5 */
210 + };
211 + };
212 + };
213 +
214 + fragment@24 {
215 + target = <&audio>;
216 + __dormant__ {
217 + brcm,disable-headphones;
218 + };
219 + };
220 +
221 + __overrides__ {
222 + compatible = <&panel>, "compatible";
223 +
224 + spi0-0 = <&panel_fragment>, "target:0=",<&spi0>,
225 + <&spidev_fragment>, "target-path=spi0/spidev@0",
226 + <&panel>, "reg:0=0";
227 + spi0-1 = <&panel_fragment>, "target:0=",<&spi0>,
228 + <&spidev_fragment>, "target-path=spi0/spidev@1",
229 + <&panel>, "reg:0=1";
230 + spi1-0 = <&panel_fragment>, "target:0=",<&spi1>,
231 + <&spidev_fragment>, "target-path=spi1/spidev@0",
232 + <&panel>, "reg:0=0";
233 + spi1-1 = <&panel_fragment>, "target:0=",<&spi1>,
234 + <&spidev_fragment>, "target-path=spi1/spidev@1",
235 + <&panel>, "reg:0=1";
236 + spi1-2 = <&panel_fragment>, "target:0=",<&spi1>,
237 + <&spidev_fragment>, "target-path=spi1/spidev@2",
238 + <&panel>, "reg:0=2";
239 + spi2-0 = <&panel_fragment>, "target:0=",<&spi2>,
240 + <&spidev_fragment>, "target-path=spi2/spidev@0",
241 + <&panel>, "reg:0=0";
242 + spi2-1 = <&panel_fragment>, "target:0=",<&spi2>,
243 + <&spidev_fragment>, "target-path=spi2/spidev@1",
244 + <&panel>, "reg:0=1";
245 + spi2-2 = <&panel_fragment>, "target:0=",<&spi2>,
246 + <&spidev_fragment>, "target-path=spi2/spidev@2",
247 + <&panel>, "reg:0=2";
248 +
249 + speed = <&panel>, "spi-max-frequency:0";
250 + cpha = <&panel>, "spi-cpha?";
251 + cpol = <&panel>, "spi-cpol?";
252 +
253 + write-only = <&panel>, "write-only?";
254 +
255 + width = <&timing>, "hactive:0";
256 + height = <&timing>, "vactive:0";
257 + x-offset = <&timing>, "hback-porch:0";
258 + y-offset = <&timing>, "vback-porch:0";
259 + clock-frequency = <&timing>, "clock-frequency:0";
260 +
261 + width-mm = <&panel>, "width-mm:0";
262 + height-mm = <&panel>, "height-mm:0";
263 +
264 + /* optional gpios */
265 + reset-gpio = <&panel>, "reset-gpios:0=", <&gpio>,
266 + <&panel>, "reset-gpios:4",
267 + <&panel>, "reset-gpios:8=0"; /* GPIO_ACTIVE_HIGH */
268 + dc-gpio = <&panel>, "dc-gpios:0=", <&gpio>,
269 + <&panel>, "dc-gpios:4",
270 + <&panel>, "dc-gpios:8=0"; /* GPIO_ACTIVE_HIGH */
271 +
272 + backlight-gpio = <0>, "+10+11",
273 + <&backlight_gpio>, "gpios:4";
274 + backlight-pwm = <0>, "+20+21+22+23+24";
275 + backlight-pwm-chan = <&backlight_pwm>, "pwms:4";
276 + backlight-pwm-gpio = <&pwm_pins>, "brcm,pins:0";
277 + backlight-pwm-func = <&pwm_pins>, "brcm,function:0";
278 + backlight-def-brightness = <&backlight_pwm>, "default-brightness-level:0";
279 + };
280 +};