1// SPDX-License-Identifier: BSD-3-Clause
2/*
3 * Copyright (c) 2021, Luca Weiss <luca@z3ntu.xyz>
4 */
5
6/dts-v1/;
7
8#include <dt-bindings/gpio/gpio.h>
9#include <dt-bindings/input/input.h>
10#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
11#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
12#include "sm7225.dtsi"
13#include "pm6350.dtsi"
14
15/ {
16	model = "Fairphone 4";
17	compatible = "fairphone,fp4", "qcom,sm7225";
18	chassis-type = "handset";
19
20	/* required for bootloader to select correct board */
21	qcom,msm-id = <434 0x10000>, <459 0x10000>;
22	qcom,board-id = <8 32>;
23
24	aliases {
25		serial0 = &uart2;
26	};
27
28	chosen {
29		#address-cells = <2>;
30		#size-cells = <2>;
31		ranges;
32
33		stdout-path = "serial0:115200n8";
34
35		framebuffer0: framebuffer@a000000 {
36			compatible = "simple-framebuffer";
37			reg = <0 0xa0000000 0 (2340 * 1080 * 4)>;
38			width = <1080>;
39			height = <2340>;
40			stride = <(1080 * 4)>;
41			format = "a8r8g8b8";
42		};
43	};
44
45	gpio-keys {
46		compatible = "gpio-keys";
47		pinctrl-names = "default";
48		pinctrl-0 = <&gpio_keys_pin>;
49
50		volume-up {
51			label = "volume_up";
52			linux,code = <KEY_VOLUMEUP>;
53			gpios = <&pm6350_gpios 2 GPIO_ACTIVE_LOW>;
54		};
55	};
56
57	reserved-memory {
58		/*
59		 * The rmtfs memory region in downstream is 'dynamically allocated'
60		 * but given the same address every time. Hard code it as this address is
61		 * where the modem firmware expects it to be.
62		 */
63		memory@efe01000 {
64			compatible = "qcom,rmtfs-mem";
65			reg = <0 0xefe01000 0 0x600000>;
66			no-map;
67
68			qcom,client-id = <1>;
69			qcom,vmid = <15>;
70		};
71	};
72};
73
74&adsp {
75	status = "okay";
76	firmware-name = "qcom/sm7225/fairphone4/adsp.mdt";
77};
78
79&apps_rsc {
80	pm6350-rpmh-regulators {
81		compatible = "qcom,pm6350-rpmh-regulators";
82		qcom,pmic-id = "a";
83
84		vreg_s1a: smps1 {
85			regulator-min-microvolt = <1000000>;
86			regulator-max-microvolt = <1200000>;
87		};
88
89		vreg_s2a: smps2 {
90			regulator-min-microvolt = <1503000>;
91			regulator-max-microvolt = <2048000>;
92		};
93
94		vreg_l2a: ldo2 {
95			regulator-min-microvolt = <1503000>;
96			regulator-max-microvolt = <1980000>;
97			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
98		};
99
100		vreg_l3a: ldo3 {
101			regulator-min-microvolt = <2700000>;
102			regulator-max-microvolt = <3300000>;
103			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
104		};
105
106		vreg_l4a: ldo4 {
107			regulator-min-microvolt = <352000>;
108			regulator-max-microvolt = <801000>;
109			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
110		};
111
112		vreg_l5a: ldo5 {
113			regulator-min-microvolt = <1503000>;
114			regulator-max-microvolt = <1980000>;
115			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
116		};
117
118		vreg_l6a: ldo6 {
119			regulator-min-microvolt = <1710000>;
120			regulator-max-microvolt = <3544000>;
121			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
122		};
123
124		vreg_l7a: ldo7 {
125			regulator-min-microvolt = <1620000>;
126			regulator-max-microvolt = <1980000>;
127			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
128		};
129
130		vreg_l8a: ldo8 {
131			regulator-min-microvolt = <2800000>;
132			regulator-max-microvolt = <2800000>;
133			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
134		};
135
136		vreg_l9a: ldo9 {
137			regulator-min-microvolt = <1650000>;
138			regulator-max-microvolt = <3401000>;
139			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
140		};
141
142		vreg_l11a: ldo11 {
143			regulator-min-microvolt = <1800000>;
144			regulator-max-microvolt = <2000000>;
145			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
146		};
147
148		vreg_l12a: ldo12 {
149			regulator-min-microvolt = <1620000>;
150			regulator-max-microvolt = <1980000>;
151			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
152		};
153
154		vreg_l13a: ldo13 {
155			regulator-min-microvolt = <570000>;
156			regulator-max-microvolt = <650000>;
157			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
158		};
159
160		vreg_l14a: ldo14 {
161			regulator-min-microvolt = <1700000>;
162			regulator-max-microvolt = <1900000>;
163			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
164		};
165
166		vreg_l15a: ldo15 {
167			regulator-min-microvolt = <1100000>;
168			regulator-max-microvolt = <1305000>;
169			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
170		};
171
172		vreg_l16a: ldo16 {
173			regulator-min-microvolt = <830000>;
174			regulator-max-microvolt = <921000>;
175			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
176		};
177
178		vreg_l18a: ldo18 {
179			regulator-min-microvolt = <788000>;
180			regulator-max-microvolt = <1049000>;
181			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
182		};
183
184		vreg_l19a: ldo19 {
185			regulator-min-microvolt = <1080000>;
186			regulator-max-microvolt = <1305000>;
187			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
188		};
189
190		vreg_l20a: ldo20 {
191			regulator-min-microvolt = <530000>;
192			regulator-max-microvolt = <801000>;
193			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
194		};
195
196		vreg_l21a: ldo21 {
197			regulator-min-microvolt = <751000>;
198			regulator-max-microvolt = <825000>;
199			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
200		};
201
202		vreg_l22a: ldo22 {
203			regulator-min-microvolt = <1080000>;
204			regulator-max-microvolt = <1305000>;
205			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
206		};
207	};
208
209	pm6150l-rpmh-regulators {
210		compatible = "qcom,pm6150l-rpmh-regulators";
211		qcom,pmic-id = "e";
212
213		vreg_s8e: smps8 {
214			regulator-min-microvolt = <313000>;
215			regulator-max-microvolt = <1395000>;
216		};
217
218		vreg_l1e: ldo1 {
219			regulator-min-microvolt = <1620000>;
220			regulator-max-microvolt = <1980000>;
221			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
222		};
223
224		vreg_l2e: ldo2 {
225			regulator-min-microvolt = <1170000>;
226			regulator-max-microvolt = <1305000>;
227			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
228		};
229
230		vreg_l3e: ldo3 {
231			regulator-min-microvolt = <1100000>;
232			regulator-max-microvolt = <1299000>;
233			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
234		};
235
236		vreg_l4e: ldo4 {
237			regulator-min-microvolt = <1620000>;
238			regulator-max-microvolt = <3300000>;
239			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
240		};
241
242		vreg_l5e: ldo5 {
243			regulator-min-microvolt = <1620000>;
244			regulator-max-microvolt = <3300000>;
245			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
246		};
247
248		vreg_l6e: ldo6 {
249			regulator-min-microvolt = <1700000>;
250			regulator-max-microvolt = <3544000>;
251			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
252		};
253
254		vreg_l7e: ldo7 {
255			regulator-min-microvolt = <2700000>;
256			regulator-max-microvolt = <3544000>;
257			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
258		};
259
260		vreg_l8e: ldo8 {
261			regulator-min-microvolt = <1620000>;
262			regulator-max-microvolt = <2000000>;
263			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
264		};
265
266		vreg_l9e: ldo9 {
267			regulator-min-microvolt = <2700000>;
268			regulator-max-microvolt = <3544000>;
269			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
270		};
271
272		vreg_l10e: ldo10 {
273			regulator-min-microvolt = <3000000>;
274			regulator-max-microvolt = <3401000>;
275			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
276		};
277
278		vreg_l11e: ldo11 {
279			regulator-min-microvolt = <3000000>;
280			regulator-max-microvolt = <3401000>;
281			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
282		};
283
284		vreg_bob: bob {
285			regulator-min-microvolt = <1620000>;
286			regulator-max-microvolt = <5492000>;
287			regulator-initial-mode = <RPMH_REGULATOR_MODE_AUTO>;
288			regulator-allow-bypass;
289		};
290	};
291};
292
293&cdsp {
294	status = "okay";
295	firmware-name = "qcom/sm7225/fairphone4/cdsp.mdt";
296};
297
298&mpss {
299	status = "okay";
300	firmware-name = "qcom/sm7225/fairphone4/modem.mdt";
301};
302
303&pm6350_gpios {
304	gpio_keys_pin: gpio-keys-pin {
305		pins = "gpio2";
306		function = PMIC_GPIO_FUNC_NORMAL;
307		bias-pull-up;
308		input-enable;
309		power-source = <0>;
310	};
311};
312
313&pm6350_resin {
314	status = "okay";
315	linux,code = <KEY_VOLUMEDOWN>;
316};
317
318&qupv3_id_1 {
319	status = "okay";
320};
321
322&tlmm {
323	gpio-reserved-ranges = <13 4>, <56 2>;
324};
325
326&uart2 {
327	status = "okay";
328};
329
330&usb_1 {
331	status = "okay";
332};
333
334&usb_1_dwc3 {
335	maximum-speed = "super-speed";
336	dr_mode = "peripheral";
337};
338
339&usb_1_hsphy {
340	status = "okay";
341
342	vdd-supply = <&vreg_l18a>;
343	vdda-pll-supply = <&vreg_l2a>;
344	vdda-phy-dpdm-supply = <&vreg_l3a>;
345};
346
347&usb_1_qmpphy {
348	status = "okay";
349
350	vdda-phy-supply = <&vreg_l22a>;
351	vdda-pll-supply = <&vreg_l16a>;
352};
353