1// SPDX-License-Identifier: BSD-3-Clause
2/*
3 * Copyright (c) 2021, Luca Weiss <luca@z3ntu.xyz>
4 */
5
6/dts-v1/;
7
8/* PM7250B is configured to use SID2/3 */
9#define PM7250B_SID 2
10#define PM7250B_SID1 3
11
12/* PMK8350 (in reality a PMK8003) is configured to use SID6 instead of 0 */
13#define PMK8350_SID 6
14
15#include <dt-bindings/firmware/qcom,scm.h>
16#include <dt-bindings/gpio/gpio.h>
17#include <dt-bindings/iio/qcom,spmi-adc7-pmk8350.h>
18#include <dt-bindings/input/input.h>
19#include <dt-bindings/leds/common.h>
20#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
21#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
22#include "sm7225.dtsi"
23#include "pm6150l.dtsi"
24#include "pm6350.dtsi"
25#include "pm7250b.dtsi"
26#include "pmk8350.dtsi"
27
28/ {
29	model = "Fairphone 4";
30	compatible = "fairphone,fp4", "qcom,sm7225";
31	chassis-type = "handset";
32
33	/* required for bootloader to select correct board */
34	qcom,msm-id = <434 0x10000>, <459 0x10000>;
35	qcom,board-id = <8 32>;
36
37	aliases {
38		serial0 = &uart9;
39		serial1 = &uart1;
40	};
41
42	chosen {
43		#address-cells = <2>;
44		#size-cells = <2>;
45		ranges;
46
47		stdout-path = "serial0:115200n8";
48
49		framebuffer0: framebuffer@a000000 {
50			compatible = "simple-framebuffer";
51			reg = <0 0xa0000000 0 (2340 * 1080 * 4)>;
52			width = <1080>;
53			height = <2340>;
54			stride = <(1080 * 4)>;
55			format = "a8r8g8b8";
56		};
57	};
58
59	gpio-keys {
60		compatible = "gpio-keys";
61		pinctrl-names = "default";
62		pinctrl-0 = <&gpio_keys_pin>;
63
64		key-volume-up {
65			label = "volume_up";
66			linux,code = <KEY_VOLUMEUP>;
67			gpios = <&pm6350_gpios 2 GPIO_ACTIVE_LOW>;
68		};
69	};
70
71	reserved-memory {
72		/*
73		 * The rmtfs memory region in downstream is 'dynamically allocated'
74		 * but given the same address every time. Hard code it as this address is
75		 * where the modem firmware expects it to be.
76		 */
77		memory@efe01000 {
78			compatible = "qcom,rmtfs-mem";
79			reg = <0 0xefe01000 0 0x600000>;
80			no-map;
81
82			qcom,client-id = <1>;
83			qcom,vmid = <QCOM_SCM_VMID_MSS_MSA>;
84		};
85	};
86
87	thermal-zones {
88		chg-skin-thermal {
89			polling-delay-passive = <0>;
90			polling-delay = <0>;
91			thermal-sensors = <&pm7250b_adc_tm 0>;
92
93			trips {
94				active-config0 {
95					temperature = <125000>;
96					hysteresis = <1000>;
97					type = "passive";
98				};
99			};
100		};
101
102		conn-thermal {
103			polling-delay-passive = <0>;
104			polling-delay = <0>;
105			thermal-sensors = <&pm7250b_adc_tm 1>;
106
107			trips {
108				active-config0 {
109					temperature = <125000>;
110					hysteresis = <1000>;
111					type = "passive";
112				};
113			};
114		};
115	};
116};
117
118&adsp {
119	firmware-name = "qcom/sm7225/fairphone4/adsp.mdt";
120	status = "okay";
121};
122
123&apps_rsc {
124	regulators-0 {
125		compatible = "qcom,pm6350-rpmh-regulators";
126		qcom,pmic-id = "a";
127
128		vreg_s1a: smps1 {
129			regulator-min-microvolt = <1000000>;
130			regulator-max-microvolt = <1200000>;
131		};
132
133		vreg_s2a: smps2 {
134			regulator-min-microvolt = <1503000>;
135			regulator-max-microvolt = <2048000>;
136		};
137
138		vreg_l2a: ldo2 {
139			regulator-min-microvolt = <1503000>;
140			regulator-max-microvolt = <1980000>;
141			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
142		};
143
144		vreg_l3a: ldo3 {
145			regulator-min-microvolt = <2700000>;
146			regulator-max-microvolt = <3300000>;
147			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
148		};
149
150		vreg_l4a: ldo4 {
151			regulator-min-microvolt = <352000>;
152			regulator-max-microvolt = <801000>;
153			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
154		};
155
156		vreg_l5a: ldo5 {
157			regulator-min-microvolt = <1503000>;
158			regulator-max-microvolt = <1980000>;
159			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
160		};
161
162		vreg_l6a: ldo6 {
163			regulator-min-microvolt = <1710000>;
164			regulator-max-microvolt = <3544000>;
165			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
166		};
167
168		vreg_l7a: ldo7 {
169			regulator-min-microvolt = <1620000>;
170			regulator-max-microvolt = <1980000>;
171			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
172		};
173
174		vreg_l8a: ldo8 {
175			regulator-min-microvolt = <2800000>;
176			regulator-max-microvolt = <2800000>;
177			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
178		};
179
180		vreg_l9a: ldo9 {
181			regulator-min-microvolt = <1650000>;
182			regulator-max-microvolt = <3401000>;
183			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
184		};
185
186		vreg_l11a: ldo11 {
187			regulator-min-microvolt = <1800000>;
188			regulator-max-microvolt = <2000000>;
189			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
190		};
191
192		vreg_l12a: ldo12 {
193			regulator-min-microvolt = <1620000>;
194			regulator-max-microvolt = <1980000>;
195			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
196		};
197
198		vreg_l13a: ldo13 {
199			regulator-min-microvolt = <570000>;
200			regulator-max-microvolt = <650000>;
201			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
202		};
203
204		vreg_l14a: ldo14 {
205			regulator-min-microvolt = <1700000>;
206			regulator-max-microvolt = <1900000>;
207			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
208		};
209
210		vreg_l15a: ldo15 {
211			regulator-min-microvolt = <1100000>;
212			regulator-max-microvolt = <1305000>;
213			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
214		};
215
216		vreg_l16a: ldo16 {
217			regulator-min-microvolt = <830000>;
218			regulator-max-microvolt = <921000>;
219			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
220		};
221
222		vreg_l18a: ldo18 {
223			regulator-min-microvolt = <788000>;
224			regulator-max-microvolt = <1049000>;
225			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
226		};
227
228		vreg_l19a: ldo19 {
229			regulator-min-microvolt = <1080000>;
230			regulator-max-microvolt = <1305000>;
231			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
232		};
233
234		vreg_l20a: ldo20 {
235			regulator-min-microvolt = <530000>;
236			regulator-max-microvolt = <801000>;
237			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
238		};
239
240		vreg_l21a: ldo21 {
241			regulator-min-microvolt = <751000>;
242			regulator-max-microvolt = <825000>;
243			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
244		};
245
246		vreg_l22a: ldo22 {
247			regulator-min-microvolt = <1080000>;
248			regulator-max-microvolt = <1305000>;
249			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
250		};
251	};
252
253	regulators-1 {
254		compatible = "qcom,pm6150l-rpmh-regulators";
255		qcom,pmic-id = "e";
256
257		vreg_s8e: smps8 {
258			regulator-min-microvolt = <313000>;
259			regulator-max-microvolt = <1395000>;
260		};
261
262		vreg_l1e: ldo1 {
263			regulator-min-microvolt = <1620000>;
264			regulator-max-microvolt = <1980000>;
265			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
266		};
267
268		vreg_l2e: ldo2 {
269			regulator-min-microvolt = <1170000>;
270			regulator-max-microvolt = <1305000>;
271			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
272		};
273
274		vreg_l3e: ldo3 {
275			regulator-min-microvolt = <1100000>;
276			regulator-max-microvolt = <1299000>;
277			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
278		};
279
280		vreg_l4e: ldo4 {
281			regulator-min-microvolt = <1620000>;
282			regulator-max-microvolt = <3300000>;
283			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
284		};
285
286		vreg_l5e: ldo5 {
287			regulator-min-microvolt = <1620000>;
288			regulator-max-microvolt = <3300000>;
289			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
290		};
291
292		vreg_l6e: ldo6 {
293			regulator-min-microvolt = <1700000>;
294			regulator-max-microvolt = <2950000>;
295			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
296			regulator-allow-set-load;
297			regulator-allowed-modes = <RPMH_REGULATOR_MODE_LPM
298						   RPMH_REGULATOR_MODE_HPM>;
299		};
300
301		vreg_l7e: ldo7 {
302			regulator-min-microvolt = <2700000>;
303			regulator-max-microvolt = <3544000>;
304			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
305		};
306
307		vreg_l8e: ldo8 {
308			regulator-min-microvolt = <1620000>;
309			regulator-max-microvolt = <2000000>;
310			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
311		};
312
313		vreg_l9e: ldo9 {
314			regulator-min-microvolt = <2700000>;
315			regulator-max-microvolt = <2960000>;
316			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
317			regulator-allow-set-load;
318			regulator-allowed-modes = <RPMH_REGULATOR_MODE_LPM
319						   RPMH_REGULATOR_MODE_HPM>;
320		};
321
322		vreg_l10e: ldo10 {
323			regulator-min-microvolt = <3000000>;
324			regulator-max-microvolt = <3401000>;
325			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
326		};
327
328		vreg_l11e: ldo11 {
329			regulator-min-microvolt = <3000000>;
330			regulator-max-microvolt = <3401000>;
331			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
332		};
333
334		vreg_bob: bob {
335			regulator-min-microvolt = <1620000>;
336			regulator-max-microvolt = <5492000>;
337			regulator-initial-mode = <RPMH_REGULATOR_MODE_AUTO>;
338			regulator-allow-bypass;
339		};
340	};
341};
342
343&cci0 {
344	status = "okay";
345};
346
347&cci0_i2c0 {
348	/* IMX582 @ 0x1a */
349};
350
351&cci0_i2c1 {
352	/* IMX582 @ 0x1a */
353};
354
355&cci1 {
356	status = "okay";
357};
358
359&cci1_i2c0 {
360	/* IMX576 @ 0x10 */
361};
362
363&cdsp {
364	firmware-name = "qcom/sm7225/fairphone4/cdsp.mdt";
365	status = "okay";
366};
367
368&gpi_dma0 {
369	status = "okay";
370};
371
372&gpi_dma1 {
373	status = "okay";
374};
375
376&i2c0 {
377	clock-frequency = <400000>;
378	status = "okay";
379
380	/* ST21NFCD NFC @ 8 */
381	/* VL53L3 ToF @ 29 */
382	/* AW88264A amplifier @ 34 */
383	/* AW88264A amplifier @ 35 */
384};
385
386&i2c8 {
387	clock-frequency = <400000>;
388	status = "okay";
389
390	/* HX83112A touchscreen @ 48 */
391};
392
393&i2c10 {
394	/* PM8008 PMIC @ 8 and 9 */
395	/* PX8618 @ 26 */
396	/* SMB1395 PMIC @ 34 */
397	/* awinic,aw8695 @ 5a */
398};
399
400&ipa {
401	qcom,gsi-loader = "self";
402	memory-region = <&pil_ipa_fw_mem>;
403	firmware-name = "qcom/sm7225/fairphone4/ipa_fws.mdt";
404	status = "okay";
405};
406
407&mpss {
408	firmware-name = "qcom/sm7225/fairphone4/modem.mdt";
409	status = "okay";
410};
411
412&pm6150l_flash {
413	status = "okay";
414
415	led-0 {
416		function = LED_FUNCTION_FLASH;
417		color = <LED_COLOR_ID_YELLOW>;
418		led-sources = <1>;
419		led-max-microamp = <180000>;
420		flash-max-microamp = <1000000>;
421		flash-max-timeout-us = <1280000>;
422	};
423
424	led-1 {
425		function = LED_FUNCTION_FLASH;
426		color = <LED_COLOR_ID_WHITE>;
427		led-sources = <2>;
428		led-max-microamp = <180000>;
429		flash-max-microamp = <1000000>;
430		flash-max-timeout-us = <1280000>;
431	};
432};
433
434&pm6150l_wled {
435	qcom,switching-freq = <800>;
436	qcom,current-limit-microamp = <20000>;
437	qcom,num-strings = <2>;
438
439	status = "okay";
440};
441
442&pm6350_gpios {
443	gpio_keys_pin: gpio-keys-state {
444		pins = "gpio2";
445		function = PMIC_GPIO_FUNC_NORMAL;
446		bias-pull-up;
447		input-enable;
448		power-source = <0>;
449	};
450};
451
452&pm6350_resin {
453	linux,code = <KEY_VOLUMEDOWN>;
454	status = "okay";
455};
456
457&pm7250b_adc {
458	channel@4d {
459		reg = <ADC5_AMUX_THM1_100K_PU>;
460		qcom,ratiometric;
461		qcom,hw-settle-time = <200>;
462		qcom,pre-scaling = <1 1>;
463		label = "charger_skin_therm";
464	};
465
466	channel@4f {
467		reg = <ADC5_AMUX_THM3_100K_PU>;
468		qcom,ratiometric;
469		qcom,hw-settle-time = <200>;
470		qcom,pre-scaling = <1 1>;
471		label = "conn_therm";
472	};
473};
474
475&pm7250b_adc_tm {
476	status = "okay";
477
478	charger-skin-therm@0 {
479		reg = <0>;
480		io-channels = <&pm7250b_adc ADC5_AMUX_THM1_100K_PU>;
481		qcom,ratiometric;
482		qcom,hw-settle-time-us = <200>;
483	};
484
485	conn-therm@1 {
486		reg = <1>;
487		io-channels = <&pm7250b_adc ADC5_AMUX_THM3_100K_PU>;
488		qcom,ratiometric;
489		qcom,hw-settle-time-us = <200>;
490	};
491};
492
493&pmk8350_rtc {
494	status = "okay";
495};
496
497&pmk8350_vadc {
498	channel@644 {
499		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
500		qcom,ratiometric;
501		qcom,hw-settle-time = <200>;
502		qcom,pre-scaling = <1 1>;
503		label = "xo_therm";
504	};
505};
506
507&qup_uart1_cts {
508	/*
509	 * Configure a bias-bus-hold on CTS to lower power
510	 * usage when Bluetooth is turned off. Bus hold will
511	 * maintain a low power state regardless of whether
512	 * the Bluetooth module drives the pin in either
513	 * direction or leaves the pin fully unpowered.
514	 */
515	bias-bus-hold;
516};
517
518&qup_uart1_rts {
519	/* We'll drive RTS, so no pull */
520	drive-strength = <2>;
521	bias-disable;
522};
523
524&qup_uart1_rx {
525	/*
526	 * Configure a pull-up on RX. This is needed to avoid
527	 * garbage data when the TX pin of the Bluetooth module is
528	 * in tri-state (module powered off or not driving the
529	 * signal yet).
530	 */
531	bias-pull-up;
532};
533
534&qup_uart1_tx {
535	/* We'll drive TX, so no pull */
536	drive-strength = <2>;
537	bias-disable;
538};
539
540&qupv3_id_0 {
541	status = "okay";
542};
543
544&qupv3_id_1 {
545	status = "okay";
546};
547
548&sdc2_off_state {
549	sd-cd-pins {
550		pins = "gpio94";
551		function = "gpio";
552		drive-strength = <2>;
553		bias-disable;
554	};
555};
556
557&sdc2_on_state {
558	sd-cd-pins {
559		pins = "gpio94";
560		function = "gpio";
561		drive-strength = <2>;
562		bias-pull-up;
563	};
564};
565
566&sdhc_2 {
567	vmmc-supply = <&vreg_l9e>;
568	vqmmc-supply = <&vreg_l6e>;
569
570	cd-gpios = <&tlmm 94 GPIO_ACTIVE_LOW>;
571
572	status = "okay";
573};
574
575&tlmm {
576	gpio-reserved-ranges = <13 4>, <56 2>;
577
578	qup_uart1_sleep_cts: qup-uart1-sleep-cts-state {
579		pins = "gpio61";
580		function = "gpio";
581		/*
582		 * Configure a bias-bus-hold on CTS to lower power
583		 * usage when Bluetooth is turned off. Bus hold will
584		 * maintain a low power state regardless of whether
585		 * the Bluetooth module drives the pin in either
586		 * direction or leaves the pin fully unpowered.
587		 */
588		bias-bus-hold;
589	};
590
591	qup_uart1_sleep_rts: qup-uart1-sleep-rts-state {
592		pins = "gpio62";
593		function = "gpio";
594		/*
595		 * Configure pull-down on RTS. As RTS is active low
596		 * signal, pull it low to indicate the BT SoC that it
597		 * can wakeup the system anytime from suspend state by
598		 * pulling RX low (by sending wakeup bytes).
599		 */
600		bias-pull-down;
601	};
602
603	qup_uart1_sleep_rx: qup-uart1-sleep-rx-state {
604		pins = "gpio64";
605		function = "gpio";
606		/*
607		 * Configure a pull-up on RX. This is needed to avoid
608		 * garbage data when the TX pin of the Bluetooth module
609		 * is floating which may cause spurious wakeups.
610		 */
611		bias-pull-up;
612	};
613
614	qup_uart1_sleep_tx: qup-uart1-sleep-tx-state {
615		pins = "gpio63";
616		function = "gpio";
617		/*
618		 * Configure pull-up on TX when it isn't actively driven
619		 * to prevent BT SoC from receiving garbage during sleep.
620		 */
621		bias-pull-up;
622	};
623};
624
625&uart1 {
626	/delete-property/ interrupts;
627	interrupts-extended = <&intc GIC_SPI 602 IRQ_TYPE_LEVEL_HIGH>,
628			      <&tlmm 64 IRQ_TYPE_EDGE_FALLING>;
629
630	pinctrl-names = "default", "sleep";
631	pinctrl-1 = <&qup_uart1_sleep_cts>, <&qup_uart1_sleep_rts>, <&qup_uart1_sleep_tx>, <&qup_uart1_sleep_rx>;
632
633	status = "okay";
634
635	bluetooth {
636		compatible = "qcom,wcn3988-bt";
637
638		vddio-supply = <&vreg_l11a>;
639		vddxo-supply = <&vreg_l7a>;
640		vddrf-supply = <&vreg_l2e>;
641		vddch0-supply = <&vreg_l10e>;
642		swctrl-gpios = <&tlmm 69 GPIO_ACTIVE_HIGH>;
643
644		max-speed = <3200000>;
645	};
646};
647
648&uart9 {
649	status = "okay";
650};
651
652&ufs_mem_hc {
653	reset-gpios = <&tlmm 156 GPIO_ACTIVE_LOW>;
654
655	vcc-supply = <&vreg_l7e>;
656	vcc-max-microamp = <800000>;
657	vccq2-supply = <&vreg_l12a>;
658	vccq2-max-microamp = <800000>;
659
660	status = "okay";
661};
662
663&ufs_mem_phy {
664	vdda-phy-supply = <&vreg_l18a>;
665	vdda-pll-supply = <&vreg_l22a>;
666
667	status = "okay";
668};
669
670&usb_1 {
671	status = "okay";
672};
673
674&usb_1_dwc3 {
675	maximum-speed = "super-speed";
676	dr_mode = "peripheral";
677};
678
679&usb_1_hsphy {
680	vdd-supply = <&vreg_l18a>;
681	vdda-pll-supply = <&vreg_l2a>;
682	vdda-phy-dpdm-supply = <&vreg_l3a>;
683
684	status = "okay";
685};
686
687&usb_1_qmpphy {
688	vdda-phy-supply = <&vreg_l22a>;
689	vdda-pll-supply = <&vreg_l16a>;
690
691	status = "okay";
692};
693
694&wifi {
695	vdd-0.8-cx-mx-supply = <&vreg_l4a>;
696	vdd-1.8-xo-supply = <&vreg_l7a>;
697	vdd-1.3-rfa-supply = <&vreg_l2e>;
698	vdd-3.3-ch0-supply = <&vreg_l10e>;
699	vdd-3.3-ch1-supply = <&vreg_l11e>;
700
701	status = "okay";
702};
703