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