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