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