1// SPDX-License-Identifier: BSD-3-Clause
2/*
3 * Copyright (c) 2021, AngeloGioacchino Del Regno
4 *                     <angelogioacchino.delregno@somainline.org>
5 * Copyright (c) 2021, Konrad Dybcio <konrad.dybcio@somainline.org>
6 */
7
8#include <dt-bindings/input/input.h>
9#include <dt-bindings/leds/common.h>
10#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
11#include "msm8998.dtsi"
12#include "pm8005.dtsi"
13#include "pm8998.dtsi"
14#include "pmi8998.dtsi"
15
16/ {
17	/* required for bootloader to select correct board */
18	qcom,msm-id = <0x124 0x20000>, <0x124 0x20001>; /* 8998v2, v2.1 */
19	qcom,board-id = <8 0>;
20
21	clocks {
22		div1_mclk: divclk1 {
23			compatible = "gpio-gate-clock";
24			pinctrl-0 = <&audio_mclk_pin>;
25			pinctrl-names = "default";
26			clocks = <&rpmcc RPM_SMD_DIV_CLK1>;
27			#clock-cells = <0>;
28			enable-gpios = <&pm8998_gpio 13 GPIO_ACTIVE_HIGH>;
29		};
30	};
31
32	board_vbat: vbat-regulator {
33		compatible = "regulator-fixed";
34		regulator-name = "VBAT";
35
36		regulator-min-microvolt = <4000000>;
37		regulator-max-microvolt = <4000000>;
38		regulator-always-on;
39		regulator-boot-on;
40	};
41
42	cam0_vdig_vreg: cam0-vdig {
43		compatible = "regulator-fixed";
44		regulator-name = "cam0_vdig";
45		startup-delay-us = <0>;
46		enable-active-high;
47		gpio = <&tlmm 21 GPIO_ACTIVE_HIGH>;
48		pinctrl-names = "default";
49		pinctrl-0 = <&cam0_vdig_default>;
50	};
51
52	cam1_vdig_vreg: cam1-vdig {
53		compatible = "regulator-fixed";
54		regulator-name = "cam1_vdig";
55		startup-delay-us = <0>;
56		enable-active-high;
57		gpio = <&tlmm 25 GPIO_ACTIVE_HIGH>;
58		pinctrl-names = "default";
59		pinctrl-0 = <&cam1_vdig_default>;
60		vin-supply = <&vreg_s3a_1p35>;
61	};
62
63	cam_vio_vreg: cam-vio-vreg {
64		compatible = "regulator-fixed";
65		regulator-name = "cam_vio_vreg";
66		startup-delay-us = <0>;
67		enable-active-high;
68		gpio = <&pmi8998_gpio 1 GPIO_ACTIVE_HIGH>;
69		pinctrl-names = "default";
70		pinctrl-0 = <&cam_vio_default>;
71		vin-supply = <&vreg_lvs1a_1p8>;
72	};
73
74	touch_vddio_vreg: touch-vddio-vreg {
75		compatible = "regulator-fixed";
76		regulator-name = "touch_vddio_vreg";
77		startup-delay-us = <10000>;
78		gpio = <&tlmm 133 GPIO_ACTIVE_HIGH>;
79		pinctrl-names = "default";
80		pinctrl-0 = <&ts_vddio_en>;
81	};
82
83	vph_pwr: vph-pwr-regulator {
84		compatible = "regulator-fixed";
85		regulator-name = "vph_pwr";
86		regulator-always-on;
87		regulator-boot-on;
88	};
89
90	extcon_usb: extcon-usb {
91		compatible = "linux,extcon-usb-gpio";
92		id-gpio = <&tlmm 38 GPIO_ACTIVE_HIGH>;
93		vbus-gpio = <&tlmm 128 GPIO_ACTIVE_HIGH>;
94		pinctrl-names = "default";
95		pinctrl-0 = <&usb_extcon_active &usb_vbus_active>;
96	};
97
98	gpio-keys {
99		compatible = "gpio-keys";
100		label = "Side buttons";
101		pinctrl-names = "default";
102		pinctrl-0 = <&vol_down_pin_a>, <&cam_focus_pin_a>,
103			    <&cam_snapshot_pin_a>;
104		button-vol-down {
105			label = "Volume Down";
106			gpios = <&pm8998_gpio 5 GPIO_ACTIVE_LOW>;
107			linux,input-type = <EV_KEY>;
108			linux,code = <KEY_VOLUMEDOWN>;
109			gpio-key,wakeup;
110			debounce-interval = <15>;
111		};
112
113		button-camera-snapshot {
114			label = "Camera Snapshot";
115			gpios = <&pm8998_gpio 7 GPIO_ACTIVE_LOW>;
116			linux,input-type = <EV_KEY>;
117			linux,code = <KEY_CAMERA>;
118			debounce-interval = <15>;
119		};
120
121		button-camera-focus {
122			label = "Camera Focus";
123			gpios = <&pm8998_gpio 8 GPIO_ACTIVE_LOW>;
124			linux,input-type = <EV_KEY>;
125			linux,code = <KEY_CAMERA_FOCUS>;
126			debounce-interval = <15>;
127		};
128	};
129
130	gpio-hall-sensor {
131		compatible = "gpio-keys";
132		label = "Hall sensors";
133		pinctrl-names = "default";
134		pinctrl-0 = <&hall_sensor0_default>;
135
136		event-hall-sensor0 {
137			label = "Cover Hall Sensor";
138			gpios = <&tlmm 124 GPIO_ACTIVE_LOW>;
139			linux,input-type = <EV_SW>;
140			linux,code = <SW_LID>;
141			gpio-key,wakeup;
142			debounce-interval = <30>;
143		};
144	};
145
146	reserved-memory {
147		#address-cells = <2>;
148		#size-cells = <2>;
149		ranges;
150
151		hyp_mem: memory@85800000 {
152			reg = <0x0 0x85800000 0x0 0x3700000>;
153			no-map;
154		};
155
156		cont_splash_mem: memory@9d400000 {
157			reg = <0x0 0x9d400000 0x0 0x2400000>;
158			no-map;
159		};
160
161		zap_shader_region: memory@f6400000 {
162			compatible = "shared-dma-pool";
163			reg = <0x0 0xf6400000 0x0 0x2000>;
164			no-map;
165		};
166
167		adsp_region: memory@fe000000 {
168			reg = <0x0 0xfe000000 0x0 0x800000>;
169			no-map;
170		};
171
172		qseecom_region: memory@fe800000 {
173			reg = <0x0 0xfe800000 0x0 0x1400000>;
174			no-map;
175		};
176
177		ramoops@ffc00000 {
178			compatible = "ramoops";
179			reg = <0x0 0xffc00000 0x0 0x100000>;
180			record-size = <0x10000>;
181			console-size = <0x60000>;
182			ftrace-size = <0x10000>;
183			pmsg-size = <0x20000>;
184			ecc-size = <16>;
185		};
186	};
187
188	vibrator {
189		compatible = "gpio-vibrator";
190		enable-gpios = <&pmi8998_gpio 5 GPIO_ACTIVE_HIGH>;
191		pinctrl-names = "default";
192		pinctrl-0 = <&vib_default>;
193	};
194};
195
196&blsp1_i2c5 {
197	status = "okay";
198	clock-frequency = <355000>;
199
200	touchscreen@2c {
201		compatible = "syna,rmi4-i2c";
202		reg = <0x2c>;
203		#address-cells = <1>;
204		#size-cells = <0>;
205		interrupts-extended = <&tlmm 125 IRQ_TYPE_EDGE_FALLING>;
206
207		pinctrl-names = "default";
208		pinctrl-0 = <&ts_int_n>;
209
210		vdd-supply = <&vreg_l28_3p0>;
211		vio-supply = <&touch_vddio_vreg>;
212
213		syna,reset-delay-ms = <220>;
214		syna,startup-delay-ms = <1000>;
215
216		rmi4-f01@1 {
217			reg = <0x01>;
218			syna,nosleep-mode = <1>;
219		};
220
221		rmi4-f11@11 {
222			reg = <0x11>;
223			syna,sensor-type = <1>;
224		};
225	};
226};
227
228&blsp1_i2c5_sleep {
229	bias-disable;
230};
231
232&blsp1_uart3 {
233	status = "okay";
234
235	bluetooth {
236		compatible = "qcom,wcn3990-bt";
237
238		vddio-supply = <&vreg_s4a_1p8>;
239		vddxo-supply = <&vreg_l7a_1p8>;
240		vddrf-supply = <&vreg_l17a_1p3>;
241		vddch0-supply = <&vreg_l25a_3p3>;
242		max-speed = <3200000>;
243
244		clocks = <&rpmcc RPM_SMD_RF_CLK2_PIN>;
245	};
246};
247
248&blsp2_uart1 {
249	status = "okay";
250};
251
252&blsp2_i2c2 {
253	status = "okay";
254
255	proximity@29 {
256		compatible = "st,vl53l0x";
257		reg = <0x29>;
258
259		interrupt-parent = <&tlmm>;
260		interrupts = <22 IRQ_TYPE_EDGE_FALLING>;
261
262		reset-gpios = <&tlmm 27 GPIO_ACTIVE_LOW>;
263		vdd-supply = <&cam_vio_vreg>;
264
265		pinctrl-names = "default";
266		pinctrl-0 = <&tof_int &tof_reset>;
267	};
268};
269
270&ibb {
271	regulator-min-microamp = <800000>;
272	regulator-max-microamp = <800000>;
273	regulator-enable-ramp-delay = <200>;
274	regulator-over-current-protection;
275	regulator-pull-down;
276	regulator-ramp-delay = <1>;
277	regulator-settling-time-up-us = <600>;
278	regulator-settling-time-down-us = <1000>;
279	regulator-soft-start;
280	qcom,discharge-resistor-kohms = <300>;
281};
282
283&lab {
284	regulator-min-microamp = <200000>;
285	regulator-max-microamp = <200000>;
286	regulator-enable-ramp-delay = <500>;
287	regulator-over-current-protection;
288	regulator-pull-down;
289	regulator-ramp-delay = <1>;
290	regulator-settling-time-up-us = <50000>;
291	regulator-settling-time-down-us = <3000>;
292	regulator-soft-start;
293};
294
295&pm8005_regulators {
296	/* VDD_GFX supply */
297	pm8005_s1: s1 {
298		regulator-min-microvolt = <524000>;
299		regulator-max-microvolt = <1088000>;
300		regulator-enable-ramp-delay = <500>;
301		/* Hack until we rig up the gpu consumer */
302		regulator-always-on;
303	};
304};
305
306&pm8998_gpio {
307	vol_down_pin_a: vol-down-active-state {
308		pins = "gpio5";
309		function = PMIC_GPIO_FUNC_NORMAL;
310		bias-pull-up;
311		input-enable;
312		qcom,drive-strength = <PMIC_GPIO_STRENGTH_NO>;
313	};
314
315	cam_focus_pin_a: cam-focus-btn-active-state {
316		pins = "gpio7";
317		function = PMIC_GPIO_FUNC_NORMAL;
318		bias-pull-up;
319		input-enable;
320		qcom,drive-strength = <PMIC_GPIO_STRENGTH_NO>;
321	};
322
323	cam_snapshot_pin_a: cam-snapshot-btn-active-state {
324		pins = "gpio8";
325		function = PMIC_GPIO_FUNC_NORMAL;
326		bias-pull-up;
327		input-enable;
328		qcom,drive-strength = <PMIC_GPIO_STRENGTH_NO>;
329	};
330
331	audio_mclk_pin: audio-mclk-pin-active-state {
332		pins = "gpio13";
333		function = "func2";
334		power-source = <0>;
335	};
336};
337
338&pmi8998_gpio {
339	cam_vio_default: cam-vio-active-state {
340		pins = "gpio1";
341		function = PMIC_GPIO_FUNC_NORMAL;
342		bias-disable;
343		drive-push-pull;
344		output-low;
345		qcom,drive-strength = <PMIC_GPIO_STRENGTH_HIGH>;
346		power-source = <1>;
347	};
348
349	vib_default: vib-en-state {
350		pins = "gpio5";
351		function = PMIC_GPIO_FUNC_NORMAL;
352		bias-disable;
353		drive-push-pull;
354		output-low;
355		qcom,drive-strength = <PMIC_GPIO_STRENGTH_NO>;
356		power-source = <0>;
357	};
358};
359
360&pm8998_pon {
361	resin {
362		compatible = "qcom,pm8941-resin";
363		interrupts = <GIC_SPI 0x8 1 IRQ_TYPE_EDGE_BOTH>;
364		debounce = <15625>;
365		bias-pull-up;
366		linux,code = <KEY_VOLUMEUP>;
367	};
368};
369
370&qusb2phy {
371	status = "okay";
372
373	vdda-pll-supply = <&vreg_l12a_1p8>;
374	vdda-phy-dpdm-supply = <&vreg_l24a_3p075>;
375};
376
377&rpm_requests {
378	regulators-0 {
379		compatible = "qcom,rpm-pm8998-regulators";
380
381		vdd_s1-supply = <&vph_pwr>;
382		vdd_s2-supply = <&vph_pwr>;
383		vdd_s3-supply = <&vph_pwr>;
384		vdd_s4-supply = <&vph_pwr>;
385		vdd_s5-supply = <&vph_pwr>;
386		vdd_s6-supply = <&vph_pwr>;
387		vdd_s7-supply = <&vph_pwr>;
388		vdd_s8-supply = <&vph_pwr>;
389		vdd_s9-supply = <&vph_pwr>;
390		vdd_s10-supply = <&vph_pwr>;
391		vdd_s11-supply = <&vph_pwr>;
392		vdd_s12-supply = <&vph_pwr>;
393		vdd_s13-supply = <&vph_pwr>;
394		vdd_l1_l27-supply = <&vreg_s7a_1p025>;
395		vdd_l2_l8_l17-supply = <&vreg_s3a_1p35>;
396		vdd_l3_l11-supply = <&vreg_s7a_1p025>;
397		vdd_l4_l5-supply = <&vreg_s7a_1p025>;
398		vdd_l6-supply = <&vreg_s5a_2p04>;
399		vdd_l7_l12_l14_l15-supply = <&vreg_s5a_2p04>;
400		vdd_l9-supply = <&vreg_bob>;
401		vdd_l10_l23_l25-supply = <&vreg_bob>;
402		vdd_l13_l19_l21-supply = <&vreg_bob>;
403		vdd_l16_l28-supply = <&vreg_bob>;
404		vdd_l18_l22-supply = <&vreg_bob>;
405		vdd_l20_l24-supply = <&vreg_bob>;
406		vdd_l26-supply = <&vreg_s3a_1p35>;
407		vdd_lvs1_lvs2-supply = <&vreg_s4a_1p8>;
408
409		vreg_s3a_1p35: s3 {
410			regulator-min-microvolt = <1352000>;
411			regulator-max-microvolt = <1352000>;
412		};
413
414		vreg_s4a_1p8: s4 {
415			regulator-min-microvolt = <1800000>;
416			regulator-max-microvolt = <1800000>;
417			regulator-system-load = <100000>;
418			regulator-allow-set-load;
419		};
420
421		vreg_s5a_2p04: s5 {
422			regulator-min-microvolt = <1904000>;
423			regulator-max-microvolt = <2032000>;
424		};
425
426		vreg_s7a_1p025: s7 {
427			regulator-min-microvolt = <900000>;
428			regulator-max-microvolt = <1028000>;
429		};
430
431		vreg_l1a_0p875: l1 {
432			regulator-min-microvolt = <880000>;
433			regulator-max-microvolt = <880000>;
434			regulator-system-load = <73400>;
435			regulator-allow-set-load;
436		};
437
438		vreg_l2a_1p2: l2 {
439			regulator-min-microvolt = <1200000>;
440			regulator-max-microvolt = <1200000>;
441			regulator-system-load = <12560>;
442			regulator-allow-set-load;
443		};
444
445		vreg_l3a_1p0: l3 {
446			regulator-min-microvolt = <1000000>;
447			regulator-max-microvolt = <1000000>;
448		};
449
450		vreg_l5a_0p8: l5 {
451			regulator-min-microvolt = <800000>;
452			regulator-max-microvolt = <800000>;
453		};
454
455		vreg_l6a_1p8: l6 {
456			regulator-min-microvolt = <1800000>;
457			regulator-max-microvolt = <1800000>;
458		};
459
460		vreg_l7a_1p8: l7 {
461			regulator-min-microvolt = <1800000>;
462			regulator-max-microvolt = <1800000>;
463		};
464
465		vreg_l8a_1p2: l8 {
466			regulator-min-microvolt = <1200000>;
467			regulator-max-microvolt = <1200000>;
468		};
469
470		vreg_l9a_1p8: l9 {
471			regulator-min-microvolt = <1808000>;
472			regulator-max-microvolt = <2960000>;
473		};
474
475		vreg_l10a_1p8: l10 {
476			regulator-min-microvolt = <1808000>;
477			regulator-max-microvolt = <2960000>;
478		};
479
480		vreg_l11a_1p0: l11 {
481			regulator-min-microvolt = <1000000>;
482			regulator-max-microvolt = <1000000>;
483		};
484
485		vreg_l12a_1p8: l12 {
486			regulator-min-microvolt = <1800000>;
487			regulator-max-microvolt = <1800000>;
488		};
489
490		vreg_l13a_2p95: l13 {
491			regulator-min-microvolt = <1808000>;
492			regulator-max-microvolt = <2960000>;
493			regulator-allow-set-load;
494		};
495
496		vreg_l14a_1p85: l14 {
497			regulator-min-microvolt = <1848000>;
498			regulator-max-microvolt = <1856000>;
499			regulator-system-load = <32000>;
500			regulator-allow-set-load;
501		};
502
503		vreg_l15a_1p8: l15 {
504			regulator-min-microvolt = <1800000>;
505			regulator-max-microvolt = <1800000>;
506		};
507
508		vreg_l16a_2p7: l16 {
509			regulator-min-microvolt = <2704000>;
510			regulator-max-microvolt = <2704000>;
511		};
512
513		vreg_l17a_1p3: l17 {
514			regulator-min-microvolt = <1304000>;
515			regulator-max-microvolt = <1304000>;
516		};
517
518		vreg_l18a_2p85: l18 { };
519
520		vreg_l19a_2p7: l19 {
521			regulator-min-microvolt = <2696000>;
522			regulator-max-microvolt = <2704000>;
523		};
524
525		vreg_l20a_2p95: l20 {
526			regulator-min-microvolt = <2960000>;
527			regulator-max-microvolt = <2960000>;
528			regulator-system-load = <10000>;
529			regulator-allow-set-load;
530		};
531
532		vreg_l21a_2p95: l21 {
533			regulator-min-microvolt = <2960000>;
534			regulator-max-microvolt = <2960000>;
535			regulator-system-load = <800000>;
536			regulator-allow-set-load;
537		};
538
539		vreg_l22a_2p85: l22 { };
540
541		vreg_l23a_3p3: l23 {
542			regulator-min-microvolt = <3312000>;
543			regulator-max-microvolt = <3312000>;
544		};
545
546		vreg_l24a_3p075: l24 {
547			regulator-min-microvolt = <3088000>;
548			regulator-max-microvolt = <3088000>;
549		};
550
551		vreg_l25a_3p3: l25 {
552			regulator-min-microvolt = <3104000>;
553			regulator-max-microvolt = <3312000>;
554		};
555
556		vreg_l26a_1p2: l26 {
557			regulator-min-microvolt = <1200000>;
558			regulator-max-microvolt = <1200000>;
559			regulator-allow-set-load;
560		};
561
562		vreg_l28_3p0: l28 {
563			regulator-min-microvolt = <3000000>;
564			regulator-max-microvolt = <3000000>;
565		};
566
567		vreg_lvs1a_1p8: lvs1 { };
568
569		vreg_lvs2a_1p8: lvs2 { };
570	};
571
572	regulators-1 {
573		compatible = "qcom,rpm-pmi8998-regulators";
574
575		vdd_bob-supply = <&vph_pwr>;
576
577		vreg_bob: bob {
578			regulator-min-microvolt = <3312000>;
579			regulator-max-microvolt = <3600000>;
580		};
581	};
582};
583
584&sdhc2 {
585	status = "okay";
586	cd-gpios = <&tlmm 95 GPIO_ACTIVE_HIGH>;
587
588	vmmc-supply = <&vreg_l21a_2p95>;
589	vqmmc-supply = <&vreg_l13a_2p95>;
590
591	pinctrl-names = "default", "sleep";
592	pinctrl-0 = <&sdc2_on &sdc2_cd>;
593	pinctrl-1 = <&sdc2_off &sdc2_cd>;
594};
595
596&tlmm {
597	gpio-reserved-ranges = <0 4>, <81 4>;
598
599	mdp_vsync_n: mdp-vsync-n-state {
600		pins = "gpio10";
601		function = "mdp_vsync_a";
602		drive-strength = <2>;
603		bias-pull-down;
604	};
605
606	nfc_ven: nfc-ven-state {
607		pins = "gpio12";
608		function = "gpio";
609		bias-disable;
610		drive-strength = <2>;
611		output-low;
612	};
613
614	msm_mclk0_default: msm-mclk0-active-state {
615		pins = "gpio13";
616		function = "cam_mclk";
617		drive-strength = <2>;
618		bias-disable;
619	};
620
621	msm_mclk1_default: msm-mclk1-active-state {
622		pins = "gpio14";
623		function = "cam_mclk";
624		drive-strength = <2>;
625		bias-disable;
626	};
627
628	cci0_default: cci0-default-state {
629		pins = "gpio18", "gpio19";
630		function = "cci_i2c";
631		bias-disable;
632		drive-strength = <2>;
633	};
634
635	cci1_default: cci1-default-state {
636		pins = "gpio19", "gpio20";
637		function = "cci_i2c";
638		bias-disable;
639		drive-strength = <2>;
640	};
641
642	cam0_vdig_default: cam0-vdig-default-state {
643		pins = "gpio21";
644		function = "gpio";
645		bias-disable;
646		drive-strength = <2>;
647	};
648
649	tof_int: tof-int-state {
650		pins = "gpio22";
651		function = "gpio";
652		bias-pull-up;
653		drive-strength = <2>;
654		input-enable;
655	};
656
657	cam1_vdig_default: cam1-vdig-default-state {
658		pins = "gpio25";
659		function = "gpio";
660		bias-disable;
661		drive-strength = <2>;
662	};
663
664	usb_extcon_active: usb-extcon-active-state {
665		pins = "gpio38";
666		function = "gpio";
667		bias-disable;
668		drive-strength = <16>;
669	};
670
671	tof_reset: tof-reset-state {
672		pins = "gpio27";
673		function = "gpio";
674		bias-disable;
675		drive-strength = <2>;
676	};
677
678	hall_sensor0_default: acc-cover-open-state {
679		pins = "gpio124";
680		function = "gpio";
681		bias-disable;
682		drive-strength = <2>;
683		input-enable;
684	};
685
686	ts_int_n: ts-int-n-state {
687		pins = "gpio125";
688		function = "gpio";
689		drive-strength = <8>;
690		bias-pull-up;
691	};
692
693	usb_vbus_active: usb-vbus-active-state {
694		pins = "gpio128";
695		function = "gpio";
696		bias-disable;
697		drive-strength = <2>;
698		output-low;
699	};
700
701	ts_vddio_en: ts-vddio-en-default-state {
702		pins = "gpio133";
703		function = "gpio";
704		bias-disable;
705		drive-strength = <2>;
706		output-low;
707	};
708};
709
710/*
711 * WARNING:
712 * Disable UFS until card quirks are in to avoid unrecoverable hard-brick
713 * that would happen as soon as the UFS card gets probed as, without the
714 * required quirks, the bootloader will be erased right after card probe.
715 */
716&ufshc {
717	status = "disabled";
718};
719
720&ufsphy {
721	status = "disabled";
722};
723
724&usb3 {
725	status = "okay";
726};
727
728&usb3_dwc3 {
729	/* Force to peripheral until we have Type-C hooked up */
730	dr_mode = "peripheral";
731	extcon = <&extcon_usb>;
732};
733
734&usb3phy {
735	status = "okay";
736
737	vdda-phy-supply = <&vreg_l1a_0p875>;
738	vdda-pll-supply = <&vreg_l2a_1p2>;
739};
740