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