1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2// Copyright (C) 2019 Icenowy Zheng <icenowy@aosc.xyz>
3// Copyright (C) 2020 Martijn Braam <martijn@brixit.nl>
4// Copyright (C) 2020 Ondrej Jirman <megous@megous.com>
5
6#include "sun50i-a64.dtsi"
7#include "sun50i-a64-cpu-opp.dtsi"
8
9#include <dt-bindings/gpio/gpio.h>
10#include <dt-bindings/input/input.h>
11#include <dt-bindings/leds/common.h>
12#include <dt-bindings/pwm/pwm.h>
13
14/ {
15	aliases {
16		serial0 = &uart0;
17	};
18
19	backlight: backlight {
20		compatible = "pwm-backlight";
21		pwms = <&r_pwm 0 50000 PWM_POLARITY_INVERTED>;
22		enable-gpios = <&pio 7 10 GPIO_ACTIVE_HIGH>; /* PH10 */
23		/* Backlight configuration differs per PinePhone revision. */
24	};
25
26	chosen {
27		stdout-path = "serial0:115200n8";
28	};
29
30	leds {
31		compatible = "gpio-leds";
32
33		blue {
34			function = LED_FUNCTION_INDICATOR;
35			color = <LED_COLOR_ID_BLUE>;
36			gpios = <&pio 3 20 GPIO_ACTIVE_HIGH>; /* PD20 */
37		};
38
39		green {
40			function = LED_FUNCTION_INDICATOR;
41			color = <LED_COLOR_ID_GREEN>;
42			gpios = <&pio 3 18 GPIO_ACTIVE_HIGH>; /* PD18 */
43		};
44
45		red {
46			function = LED_FUNCTION_INDICATOR;
47			color = <LED_COLOR_ID_RED>;
48			gpios = <&pio 3 19 GPIO_ACTIVE_HIGH>; /* PD19 */
49		};
50	};
51
52	sgm3140: led-controller {
53		compatible = "sgmicro,sgm3140";
54		vin-supply = <&reg_dcdc1>;
55
56		sgm3140_flash: led {
57			function = LED_FUNCTION_FLASH;
58			color = <LED_COLOR_ID_WHITE>;
59			flash-max-timeout-us = <250000>;
60		};
61	};
62
63	speaker_amp: audio-amplifier {
64		compatible = "simple-audio-amplifier";
65		enable-gpios = <&pio 2 7 GPIO_ACTIVE_HIGH>; /* PC7 */
66		sound-name-prefix = "Speaker Amp";
67	};
68
69	vibrator {
70		compatible = "gpio-vibrator";
71		enable-gpios = <&pio 3 2 GPIO_ACTIVE_HIGH>; /* PD2 */
72		vcc-supply = <&reg_dcdc1>;
73	};
74};
75
76&codec {
77	status = "okay";
78};
79
80&codec_analog {
81	cpvdd-supply = <&reg_eldo1>;
82	status = "okay";
83};
84
85&cpu0 {
86	cpu-supply = <&reg_dcdc2>;
87};
88
89&cpu1 {
90	cpu-supply = <&reg_dcdc2>;
91};
92
93&cpu2 {
94	cpu-supply = <&reg_dcdc2>;
95};
96
97&cpu3 {
98	cpu-supply = <&reg_dcdc2>;
99};
100
101&dai {
102	status = "okay";
103};
104
105&de {
106	status = "okay";
107};
108
109&dphy {
110	status = "okay";
111};
112
113&dsi {
114	vcc-dsi-supply = <&reg_dldo1>;
115	status = "okay";
116
117	panel@0 {
118		compatible = "xingbangda,xbd599";
119		reg = <0>;
120		reset-gpios = <&pio 3 23 GPIO_ACTIVE_LOW>; /* PD23 */
121		iovcc-supply = <&reg_dldo2>;
122		vcc-supply = <&reg_ldo_io0>;
123		backlight = <&backlight>;
124	};
125};
126
127&ehci0 {
128	status = "okay";
129};
130
131&ehci1 {
132	status = "okay";
133};
134
135&i2c0 {
136	status = "okay";
137
138	touchscreen@5d {
139		compatible = "goodix,gt917s";
140		reg = <0x5d>;
141		interrupt-parent = <&pio>;
142		interrupts = <7 4 IRQ_TYPE_LEVEL_HIGH>; /* PH4 */
143		irq-gpios = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */
144		reset-gpios = <&pio 7 11 GPIO_ACTIVE_HIGH>; /* PH11 */
145		AVDD28-supply = <&reg_ldo_io0>;
146		VDDIO-supply = <&reg_ldo_io0>;
147		touchscreen-size-x = <720>;
148		touchscreen-size-y = <1440>;
149	};
150};
151
152&i2c1 {
153	status = "okay";
154
155	/* Magnetometer */
156	lis3mdl: lis3mdl@1e {
157		compatible = "st,lis3mdl-magn";
158		reg = <0x1e>;
159		vdd-supply = <&reg_dldo1>;
160		vddio-supply = <&reg_dldo1>;
161	};
162
163	/* Light/proximity sensor */
164	stk3311@48 {
165		compatible = "sensortek,stk3311";
166		reg = <0x48>;
167		interrupt-parent = <&pio>;
168		interrupts = <1 0 IRQ_TYPE_EDGE_FALLING>; /* PB0 */
169		vdd-supply = <&reg_ldo_io0>;
170		leda-supply = <&reg_dldo1>;
171	};
172
173	/* Accelerometer/gyroscope */
174	mpu6050@68 {
175		compatible = "invensense,mpu6050";
176		reg = <0x68>;
177		interrupt-parent = <&pio>;
178		interrupts = <7 5 IRQ_TYPE_EDGE_RISING>; /* PH5 */
179		vdd-supply = <&reg_dldo1>;
180		vddio-supply = <&reg_dldo1>;
181	};
182};
183
184/* Connected to pogo pins (external spring based pinheader for user addons) */
185&i2c2 {
186	status = "okay";
187};
188
189&lradc {
190	vref-supply = <&reg_aldo3>;
191	status = "okay";
192
193	button-200 {
194		label = "Volume Up";
195		linux,code = <KEY_VOLUMEUP>;
196		channel = <0>;
197		voltage = <200000>;
198	};
199
200	button-400 {
201		label = "Volume Down";
202		linux,code = <KEY_VOLUMEDOWN>;
203		channel = <0>;
204		voltage = <400000>;
205	};
206};
207
208&mmc0 {
209	pinctrl-names = "default";
210	pinctrl-0 = <&mmc0_pins>;
211	vmmc-supply = <&reg_dcdc1>;
212	vqmmc-supply = <&reg_dcdc1>;
213	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
214	disable-wp;
215	bus-width = <4>;
216	status = "okay";
217};
218
219&mmc2 {
220	pinctrl-names = "default";
221	pinctrl-0 = <&mmc2_pins>;
222	vmmc-supply = <&reg_dcdc1>;
223	vqmmc-supply = <&reg_dcdc1>;
224	bus-width = <8>;
225	non-removable;
226	cap-mmc-hw-reset;
227	status = "okay";
228};
229
230&ohci0 {
231	status = "okay";
232};
233
234&ohci1 {
235	status = "okay";
236};
237
238&pio {
239	vcc-pb-supply = <&reg_dcdc1>;
240	vcc-pc-supply = <&reg_dcdc1>;
241	vcc-pd-supply = <&reg_dcdc1>;
242	vcc-pe-supply = <&reg_aldo1>;
243	vcc-pf-supply = <&reg_dcdc1>;
244	vcc-pg-supply = <&reg_dldo4>;
245	vcc-ph-supply = <&reg_dcdc1>;
246};
247
248&r_pio {
249	/*
250	 * FIXME: We can't add that supply for now since it would
251	 * create a circular dependency between pinctrl, the regulator
252	 * and the RSB Bus.
253	 *
254	 * vcc-pl-supply = <&reg_aldo2>;
255	 */
256};
257
258&r_pwm {
259	status = "okay";
260};
261
262&r_rsb {
263	status = "okay";
264
265	axp803: pmic@3a3 {
266		compatible = "x-powers,axp803";
267		reg = <0x3a3>;
268		interrupt-parent = <&r_intc>;
269		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
270	};
271};
272
273#include "axp803.dtsi"
274
275&battery_power_supply {
276	status = "okay";
277};
278
279&reg_aldo1 {
280	regulator-min-microvolt = <1800000>;
281	regulator-max-microvolt = <1800000>;
282	regulator-name = "dovdd-csi";
283};
284
285&reg_aldo2 {
286	regulator-always-on;
287	regulator-min-microvolt = <1800000>;
288	regulator-max-microvolt = <1800000>;
289	regulator-name = "vcc-pl";
290};
291
292&reg_aldo3 {
293	regulator-always-on;
294	regulator-min-microvolt = <3000000>;
295	regulator-max-microvolt = <3000000>;
296	regulator-name = "vcc-pll-avcc";
297};
298
299&reg_dcdc1 {
300	regulator-always-on;
301	regulator-min-microvolt = <3300000>;
302	regulator-max-microvolt = <3300000>;
303	regulator-name = "vcc-3v3";
304};
305
306&reg_dcdc2 {
307	regulator-always-on;
308	regulator-min-microvolt = <1000000>;
309	regulator-max-microvolt = <1300000>;
310	regulator-name = "vdd-cpux";
311};
312
313/* DCDC3 is polyphased with DCDC2 */
314
315&reg_dcdc5 {
316	regulator-always-on;
317	regulator-min-microvolt = <1200000>;
318	regulator-max-microvolt = <1200000>;
319	regulator-name = "vcc-dram";
320};
321
322&reg_dcdc6 {
323	regulator-always-on;
324	regulator-min-microvolt = <1100000>;
325	regulator-max-microvolt = <1100000>;
326	regulator-name = "vdd-sys";
327};
328
329&reg_dldo1 {
330	regulator-min-microvolt = <3300000>;
331	regulator-max-microvolt = <3300000>;
332	regulator-name = "vcc-dsi-sensor";
333};
334
335&reg_dldo2 {
336	regulator-min-microvolt = <1800000>;
337	regulator-max-microvolt = <1800000>;
338	regulator-name = "vcc-mipi-io";
339};
340
341&reg_dldo3 {
342	regulator-min-microvolt = <2800000>;
343	regulator-max-microvolt = <2800000>;
344	regulator-name = "avdd-csi";
345};
346
347&reg_dldo4 {
348	regulator-min-microvolt = <1800000>;
349	regulator-max-microvolt = <1800000>;
350	regulator-name = "vcc-wifi-io";
351};
352
353&reg_eldo1 {
354	regulator-always-on;
355	regulator-min-microvolt = <1800000>;
356	regulator-max-microvolt = <1800000>;
357	regulator-name = "vcc-lpddr";
358};
359
360&reg_eldo3 {
361	regulator-min-microvolt = <1800000>;
362	regulator-max-microvolt = <1800000>;
363	regulator-name = "dvdd-1v8-csi";
364};
365
366&reg_fldo1 {
367	regulator-min-microvolt = <1200000>;
368	regulator-max-microvolt = <1200000>;
369	regulator-name = "vcc-1v2-hsic";
370};
371
372&reg_fldo2 {
373	regulator-always-on;
374	regulator-min-microvolt = <1100000>;
375	regulator-max-microvolt = <1100000>;
376	regulator-name = "vdd-cpus";
377};
378
379&reg_ldo_io0 {
380	regulator-min-microvolt = <3300000>;
381	regulator-max-microvolt = <3300000>;
382	regulator-name = "vcc-lcd-ctp-stk";
383	status = "okay";
384};
385
386&reg_ldo_io1 {
387	regulator-min-microvolt = <1800000>;
388	regulator-max-microvolt = <1800000>;
389	regulator-name = "vcc-1v8-typec";
390	status = "okay";
391};
392
393&reg_rtc_ldo {
394	regulator-name = "vcc-rtc";
395};
396
397&sound {
398	status = "okay";
399	simple-audio-card,aux-devs = <&codec_analog>, <&speaker_amp>;
400	simple-audio-card,widgets = "Microphone", "Headset Microphone",
401				    "Microphone", "Internal Microphone",
402				    "Headphone", "Headphone Jack",
403				    "Speaker", "Internal Earpiece",
404				    "Speaker", "Internal Speaker";
405	simple-audio-card,routing =
406			"Headphone Jack", "HP",
407			"Internal Earpiece", "EARPIECE",
408			"Internal Speaker", "Speaker Amp OUTL",
409			"Internal Speaker", "Speaker Amp OUTR",
410			"Speaker Amp INL", "LINEOUT",
411			"Speaker Amp INR", "LINEOUT",
412			"Left DAC", "DACL",
413			"Right DAC", "DACR",
414			"ADCL", "Left ADC",
415			"ADCR", "Right ADC",
416			"Internal Microphone", "MBIAS",
417			"MIC1", "Internal Microphone",
418			"Headset Microphone", "HBIAS",
419			"MIC2", "Headset Microphone";
420};
421
422&uart0 {
423	pinctrl-names = "default";
424	pinctrl-0 = <&uart0_pb_pins>;
425	status = "okay";
426};
427
428/* Connected to the modem (hardware flow control can't be used) */
429&uart3 {
430	pinctrl-names = "default";
431	pinctrl-0 = <&uart3_pins>;
432	status = "okay";
433};
434
435&usb_otg {
436	dr_mode = "peripheral";
437	status = "okay";
438};
439
440&usb_power_supply {
441	status = "okay";
442};
443
444&usbphy {
445	status = "okay";
446};
447