1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (C) 2019 Icenowy Zheng <icenowy@aosc.xyz>
4 *
5 */
6
7/dts-v1/;
8
9#include "sun50i-a64.dtsi"
10#include "sun50i-a64-cpu-opp.dtsi"
11
12#include <dt-bindings/gpio/gpio.h>
13#include <dt-bindings/input/input.h>
14#include <dt-bindings/pwm/pwm.h>
15
16/ {
17	model = "PineTab, Development Sample";
18	compatible = "pine64,pinetab", "allwinner,sun50i-a64";
19
20	aliases {
21		serial0 = &uart0;
22		ethernet0 = &rtl8723cs;
23	};
24
25	backlight: backlight {
26		compatible = "pwm-backlight";
27		pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>;
28		brightness-levels = <0 16 18 20 22 24 26 29 32 35 38 42 46 51 56 62 68 75 83 91 100>;
29		default-brightness-level = <15>;
30		enable-gpios = <&pio 3 23 GPIO_ACTIVE_HIGH>; /* PD23 */
31		power-supply = <&vdd_bl>;
32	};
33
34	chosen {
35		stdout-path = "serial0:115200n8";
36	};
37
38	i2c-csi {
39		compatible = "i2c-gpio";
40		sda-gpios = <&pio 4 13 GPIO_ACTIVE_HIGH>; /* PE13 */
41		scl-gpios = <&pio 4 12 GPIO_ACTIVE_HIGH>; /* PE12 */
42		i2c-gpio,delay-us = <5>;
43		#address-cells = <1>;
44		#size-cells = <0>;
45
46		/* Rear camera */
47		ov5640: camera@3c {
48			compatible = "ovti,ov5640";
49			reg = <0x3c>;
50			pinctrl-names = "default";
51			pinctrl-0 = <&csi_mclk_pin>;
52			clocks = <&ccu CLK_CSI_MCLK>;
53			clock-names = "xclk";
54
55			AVDD-supply = <&reg_dldo3>;
56			DOVDD-supply = <&reg_aldo1>;
57			DVDD-supply = <&reg_eldo3>;
58			reset-gpios = <&pio 4 14 GPIO_ACTIVE_LOW>; /* PE14 */
59			powerdown-gpios = <&pio 4 15 GPIO_ACTIVE_HIGH>; /* PE15 */
60
61			port {
62				ov5640_ep: endpoint {
63					remote-endpoint = <&csi_ep>;
64					bus-width = <8>;
65					hsync-active = <1>; /* Active high */
66					vsync-active = <0>; /* Active low */
67					data-active = <1>;  /* Active high */
68					pclk-sample = <1>;  /* Rising */
69				};
70			};
71		};
72	};
73
74	speaker_amp: audio-amplifier {
75		compatible = "simple-audio-amplifier";
76		enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */
77		sound-name-prefix = "Speaker Amp";
78	};
79
80	vdd_bl: regulator@0 {
81		compatible = "regulator-fixed";
82		regulator-name = "bl-3v3";
83		regulator-min-microvolt = <3300000>;
84		regulator-max-microvolt = <3300000>;
85		gpio = <&pio 7 6 GPIO_ACTIVE_HIGH>; /* PH6 */
86		enable-active-high;
87	};
88
89	wifi_pwrseq: wifi_pwrseq {
90		compatible = "mmc-pwrseq-simple";
91		reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 */
92		post-power-on-delay-ms = <200>;
93	};
94};
95
96&codec {
97	status = "okay";
98};
99
100&codec_analog {
101	cpvdd-supply = <&reg_eldo1>;
102	status = "okay";
103};
104
105&cpu0 {
106	cpu-supply = <&reg_dcdc2>;
107};
108
109&cpu1 {
110	cpu-supply = <&reg_dcdc2>;
111};
112
113&cpu2 {
114	cpu-supply = <&reg_dcdc2>;
115};
116
117&cpu3 {
118	cpu-supply = <&reg_dcdc2>;
119};
120
121&csi {
122	status = "okay";
123
124	port {
125		csi_ep: endpoint {
126			remote-endpoint = <&ov5640_ep>;
127			bus-width = <8>;
128			hsync-active = <1>; /* Active high */
129			vsync-active = <0>; /* Active low */
130			data-active = <1>;  /* Active high */
131			pclk-sample = <1>;  /* Rising */
132		};
133	};
134};
135
136&dai {
137	status = "okay";
138};
139
140&de {
141	status = "okay";
142};
143
144&dphy {
145	status = "okay";
146};
147
148&dsi {
149	vcc-dsi-supply = <&reg_dldo1>;
150	status = "okay";
151
152	panel@0 {
153		compatible = "feixin,k101-im2ba02";
154		reg = <0>;
155		avdd-supply = <&reg_dc1sw>;
156		dvdd-supply = <&reg_dc1sw>;
157		cvdd-supply = <&reg_ldo_io1>;
158		reset-gpios = <&pio 3 24 GPIO_ACTIVE_HIGH>; /* PD24 */
159		backlight = <&backlight>;
160	};
161};
162
163&ehci0 {
164	status = "okay";
165};
166
167&ehci1 {
168	status = "okay";
169};
170
171&i2c0 {
172	status = "okay";
173
174	touchscreen@5d {
175		compatible = "goodix,gt9271";
176		reg = <0x5d>;
177		interrupt-parent = <&pio>;
178		interrupts = <7 4 IRQ_TYPE_LEVEL_HIGH>; /* PH4 */
179		irq-gpios = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */
180		reset-gpios = <&pio 7 8 GPIO_ACTIVE_HIGH>; /* PH8 */
181		AVDD28-supply = <&reg_ldo_io1>;
182	};
183};
184
185&i2c0_pins {
186	bias-pull-up;
187};
188
189&i2c1 {
190	status = "okay";
191
192	/* TODO: add Bochs BMA223 accelerometer here */
193};
194
195&lradc {
196	vref-supply = <&reg_aldo3>;
197	status = "okay";
198
199	button-200 {
200		label = "Volume Up";
201		linux,code = <KEY_VOLUMEUP>;
202		channel = <0>;
203		voltage = <200000>;
204	};
205
206	button-400 {
207		label = "Volume Down";
208		linux,code = <KEY_VOLUMEDOWN>;
209		channel = <0>;
210		voltage = <400000>;
211	};
212};
213
214&mixer1 {
215	status = "okay";
216};
217
218&mmc0 {
219	pinctrl-names = "default";
220	pinctrl-0 = <&mmc0_pins>;
221	vmmc-supply = <&reg_dcdc1>;
222	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;
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_dldo4>;
232	vqmmc-supply = <&reg_eldo1>;
233	mmc-pwrseq = <&wifi_pwrseq>;
234	bus-width = <4>;
235	non-removable;
236	status = "okay";
237
238	rtl8723cs: wifi@1 {
239		reg = <1>;
240	};
241};
242
243&mmc2 {
244	pinctrl-names = "default";
245	pinctrl-0 = <&mmc2_pins>;
246	vmmc-supply = <&reg_dcdc1>;
247	vqmmc-supply = <&reg_dcdc1>;
248	bus-width = <8>;
249	non-removable;
250	cap-mmc-hw-reset;
251	status = "okay";
252};
253
254&ohci0 {
255	status = "okay";
256};
257
258&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		x-powers,drive-vbus-en;
271	};
272};
273
274#include "axp803.dtsi"
275
276&ac_power_supply {
277	status = "okay";
278};
279
280&battery_power_supply {
281	status = "okay";
282};
283
284&reg_aldo1 {
285	regulator-min-microvolt = <2800000>;
286	regulator-max-microvolt = <2800000>;
287	regulator-name = "dovdd-csi";
288};
289
290&reg_aldo2 {
291	regulator-always-on;
292	regulator-min-microvolt = <1800000>;
293	regulator-max-microvolt = <3300000>;
294	regulator-name = "vcc-pl";
295};
296
297&reg_aldo3 {
298	regulator-always-on;
299	regulator-min-microvolt = <2700000>;
300	regulator-max-microvolt = <3300000>;
301	regulator-name = "vcc-pll-avcc";
302};
303
304&reg_dc1sw {
305	regulator-name = "vcc-lcd";
306};
307
308&reg_dcdc1 {
309	regulator-always-on;
310	regulator-min-microvolt = <3300000>;
311	regulator-max-microvolt = <3300000>;
312	regulator-name = "vcc-3v3";
313};
314
315&reg_dcdc2 {
316	regulator-always-on;
317	regulator-min-microvolt = <1000000>;
318	regulator-max-microvolt = <1300000>;
319	regulator-name = "vdd-cpux";
320};
321
322/* DCDC3 is polyphased with DCDC2 */
323
324&reg_dcdc5 {
325	regulator-always-on;
326	regulator-min-microvolt = <1200000>;
327	regulator-max-microvolt = <1200000>;
328	regulator-name = "vcc-dram";
329};
330
331&reg_dcdc6 {
332	regulator-always-on;
333	regulator-min-microvolt = <1100000>;
334	regulator-max-microvolt = <1100000>;
335	regulator-name = "vdd-sys";
336};
337
338&reg_dldo1 {
339	regulator-always-on;
340	regulator-min-microvolt = <3300000>;
341	regulator-max-microvolt = <3300000>;
342	regulator-name = "vcc-hdmi-dsi-sensor";
343};
344
345&reg_dldo3 {
346	regulator-min-microvolt = <2800000>;
347	regulator-max-microvolt = <2800000>;
348	regulator-name = "avdd-csi";
349};
350
351&reg_dldo4 {
352	regulator-min-microvolt = <3300000>;
353	regulator-max-microvolt = <3300000>;
354	regulator-name = "vcc-wifi";
355};
356
357&reg_drivevbus {
358	regulator-name = "usb0-vbus";
359	status = "okay";
360};
361
362&reg_eldo1 {
363	regulator-always-on;
364	regulator-min-microvolt = <1800000>;
365	regulator-max-microvolt = <1800000>;
366	regulator-name = "cpvdd";
367};
368
369&reg_eldo2 {
370	regulator-min-microvolt = <1800000>;
371	regulator-max-microvolt = <1800000>;
372	regulator-name = "vcca-1v8";
373};
374
375&reg_eldo3 {
376	regulator-min-microvolt = <1800000>;
377	regulator-max-microvolt = <1800000>;
378	regulator-name = "dvdd-1v8-csi";
379};
380
381&reg_fldo1 {
382	regulator-min-microvolt = <1200000>;
383	regulator-max-microvolt = <1200000>;
384	regulator-name = "vcc-1v2-hsic";
385};
386
387&reg_fldo2 {
388	regulator-always-on;
389	regulator-min-microvolt = <1100000>;
390	regulator-max-microvolt = <1100000>;
391	regulator-name = "vdd-cpus";
392};
393
394&reg_ldo_io0 {
395	regulator-min-microvolt = <3300000>;
396	regulator-max-microvolt = <3300000>;
397	regulator-name = "vcc-usb";
398	status = "okay";
399};
400
401&reg_ldo_io1 {
402	regulator-min-microvolt = <3300000>;
403	regulator-max-microvolt = <3300000>;
404	regulator-enable-ramp-delay = <3500000>;
405	regulator-name = "vcc-touchscreen";
406	status = "okay";
407};
408
409&reg_rtc_ldo {
410	regulator-name = "vcc-rtc";
411};
412
413&sound {
414	status = "okay";
415	simple-audio-card,aux-devs = <&codec_analog>, <&speaker_amp>;
416	simple-audio-card,widgets = "Microphone", "Internal Microphone Left",
417				    "Microphone", "Internal Microphone Right",
418				    "Headphone", "Headphone Jack",
419				    "Speaker", "Internal Speaker";
420	simple-audio-card,routing =
421			"Left DAC", "DACL",
422			"Right DAC", "DACR",
423			"Speaker Amp INL", "LINEOUT",
424			"Speaker Amp INR", "LINEOUT",
425			"Internal Speaker", "Speaker Amp OUTL",
426			"Internal Speaker", "Speaker Amp OUTR",
427			"Headphone Jack", "HP",
428			"ADCL", "Left ADC",
429			"ADCR", "Right ADC",
430			"Internal Microphone Left", "MBIAS",
431			"MIC1", "Internal Microphone Left",
432			"Internal Microphone Right", "HBIAS",
433			"MIC2", "Internal Microphone Right";
434};
435
436&uart0 {
437	pinctrl-names = "default";
438	pinctrl-0 = <&uart0_pb_pins>;
439	status = "okay";
440};
441
442&usb_otg {
443	dr_mode = "otg";
444	status = "okay";
445};
446
447&usb_power_supply {
448	status = "okay";
449};
450
451&usbphy {
452	usb0_id_det-gpios = <&pio 7 9 GPIO_ACTIVE_HIGH>; /* PH9 */
453	usb0_vbus_power-supply = <&usb_power_supply>;
454	usb0_vbus-supply = <&reg_drivevbus>;
455	usb1_vbus-supply = <&reg_ldo_io0>;
456	status = "okay";
457};
458