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