1// SPDX-License-Identifier: BSD-3-Clause
2/*
3 * Copyright (c) 2020, Konrad Dybcio <konrad.dybcio@somainline.org>
4 * Copyright (c) 2020, AngeloGioacchino Del Regno
5 *                     <angelogioacchino.delregno@somainline.org>
6 */
7
8#include "pm660.dtsi"
9#include "pm660l.dtsi"
10#include <dt-bindings/gpio/gpio.h>
11#include <dt-bindings/input/input.h>
12#include <dt-bindings/input/gpio-keys.h>
13
14/ {
15	/* required for bootloader to select correct board */
16	qcom,msm-id = <318 0>;
17	qcom,board-id = <8 1>;
18	qcom,pmic-id = <0x1001b 0x101011a 0x00 0x00 0x1001b 0x201011a 0x00 0x00>;
19
20	/* This part enables graphical output via bootloader-enabled display */
21	chosen {
22		bootargs = "earlycon=tty0 console=tty0";
23
24		#address-cells = <2>;
25		#size-cells = <2>;
26		ranges;
27
28		stdout-path = "framebuffer0";
29
30		framebuffer0: framebuffer@9d400000 {
31			compatible = "simple-framebuffer";
32			reg = <0 0x9d400000 0 (1920 * 1080 * 4)>;
33			width = <1080>;
34			height = <1920>;
35			stride = <(1080 * 4)>;
36			format = "a8r8g8b8";
37			status= "okay";
38		};
39	};
40
41	board_vbat: vbat-regulator {
42		compatible = "regulator-fixed";
43		regulator-name = "VBAT";
44
45		regulator-min-microvolt = <4000000>;
46		regulator-max-microvolt = <4000000>;
47		regulator-always-on;
48		regulator-boot-on;
49	};
50
51	vph_pwr: vph-pwr-regulator {
52		compatible = "regulator-fixed";
53		regulator-name = "vph_pwr";
54
55		regulator-always-on;
56		regulator-boot-on;
57	};
58
59	cam_vdig_imx300_219_vreg: cam_vdig_imx300_219_vreg {
60		compatible = "regulator-fixed";
61		regulator-name = "cam_vdig_imx300_219_vreg";
62		startup-delay-us = <0>;
63		enable-active-high;
64		gpio = <&tlmm 52 GPIO_ACTIVE_HIGH>;
65		pinctrl-names = "default";
66		pinctrl-0 = <&cam_vdig_default>;
67	};
68
69	cam_vana_front_vreg: cam_vana_front_vreg {
70		compatible = "regulator-fixed";
71		regulator-name = "cam_vana_front_vreg";
72		startup-delay-us = <0>;
73		enable-active-high;
74		gpio = <&tlmm 51 GPIO_ACTIVE_HIGH>;
75		pinctrl-names = "default";
76		pinctrl-0 = <&imx219_vana_default>;
77	};
78
79	cam_vana_rear_vreg: cam_vana_rear_vreg {
80		compatible = "regulator-fixed";
81		regulator-name = "cam_vana_rear_vreg";
82		startup-delay-us = <0>;
83		enable-active-high;
84		gpio = <&tlmm 50 GPIO_ACTIVE_HIGH>;
85		regulator-always-on;
86		pinctrl-names = "default";
87		pinctrl-0 = <&imx300_vana_default>;
88	};
89
90	gpio_keys {
91		status = "okay";
92		compatible = "gpio-keys";
93		input-name = "gpio-keys";
94		#address-cells = <1>;
95		#size-cells = <0>;
96
97		camera_focus {
98			label = "Camera Focus";
99			gpios = <&tlmm 64 GPIO_ACTIVE_LOW>;
100			linux,input-type = <1>;
101			linux,code = <KEY_CAMERA_FOCUS>;
102			debounce-interval = <15>;
103		};
104
105		camera_snapshot {
106			label = "Camera Snapshot";
107			gpios = <&tlmm 113 GPIO_ACTIVE_LOW>;
108			linux,input-type = <1>;
109			linux,code = <KEY_CAMERA>;
110			debounce-interval = <15>;
111		};
112
113		vol_down {
114			label = "Volume Down";
115			gpios = <&pm660l_gpios 7 GPIO_ACTIVE_LOW>;
116			linux,input-type = <1>;
117			linux,code = <KEY_VOLUMEDOWN>;
118			gpio-key,wakeup;
119			debounce-interval = <15>;
120		};
121	};
122
123	reserved-memory {
124		#address-cells = <2>;
125		#size-cells = <2>;
126		ranges;
127
128		ramoops@ffc00000 {
129			compatible = "ramoops";
130			reg = <0x0 0xffc00000 0x0 0x100000>;
131			record-size = <0x10000>;
132			console-size = <0x60000>;
133			ftrace-size = <0x10000>;
134			pmsg-size = <0x20000>;
135			ecc-size = <16>;
136			status = "okay";
137		};
138
139		debug_region@ffb00000 {
140			reg = <0x00 0xffb00000 0x00 0x100000>;
141			no-map;
142		};
143
144		removed_region@85800000 {
145			reg = <0x00 0x85800000 0x00 0x3700000>;
146			no-map;
147		};
148	};
149
150	/*
151	 * Until we hook up type-c detection, we
152	 * have to stick with this. But it works.
153	 */
154	extcon_usb: extcon-usb {
155		compatible = "linux,extcon-usb-gpio";
156		id-gpio = <&tlmm 58 GPIO_ACTIVE_HIGH>;
157	};
158};
159
160&adsp_pil {
161	firmware-name = "adsp.mdt";
162};
163
164&blsp_i2c1 {
165	status = "okay";
166
167	touchscreen: synaptics-rmi4-i2c@70 {
168		compatible = "syna,rmi4-i2c";
169		reg = <0x70>;
170		#address-cells = <1>;
171		#size-cells = <0>;
172		interrupts-extended = <&tlmm 45 0x2008>;
173
174		pinctrl-names = "default";
175		pinctrl-0 = <&ts_int_active &ts_lcd_id_active>;
176
177		syna,reset-delay-ms = <200>;
178		syna,startup-delay-ms = <220>;
179
180		rmi4-f01@1 {
181			reg = <0x01>;
182			syna,nosleep-mode = <1>;
183		};
184
185		rmi4-f11@11 {
186			reg = <0x11>;
187			syna,sensor-type = <1>;
188		};
189	};
190};
191
192&blsp_i2c2 {
193	status = "okay";
194
195	/* SMB1351 charger */
196};
197
198/* I2C3, 4, 5, 7 and 8 are disabled on this board. */
199
200&blsp_i2c6 {
201	status = "okay";
202
203	/* NXP NFC */
204};
205
206&blsp1_uart2 {
207	status = "okay";
208
209	/* MSM serial console */
210};
211
212&blsp2_uart1 {
213	status = "okay";
214
215	/* HCI Bluetooth */
216};
217
218&pon {
219	volup {
220		compatible = "qcom,pm8941-resin";
221		interrupts = <0x0 0x8 1 IRQ_TYPE_EDGE_BOTH>;
222		debounce = <15625>;
223		bias-pull-up;
224		linux,code = <KEY_VOLUMEUP>;
225	};
226};
227
228&qusb2phy {
229	status = "okay";
230
231	vdd-supply = <&vreg_l1b_0p925>;
232	vdda-pll-supply = <&vreg_l10a_1p8>;
233	vdda-phy-dpdm-supply = <&vreg_l7b_3p125>;
234};
235
236&rpm_requests {
237	pm660l-regulators {
238		compatible = "qcom,rpm-pm660l-regulators";
239
240		vdd_s1-supply = <&vph_pwr>;
241		vdd_s2-supply = <&vph_pwr>;
242		vdd_s3_s4-supply = <&vph_pwr>;
243		vdd_s5-supply = <&vph_pwr>;
244		vdd_s6-supply = <&vph_pwr>;
245
246		vdd_l1_l9_l10-supply = <&vreg_s2b_1p05>;
247		vdd_l2-supply = <&vreg_bob>;
248		vdd_l3_l5_l7_l8-supply = <&vreg_bob>;
249		vdd_l4_l6-supply = <&vreg_bob>;
250		vdd_bob-supply = <&vph_pwr>;
251
252		vreg_s1b_1p125: s1 {
253			regulator-min-microvolt = <1125000>;
254			regulator-max-microvolt = <1125000>;
255			regulator-enable-ramp-delay = <200>;
256			regulator-ramp-delay = <0>;
257		};
258
259		vreg_s2b_1p05: s2 {
260			regulator-min-microvolt = <1050000>;
261			regulator-max-microvolt = <1050000>;
262			regulator-enable-ramp-delay = <200>;
263			regulator-ramp-delay = <0>;
264		};
265
266		/*
267		 * At least on Nile's configuration, S3B/S4B (VDD_CX) and
268		 * S5B (VDD_MX) are managed only through RPM Power Domains.
269		 * Trying to set a voltage on the main supply will create
270		 * havoc and freeze the SoC.
271		 * In any case, reference voltages for these regulators are:
272		 * S3B/S4B: 0.870V
273		 * S5B: 0.915V
274		 */
275
276		/* LDOs */
277		vreg_l1b_0p925: l1 {
278			regulator-min-microvolt = <920000>;
279			regulator-max-microvolt = <928000>;
280			regulator-enable-ramp-delay = <250>;
281			regulator-ramp-delay = <0>;
282			regulator-allow-set-load;
283		};
284
285		vreg_l2b_2p95: l2 {
286			/*
287			 * This regulator supports 1.648 - 3.104V on this board
288			 * but we set a max voltage of anything less than 2.7V
289			 * to satisfy a condition in sdhci.c that will disable
290			 * 3.3V SDHCI signaling, which happens to be not really
291			 * supported on the Xperia Nile/Ganges platform.
292			 */
293			regulator-min-microvolt = <1648000>;
294			regulator-max-microvolt = <2696000>;
295			regulator-enable-ramp-delay = <250>;
296			regulator-ramp-delay = <0>;
297			regulator-allow-set-load;
298		};
299
300		vreg_l3b_3p0: l3 {
301			regulator-min-microvolt = <2800000>;
302			regulator-max-microvolt = <2800000>;
303			regulator-enable-ramp-delay = <250>;
304			regulator-ramp-delay = <0>;
305			regulator-min-microamp = <200>;
306			regulator-max-microamp = <600000>;
307			regulator-system-load = <100000>;
308			regulator-allow-set-load;
309		};
310
311		vreg_l4b_2p95: l4 {
312			regulator-min-microvolt = <2944000>;
313			regulator-max-microvolt = <2952000>;
314			regulator-enable-ramp-delay = <250>;
315			regulator-ramp-delay = <0>;
316
317			regulator-min-microamp = <200>;
318			regulator-max-microamp = <600000>;
319			regulator-system-load = <570000>;
320			regulator-allow-set-load;
321		};
322
323		/*
324		 * Downstream specifies a range of 1721-3600mV,
325		 * but the only assigned consumers are SDHCI2 VMMC
326		 * and Coresight QPDI that both request pinned 2.95V.
327		 * Tighten the range to 1.8-3.328 (closest to 3.3) to
328		 * make the mmc driver happy.
329		 */
330		vreg_l5b_2p95: l5 {
331			regulator-min-microvolt = <1800000>;
332			regulator-max-microvolt = <3328000>;
333			regulator-enable-ramp-delay = <250>;
334			regulator-ramp-delay = <0>;
335			regulator-allow-set-load;
336			regulator-system-load = <800000>;
337		};
338
339		vreg_l6b_3p3: l6 {
340			regulator-min-microvolt = <1704000>;
341			regulator-max-microvolt = <3312000>;
342			regulator-enable-ramp-delay = <250>;
343			regulator-ramp-delay = <0>;
344		};
345
346		vreg_l7b_3p125: l7 {
347			regulator-min-microvolt = <2704000>;
348			regulator-max-microvolt = <3128000>;
349			regulator-enable-ramp-delay = <250>;
350			regulator-ramp-delay = <0>;
351		};
352
353		vreg_l8b_3p3: l8 {
354			regulator-min-microvolt = <2800000>;
355			regulator-max-microvolt = <3400000>;
356			regulator-enable-ramp-delay = <250>;
357			regulator-ramp-delay = <0>;
358		};
359
360		/* L9B (870mV) is currently unused */
361		/* L10B (915mV) is currently unused */
362
363		vreg_bob: bob {
364			regulator-min-microvolt = <3304000>;
365			regulator-max-microvolt = <3624000>;
366			regulator-enable-ramp-delay = <500>;
367			regulator-ramp-delay = <0>;
368		};
369	};
370
371	pm660-regulators {
372		compatible = "qcom,rpm-pm660-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
381		vdd_l1_l6_l7-supply = <&vreg_s5a_1p35>;
382		vdd_l2_l3-supply = <&vreg_s2b_1p05>;
383		vdd_l5-supply = <&vreg_s2b_1p05>;
384		vdd_l8_l9_l10_l11_l12_l13_l14-supply = <&vreg_s4a_2p04>;
385		vdd_l15_l16_l17_l18_l19-supply = <&vreg_bob>;
386
387		/*
388		 * S1A (FTAPC0), S2A (FTAPC1), S3A (HFAPC1) are managed
389		 * by the Core Power Reduction hardened (CPRh) and the
390		 * Operating State Manager (OSM) HW automatically.
391		 */
392
393		vreg_s4a_2p04: s4 {
394			regulator-min-microvolt = <2040000>;
395			regulator-max-microvolt = <2040000>;
396			regulator-enable-ramp-delay = <200>;
397			regulator-ramp-delay = <0>;
398			regulator-always-on;
399		};
400
401		vreg_s5a_1p35: s5 {
402			regulator-min-microvolt = <1224000>;
403			regulator-max-microvolt = <1350000>;
404			regulator-enable-ramp-delay = <200>;
405			regulator-ramp-delay = <0>;
406		};
407
408		vreg_s6a_0p87: s6 {
409			regulator-min-microvolt = <504000>;
410			regulator-max-microvolt = <992000>;
411			regulator-enable-ramp-delay = <150>;
412			regulator-ramp-delay = <0>;
413		};
414
415		/* LDOs */
416		vreg_l1a_1p225: l1 {
417			regulator-min-microvolt = <1226000>;
418			regulator-max-microvolt = <1250000>;
419			regulator-enable-ramp-delay = <250>;
420			regulator-ramp-delay = <0>;
421			regulator-allow-set-load;
422		};
423
424		vreg_l2a_1p0: l2 {
425			regulator-min-microvolt = <944000>;
426			regulator-max-microvolt = <1008000>;
427			regulator-enable-ramp-delay = <250>;
428			regulator-ramp-delay = <0>;
429		};
430
431		vreg_l3a_1p0: l3 {
432			regulator-min-microvolt = <944000>;
433			regulator-max-microvolt = <1008000>;
434			regulator-enable-ramp-delay = <250>;
435			regulator-ramp-delay = <0>;
436		};
437
438		vreg_l5a_0p848: l5 {
439			regulator-min-microvolt = <800000>;
440			regulator-max-microvolt = <952000>;
441			regulator-enable-ramp-delay = <250>;
442			regulator-ramp-delay = <0>;
443		};
444
445		vreg_l6a_1p3: l6 {
446			regulator-min-microvolt = <1304000>;
447			regulator-max-microvolt = <1368000>;
448			regulator-allow-set-load;
449			regulator-enable-ramp-delay = <250>;
450			regulator-ramp-delay = <0>;
451		};
452
453		vreg_l7a_1p2: l7 {
454			regulator-min-microvolt = <1200000>;
455			regulator-max-microvolt = <1200000>;
456			regulator-enable-ramp-delay = <250>;
457			regulator-ramp-delay = <0>;
458		};
459
460		vreg_l8a_1p8: l8 {
461			regulator-min-microvolt = <1800000>;
462			regulator-max-microvolt = <1800000>;
463			regulator-enable-ramp-delay = <250>;
464			regulator-ramp-delay = <0>;
465			regulator-system-load = <325000>;
466			regulator-allow-set-load;
467		};
468
469		vreg_l9a_1p8: l9 {
470			regulator-min-microvolt = <1804000>;
471			regulator-max-microvolt = <1896000>;
472			regulator-enable-ramp-delay = <250>;
473			regulator-ramp-delay = <0>;
474			regulator-allow-set-load;
475		};
476
477		vreg_l10a_1p8: l10 {
478			regulator-min-microvolt = <1800000>;
479			regulator-max-microvolt = <1944000>;
480			regulator-enable-ramp-delay = <250>;
481			regulator-ramp-delay = <0>;
482			regulator-allow-set-load;
483		};
484
485		vreg_l11a_1p8: l11 {
486			regulator-min-microvolt = <1784000>;
487			regulator-max-microvolt = <1944000>;
488			regulator-enable-ramp-delay = <250>;
489			regulator-ramp-delay = <0>;
490		};
491
492		vreg_l12a_1p8: l12 {
493			regulator-min-microvolt = <1800000>;
494			regulator-max-microvolt = <1944000>;
495			regulator-enable-ramp-delay = <250>;
496			regulator-ramp-delay = <0>;
497		};
498
499		/* This gives power to the LPDDR4: never turn it off! */
500		vreg_l13a_1p8: l13 {
501			regulator-min-microvolt = <1800000>;
502			regulator-max-microvolt = <1944000>;
503			regulator-enable-ramp-delay = <250>;
504			regulator-ramp-delay = <0>;
505			regulator-boot-on;
506			regulator-always-on;
507		};
508
509		vreg_l14a_1p8: l14 {
510			regulator-min-microvolt = <1710000>;
511			regulator-max-microvolt = <1904000>;
512			regulator-enable-ramp-delay = <250>;
513			regulator-ramp-delay = <0>;
514		};
515
516		vreg_l15a_1p8: l15 {
517			regulator-min-microvolt = <1648000>;
518			regulator-max-microvolt = <2952000>;
519			regulator-enable-ramp-delay = <250>;
520			regulator-ramp-delay = <0>;
521		};
522
523		/* L16A (2.70V) is unused */
524
525		vreg_l17a_1p8: l17 {
526			regulator-min-microvolt = <1648000>;
527			regulator-max-microvolt = <2952000>;
528			regulator-enable-ramp-delay = <250>;
529			regulator-ramp-delay = <0>;
530		};
531
532		vreg_l18a_1v8: l18 {
533			regulator-min-microvolt = <1800000>;
534			regulator-max-microvolt = <1800000>;
535			regulator-enable-ramp-delay = <250>;
536			regulator-ramp-delay = <10>;
537			regulator-min-microamp = <200>;
538			regulator-max-microamp = <50000>;
539			regulator-system-load = <10000>;
540			regulator-allow-set-load;
541		};
542
543		vreg_l19a_3p3: l19 {
544			regulator-min-microvolt = <3312000>;
545			regulator-max-microvolt = <3400000>;
546			regulator-enable-ramp-delay = <250>;
547			regulator-ramp-delay = <0>;
548			regulator-allow-set-load;
549		};
550	};
551};
552
553&sdhc_1 {
554	status = "okay";
555	supports-cqe;
556
557	/* SoMC Nile platform's eMMC doesn't support HS200 mode */
558	mmc-ddr-1_8v;
559	mmc-hs400-1_8v;
560	mmc-hs400-enhanced-strobe;
561
562	vmmc-supply = <&vreg_l4b_2p95>;
563	vqmmc-supply = <&vreg_l8a_1p8>;
564};
565
566&sdhc_2 {
567	status = "okay";
568
569	vmmc-supply = <&vreg_l5b_2p95>;
570	vqmmc-supply = <&vreg_l2b_2p95>;
571};
572
573&tlmm {
574	gpio-reserved-ranges = <8 4>;
575
576	ts_int_active: ts-int-active {
577		pins = "gpio45";
578		drive-strength = <8>;
579		bias-pull-up;
580	};
581
582	ts_lcd_id_active: ts-lcd-id-active {
583		pins = "gpio56";
584		drive-strength = <8>;
585		bias-disable;
586	};
587
588	imx300_vana_default: imx300-vana-default {
589		pins = "gpio50";
590		function = "gpio";
591		bias-disable;
592		drive-strength = <2>;
593	};
594
595	imx219_vana_default: imx219-vana-default {
596		pins = "gpio51";
597		function = "gpio";
598		bias-disable;
599		drive-strength = <2>;
600	};
601
602	cam_vdig_default: cam-vdig-default {
603		pins = "gpio52";
604		function = "gpio";
605		bias-disable;
606		drive-strength = <2>;
607	};
608};
609
610&usb3 {
611	status = "okay";
612};
613
614&usb3_dwc3 {
615	dr_mode = "peripheral";
616	extcon = <&extcon_usb>;
617};
618