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