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