1// SPDX-License-Identifier: BSD-3-Clause
2/*
3 * Copyright (c) 2020, Konrad Dybcio
4 */
5
6/dts-v1/;
7
8#include "msm8992.dtsi"
9#include "pm8994.dtsi"
10#include "pmi8994.dtsi"
11#include <dt-bindings/gpio/gpio.h>
12#include <dt-bindings/input/gpio-keys.h>
13
14/ {
15	model = "Xiaomi Mi 4C";
16	compatible = "xiaomi,libra", "qcom,msm8992";
17	chassis-type = "handset";
18
19	/* required for bootloader to select correct board */
20	qcom,msm-id = <251 0>, <252 0>;
21	qcom,pmic-id = <65545 65546 0 0>;
22	qcom,board-id = <12 0>;
23
24	/* This enables graphical output via bootloader-enabled display */
25	chosen {
26		bootargs = "earlycon=tty0 console=tty0 maxcpus=1";
27
28		#address-cells = <2>;
29		#size-cells = <2>;
30		ranges;
31
32		framebuffer0: framebuffer@3400000 {
33			compatible = "simple-framebuffer";
34			reg = <0 0x3400000 0 (1080 * 1920 * 3)>;
35			width = <1080>;
36			height = <1920>;
37			stride = <(1080 * 3)>;
38			format = "r8g8b8";
39			/*
40			 * That's a lot of clocks, but it's necessary due
41			 * to unused clk cleanup & no panel driver yet..
42			 */
43			clocks = <&mmcc MDSS_AHB_CLK>,
44				 <&mmcc MDSS_AXI_CLK>,
45				 <&mmcc MDSS_VSYNC_CLK>,
46				 <&mmcc MDSS_MDP_CLK>,
47				 <&mmcc MDSS_BYTE0_CLK>,
48				 <&mmcc MDSS_PCLK0_CLK>,
49				 <&mmcc MDSS_ESC0_CLK>;
50			power-domains = <&mmcc MDSS_GDSC>;
51		};
52	};
53
54	gpio-keys {
55		compatible = "gpio-keys";
56		autorepeat;
57
58		button {
59			label = "Volume Up";
60			gpios = <&pm8994_gpios 3 GPIO_ACTIVE_LOW>;
61			linux,input-type = <1>;
62			linux,code = <KEY_VOLUMEUP>;
63			wakeup-source;
64			debounce-interval = <15>;
65		};
66	};
67
68	reserved-memory {
69		#address-cells = <2>;
70		#size-cells = <2>;
71		ranges;
72
73		/* This is for getting crash logs using Android downstream kernels */
74		ramoops@dfc00000 {
75			compatible = "ramoops";
76			reg = <0x0 0xdfc00000 0x0 0x40000>;
77			console-size = <0x10000>;
78			record-size = <0x10000>;
79			ftrace-size = <0x10000>;
80			pmsg-size = <0x20000>;
81		};
82
83		modem_region: modem_region@9000000 {
84			reg = <0x0 0x9000000 0x0 0x5a00000>;
85			no-map;
86		};
87
88		tzapp: modem_region@ea00000 {
89			reg = <0x0 0xea00000 0x0 0x1900000>;
90			no-map;
91		};
92	};
93};
94
95&blsp1_i2c2 {
96	status = "okay";
97
98	/* Atmel or Synaptics touchscreen */
99};
100
101&blsp1_i2c5 {
102	status = "okay";
103
104	/* ST lsm6db0 gyro/accelerometer */
105};
106
107&blsp1_i2c6 {
108	status = "okay";
109
110	/*
111	 * NXP NCI NFC,
112	 * TI USB320 Type-C controller,
113	 * Pericom 30216a USB (de)mux switch
114	 */
115};
116
117&blsp2_i2c1 {
118	status = "okay";
119
120	/* cm36686 proximity and ambient light sensor */
121};
122
123&blsp2_i2c5 {
124	status = "okay";
125
126	/* Silabs si4705 FM transmitter */
127};
128
129&blsp2_uart2 {
130	status = "okay";
131};
132
133&peripheral_region {
134	reg = <0x0 0x7400000 0x0 0x1c00000>;
135	no-map;
136};
137
138&pm8994_spmi_regulators {
139	VDD_APC0: s8 {
140		regulator-min-microvolt = <680000>;
141		regulator-max-microvolt = <1180000>;
142		regulator-always-on;
143		regulator-boot-on;
144	};
145
146	/* APC1 is 3-phase, but quoting downstream, s11 is "the gang leader" */
147	VDD_APC1: s11 {
148		regulator-min-microvolt = <700000>;
149		regulator-max-microvolt = <1225000>;
150		regulator-always-on;
151		regulator-boot-on;
152	};
153};
154
155&rpm_requests {
156	pm8994-regulators {
157		compatible = "qcom,rpm-pm8994-regulators";
158
159		vdd_l1-supply = <&pm8994_s7>;
160		vdd_l2_26_28-supply = <&pm8994_s3>;
161		vdd_l3_11-supply = <&pm8994_s3>;
162		vdd_l4_27_31-supply = <&pm8994_s3>;
163		vdd_l5_7-supply = <&pm8994_s3>;
164		vdd_l6_12_32-supply = <&pm8994_s5>;
165		vdd_l8_16_30-supply = <&vph_pwr>;
166		vdd_l9_10_18_22-supply = <&vph_pwr>;
167		vdd_l13_19_23_24-supply = <&vph_pwr>;
168		vdd_l14_15-supply = <&pm8994_s5>;
169		vdd_l17_29-supply = <&vph_pwr>;
170		vdd_l20_21-supply = <&vph_pwr>;
171		vdd_l25-supply = <&pm8994_s5>;
172		vdd_lvs1_2-supply = <&pm8994_s4>;
173
174		/* S1, S2, S6 and S12 are managed by RPMPD */
175
176		pm8994_s3: s3 {
177			regulator-min-microvolt = <1300000>;
178			regulator-max-microvolt = <1300000>;
179		};
180
181		pm8994_s4: s4 {
182			regulator-min-microvolt = <1800000>;
183			regulator-max-microvolt = <1800000>;
184			regulator-allow-set-load;
185			regulator-always-on;
186			regulator-system-load = <325000>;
187		};
188
189		pm8994_s5: s5 {
190			regulator-min-microvolt = <2150000>;
191			regulator-max-microvolt = <2150000>;
192		};
193
194		pm8994_s7: s7 {
195			regulator-min-microvolt = <1000000>;
196			regulator-max-microvolt = <1000000>;
197		};
198
199		/* S8, S9, S10 and S11 - SPMI-managed VDD_APC */
200
201		pm8994_l1: l1 {
202			regulator-min-microvolt = <1000000>;
203			regulator-max-microvolt = <1000000>;
204		};
205
206		pm8994_l2: l2 {
207			regulator-min-microvolt = <1250000>;
208			regulator-max-microvolt = <1250000>;
209		};
210
211		pm8994_l3: l3 {
212			regulator-min-microvolt = <1200000>;
213			regulator-max-microvolt = <1200000>;
214		};
215
216		pm8994_l4: l4 {
217			regulator-min-microvolt = <1225000>;
218			regulator-max-microvolt = <1225000>;
219		};
220
221		/* L5 is inaccessible from RPM */
222
223		pm8994_l6: l6 {
224			regulator-min-microvolt = <1800000>;
225			regulator-max-microvolt = <1800000>;
226		};
227
228		/* L7 is inaccessible from RPM */
229
230		pm8994_l8: l8 {
231			regulator-min-microvolt = <1800000>;
232			regulator-max-microvolt = <1800000>;
233		};
234
235		pm8994_l9: l9 {
236			regulator-min-microvolt = <1800000>;
237			regulator-max-microvolt = <1800000>;
238		};
239
240		pm8994_l10: l10 {
241			regulator-min-microvolt = <1800000>;
242			regulator-max-microvolt = <1800000>;
243		};
244
245		pm8994_l11: l11 {
246			regulator-min-microvolt = <1200000>;
247			regulator-max-microvolt = <1200000>;
248		};
249
250		pm8994_l12: l12 {
251			regulator-min-microvolt = <1800000>;
252			regulator-max-microvolt = <1800000>;
253		};
254
255		pm8994_l13: l13 {
256			regulator-min-microvolt = <1800000>;
257			regulator-max-microvolt = <2950000>;
258		};
259
260		pm8994_l14: l14 {
261			regulator-min-microvolt = <1800000>;
262			regulator-max-microvolt = <1800000>;
263		};
264
265		pm8994_l15: l15 {
266			regulator-min-microvolt = <1800000>;
267			regulator-max-microvolt = <1800000>;
268		};
269
270		pm8994_l16: l16 {
271			regulator-min-microvolt = <2700000>;
272			regulator-max-microvolt = <2700000>;
273		};
274
275		pm8994_l17: l17 {
276			regulator-min-microvolt = <2700000>;
277			regulator-max-microvolt = <2700000>;
278		};
279
280		pm8994_l18: l18 {
281			regulator-min-microvolt = <2850000>;
282			regulator-max-microvolt = <2850000>;
283			regulator-always-on;
284		};
285
286		pm8994_l19: l19 {
287			regulator-min-microvolt = <2800000>;
288			regulator-max-microvolt = <2800000>;
289		};
290
291		pm8994_l20: l20 {
292			regulator-min-microvolt = <2950000>;
293			regulator-max-microvolt = <2950000>;
294			regulator-always-on;
295			regulator-boot-on;
296			regulator-allow-set-load;
297			regulator-system-load = <570000>;
298		};
299
300		pm8994_l21: l21 {
301			regulator-min-microvolt = <2950000>;
302			regulator-max-microvolt = <2950000>;
303			regulator-always-on;
304		};
305
306		pm8994_l22: l22 {
307			regulator-min-microvolt = <3000000>;
308			regulator-max-microvolt = <3000000>;
309		};
310
311		pm8994_l23: l23 {
312			regulator-min-microvolt = <2800000>;
313			regulator-max-microvolt = <2800000>;
314		};
315
316		pm8994_l24: l24 {
317			regulator-min-microvolt = <3075000>;
318			regulator-max-microvolt = <3150000>;
319		};
320
321		pm8994_l25: l25 {
322			regulator-min-microvolt = <1000000>;
323			regulator-max-microvolt = <1000000>;
324		};
325
326		pm8994_l26: l26 {
327			regulator-min-microvolt = <987500>;
328			regulator-max-microvolt = <987500>;
329
330		};
331
332		pm8994_l27: l27 {
333			regulator-min-microvolt = <1050000>;
334			regulator-max-microvolt = <1050000>;
335		};
336
337		pm8994_l28: l28 {
338			regulator-min-microvolt = <1000000>;
339			regulator-max-microvolt = <1000000>;
340		};
341
342		pm8994_l29: l29 {
343			regulator-min-microvolt = <2800000>;
344			regulator-max-microvolt = <2800000>;
345		};
346
347		pm8994_l30: l30 {
348			regulator-min-microvolt = <1800000>;
349			regulator-max-microvolt = <1800000>;
350		};
351
352		pm8994_l31: l31 {
353			regulator-min-microvolt = <1262500>;
354			regulator-max-microvolt = <1262500>;
355		};
356
357		pm8994_l32: l32 {
358			regulator-min-microvolt = <1800000>;
359			regulator-max-microvolt = <1800000>;
360		};
361
362		pm8994_lvs1: lvs1 {};
363		pm8994_lvs2: lvs2 {};
364	};
365
366	pmi8994_regulators: pmi8994-regulators {
367		compatible = "qcom,rpm-pmi8994-regulators";
368		vdd_s1-supply = <&vph_pwr>;
369		vdd_bst_byp-supply = <&vph_pwr>;
370
371		pmi8994_s1: s1 {
372			regulator-min-microvolt = <1025000>;
373			regulator-max-microvolt = <1025000>;
374		};
375
376		/* S2 & S3 - VDD_GFX */
377
378		pmi8994_bby: boost-bypass {
379			regulator-min-microvolt = <3150000>;
380			regulator-max-microvolt = <3600000>;
381		};
382	};
383};
384
385&sdhc1 {
386	status = "okay";
387
388	mmc-hs400-1_8v;
389	vmmc-supply = <&pm8994_l20>;
390	vqmmc-supply = <&pm8994_s4>;
391};
392