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