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&apps_rsc {
102	regulators-0 {
103		compatible = "qcom,pm8998-rpmh-regulators";
104		qcom,pmic-id = "a";
105
106		vdd-s1-supply = <&vph_pwr>;
107		vdd-s2-supply = <&vph_pwr>;
108		vdd-s3-supply = <&vph_pwr>;
109		vdd-s4-supply = <&vph_pwr>;
110		vdd-s5-supply = <&vph_pwr>;
111		vdd-s6-supply = <&vph_pwr>;
112		vdd-s7-supply = <&vph_pwr>;
113		vdd-s8-supply = <&vph_pwr>;
114		vdd-s9-supply = <&vph_pwr>;
115		vdd-s10-supply = <&vph_pwr>;
116		vdd-s11-supply = <&vph_pwr>;
117		vdd-s12-supply = <&vph_pwr>;
118		vdd-s13-supply = <&vph_pwr>;
119		vdd-l1-l27-supply = <&vreg_s7a_0p9>;
120		vdd-l2-l8-l17-supply = <&vreg_s3a_1p3>;
121		vdd-l3-l11-supply = <&vreg_s7a_0p9>;
122		vdd-l4-l5-supply = <&vreg_s7a_0p9>;
123		vdd-l6-supply = <&vph_pwr>;
124		vdd-l7-l12-l14-l15-supply = <&vreg_s5a_1p9>;
125		vdd-l9-supply = <&vreg_s5a_1p9>;
126		vdd-l10-l23-l25-supply = <&src_vreg_bob>;
127		vdd-l13-l19-l21-supply = <&src_vreg_bob>;
128		vdd-l16-l28-supply = <&src_vreg_bob>;
129		vdd-l18-l22-supply = <&src_vreg_bob>;
130		vdd-l20-l24-supply = <&src_vreg_bob>;
131		vdd-l26-supply = <&vreg_s3a_1p3>;
132		vin-lvs-1-2-supply = <&vreg_s4a_1p8>;
133
134		vreg_s2a_1p1: smps2 {
135			regulator-min-microvolt = <1100000>;
136			regulator-max-microvolt = <1100000>;
137		};
138
139		vreg_s3a_1p3: smps3 {
140			regulator-min-microvolt = <1352000>;
141			regulator-max-microvolt = <1352000>;
142		};
143
144		vreg_s5a_1p9: smps5 {
145			regulator-min-microvolt = <1904000>;
146			regulator-max-microvolt = <2040000>;
147		};
148
149		vreg_s7a_0p9: smps7 {
150			regulator-min-microvolt = <900000>;
151			regulator-max-microvolt = <1028000>;
152		};
153
154		vreg_l1a_0p9: ldo1 {
155			regulator-min-microvolt = <880000>;
156			regulator-max-microvolt = <880000>;
157			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
158		};
159
160		vreg_l2a_1p2: ldo2 {
161			regulator-min-microvolt = <1200000>;
162			regulator-max-microvolt = <1200000>;
163			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
164			regulator-always-on;
165		};
166
167		vreg_l3a_1p0: ldo3 {
168			regulator-min-microvolt = <1000000>;
169			regulator-max-microvolt = <1000000>;
170			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
171		};
172
173		vreg_l5a_0p8: ldo5 {
174			regulator-min-microvolt = <800000>;
175			regulator-max-microvolt = <800000>;
176			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
177		};
178
179		vreg_l6a_1p8: ldo6 {
180			regulator-min-microvolt = <1856000>;
181			regulator-max-microvolt = <1856000>;
182			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
183		};
184
185		vreg_l7a_1p8: ldo7 {
186			regulator-min-microvolt = <1800000>;
187			regulator-max-microvolt = <1800000>;
188			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
189		};
190
191		vreg_l8a_1p2: ldo8 {
192			regulator-min-microvolt = <1200000>;
193			regulator-max-microvolt = <1248000>;
194			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
195		};
196
197		vreg_l9a_1p7: ldo9 {
198			regulator-min-microvolt = <1704000>;
199			regulator-max-microvolt = <2928000>;
200			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
201		};
202
203		vreg_l10a_1p7: ldo10 {
204			regulator-min-microvolt = <1704000>;
205			regulator-max-microvolt = <2928000>;
206			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
207		};
208
209		vreg_l11a_1p0: ldo11 {
210			regulator-min-microvolt = <1000000>;
211			regulator-max-microvolt = <1048000>;
212			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
213		};
214
215		vreg_l12a_1p8: ldo12 {
216			regulator-min-microvolt = <1800000>;
217			regulator-max-microvolt = <1800000>;
218			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
219		};
220
221		vreg_l13a_1p8: ldo13 {
222			regulator-min-microvolt = <1800000>;
223			regulator-max-microvolt = <2960000>;
224			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
225		};
226
227		vreg_l14a_1p8: ldo14 {
228			regulator-min-microvolt = <1800000>;
229			regulator-max-microvolt = <1800000>;
230			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
231		};
232
233		vreg_l15a_1p8: ldo15 {
234			regulator-min-microvolt = <1800000>;
235			regulator-max-microvolt = <1800000>;
236			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
237		};
238
239		vreg_l16a_2p7: ldo16 {
240			regulator-min-microvolt = <2704000>;
241			regulator-max-microvolt = <2704000>;
242			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
243		};
244
245		vreg_l17a_1p3: ldo17 {
246			regulator-min-microvolt = <1304000>;
247			regulator-max-microvolt = <1304000>;
248			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
249		};
250
251		vreg_l18a_2p7: ldo18 {
252			regulator-min-microvolt = <2704000>;
253			regulator-max-microvolt = <2960000>;
254			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
255		};
256
257		vreg_l19a_2p7: ldo19 {
258			regulator-min-microvolt = <2700000>;
259			regulator-max-microvolt = <2700000>;
260			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
261
262			/*
263			 * The driver *really* doesn't want this regualtor to exist,
264			 * saying that it could not get the current voltage (-ENOTRECOVERABLE)
265			 * even though it surely is used on these devices (as a voltage
266			 * source for camera autofocus)
267			 */
268			status = "disabled";
269		};
270
271		vreg_l20a_2p7: ldo20 {
272			regulator-min-microvolt = <2704000>;
273			regulator-max-microvolt = <2960000>;
274			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
275		};
276
277		vreg_l21a_2p7: ldo21 {
278			regulator-min-microvolt = <2704000>;
279			regulator-max-microvolt = <2960000>;
280			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
281		};
282
283		vreg_l22a_2p8: ldo22 {
284			regulator-min-microvolt = <2800000>;
285			regulator-max-microvolt = <2800000>;
286			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
287		};
288
289		vreg_l23a_3p0: ldo23 {
290			regulator-min-microvolt = <3000000>;
291			regulator-max-microvolt = <3312000>;
292			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
293		};
294
295		vreg_l24a_3p1: ldo24 {
296			regulator-min-microvolt = <3088000>;
297			regulator-max-microvolt = <3088000>;
298			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
299		};
300
301		vreg_l25a_3p0: ldo25 {
302			regulator-min-microvolt = <3000000>;
303			regulator-max-microvolt = <3312000>;
304			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
305		};
306
307		vreg_l26a_1p2: ldo26 {
308			regulator-min-microvolt = <1200000>;
309			regulator-max-microvolt = <1200000>;
310			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
311		};
312
313		vreg_l28a_2p8: ldo28 {
314			regulator-min-microvolt = <2856000>;
315			regulator-max-microvolt = <3008000>;
316			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
317		};
318
319		vreg_lvs1a_1p8: lvs1 {
320			regulator-min-microvolt = <1800000>;
321			regulator-max-microvolt = <1800000>;
322			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
323		};
324
325		vreg_lvs2a_1p8: lvs2 {
326			regulator-min-microvolt = <1800000>;
327			regulator-max-microvolt = <1800000>;
328			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
329		};
330	};
331
332	regulators-1 {
333		compatible = "qcom,pmi8998-rpmh-regulators";
334		qcom,pmic-id = "b";
335
336		src_vreg_bob: bob {
337			regulator-min-microvolt = <3312000>;
338			regulator-max-microvolt = <3600000>;
339			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
340		};
341	};
342
343	regulators-2 {
344		compatible = "qcom,pm8005-rpmh-regulators";
345		qcom,pmic-id = "c";
346
347		vdd-s1-supply = <&vph_pwr>;
348		vdd-s2-supply = <&vph_pwr>;
349		vdd-s3-supply = <&vph_pwr>;
350		vdd-s4-supply = <&vph_pwr>;
351
352		vreg_s3c_0p6: smps3 {
353			regulator-min-microvolt = <600000>;
354			regulator-max-microvolt = <600000>;
355		};
356	};
357};
358
359&gcc {
360	protected-clocks = <GCC_QSPI_CORE_CLK>,
361			<GCC_QSPI_CORE_CLK_SRC>,
362			<GCC_QSPI_CNOC_PERIPH_AHB_CLK>,
363			<GCC_LPASS_Q6_AXI_CLK>,
364			<GCC_LPASS_SWAY_CLK>;
365};
366
367&i2c5 {
368	status = "okay";
369	clock-frequency = <400000>;
370
371	/* Synaptics touchscreen @ 2c, 3c */
372};
373
374&i2c10 {
375	status = "okay";
376	clock-frequency = <400000>;
377
378	/* Qcom SMB1355 @ 8, c */
379	/* NXP PN547 NFC @ 28 */
380	/* Renesas IDTP9221 Qi charger @ 61 */
381};
382
383&i2c14 {
384	status = "okay";
385	clock-frequency = <400000>;
386
387	/* SONY ToF sensor @ 52 */
388	/* AMS TCS3490 RGB+IR color sensor @ 72 */
389};
390
391&pm8998_gpios {
392	focus_n: focus-n-state {
393		pins = "gpio2";
394		function = PMIC_GPIO_FUNC_NORMAL;
395		power-source = <0>;
396		bias-pull-up;
397		input-enable;
398	};
399
400	vol_down_n: vol-down-n-state {
401		pins = "gpio5";
402		function = PMIC_GPIO_FUNC_NORMAL;
403		power-source = <0>;
404		bias-pull-up;
405		input-enable;
406	};
407
408	vol_up_n: vol-up-n-state {
409		pins = "gpio6";
410		function = PMIC_GPIO_FUNC_NORMAL;
411		power-source = <0>;
412		bias-pull-up;
413		input-enable;
414	};
415
416	snapshot_n: snapshot-n-state {
417		pins = "gpio7";
418		function = PMIC_GPIO_FUNC_NORMAL;
419		power-source = <0>;
420		bias-pull-up;
421		input-enable;
422	};
423};
424
425&qupv3_id_0 {
426	status = "okay";
427};
428
429&qupv3_id_1 {
430	status = "okay";
431};
432
433&sdhc_2 {
434	status = "okay";
435
436	vmmc-supply = <&vreg_l21a_2p7>;
437	vqmmc-supply = <&vreg_l13a_1p8>;
438	cd-gpios = <&tlmm 126 GPIO_ACTIVE_HIGH>;
439	pinctrl-0 = <&sdc2_default_state>;
440	pinctrl-names = "default";
441	bus-width = <4>;
442	no-sdio;
443	no-mmc;
444};
445
446&tlmm {
447	gpio-reserved-ranges = <0 4>, <81 4>;
448
449	sdc2_default_state: sdc2-default-state {
450		clk-pins {
451			pins = "sdc2_clk";
452			drive-strength = <16>;
453			bias-disable;
454		};
455
456		cmd-pins {
457			pins = "sdc2_cmd";
458			drive-strength = <10>;
459			bias-pull-up;
460		};
461
462		data-pins {
463			pins = "sdc2_data";
464			drive-strength = <10>;
465			bias-pull-up;
466		};
467	};
468};
469
470&uart6 {
471	status = "okay";
472};
473
474&uart9 {
475	status = "okay";
476};
477
478/* BIG WARNING! DO NOT TOUCH UFS, YOUR DEVICE WILL DIE! */
479&ufs_mem_hc { status = "disabled"; };
480&ufs_mem_phy { status = "disabled"; };
481
482&usb_1 {
483	status = "okay";
484
485	qcom,select-utmi-as-pipe-clk;
486};
487
488&usb_1_dwc3 {
489	dr_mode = "peripheral";
490
491	maximum-speed = "high-speed";
492	phys = <&usb_1_hsphy>;
493	phy-names = "usb2-phy";
494};
495
496&usb_1_hsphy {
497	status = "okay";
498
499	vdd-supply = <&vreg_l1a_0p9>;
500	vdda-pll-supply = <&vreg_l12a_1p8>;
501	vdda-phy-dpdm-supply = <&vreg_l24a_3p1>;
502};
503