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