1// SPDX-License-Identifier: BSD-3-Clause
2/*
3 * Copyright (c) 2021, Konrad Dybcio <konrad.dybcio@somainline.org>
4 */
5
6#include <dt-bindings/input/input.h>
7#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
8#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
9#include "sdm845.dtsi"
10#include "pm8005.dtsi"
11#include "pm8998.dtsi"
12#include "pmi8998.dtsi"
13
14/ {
15	qcom,msm-id = <321 0x20001>; /* SDM845 v2.1 */
16	qcom,board-id = <8 0>;
17
18	aliases {
19		serial0 = &uart6;
20		serial1 = &uart9;
21	};
22
23	chosen {
24		stdout-path = "serial0:115200n8";
25	};
26
27	gpio-keys {
28		compatible = "gpio-keys";
29
30		pinctrl-0 = <&focus_n &snapshot_n &vol_down_n &vol_up_n>;
31		pinctrl-names = "default";
32
33		key-camera-focus {
34			label = "Camera Focus";
35			gpios = <&pm8998_gpios 2 GPIO_ACTIVE_LOW>;
36			linux,code = <KEY_CAMERA_FOCUS>;
37			debounce-interval = <15>;
38			linux,can-disable;
39			wakeup-source;
40		};
41
42		key-camera-snapshot {
43			label = "Camera Snapshot";
44			gpios = <&pm8998_gpios 7 GPIO_ACTIVE_LOW>;
45			linux,code = <KEY_CAMERA>;
46			debounce-interval = <15>;
47			linux,can-disable;
48			wakeup-source;
49		};
50
51		key-volume-down {
52			label = "Volume Down";
53			gpios = <&pm8998_gpios 5 GPIO_ACTIVE_LOW>;
54			linux,code = <KEY_VOLUMEDOWN>;
55			debounce-interval = <15>;
56			linux,can-disable;
57			wakeup-source;
58		};
59
60		key-volume-up {
61			label = "Volume Up";
62			gpios = <&pm8998_gpios 6 GPIO_ACTIVE_LOW>;
63			linux,code = <KEY_VOLUMEUP>;
64			debounce-interval = <15>;
65			linux,can-disable;
66			wakeup-source;
67		};
68	};
69
70	vph_pwr: vph-pwr-regulator {
71		compatible = "regulator-fixed";
72		regulator-name = "vph_pwr";
73		regulator-min-microvolt = <3700000>;
74		regulator-max-microvolt = <3700000>;
75	};
76
77	vreg_s4a_1p8: pm8998-smps4 {
78		compatible = "regulator-fixed";
79		regulator-name = "vreg_s4a_1p8";
80
81		regulator-min-microvolt = <1800000>;
82		regulator-max-microvolt = <1800000>;
83
84		regulator-always-on;
85		regulator-boot-on;
86
87		vin-supply = <&vph_pwr>;
88	};
89
90	reserved-memory {
91		/* SONY was cool and didn't diverge from MTP this time, yay! */
92		cont_splash_mem: memory@9d400000 {
93			reg = <0x0 0x9d400000 0x0 0x2400000>;
94			no-map;
95		};
96
97		ramoops@ffc00000 {
98			compatible = "ramoops";
99			reg = <0x0 0xffc00000 0x0 0x100000>;
100			record-size = <0x10000>;
101			console-size = <0x60000>;
102			ftrace-size = <0x10000>;
103			pmsg-size = <0x20000>;
104			ecc-size = <16>;
105			no-map;
106		};
107	};
108};
109
110&adsp_pas {
111	firmware-name = "qcom/sdm845/Sony/tama/adsp.mbn";
112	status = "okay";
113};
114
115&apps_rsc {
116	regulators-0 {
117		compatible = "qcom,pm8998-rpmh-regulators";
118		qcom,pmic-id = "a";
119
120		vdd-s1-supply = <&vph_pwr>;
121		vdd-s2-supply = <&vph_pwr>;
122		vdd-s3-supply = <&vph_pwr>;
123		vdd-s4-supply = <&vph_pwr>;
124		vdd-s5-supply = <&vph_pwr>;
125		vdd-s6-supply = <&vph_pwr>;
126		vdd-s7-supply = <&vph_pwr>;
127		vdd-s8-supply = <&vph_pwr>;
128		vdd-s9-supply = <&vph_pwr>;
129		vdd-s10-supply = <&vph_pwr>;
130		vdd-s11-supply = <&vph_pwr>;
131		vdd-s12-supply = <&vph_pwr>;
132		vdd-s13-supply = <&vph_pwr>;
133		vdd-l1-l27-supply = <&vreg_s7a_0p9>;
134		vdd-l2-l8-l17-supply = <&vreg_s3a_1p3>;
135		vdd-l3-l11-supply = <&vreg_s7a_0p9>;
136		vdd-l4-l5-supply = <&vreg_s7a_0p9>;
137		vdd-l6-supply = <&vph_pwr>;
138		vdd-l7-l12-l14-l15-supply = <&vreg_s5a_1p9>;
139		vdd-l9-supply = <&vreg_s5a_1p9>;
140		vdd-l10-l23-l25-supply = <&src_vreg_bob>;
141		vdd-l13-l19-l21-supply = <&src_vreg_bob>;
142		vdd-l16-l28-supply = <&src_vreg_bob>;
143		vdd-l18-l22-supply = <&src_vreg_bob>;
144		vdd-l20-l24-supply = <&src_vreg_bob>;
145		vdd-l26-supply = <&vreg_s3a_1p3>;
146		vin-lvs-1-2-supply = <&vreg_s4a_1p8>;
147
148		vreg_s2a_1p1: smps2 {
149			regulator-min-microvolt = <1100000>;
150			regulator-max-microvolt = <1100000>;
151		};
152
153		vreg_s3a_1p3: smps3 {
154			regulator-min-microvolt = <1352000>;
155			regulator-max-microvolt = <1352000>;
156		};
157
158		vreg_s5a_1p9: smps5 {
159			regulator-min-microvolt = <1904000>;
160			regulator-max-microvolt = <2040000>;
161		};
162
163		vreg_s7a_0p9: smps7 {
164			regulator-min-microvolt = <900000>;
165			regulator-max-microvolt = <1028000>;
166		};
167
168		vreg_l1a_0p9: ldo1 {
169			regulator-min-microvolt = <880000>;
170			regulator-max-microvolt = <880000>;
171			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
172		};
173
174		vreg_l2a_1p2: ldo2 {
175			regulator-min-microvolt = <1200000>;
176			regulator-max-microvolt = <1200000>;
177			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
178			regulator-always-on;
179		};
180
181		vreg_l3a_1p0: ldo3 {
182			regulator-min-microvolt = <1000000>;
183			regulator-max-microvolt = <1000000>;
184			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
185		};
186
187		vreg_l5a_0p8: ldo5 {
188			regulator-min-microvolt = <800000>;
189			regulator-max-microvolt = <800000>;
190			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
191		};
192
193		vreg_l6a_1p8: ldo6 {
194			regulator-min-microvolt = <1856000>;
195			regulator-max-microvolt = <1856000>;
196			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
197		};
198
199		vreg_l7a_1p8: ldo7 {
200			regulator-min-microvolt = <1800000>;
201			regulator-max-microvolt = <1800000>;
202			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
203		};
204
205		vreg_l8a_1p2: ldo8 {
206			regulator-min-microvolt = <1200000>;
207			regulator-max-microvolt = <1248000>;
208			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
209		};
210
211		vreg_l9a_1p7: ldo9 {
212			regulator-min-microvolt = <1704000>;
213			regulator-max-microvolt = <2928000>;
214			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
215		};
216
217		vreg_l10a_1p7: ldo10 {
218			regulator-min-microvolt = <1704000>;
219			regulator-max-microvolt = <2928000>;
220			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
221		};
222
223		vreg_l11a_1p0: ldo11 {
224			regulator-min-microvolt = <1000000>;
225			regulator-max-microvolt = <1048000>;
226			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
227		};
228
229		vreg_l12a_1p8: ldo12 {
230			regulator-min-microvolt = <1800000>;
231			regulator-max-microvolt = <1800000>;
232			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
233		};
234
235		vreg_l13a_1p8: ldo13 {
236			regulator-min-microvolt = <1800000>;
237			regulator-max-microvolt = <2960000>;
238			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
239		};
240
241		vreg_l14a_1p8: ldo14 {
242			regulator-min-microvolt = <1800000>;
243			regulator-max-microvolt = <1800000>;
244			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
245			regulator-system-load = <62000>;
246		};
247
248		vreg_l15a_1p8: ldo15 {
249			regulator-min-microvolt = <1800000>;
250			regulator-max-microvolt = <1800000>;
251			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
252		};
253
254		vreg_l16a_2p7: ldo16 {
255			regulator-min-microvolt = <2704000>;
256			regulator-max-microvolt = <2704000>;
257			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
258		};
259
260		vreg_l17a_1p3: ldo17 {
261			regulator-min-microvolt = <1304000>;
262			regulator-max-microvolt = <1304000>;
263			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
264		};
265
266		vreg_l18a_2p7: ldo18 {
267			regulator-min-microvolt = <2704000>;
268			regulator-max-microvolt = <2960000>;
269			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
270		};
271
272		vreg_l19a_2p7: ldo19 {
273			regulator-min-microvolt = <2700000>;
274			regulator-max-microvolt = <2700000>;
275			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
276
277			/*
278			 * The driver *really* doesn't want this regualtor to exist,
279			 * saying that it could not get the current voltage (-ENOTRECOVERABLE)
280			 * even though it surely is used on these devices (as a voltage
281			 * source for camera autofocus)
282			 */
283			status = "disabled";
284		};
285
286		vreg_l20a_2p7: ldo20 {
287			regulator-min-microvolt = <2704000>;
288			regulator-max-microvolt = <2960000>;
289			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
290		};
291
292		vreg_l21a_2p7: ldo21 {
293			regulator-min-microvolt = <2704000>;
294			regulator-max-microvolt = <2960000>;
295			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
296		};
297
298		vreg_l22a_2p8: ldo22 {
299			regulator-min-microvolt = <2800000>;
300			regulator-max-microvolt = <2800000>;
301			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
302		};
303
304		vreg_l23a_3p0: ldo23 {
305			regulator-min-microvolt = <3000000>;
306			regulator-max-microvolt = <3312000>;
307			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
308		};
309
310		vreg_l24a_3p1: ldo24 {
311			regulator-min-microvolt = <3088000>;
312			regulator-max-microvolt = <3088000>;
313			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
314		};
315
316		vreg_l25a_3p0: ldo25 {
317			regulator-min-microvolt = <3000000>;
318			regulator-max-microvolt = <3312000>;
319			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
320		};
321
322		vreg_l26a_1p2: ldo26 {
323			regulator-min-microvolt = <1200000>;
324			regulator-max-microvolt = <1200000>;
325			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
326		};
327
328		vreg_l28a_2p8: ldo28 {
329			regulator-min-microvolt = <2856000>;
330			regulator-max-microvolt = <3008000>;
331			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
332			regulator-system-load = <100000>;
333		};
334
335		vreg_lvs1a_1p8: lvs1 {
336			regulator-min-microvolt = <1800000>;
337			regulator-max-microvolt = <1800000>;
338			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
339		};
340
341		vreg_lvs2a_1p8: lvs2 {
342			regulator-min-microvolt = <1800000>;
343			regulator-max-microvolt = <1800000>;
344			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
345		};
346	};
347
348	regulators-1 {
349		compatible = "qcom,pmi8998-rpmh-regulators";
350		qcom,pmic-id = "b";
351
352		src_vreg_bob: bob {
353			regulator-min-microvolt = <3312000>;
354			regulator-max-microvolt = <3600000>;
355			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
356		};
357	};
358
359	regulators-2 {
360		compatible = "qcom,pm8005-rpmh-regulators";
361		qcom,pmic-id = "c";
362
363		vdd-s1-supply = <&vph_pwr>;
364		vdd-s2-supply = <&vph_pwr>;
365		vdd-s3-supply = <&vph_pwr>;
366		vdd-s4-supply = <&vph_pwr>;
367
368		vreg_s3c_0p6: smps3 {
369			regulator-min-microvolt = <600000>;
370			regulator-max-microvolt = <600000>;
371		};
372	};
373};
374
375&cdsp_pas {
376	firmware-name = "qcom/sdm845/Sony/tama/cdsp.mbn";
377	status = "okay";
378};
379
380&gcc {
381	protected-clocks = <GCC_QSPI_CORE_CLK>,
382			<GCC_QSPI_CORE_CLK_SRC>,
383			<GCC_QSPI_CNOC_PERIPH_AHB_CLK>,
384			<GCC_LPASS_Q6_AXI_CLK>,
385			<GCC_LPASS_SWAY_CLK>;
386};
387
388&gmu {
389	status = "okay";
390};
391
392&gpi_dma0 {
393	status = "okay";
394};
395
396&gpi_dma1 {
397	status = "okay";
398};
399
400&gpu {
401	status = "okay";
402
403	zap-shader {
404		memory-region = <&gpu_mem>;
405		firmware-name = "qcom/sdm845/Sony/tama/a630_zap.mbn";
406	};
407};
408
409&i2c5 {
410	clock-frequency = <400000>;
411	status = "okay";
412
413	touchscreen: touchscreen@2c {
414		compatible = "syna,rmi4-i2c";
415		reg = <0x2c>;
416
417		interrupts-extended = <&tlmm 125 IRQ_TYPE_EDGE_FALLING>;
418		vdd-supply = <&vreg_l14a_1p8>;
419		/*
420		 * This is a blatant abuse of OF, but the panel driver *needs*
421		 * to probe first, as the power/gpio switching needs to be precisely
422		 * timed in order for both the display and touch panel to function properly.
423		 */
424		incell-supply = <&panel>;
425
426		syna,reset-delay-ms = <220>;
427		syna,startup-delay-ms = <1000>;
428
429		pinctrl-0 = <&ts_default>;
430		pinctrl-1 = <&ts_sleep>;
431		pinctrl-names = "default", "sleep";
432
433		#address-cells = <1>;
434		#size-cells = <0>;
435
436		rmi4-f01@1 {
437			reg = <0x01>;
438			syna,nosleep-mode = <1>;
439		};
440
441		rmi4-f12@12 {
442			reg = <0x12>;
443			syna,sensor-type = <1>;
444		};
445	};
446};
447
448&i2c10 {
449	status = "okay";
450	clock-frequency = <400000>;
451
452	/* Qcom SMB1355 @ 8, c */
453	/* NXP PN547 NFC @ 28 */
454	/* Renesas IDTP9221 Qi charger @ 61 */
455};
456
457&i2c14 {
458	status = "okay";
459	clock-frequency = <400000>;
460
461	/* SONY ToF sensor @ 52 */
462	/* AMS TCS3490 RGB+IR color sensor @ 72 */
463};
464
465&ibb {
466	qcom,discharge-resistor-kohms = <300>;
467	regulator-min-microvolt = <5500000>;
468	regulator-max-microvolt = <5700000>;
469	regulator-min-microamp = <0>;
470	regulator-max-microamp = <800000>;
471	regulator-over-current-protection;
472	regulator-soft-start;
473	regulator-pull-down;
474};
475
476&lab {
477	regulator-min-microvolt = <5500000>;
478	regulator-max-microvolt = <5700000>;
479	regulator-min-microamp = <200000>;
480	regulator-max-microamp = <200000>;
481	regulator-over-current-protection;
482	regulator-soft-start;
483	regulator-pull-down;
484};
485
486&mdss {
487	status = "okay";
488};
489
490&mdss_dsi0 {
491	vdda-supply = <&vreg_l26a_1p2>;
492	status = "okay";
493
494	panel: panel@0 {
495		/* The compatible is assigned in device DTs. */
496		reg = <0>;
497
498		backlight = <&pmi8998_wled>;
499		vddio-supply = <&vreg_l14a_1p8>;
500		vsp-supply = <&lab>;
501		vsn-supply = <&ibb>;
502		panel-reset-gpios = <&tlmm 6 GPIO_ACTIVE_HIGH>;
503		touch-reset-gpios = <&tlmm 99 GPIO_ACTIVE_HIGH>;
504
505		pinctrl-0 = <&sde_dsi_active &sde_te_active_sleep>;
506		pinctrl-1 = <&sde_dsi_sleep &sde_te_active_sleep>;
507		pinctrl-names = "default", "sleep";
508
509		port {
510			panel_in: endpoint {
511				remote-endpoint = <&mdss_dsi0_out>;
512			};
513		};
514	};
515};
516
517&mdss_dsi0_out {
518	remote-endpoint = <&panel_in>;
519	data-lanes = <0 1 2 3>;
520};
521
522&mdss_dsi0_phy {
523	vdds-supply = <&vreg_l1a_0p9>;
524	status = "okay";
525};
526
527&pm8998_gpios {
528	focus_n: focus-n-state {
529		pins = "gpio2";
530		function = PMIC_GPIO_FUNC_NORMAL;
531		power-source = <0>;
532		bias-pull-up;
533		input-enable;
534	};
535
536	vol_down_n: vol-down-n-state {
537		pins = "gpio5";
538		function = PMIC_GPIO_FUNC_NORMAL;
539		power-source = <0>;
540		bias-pull-up;
541		input-enable;
542	};
543
544	vol_up_n: vol-up-n-state {
545		pins = "gpio6";
546		function = PMIC_GPIO_FUNC_NORMAL;
547		power-source = <0>;
548		bias-pull-up;
549		input-enable;
550	};
551
552	snapshot_n: snapshot-n-state {
553		pins = "gpio7";
554		function = PMIC_GPIO_FUNC_NORMAL;
555		power-source = <0>;
556		bias-pull-up;
557		input-enable;
558	};
559};
560
561&pmi8998_wled {
562	default-brightness = <800>;
563	qcom,switching-freq = <800>;
564	qcom,ovp-millivolt = <29600>;
565	qcom,current-boost-limit = <970>;
566	qcom,current-limit-microamp = <20000>;
567	qcom,enabled-strings = <0 1 2 3>;
568	status = "okay";
569};
570
571&qupv3_id_0 {
572	status = "okay";
573};
574
575&qupv3_id_1 {
576	status = "okay";
577};
578
579&sdhc_2 {
580	status = "okay";
581
582	vmmc-supply = <&vreg_l21a_2p7>;
583	vqmmc-supply = <&vreg_l13a_1p8>;
584	cd-gpios = <&tlmm 126 GPIO_ACTIVE_HIGH>;
585	pinctrl-0 = <&sdc2_default_state>;
586	pinctrl-names = "default";
587	bus-width = <4>;
588	no-sdio;
589	no-mmc;
590};
591
592&tlmm {
593	gpio-reserved-ranges = <0 4>, <81 4>;
594
595	sdc2_default_state: sdc2-default-state {
596		clk-pins {
597			pins = "sdc2_clk";
598			drive-strength = <16>;
599			bias-disable;
600		};
601
602		cmd-pins {
603			pins = "sdc2_cmd";
604			drive-strength = <10>;
605			bias-pull-up;
606		};
607
608		data-pins {
609			pins = "sdc2_data";
610			drive-strength = <10>;
611			bias-pull-up;
612		};
613	};
614
615	sde_dsi_active: sde-dsi-active-state {
616		pins = "gpio6";
617		function = "gpio";
618		drive-strength = <8>;
619		bias-disable;
620	};
621
622	sde_dsi_sleep: sde-dsi-sleep-state {
623		pins = "gpio6";
624		function = "gpio";
625		drive-strength = <2>;
626		bias-pull-down;
627	};
628
629	sde_te_active_sleep: sde-te-active-sleep-state {
630		pins = "gpio10";
631		function = "mdp_vsync";
632		drive-strength = <2>;
633		bias-pull-down;
634	};
635
636	ts_default: ts-default-state {
637		reset-pins {
638			pins = "gpio99";
639			function = "gpio";
640			drive-strength = <2>;
641			bias-pull-up;
642		};
643
644		int-pins {
645			pins = "gpio125";
646			function = "gpio";
647			drive-strength = <2>;
648			bias-pull-up;
649		};
650	};
651
652	ts_sleep: ts-sleep-state {
653		reset-pins {
654			pins = "gpio99";
655			function = "gpio";
656			drive-strength = <2>;
657			bias-pull-down;
658		};
659
660		int-pins {
661			pins = "gpio125";
662			function = "gpio";
663			drive-strength = <2>;
664			bias-pull-down;
665		};
666	};
667};
668
669&uart6 {
670	status = "okay";
671};
672
673&uart9 {
674	status = "okay";
675};
676
677/* BIG WARNING! DO NOT TOUCH UFS, YOUR DEVICE WILL DIE! */
678&ufs_mem_hc { status = "disabled"; };
679&ufs_mem_phy { status = "disabled"; };
680
681&usb_1 {
682	status = "okay";
683
684	qcom,select-utmi-as-pipe-clk;
685};
686
687&usb_1_dwc3 {
688	dr_mode = "peripheral";
689
690	maximum-speed = "high-speed";
691	phys = <&usb_1_hsphy>;
692	phy-names = "usb2-phy";
693};
694
695&usb_1_hsphy {
696	status = "okay";
697
698	vdd-supply = <&vreg_l1a_0p9>;
699	vdda-pll-supply = <&vreg_l12a_1p8>;
700	vdda-phy-dpdm-supply = <&vreg_l24a_3p1>;
701};
702
703&venus {
704	firmware-name = "qcom/sdm845/Sony/tama/venus.mbn";
705	status = "okay";
706};
707