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	pm8998-regulators {
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		vreg_s4a_1p8: s4 {
414			regulator-min-microvolt = <1800000>;
415			regulator-max-microvolt = <1800000>;
416			regulator-system-load = <100000>;
417			regulator-allow-set-load;
418		};
419		vreg_s5a_2p04: s5 {
420			regulator-min-microvolt = <1904000>;
421			regulator-max-microvolt = <2032000>;
422		};
423		vreg_s7a_1p025: s7 {
424			regulator-min-microvolt = <900000>;
425			regulator-max-microvolt = <1028000>;
426		};
427		vreg_l1a_0p875: l1 {
428			regulator-min-microvolt = <880000>;
429			regulator-max-microvolt = <880000>;
430			regulator-system-load = <73400>;
431			regulator-allow-set-load;
432		};
433		vreg_l2a_1p2: l2 {
434			regulator-min-microvolt = <1200000>;
435			regulator-max-microvolt = <1200000>;
436			regulator-system-load = <12560>;
437			regulator-allow-set-load;
438		};
439		vreg_l3a_1p0: l3 {
440			regulator-min-microvolt = <1000000>;
441			regulator-max-microvolt = <1000000>;
442		};
443		vreg_l5a_0p8: l5 {
444			regulator-min-microvolt = <800000>;
445			regulator-max-microvolt = <800000>;
446		};
447		vreg_l6a_1p8: l6 {
448			regulator-min-microvolt = <1800000>;
449			regulator-max-microvolt = <1800000>;
450		};
451		vreg_l7a_1p8: l7 {
452			regulator-min-microvolt = <1800000>;
453			regulator-max-microvolt = <1800000>;
454		};
455		vreg_l8a_1p2: l8 {
456			regulator-min-microvolt = <1200000>;
457			regulator-max-microvolt = <1200000>;
458		};
459		vreg_l9a_1p8: l9 {
460			regulator-min-microvolt = <1808000>;
461			regulator-max-microvolt = <2960000>;
462		};
463		vreg_l10a_1p8: l10 {
464			regulator-min-microvolt = <1808000>;
465			regulator-max-microvolt = <2960000>;
466		};
467		vreg_l11a_1p0: l11 {
468			regulator-min-microvolt = <1000000>;
469			regulator-max-microvolt = <1000000>;
470		};
471		vreg_l12a_1p8: l12 {
472			regulator-min-microvolt = <1800000>;
473			regulator-max-microvolt = <1800000>;
474		};
475		vreg_l13a_2p95: l13 {
476			regulator-min-microvolt = <1808000>;
477			regulator-max-microvolt = <2960000>;
478			regulator-allow-set-load;
479		};
480		vreg_l14a_1p85: l14 {
481			regulator-min-microvolt = <1848000>;
482			regulator-max-microvolt = <1856000>;
483			regulator-system-load = <32000>;
484			regulator-allow-set-load;
485		};
486		vreg_l15a_1p8: l15 {
487			regulator-min-microvolt = <1800000>;
488			regulator-max-microvolt = <1800000>;
489		};
490		vreg_l16a_2p7: l16 {
491			regulator-min-microvolt = <2704000>;
492			regulator-max-microvolt = <2704000>;
493		};
494		vreg_l17a_1p3: l17 {
495			regulator-min-microvolt = <1304000>;
496			regulator-max-microvolt = <1304000>;
497		};
498		vreg_l18a_2p85: l18 {};
499		vreg_l19a_2p7: l19 {
500			regulator-min-microvolt = <2696000>;
501			regulator-max-microvolt = <2704000>;
502		};
503		vreg_l20a_2p95: l20 {
504			regulator-min-microvolt = <2960000>;
505			regulator-max-microvolt = <2960000>;
506			regulator-system-load = <10000>;
507			regulator-allow-set-load;
508		};
509		vreg_l21a_2p95: l21 {
510			regulator-min-microvolt = <2960000>;
511			regulator-max-microvolt = <2960000>;
512			regulator-system-load = <800000>;
513			regulator-allow-set-load;
514		};
515		vreg_l22a_2p85: l22 { };
516		vreg_l23a_3p3: l23 {
517			regulator-min-microvolt = <3312000>;
518			regulator-max-microvolt = <3312000>;
519		};
520		vreg_l24a_3p075: l24 {
521			regulator-min-microvolt = <3088000>;
522			regulator-max-microvolt = <3088000>;
523		};
524		vreg_l25a_3p3: l25 {
525			regulator-min-microvolt = <3104000>;
526			regulator-max-microvolt = <3312000>;
527		};
528		vreg_l26a_1p2: l26 {
529			regulator-min-microvolt = <1200000>;
530			regulator-max-microvolt = <1200000>;
531			regulator-allow-set-load;
532		};
533		vreg_l28_3p0: l28 {
534			regulator-min-microvolt = <3000000>;
535			regulator-max-microvolt = <3000000>;
536		};
537		vreg_lvs1a_1p8: lvs1 { };
538		vreg_lvs2a_1p8: lvs2 { };
539	};
540
541	pmi8998-regulators {
542		compatible = "qcom,rpm-pmi8998-regulators";
543
544		vdd_bob-supply = <&vph_pwr>;
545
546		vreg_bob: bob {
547			regulator-min-microvolt = <3312000>;
548			regulator-max-microvolt = <3600000>;
549		};
550	};
551};
552
553&sdhc2 {
554	status = "okay";
555	cd-gpios = <&tlmm 95 GPIO_ACTIVE_HIGH>;
556
557	vmmc-supply = <&vreg_l21a_2p95>;
558	vqmmc-supply = <&vreg_l13a_2p95>;
559
560	pinctrl-names = "default", "sleep";
561	pinctrl-0 = <&sdc2_on &sdc2_cd>;
562	pinctrl-1 = <&sdc2_off &sdc2_cd>;
563};
564
565&tlmm {
566	gpio-reserved-ranges = <0 4>, <81 4>;
567
568	mdp_vsync_n: mdp-vsync-n {
569		pins = "gpio10";
570		function = "mdp_vsync_a";
571		drive-strength = <2>;
572		bias-pull-down;
573	};
574
575	nfc_ven: nfc-ven {
576		pins = "gpio12";
577		function = "gpio";
578		bias-disable;
579		drive-strength = <2>;
580		output-low;
581	};
582
583	msm_mclk0_default: msm-mclk0-active {
584		pins = "gpio13";
585		function = "cam_mclk";
586		drive-strength = <2>;
587		bias-disable;
588	};
589
590	msm_mclk1_default: msm-mclk1-active {
591		pins = "gpio14";
592		function = "cam_mclk";
593		drive-strength = <2>;
594		bias-disable;
595	};
596
597	cci0_default: cci0-default {
598		pins = "gpio18", "gpio19";
599		function = "cci_i2c";
600		bias-disable;
601		drive-strength = <2>;
602	};
603
604	cci1_default: cci1-default {
605		pins = "gpio19", "gpio20";
606		function = "cci_i2c";
607		bias-disable;
608		drive-strength = <2>;
609	};
610
611	cam0_vdig_default: cam0-vdig-default {
612		pins = "gpio21";
613		function = "gpio";
614		bias-disable;
615		drive-strength = <2>;
616	};
617
618	tof_int: tof-int {
619		pins = "gpio22";
620		function = "gpio";
621		bias-pull-up;
622		drive-strength = <2>;
623		input-enable;
624	};
625
626	cam1_vdig_default: cam1-vdig-default {
627		pins = "gpio25";
628		function = "gpio";
629		bias-disable;
630		drive-strength = <2>;
631	};
632
633	usb_extcon_active: usb-extcon-active {
634		pins = "gpio38";
635		function = "gpio";
636		bias-disable;
637		drive-strength = <16>;
638	};
639
640	tof_reset: tof-reset {
641		pins = "gpio27";
642		function = "gpio";
643		bias-disable;
644		drive-strength = <2>;
645	};
646
647	hall_sensor0_default: acc-cover-open {
648		pins = "gpio124";
649		function = "gpio";
650		bias-disable;
651		drive-strength = <2>;
652		input-enable;
653	};
654
655	ts_int_n: ts-int-n {
656		pins = "gpio125";
657		function = "gpio";
658		drive-strength = <8>;
659		bias-pull-up;
660	};
661
662	usb_vbus_active: usb-vbus-active {
663		pins = "gpio128";
664		function = "gpio";
665		bias-disable;
666		drive-strength = <2>;
667		output-low;
668	};
669
670	ts_vddio_en: ts-vddio-en-default {
671		pins = "gpio133";
672		function = "gpio";
673		bias-disable;
674		drive-strength = <2>;
675		output-low;
676	};
677};
678
679/*
680 * WARNING:
681 * Disable UFS until card quirks are in to avoid unrecoverable hard-brick
682 * that would happen as soon as the UFS card gets probed as, without the
683 * required quirks, the bootloader will be erased right after card probe.
684 */
685&ufshc {
686	status = "disabled";
687};
688
689&ufsphy {
690	status = "disabled";
691};
692
693&usb3 {
694	status = "okay";
695};
696
697&usb3_dwc3 {
698	/* Force to peripheral until we have Type-C hooked up */
699	dr_mode = "peripheral";
700	extcon = <&extcon_usb>;
701};
702
703&usb3phy {
704	status = "okay";
705
706	vdda-phy-supply = <&vreg_l1a_0p875>;
707	vdda-pll-supply = <&vreg_l2a_1p2>;
708};
709