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