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		#address-cells = <1>;
94		#size-cells = <0>;
95
96		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		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		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			gpio-key,wakeup;
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_region@ffb00000 {
139			reg = <0x00 0xffb00000 0x00 0x100000>;
140			no-map;
141		};
142
143		removed_region@85800000 {
144			reg = <0x00 0x85800000 0x00 0x3700000>;
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-gpio = <&tlmm 58 GPIO_ACTIVE_HIGH>;
156	};
157};
158
159&adsp_pil {
160	firmware-name = "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&pon_pwrkey {
218	status = "okay";
219};
220
221&pon_resin {
222	status = "okay";
223
224	linux,code = <KEY_VOLUMEUP>;
225};
226
227&qusb2phy {
228	status = "okay";
229
230	vdd-supply = <&vreg_l1b_0p925>;
231	vdda-pll-supply = <&vreg_l10a_1p8>;
232	vdda-phy-dpdm-supply = <&vreg_l7b_3p125>;
233};
234
235&rpm_requests {
236	pm660l-regulators {
237		compatible = "qcom,rpm-pm660l-regulators";
238
239		vdd_s1-supply = <&vph_pwr>;
240		vdd_s2-supply = <&vph_pwr>;
241		vdd_s3_s4-supply = <&vph_pwr>;
242		vdd_s5-supply = <&vph_pwr>;
243		vdd_s6-supply = <&vph_pwr>;
244
245		vdd_l1_l9_l10-supply = <&vreg_s2b_1p05>;
246		vdd_l2-supply = <&vreg_bob>;
247		vdd_l3_l5_l7_l8-supply = <&vreg_bob>;
248		vdd_l4_l6-supply = <&vreg_bob>;
249		vdd_bob-supply = <&vph_pwr>;
250
251		vreg_s1b_1p125: s1 {
252			regulator-min-microvolt = <1125000>;
253			regulator-max-microvolt = <1125000>;
254			regulator-enable-ramp-delay = <200>;
255			regulator-ramp-delay = <0>;
256		};
257
258		vreg_s2b_1p05: s2 {
259			regulator-min-microvolt = <1050000>;
260			regulator-max-microvolt = <1050000>;
261			regulator-enable-ramp-delay = <200>;
262			regulator-ramp-delay = <0>;
263		};
264
265		/*
266		 * At least on Nile's configuration, S3B/S4B (VDD_CX) and
267		 * S5B (VDD_MX) are managed only through RPM Power Domains.
268		 * Trying to set a voltage on the main supply will create
269		 * havoc and freeze the SoC.
270		 * In any case, reference voltages for these regulators are:
271		 * S3B/S4B: 0.870V
272		 * S5B: 0.915V
273		 */
274
275		/* LDOs */
276		vreg_l1b_0p925: l1 {
277			regulator-min-microvolt = <920000>;
278			regulator-max-microvolt = <928000>;
279			regulator-enable-ramp-delay = <250>;
280			regulator-ramp-delay = <0>;
281			regulator-allow-set-load;
282		};
283
284		vreg_l2b_2p95: l2 {
285			/*
286			 * This regulator supports 1.648 - 3.104V on this board
287			 * but we set a max voltage of anything less than 2.7V
288			 * to satisfy a condition in sdhci.c that will disable
289			 * 3.3V SDHCI signaling, which happens to be not really
290			 * supported on the Xperia Nile/Ganges platform.
291			 */
292			regulator-min-microvolt = <1648000>;
293			regulator-max-microvolt = <2696000>;
294			regulator-enable-ramp-delay = <250>;
295			regulator-ramp-delay = <0>;
296			regulator-allow-set-load;
297		};
298
299		vreg_l3b_3p0: l3 {
300			regulator-min-microvolt = <2800000>;
301			regulator-max-microvolt = <2800000>;
302			regulator-enable-ramp-delay = <250>;
303			regulator-ramp-delay = <0>;
304			regulator-min-microamp = <200>;
305			regulator-max-microamp = <600000>;
306			regulator-system-load = <100000>;
307			regulator-allow-set-load;
308		};
309
310		vreg_l4b_2p95: l4 {
311			regulator-min-microvolt = <2944000>;
312			regulator-max-microvolt = <2952000>;
313			regulator-enable-ramp-delay = <250>;
314			regulator-ramp-delay = <0>;
315
316			regulator-min-microamp = <200>;
317			regulator-max-microamp = <600000>;
318			regulator-system-load = <570000>;
319			regulator-allow-set-load;
320		};
321
322		/*
323		 * Downstream specifies a range of 1721-3600mV,
324		 * but the only assigned consumers are SDHCI2 VMMC
325		 * and Coresight QPDI that both request pinned 2.95V.
326		 * Tighten the range to 1.8-3.328 (closest to 3.3) to
327		 * make the mmc driver happy.
328		 */
329		vreg_l5b_2p95: l5 {
330			regulator-min-microvolt = <1800000>;
331			regulator-max-microvolt = <3328000>;
332			regulator-enable-ramp-delay = <250>;
333			regulator-ramp-delay = <0>;
334			regulator-allow-set-load;
335			regulator-system-load = <800000>;
336		};
337
338		vreg_l6b_3p3: l6 {
339			regulator-min-microvolt = <1704000>;
340			regulator-max-microvolt = <3312000>;
341			regulator-enable-ramp-delay = <250>;
342			regulator-ramp-delay = <0>;
343		};
344
345		vreg_l7b_3p125: l7 {
346			regulator-min-microvolt = <2704000>;
347			regulator-max-microvolt = <3128000>;
348			regulator-enable-ramp-delay = <250>;
349			regulator-ramp-delay = <0>;
350		};
351
352		vreg_l8b_3p3: l8 {
353			regulator-min-microvolt = <2800000>;
354			regulator-max-microvolt = <3400000>;
355			regulator-enable-ramp-delay = <250>;
356			regulator-ramp-delay = <0>;
357		};
358
359		/* L9B (870mV) is currently unused */
360		/* L10B (915mV) is currently unused */
361
362		vreg_bob: bob {
363			regulator-min-microvolt = <3304000>;
364			regulator-max-microvolt = <3624000>;
365			regulator-enable-ramp-delay = <500>;
366			regulator-ramp-delay = <0>;
367		};
368	};
369
370	pm660-regulators {
371		compatible = "qcom,rpm-pm660-regulators";
372
373		vdd_s1-supply = <&vph_pwr>;
374		vdd_s2-supply = <&vph_pwr>;
375		vdd_s3-supply = <&vph_pwr>;
376		vdd_s4-supply = <&vph_pwr>;
377		vdd_s5-supply = <&vph_pwr>;
378		vdd_s6-supply = <&vph_pwr>;
379
380		vdd_l1_l6_l7-supply = <&vreg_s5a_1p35>;
381		vdd_l2_l3-supply = <&vreg_s2b_1p05>;
382		vdd_l5-supply = <&vreg_s2b_1p05>;
383		vdd_l8_l9_l10_l11_l12_l13_l14-supply = <&vreg_s4a_2p04>;
384		vdd_l15_l16_l17_l18_l19-supply = <&vreg_bob>;
385
386		/*
387		 * S1A (FTAPC0), S2A (FTAPC1), S3A (HFAPC1) are managed
388		 * by the Core Power Reduction hardened (CPRh) and the
389		 * Operating State Manager (OSM) HW automatically.
390		 */
391
392		vreg_s4a_2p04: s4 {
393			regulator-min-microvolt = <2040000>;
394			regulator-max-microvolt = <2040000>;
395			regulator-enable-ramp-delay = <200>;
396			regulator-ramp-delay = <0>;
397			regulator-always-on;
398		};
399
400		vreg_s5a_1p35: s5 {
401			regulator-min-microvolt = <1224000>;
402			regulator-max-microvolt = <1350000>;
403			regulator-enable-ramp-delay = <200>;
404			regulator-ramp-delay = <0>;
405		};
406
407		vreg_s6a_0p87: s6 {
408			regulator-min-microvolt = <504000>;
409			regulator-max-microvolt = <992000>;
410			regulator-enable-ramp-delay = <150>;
411			regulator-ramp-delay = <0>;
412		};
413
414		/* LDOs */
415		vreg_l1a_1p225: l1 {
416			regulator-min-microvolt = <1226000>;
417			regulator-max-microvolt = <1250000>;
418			regulator-enable-ramp-delay = <250>;
419			regulator-ramp-delay = <0>;
420			regulator-allow-set-load;
421		};
422
423		vreg_l2a_1p0: l2 {
424			regulator-min-microvolt = <944000>;
425			regulator-max-microvolt = <1008000>;
426			regulator-enable-ramp-delay = <250>;
427			regulator-ramp-delay = <0>;
428		};
429
430		vreg_l3a_1p0: l3 {
431			regulator-min-microvolt = <944000>;
432			regulator-max-microvolt = <1008000>;
433			regulator-enable-ramp-delay = <250>;
434			regulator-ramp-delay = <0>;
435		};
436
437		vreg_l5a_0p848: l5 {
438			regulator-min-microvolt = <800000>;
439			regulator-max-microvolt = <952000>;
440			regulator-enable-ramp-delay = <250>;
441			regulator-ramp-delay = <0>;
442		};
443
444		vreg_l6a_1p3: l6 {
445			regulator-min-microvolt = <1304000>;
446			regulator-max-microvolt = <1368000>;
447			regulator-allow-set-load;
448			regulator-enable-ramp-delay = <250>;
449			regulator-ramp-delay = <0>;
450		};
451
452		vreg_l7a_1p2: l7 {
453			regulator-min-microvolt = <1200000>;
454			regulator-max-microvolt = <1200000>;
455			regulator-enable-ramp-delay = <250>;
456			regulator-ramp-delay = <0>;
457		};
458
459		vreg_l8a_1p8: l8 {
460			regulator-min-microvolt = <1800000>;
461			regulator-max-microvolt = <1800000>;
462			regulator-enable-ramp-delay = <250>;
463			regulator-ramp-delay = <0>;
464			regulator-system-load = <325000>;
465			regulator-allow-set-load;
466		};
467
468		vreg_l9a_1p8: l9 {
469			regulator-min-microvolt = <1804000>;
470			regulator-max-microvolt = <1896000>;
471			regulator-enable-ramp-delay = <250>;
472			regulator-ramp-delay = <0>;
473			regulator-allow-set-load;
474		};
475
476		vreg_l10a_1p8: l10 {
477			regulator-min-microvolt = <1800000>;
478			regulator-max-microvolt = <1944000>;
479			regulator-enable-ramp-delay = <250>;
480			regulator-ramp-delay = <0>;
481			regulator-allow-set-load;
482		};
483
484		vreg_l11a_1p8: l11 {
485			regulator-min-microvolt = <1784000>;
486			regulator-max-microvolt = <1944000>;
487			regulator-enable-ramp-delay = <250>;
488			regulator-ramp-delay = <0>;
489		};
490
491		vreg_l12a_1p8: l12 {
492			regulator-min-microvolt = <1800000>;
493			regulator-max-microvolt = <1944000>;
494			regulator-enable-ramp-delay = <250>;
495			regulator-ramp-delay = <0>;
496		};
497
498		/* This gives power to the LPDDR4: never turn it off! */
499		vreg_l13a_1p8: l13 {
500			regulator-min-microvolt = <1800000>;
501			regulator-max-microvolt = <1944000>;
502			regulator-enable-ramp-delay = <250>;
503			regulator-ramp-delay = <0>;
504			regulator-boot-on;
505			regulator-always-on;
506		};
507
508		vreg_l14a_1p8: l14 {
509			regulator-min-microvolt = <1710000>;
510			regulator-max-microvolt = <1904000>;
511			regulator-enable-ramp-delay = <250>;
512			regulator-ramp-delay = <0>;
513		};
514
515		vreg_l15a_1p8: l15 {
516			regulator-min-microvolt = <1648000>;
517			regulator-max-microvolt = <2952000>;
518			regulator-enable-ramp-delay = <250>;
519			regulator-ramp-delay = <0>;
520		};
521
522		/* L16A (2.70V) is unused */
523
524		vreg_l17a_1p8: l17 {
525			regulator-min-microvolt = <1648000>;
526			regulator-max-microvolt = <2952000>;
527			regulator-enable-ramp-delay = <250>;
528			regulator-ramp-delay = <0>;
529		};
530
531		vreg_l18a_1v8: l18 {
532			regulator-min-microvolt = <1800000>;
533			regulator-max-microvolt = <1800000>;
534			regulator-enable-ramp-delay = <250>;
535			regulator-ramp-delay = <10>;
536			regulator-min-microamp = <200>;
537			regulator-max-microamp = <50000>;
538			regulator-system-load = <10000>;
539			regulator-allow-set-load;
540		};
541
542		vreg_l19a_3p3: l19 {
543			regulator-min-microvolt = <3312000>;
544			regulator-max-microvolt = <3400000>;
545			regulator-enable-ramp-delay = <250>;
546			regulator-ramp-delay = <0>;
547			regulator-allow-set-load;
548		};
549	};
550};
551
552&sdhc_1 {
553	status = "okay";
554	supports-cqe;
555
556	/* SoMC Nile platform's eMMC doesn't support HS200 mode */
557	mmc-ddr-1_8v;
558	mmc-hs400-1_8v;
559	mmc-hs400-enhanced-strobe;
560
561	vmmc-supply = <&vreg_l4b_2p95>;
562	vqmmc-supply = <&vreg_l8a_1p8>;
563};
564
565&sdhc_2 {
566	status = "okay";
567
568	vmmc-supply = <&vreg_l5b_2p95>;
569	vqmmc-supply = <&vreg_l2b_2p95>;
570};
571
572&tlmm {
573	gpio-reserved-ranges = <8 4>;
574
575	ts_int_active: ts-int-active {
576		pins = "gpio45";
577		drive-strength = <8>;
578		bias-pull-up;
579	};
580
581	ts_lcd_id_active: ts-lcd-id-active {
582		pins = "gpio56";
583		drive-strength = <8>;
584		bias-disable;
585	};
586
587	imx300_vana_default: imx300-vana-default {
588		pins = "gpio50";
589		function = "gpio";
590		bias-disable;
591		drive-strength = <2>;
592	};
593
594	imx219_vana_default: imx219-vana-default {
595		pins = "gpio51";
596		function = "gpio";
597		bias-disable;
598		drive-strength = <2>;
599	};
600
601	cam_vdig_default: cam-vdig-default {
602		pins = "gpio52";
603		function = "gpio";
604		bias-disable;
605		drive-strength = <2>;
606	};
607};
608
609&usb3 {
610	status = "okay";
611};
612
613&usb3_dwc3 {
614	dr_mode = "peripheral";
615	extcon = <&extcon_usb>;
616};
617