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 "pm6150l.dtsi"
14#include "pm6350.dtsi"
15#include "pm7250b.dtsi"
16
17/ {
18	model = "Fairphone 4";
19	compatible = "fairphone,fp4", "qcom,sm7225";
20	chassis-type = "handset";
21
22	/* required for bootloader to select correct board */
23	qcom,msm-id = <434 0x10000>, <459 0x10000>;
24	qcom,board-id = <8 32>;
25
26	aliases {
27		serial0 = &uart9;
28	};
29
30	chosen {
31		#address-cells = <2>;
32		#size-cells = <2>;
33		ranges;
34
35		stdout-path = "serial0:115200n8";
36
37		framebuffer0: framebuffer@a000000 {
38			compatible = "simple-framebuffer";
39			reg = <0 0xa0000000 0 (2340 * 1080 * 4)>;
40			width = <1080>;
41			height = <2340>;
42			stride = <(1080 * 4)>;
43			format = "a8r8g8b8";
44		};
45	};
46
47	gpio-keys {
48		compatible = "gpio-keys";
49		pinctrl-names = "default";
50		pinctrl-0 = <&gpio_keys_pin>;
51
52		key-volume-up {
53			label = "volume_up";
54			linux,code = <KEY_VOLUMEUP>;
55			gpios = <&pm6350_gpios 2 GPIO_ACTIVE_LOW>;
56		};
57	};
58
59	reserved-memory {
60		/*
61		 * The rmtfs memory region in downstream is 'dynamically allocated'
62		 * but given the same address every time. Hard code it as this address is
63		 * where the modem firmware expects it to be.
64		 */
65		memory@efe01000 {
66			compatible = "qcom,rmtfs-mem";
67			reg = <0 0xefe01000 0 0x600000>;
68			no-map;
69
70			qcom,client-id = <1>;
71			qcom,vmid = <15>;
72		};
73	};
74
75	thermal-zones {
76		chg-skin-thermal {
77			polling-delay-passive = <0>;
78			polling-delay = <0>;
79			thermal-sensors = <&pm7250b_adc_tm 0>;
80
81			trips {
82				active-config0 {
83					temperature = <125000>;
84					hysteresis = <1000>;
85					type = "passive";
86				};
87			};
88		};
89
90		conn-thermal {
91			polling-delay-passive = <0>;
92			polling-delay = <0>;
93			thermal-sensors = <&pm7250b_adc_tm 1>;
94
95			trips {
96				active-config0 {
97					temperature = <125000>;
98					hysteresis = <1000>;
99					type = "passive";
100				};
101			};
102		};
103	};
104};
105
106&adsp {
107	status = "okay";
108	firmware-name = "qcom/sm7225/fairphone4/adsp.mdt";
109};
110
111&apps_rsc {
112	pm6350-rpmh-regulators {
113		compatible = "qcom,pm6350-rpmh-regulators";
114		qcom,pmic-id = "a";
115
116		vreg_s1a: smps1 {
117			regulator-min-microvolt = <1000000>;
118			regulator-max-microvolt = <1200000>;
119		};
120
121		vreg_s2a: smps2 {
122			regulator-min-microvolt = <1503000>;
123			regulator-max-microvolt = <2048000>;
124		};
125
126		vreg_l2a: ldo2 {
127			regulator-min-microvolt = <1503000>;
128			regulator-max-microvolt = <1980000>;
129			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
130		};
131
132		vreg_l3a: ldo3 {
133			regulator-min-microvolt = <2700000>;
134			regulator-max-microvolt = <3300000>;
135			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
136		};
137
138		vreg_l4a: ldo4 {
139			regulator-min-microvolt = <352000>;
140			regulator-max-microvolt = <801000>;
141			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
142		};
143
144		vreg_l5a: ldo5 {
145			regulator-min-microvolt = <1503000>;
146			regulator-max-microvolt = <1980000>;
147			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
148		};
149
150		vreg_l6a: ldo6 {
151			regulator-min-microvolt = <1710000>;
152			regulator-max-microvolt = <3544000>;
153			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
154		};
155
156		vreg_l7a: ldo7 {
157			regulator-min-microvolt = <1620000>;
158			regulator-max-microvolt = <1980000>;
159			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
160		};
161
162		vreg_l8a: ldo8 {
163			regulator-min-microvolt = <2800000>;
164			regulator-max-microvolt = <2800000>;
165			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
166		};
167
168		vreg_l9a: ldo9 {
169			regulator-min-microvolt = <1650000>;
170			regulator-max-microvolt = <3401000>;
171			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
172		};
173
174		vreg_l11a: ldo11 {
175			regulator-min-microvolt = <1800000>;
176			regulator-max-microvolt = <2000000>;
177			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
178		};
179
180		vreg_l12a: ldo12 {
181			regulator-min-microvolt = <1620000>;
182			regulator-max-microvolt = <1980000>;
183			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
184		};
185
186		vreg_l13a: ldo13 {
187			regulator-min-microvolt = <570000>;
188			regulator-max-microvolt = <650000>;
189			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
190		};
191
192		vreg_l14a: ldo14 {
193			regulator-min-microvolt = <1700000>;
194			regulator-max-microvolt = <1900000>;
195			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
196		};
197
198		vreg_l15a: ldo15 {
199			regulator-min-microvolt = <1100000>;
200			regulator-max-microvolt = <1305000>;
201			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
202		};
203
204		vreg_l16a: ldo16 {
205			regulator-min-microvolt = <830000>;
206			regulator-max-microvolt = <921000>;
207			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
208		};
209
210		vreg_l18a: ldo18 {
211			regulator-min-microvolt = <788000>;
212			regulator-max-microvolt = <1049000>;
213			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
214		};
215
216		vreg_l19a: ldo19 {
217			regulator-min-microvolt = <1080000>;
218			regulator-max-microvolt = <1305000>;
219			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
220		};
221
222		vreg_l20a: ldo20 {
223			regulator-min-microvolt = <530000>;
224			regulator-max-microvolt = <801000>;
225			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
226		};
227
228		vreg_l21a: ldo21 {
229			regulator-min-microvolt = <751000>;
230			regulator-max-microvolt = <825000>;
231			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
232		};
233
234		vreg_l22a: ldo22 {
235			regulator-min-microvolt = <1080000>;
236			regulator-max-microvolt = <1305000>;
237			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
238		};
239	};
240
241	pm6150l-rpmh-regulators {
242		compatible = "qcom,pm6150l-rpmh-regulators";
243		qcom,pmic-id = "e";
244
245		vreg_s8e: smps8 {
246			regulator-min-microvolt = <313000>;
247			regulator-max-microvolt = <1395000>;
248		};
249
250		vreg_l1e: ldo1 {
251			regulator-min-microvolt = <1620000>;
252			regulator-max-microvolt = <1980000>;
253			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
254		};
255
256		vreg_l2e: ldo2 {
257			regulator-min-microvolt = <1170000>;
258			regulator-max-microvolt = <1305000>;
259			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
260		};
261
262		vreg_l3e: ldo3 {
263			regulator-min-microvolt = <1100000>;
264			regulator-max-microvolt = <1299000>;
265			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
266		};
267
268		vreg_l4e: ldo4 {
269			regulator-min-microvolt = <1620000>;
270			regulator-max-microvolt = <3300000>;
271			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
272		};
273
274		vreg_l5e: ldo5 {
275			regulator-min-microvolt = <1620000>;
276			regulator-max-microvolt = <3300000>;
277			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
278		};
279
280		vreg_l6e: ldo6 {
281			regulator-min-microvolt = <1700000>;
282			regulator-max-microvolt = <2950000>;
283			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
284			regulator-allow-set-load;
285			regulator-allowed-modes = <RPMH_REGULATOR_MODE_LPM
286						   RPMH_REGULATOR_MODE_HPM>;
287		};
288
289		vreg_l7e: ldo7 {
290			regulator-min-microvolt = <2700000>;
291			regulator-max-microvolt = <3544000>;
292			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
293		};
294
295		vreg_l8e: ldo8 {
296			regulator-min-microvolt = <1620000>;
297			regulator-max-microvolt = <2000000>;
298			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
299		};
300
301		vreg_l9e: ldo9 {
302			regulator-min-microvolt = <2700000>;
303			regulator-max-microvolt = <2960000>;
304			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
305			regulator-allow-set-load;
306			regulator-allowed-modes = <RPMH_REGULATOR_MODE_LPM
307						   RPMH_REGULATOR_MODE_HPM>;
308		};
309
310		vreg_l10e: ldo10 {
311			regulator-min-microvolt = <3000000>;
312			regulator-max-microvolt = <3401000>;
313			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
314		};
315
316		vreg_l11e: ldo11 {
317			regulator-min-microvolt = <3000000>;
318			regulator-max-microvolt = <3401000>;
319			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
320		};
321
322		vreg_bob: bob {
323			regulator-min-microvolt = <1620000>;
324			regulator-max-microvolt = <5492000>;
325			regulator-initial-mode = <RPMH_REGULATOR_MODE_AUTO>;
326			regulator-allow-bypass;
327		};
328	};
329};
330
331&cdsp {
332	status = "okay";
333	firmware-name = "qcom/sm7225/fairphone4/cdsp.mdt";
334};
335
336&i2c10 {
337	status = "okay";
338	clock-frequency = <400000>;
339
340	haptics@5a {
341		compatible = "awinic,aw8695";
342		reg = <0x5a>;
343		interrupts-extended = <&tlmm 85 IRQ_TYPE_EDGE_FALLING>;
344		reset-gpios = <&tlmm 90 GPIO_ACTIVE_HIGH>;
345
346		awinic,f0-preset = <2350>;
347		awinic,f0-coefficient = <260>;
348		awinic,f0-calibration-percent = <7>;
349		awinic,drive-level = <125>;
350
351		awinic,f0-detection-play-time = <5>;
352		awinic,f0-detection-wait-time = <3>;
353		awinic,f0-detection-repeat = <2>;
354		awinic,f0-detection-trace = <15>;
355
356		awinic,boost-debug = /bits/ 8 <0x30 0xeb 0xd4>;
357		awinic,tset = /bits/ 8 <0x12>;
358		awinic,r-spare = /bits/ 8 <0x68>;
359
360		awinic,bemf-upper-threshold = <4104>;
361		awinic,bemf-lower-threshold = <1016>;
362	};
363};
364
365&mpss {
366	status = "okay";
367	firmware-name = "qcom/sm7225/fairphone4/modem.mdt";
368};
369
370&pm6150l_wled {
371	status = "okay";
372
373	qcom,switching-freq = <800>;
374	qcom,current-limit-microamp = <20000>;
375	qcom,num-strings = <2>;
376};
377
378&pm6350_gpios {
379	gpio_keys_pin: gpio-keys-state {
380		pins = "gpio2";
381		function = PMIC_GPIO_FUNC_NORMAL;
382		bias-pull-up;
383		input-enable;
384		power-source = <0>;
385	};
386};
387
388&pm6350_resin {
389	status = "okay";
390	linux,code = <KEY_VOLUMEDOWN>;
391};
392
393&pm7250b_adc {
394	adc-chan@4d {
395		reg = <ADC5_AMUX_THM1_100K_PU>;
396		qcom,ratiometric;
397		qcom,hw-settle-time = <200>;
398		qcom,pre-scaling = <1 1>;
399		label = "charger_skin_therm";
400	};
401
402	adc-chan@4f {
403		reg = <ADC5_AMUX_THM3_100K_PU>;
404		qcom,ratiometric;
405		qcom,hw-settle-time = <200>;
406		qcom,pre-scaling = <1 1>;
407		label = "conn_therm";
408	};
409};
410
411&pm7250b_adc_tm {
412	status = "okay";
413
414	charger-skin-therm@0 {
415		reg = <0>;
416		io-channels = <&pm7250b_adc ADC5_AMUX_THM1_100K_PU>;
417		qcom,ratiometric;
418		qcom,hw-settle-time-us = <200>;
419	};
420
421	conn-therm@1 {
422		reg = <1>;
423		io-channels = <&pm7250b_adc ADC5_AMUX_THM3_100K_PU>;
424		qcom,ratiometric;
425		qcom,hw-settle-time-us = <200>;
426	};
427};
428
429&qupv3_id_1 {
430	status = "okay";
431};
432
433&sdc2_off_state {
434	sd-cd-pins {
435		pins = "gpio94";
436		function = "gpio";
437		drive-strength = <2>;
438		bias-disable;
439	};
440};
441
442&sdc2_on_state {
443	sd-cd-pins {
444		pins = "gpio94";
445		function = "gpio";
446		drive-strength = <2>;
447		bias-pull-up;
448	};
449};
450
451&sdhc_2 {
452	vmmc-supply = <&vreg_l9e>;
453	vqmmc-supply = <&vreg_l6e>;
454
455	cd-gpios = <&tlmm 94 GPIO_ACTIVE_LOW>;
456
457	status = "okay";
458};
459
460&tlmm {
461	gpio-reserved-ranges = <13 4>, <56 2>;
462};
463
464&uart9 {
465	status = "okay";
466};
467
468&ufs_mem_hc {
469	status = "okay";
470
471	reset-gpios = <&tlmm 156 GPIO_ACTIVE_LOW>;
472
473	vcc-supply = <&vreg_l7e>;
474	vcc-max-microamp = <800000>;
475	vccq2-supply = <&vreg_l12a>;
476	vccq2-max-microamp = <800000>;
477};
478
479&ufs_mem_phy {
480	status = "okay";
481
482	vdda-phy-supply = <&vreg_l18a>;
483	vdda-pll-supply = <&vreg_l22a>;
484};
485
486&usb_1 {
487	status = "okay";
488};
489
490&usb_1_dwc3 {
491	maximum-speed = "super-speed";
492	dr_mode = "peripheral";
493};
494
495&usb_1_hsphy {
496	status = "okay";
497
498	vdd-supply = <&vreg_l18a>;
499	vdda-pll-supply = <&vreg_l2a>;
500	vdda-phy-dpdm-supply = <&vreg_l3a>;
501};
502
503&usb_1_qmpphy {
504	status = "okay";
505
506	vdda-phy-supply = <&vreg_l22a>;
507	vdda-pll-supply = <&vreg_l16a>;
508};
509
510&wifi {
511	status = "okay";
512
513	vdd-0.8-cx-mx-supply = <&vreg_l4a>;
514	vdd-1.8-xo-supply = <&vreg_l7a>;
515	vdd-1.3-rfa-supply = <&vreg_l2e>;
516	vdd-3.3-ch0-supply = <&vreg_l10e>;
517	vdd-3.3-ch1-supply = <&vreg_l11e>;
518};
519