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