1 From 322899a48088cb09b3f2a068f78c93a63615da9e Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Sat, 20 Nov 2021 10:48:36 +0000
4 Subject: [PATCH] dt: Create static regulators and clocks for camera
7 Unloading regulators through dynamic device tree doesn't work
8 as the regulators will unregister whilst clients are still
9 registered. Whilst the regulator framework does WARN when that
10 happens, the client putting the regulator then typically results
11 in a NULL dereference and badness.
13 Instead of creating regulators and clocks from the overlays,
14 create regulators and clocks for the sensors in the base DT.
16 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
18 arch/arm/boot/dts/bcm2708-rpi-b-plus.dts | 4 ++-
19 arch/arm/boot/dts/bcm2708-rpi-b-rev1.dts | 4 ++-
20 arch/arm/boot/dts/bcm2708-rpi-b.dts | 4 ++-
21 arch/arm/boot/dts/bcm2708-rpi-cm.dts | 21 ++++--------
22 arch/arm/boot/dts/bcm2708-rpi-zero-w.dts | 4 ++-
23 arch/arm/boot/dts/bcm2708-rpi-zero.dts | 4 ++-
24 arch/arm/boot/dts/bcm2709-rpi-2-b.dts | 4 ++-
25 arch/arm/boot/dts/bcm270x.dtsi | 33 +++++++++++++++++++
26 arch/arm/boot/dts/bcm2710-rpi-2-b.dts | 4 ++-
27 arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts | 4 ++-
28 arch/arm/boot/dts/bcm2710-rpi-3-b.dts | 4 ++-
29 arch/arm/boot/dts/bcm2710-rpi-cm3.dts | 21 ++++--------
30 arch/arm/boot/dts/bcm2710-rpi-zero-2-w.dts | 4 ++-
31 arch/arm/boot/dts/bcm2711-rpi-4-b.dts | 4 ++-
32 arch/arm/boot/dts/bcm2711-rpi-cm4.dts | 1 -
33 .../boot/dts/bcm283x-rpi-cam1-regulator.dtsi | 10 ------
34 16 files changed, 80 insertions(+), 50 deletions(-)
35 delete mode 100644 arch/arm/boot/dts/bcm283x-rpi-cam1-regulator.dtsi
37 --- a/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts
38 +++ b/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts
40 #include "bcm283x-rpi-smsc9514.dtsi"
41 #include "bcm283x-rpi-csi1-2lane.dtsi"
42 #include "bcm283x-rpi-i2c0mux_0_28.dtsi"
43 -#include "bcm283x-rpi-cam1-regulator.dtsi"
46 compatible = "raspberrypi,model-b-plus", "brcm,bcm2835";
48 gpio = <&gpio 41 GPIO_ACTIVE_HIGH>;
51 +cam0_reg: &cam_dummy_reg {
56 act_led_gpio = <&act_led>,"gpios:4";
57 --- a/arch/arm/boot/dts/bcm2708-rpi-b-rev1.dts
58 +++ b/arch/arm/boot/dts/bcm2708-rpi-b-rev1.dts
60 #include "bcm2708-rpi.dtsi"
61 #include "bcm283x-rpi-smsc9512.dtsi"
62 #include "bcm283x-rpi-csi1-2lane.dtsi"
63 -#include "bcm283x-rpi-cam1-regulator.dtsi"
66 compatible = "raspberrypi,model-b", "brcm,bcm2835";
67 @@ -123,6 +122,9 @@ i2c_csi_dsi: &i2c1 {
68 gpio = <&gpio 27 GPIO_ACTIVE_HIGH>;
71 +cam0_reg: &cam_dummy_reg {
76 act_led_gpio = <&act_led>,"gpios:4";
77 --- a/arch/arm/boot/dts/bcm2708-rpi-b.dts
78 +++ b/arch/arm/boot/dts/bcm2708-rpi-b.dts
80 #include "bcm283x-rpi-smsc9512.dtsi"
81 #include "bcm283x-rpi-csi1-2lane.dtsi"
82 #include "bcm283x-rpi-i2c0mux_0_28.dtsi"
83 -#include "bcm283x-rpi-cam1-regulator.dtsi"
86 compatible = "raspberrypi,model-b", "brcm,bcm2835";
88 gpio = <&gpio 21 GPIO_ACTIVE_HIGH>;
91 +cam0_reg: &cam_dummy_reg {
96 act_led_gpio = <&act_led>,"gpios:4";
97 --- a/arch/arm/boot/dts/bcm2708-rpi-cm.dts
98 +++ b/arch/arm/boot/dts/bcm2708-rpi-cm.dts
101 compatible = "raspberrypi,compute-module", "brcm,bcm2835";
102 model = "Raspberry Pi Compute Module";
106 + gpio = <&gpio 2 GPIO_ACTIVE_HIGH>;
109 - cam1_reg: cam1_reg {
110 - compatible = "regulator-fixed";
111 - regulator-name = "cam1-regulator";
112 - gpio = <&gpio 2 GPIO_ACTIVE_HIGH>;
113 - enable-active-high;
114 - status = "disabled";
116 - cam0_reg: cam0_reg {
117 - compatible = "regulator-fixed";
118 - regulator-name = "cam0-regulator";
119 - gpio = <&gpio 30 GPIO_ACTIVE_HIGH>;
120 - enable-active-high;
121 - status = "disabled";
123 +cam0_reg: &cam0_regulator {
124 + gpio = <&gpio 30 GPIO_ACTIVE_HIGH>;
128 --- a/arch/arm/boot/dts/bcm2708-rpi-zero-w.dts
129 +++ b/arch/arm/boot/dts/bcm2708-rpi-zero-w.dts
131 #include "bcm283x-rpi-csi1-2lane.dtsi"
132 #include "bcm283x-rpi-i2c0mux_0_28.dtsi"
133 #include "bcm2708-rpi-bt.dtsi"
134 -#include "bcm283x-rpi-cam1-regulator.dtsi"
137 compatible = "raspberrypi,model-zero-w", "brcm,bcm2835";
139 gpio = <&gpio 44 GPIO_ACTIVE_HIGH>;
142 +cam0_reg: &cam_dummy_reg {
147 act_led_gpio = <&act_led>,"gpios:4";
148 --- a/arch/arm/boot/dts/bcm2708-rpi-zero.dts
149 +++ b/arch/arm/boot/dts/bcm2708-rpi-zero.dts
151 #include "bcm2708-rpi.dtsi"
152 #include "bcm283x-rpi-csi1-2lane.dtsi"
153 #include "bcm283x-rpi-i2c0mux_0_28.dtsi"
154 -#include "bcm283x-rpi-cam1-regulator.dtsi"
157 compatible = "raspberrypi,model-zero", "brcm,bcm2835";
159 gpio = <&gpio 41 GPIO_ACTIVE_HIGH>;
162 +cam0_reg: &cam_dummy_reg {
167 act_led_gpio = <&act_led>,"gpios:4";
168 --- a/arch/arm/boot/dts/bcm2709-rpi-2-b.dts
169 +++ b/arch/arm/boot/dts/bcm2709-rpi-2-b.dts
171 #include "bcm283x-rpi-smsc9514.dtsi"
172 #include "bcm283x-rpi-csi1-2lane.dtsi"
173 #include "bcm283x-rpi-i2c0mux_0_28.dtsi"
174 -#include "bcm283x-rpi-cam1-regulator.dtsi"
177 compatible = "raspberrypi,2-model-b", "brcm,bcm2836";
179 gpio = <&gpio 41 GPIO_ACTIVE_HIGH>;
182 +cam0_reg: &cam_dummy_reg {
187 act_led_gpio = <&act_led>,"gpios:4";
188 --- a/arch/arm/boot/dts/bcm270x.dtsi
189 +++ b/arch/arm/boot/dts/bcm270x.dtsi
194 + cam1_reg: cam1_regulator {
195 + compatible = "regulator-fixed";
196 + regulator-name = "cam1-reg";
197 + enable-active-high;
198 + /* Needs to be enabled, as removing a regulator is very unsafe */
202 + cam1_clk: cam1_clk {
203 + compatible = "fixed-clock";
204 + #clock-cells = <0>;
205 + status = "disabled";
208 + cam0_regulator: cam0_regulator {
209 + compatible = "regulator-fixed";
210 + regulator-name = "cam0-reg";
211 + enable-active-high;
212 + status = "disabled";
215 + cam0_clk: cam0_clk {
216 + compatible = "fixed-clock";
217 + #clock-cells = <0>;
218 + status = "disabled";
221 + cam_dummy_reg: cam_dummy_reg {
222 + compatible = "regulator-fixed";
223 + regulator-name = "cam-dummy-reg";
230 --- a/arch/arm/boot/dts/bcm2710-rpi-2-b.dts
231 +++ b/arch/arm/boot/dts/bcm2710-rpi-2-b.dts
233 #include "bcm283x-rpi-smsc9514.dtsi"
234 #include "bcm283x-rpi-csi1-2lane.dtsi"
235 #include "bcm283x-rpi-i2c0mux_0_28.dtsi"
236 -#include "bcm283x-rpi-cam1-regulator.dtsi"
239 compatible = "raspberrypi,2-model-b-rev2", "brcm,bcm2837";
241 gpio = <&gpio 41 GPIO_ACTIVE_HIGH>;
244 +cam0_reg: &cam_dummy_reg {
249 act_led_gpio = <&act_led>,"gpios:4";
250 --- a/arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts
251 +++ b/arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts
253 #include "bcm283x-rpi-csi1-2lane.dtsi"
254 #include "bcm283x-rpi-i2c0mux_0_44.dtsi"
255 #include "bcm271x-rpi-bt.dtsi"
256 -#include "bcm283x-rpi-cam1-regulator.dtsi"
259 compatible = "raspberrypi,3-model-b-plus", "brcm,bcm2837";
261 gpio = <&expgpio 5 GPIO_ACTIVE_HIGH>;
264 +cam0_reg: &cam_dummy_reg {
269 act_led_gpio = <&act_led>,"gpios:4";
270 --- a/arch/arm/boot/dts/bcm2710-rpi-3-b.dts
271 +++ b/arch/arm/boot/dts/bcm2710-rpi-3-b.dts
273 #include "bcm283x-rpi-csi1-2lane.dtsi"
274 #include "bcm283x-rpi-i2c0mux_0_44.dtsi"
275 #include "bcm271x-rpi-bt.dtsi"
276 -#include "bcm283x-rpi-cam1-regulator.dtsi"
279 compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
281 gpio = <&expgpio 5 GPIO_ACTIVE_HIGH>;
284 +cam0_reg: &cam_dummy_reg {
289 act_led_gpio = <&act_led>,"gpios:4";
290 --- a/arch/arm/boot/dts/bcm2710-rpi-cm3.dts
291 +++ b/arch/arm/boot/dts/bcm2710-rpi-cm3.dts
294 compatible = "raspberrypi,3-compute-module", "brcm,bcm2837";
295 model = "Raspberry Pi Compute Module 3";
299 + gpio = <&gpio 2 GPIO_ACTIVE_HIGH>;
302 - cam1_reg: cam1_reg {
303 - compatible = "regulator-fixed";
304 - regulator-name = "cam1-regulator";
305 - gpio = <&gpio 2 GPIO_ACTIVE_HIGH>;
306 - enable-active-high;
307 - status = "disabled";
309 - cam0_reg: cam0_reg {
310 - compatible = "regulator-fixed";
311 - regulator-name = "cam0-regulator";
312 - gpio = <&gpio 30 GPIO_ACTIVE_HIGH>;
313 - enable-active-high;
314 - status = "disabled";
316 +cam0_reg: &cam0_regulator {
317 + gpio = <&gpio 30 GPIO_ACTIVE_HIGH>;
321 --- a/arch/arm/boot/dts/bcm2710-rpi-zero-2-w.dts
322 +++ b/arch/arm/boot/dts/bcm2710-rpi-zero-2-w.dts
324 #include "bcm283x-rpi-csi1-2lane.dtsi"
325 #include "bcm283x-rpi-i2c0mux_0_44.dtsi"
326 #include "bcm2708-rpi-bt.dtsi"
327 -#include "bcm283x-rpi-cam1-regulator.dtsi"
330 compatible = "raspberrypi,model-zero-2-w", "brcm,bcm2837";
332 gpio = <&gpio 40 GPIO_ACTIVE_HIGH>;
335 +cam0_reg: &cam_dummy_reg {
340 act_led_gpio = <&act_led>,"gpios:4";
341 --- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
342 +++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
344 #include "bcm2711-rpi-ds.dtsi"
345 #include "bcm283x-rpi-csi1-2lane.dtsi"
346 #include "bcm283x-rpi-i2c0mux_0_44.dtsi"
347 -#include "bcm283x-rpi-cam1-regulator.dtsi"
352 gpio = <&expgpio 5 GPIO_ACTIVE_HIGH>;
355 +cam0_reg: &cam_dummy_reg {
360 act_led_gpio = <&act_led>,"gpios:4";
361 --- a/arch/arm/boot/dts/bcm2711-rpi-cm4.dts
362 +++ b/arch/arm/boot/dts/bcm2711-rpi-cm4.dts
364 #include "bcm283x-rpi-csi0-2lane.dtsi"
365 #include "bcm283x-rpi-csi1-4lane.dtsi"
366 #include "bcm283x-rpi-i2c0mux_0_44.dtsi"
367 -#include "bcm283x-rpi-cam1-regulator.dtsi"
371 --- a/arch/arm/boot/dts/bcm283x-rpi-cam1-regulator.dtsi
374 -// SPDX-License-Identifier: GPL-2.0
377 - cam1_reg: cam1_reg {
378 - compatible = "regulator-fixed";
379 - regulator-name = "cam1-reg";
380 - enable-active-high;
381 - status = "disabled";