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";
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		#address-cells = <1>;
126		#size-cells = <0>;
127
128		csi_ep: endpoint {
129			remote-endpoint = <&ov5640_ep>;
130			bus-width = <8>;
131			hsync-active = <1>; /* Active high */
132			vsync-active = <0>; /* Active low */
133			data-active = <1>;  /* Active high */
134			pclk-sample = <1>;  /* Rising */
135		};
136	};
137};
138
139&dai {
140	status = "okay";
141};
142
143&de {
144	status = "okay";
145};
146
147&dphy {
148	status = "okay";
149};
150
151&dsi {
152	vcc-dsi-supply = <&reg_dldo1>;
153	status = "okay";
154
155	panel@0 {
156		compatible = "feixin,k101-im2ba02";
157		reg = <0>;
158		avdd-supply = <&reg_dc1sw>;
159		dvdd-supply = <&reg_dc1sw>;
160		cvdd-supply = <&reg_ldo_io1>;
161		reset-gpios = <&pio 3 24 GPIO_ACTIVE_HIGH>; /* PD24 */
162		backlight = <&backlight>;
163	};
164};
165
166&ehci0 {
167	status = "okay";
168};
169
170&ehci1 {
171	status = "okay";
172};
173
174&i2c0 {
175	status = "okay";
176
177	touchscreen@5d {
178		compatible = "goodix,gt9271";
179		reg = <0x5d>;
180		interrupt-parent = <&pio>;
181		interrupts = <7 4 IRQ_TYPE_LEVEL_HIGH>; /* PH4 */
182		irq-gpios = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */
183		reset-gpios = <&pio 7 8 GPIO_ACTIVE_HIGH>; /* PH8 */
184		AVDD28-supply = <&reg_ldo_io1>;
185	};
186};
187
188&i2c0_pins {
189	bias-pull-up;
190};
191
192&i2c1 {
193	status = "okay";
194
195	/* TODO: add Bochs BMA223 accelerometer here */
196};
197
198&lradc {
199	vref-supply = <&reg_aldo3>;
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&mixer1 {
218	status = "okay";
219};
220
221&mmc0 {
222	pinctrl-names = "default";
223	pinctrl-0 = <&mmc0_pins>;
224	vmmc-supply = <&reg_dcdc1>;
225	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;
226	disable-wp;
227	bus-width = <4>;
228	status = "okay";
229};
230
231&mmc1 {
232	pinctrl-names = "default";
233	pinctrl-0 = <&mmc1_pins>;
234	vmmc-supply = <&reg_dldo4>;
235	vqmmc-supply = <&reg_eldo1>;
236	mmc-pwrseq = <&wifi_pwrseq>;
237	bus-width = <4>;
238	non-removable;
239	status = "okay";
240
241	rtl8723cs: wifi@1 {
242		reg = <1>;
243	};
244};
245
246&mmc2 {
247	pinctrl-names = "default";
248	pinctrl-0 = <&mmc2_pins>;
249	vmmc-supply = <&reg_dcdc1>;
250	vqmmc-supply = <&reg_dcdc1>;
251	bus-width = <8>;
252	non-removable;
253	cap-mmc-hw-reset;
254	status = "okay";
255};
256
257&ohci0 {
258	status = "okay";
259};
260
261&pwm {
262	status = "okay";
263};
264
265&r_rsb {
266	status = "okay";
267
268	axp803: pmic@3a3 {
269		compatible = "x-powers,axp803";
270		reg = <0x3a3>;
271		interrupt-parent = <&r_intc>;
272		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
273		x-powers,drive-vbus-en;
274	};
275};
276
277#include "axp803.dtsi"
278
279&ac_power_supply {
280	status = "okay";
281};
282
283&battery_power_supply {
284	status = "okay";
285};
286
287&reg_aldo1 {
288	regulator-min-microvolt = <2800000>;
289	regulator-max-microvolt = <2800000>;
290	regulator-name = "dovdd-csi";
291};
292
293&reg_aldo2 {
294	regulator-always-on;
295	regulator-min-microvolt = <1800000>;
296	regulator-max-microvolt = <3300000>;
297	regulator-name = "vcc-pl";
298};
299
300&reg_aldo3 {
301	regulator-always-on;
302	regulator-min-microvolt = <2700000>;
303	regulator-max-microvolt = <3300000>;
304	regulator-name = "vcc-pll-avcc";
305};
306
307&reg_dc1sw {
308	regulator-name = "vcc-lcd";
309};
310
311&reg_dcdc1 {
312	regulator-always-on;
313	regulator-min-microvolt = <3300000>;
314	regulator-max-microvolt = <3300000>;
315	regulator-name = "vcc-3v3";
316};
317
318&reg_dcdc2 {
319	regulator-always-on;
320	regulator-min-microvolt = <1000000>;
321	regulator-max-microvolt = <1300000>;
322	regulator-name = "vdd-cpux";
323};
324
325/* DCDC3 is polyphased with DCDC2 */
326
327&reg_dcdc5 {
328	regulator-always-on;
329	regulator-min-microvolt = <1200000>;
330	regulator-max-microvolt = <1200000>;
331	regulator-name = "vcc-dram";
332};
333
334&reg_dcdc6 {
335	regulator-always-on;
336	regulator-min-microvolt = <1100000>;
337	regulator-max-microvolt = <1100000>;
338	regulator-name = "vdd-sys";
339};
340
341&reg_dldo1 {
342	regulator-always-on;
343	regulator-min-microvolt = <3300000>;
344	regulator-max-microvolt = <3300000>;
345	regulator-name = "vcc-hdmi-dsi-sensor";
346};
347
348&reg_dldo3 {
349	regulator-min-microvolt = <2800000>;
350	regulator-max-microvolt = <2800000>;
351	regulator-name = "avdd-csi";
352};
353
354&reg_dldo4 {
355	regulator-min-microvolt = <3300000>;
356	regulator-max-microvolt = <3300000>;
357	regulator-name = "vcc-wifi";
358};
359
360&reg_drivevbus {
361	regulator-name = "usb0-vbus";
362	status = "okay";
363};
364
365&reg_eldo1 {
366	regulator-always-on;
367	regulator-min-microvolt = <1800000>;
368	regulator-max-microvolt = <1800000>;
369	regulator-name = "cpvdd";
370};
371
372&reg_eldo2 {
373	regulator-min-microvolt = <1800000>;
374	regulator-max-microvolt = <1800000>;
375	regulator-name = "vcca-1v8";
376};
377
378&reg_eldo3 {
379	regulator-min-microvolt = <1800000>;
380	regulator-max-microvolt = <1800000>;
381	regulator-name = "dvdd-1v8-csi";
382};
383
384&reg_fldo1 {
385	regulator-min-microvolt = <1200000>;
386	regulator-max-microvolt = <1200000>;
387	regulator-name = "vcc-1v2-hsic";
388};
389
390&reg_fldo2 {
391	regulator-always-on;
392	regulator-min-microvolt = <1100000>;
393	regulator-max-microvolt = <1100000>;
394	regulator-name = "vdd-cpus";
395};
396
397&reg_ldo_io0 {
398	regulator-min-microvolt = <3300000>;
399	regulator-max-microvolt = <3300000>;
400	regulator-name = "vcc-usb";
401	status = "okay";
402};
403
404&reg_ldo_io1 {
405	regulator-min-microvolt = <3300000>;
406	regulator-max-microvolt = <3300000>;
407	regulator-enable-ramp-delay = <3500000>;
408	regulator-name = "vcc-touchscreen";
409	status = "okay";
410};
411
412&reg_rtc_ldo {
413	regulator-name = "vcc-rtc";
414};
415
416&sound {
417	status = "okay";
418	simple-audio-card,aux-devs = <&codec_analog>, <&speaker_amp>;
419	simple-audio-card,widgets = "Microphone", "Internal Microphone Left",
420				    "Microphone", "Internal Microphone Right",
421				    "Headphone", "Headphone Jack",
422				    "Speaker", "Internal Speaker";
423	simple-audio-card,routing =
424			"Left DAC", "AIF1 Slot 0 Left",
425			"Right DAC", "AIF1 Slot 0 Right",
426			"Speaker Amp INL", "LINEOUT",
427			"Speaker Amp INR", "LINEOUT",
428			"Internal Speaker", "Speaker Amp OUTL",
429			"Internal Speaker", "Speaker Amp OUTR",
430			"Headphone Jack", "HP",
431			"AIF1 Slot 0 Left ADC", "Left ADC",
432			"AIF1 Slot 0 Right ADC", "Right ADC",
433			"Internal Microphone Left", "MBIAS",
434			"MIC1", "Internal Microphone Left",
435			"Internal Microphone Right", "HBIAS",
436			"MIC2", "Internal Microphone Right";
437};
438
439&uart0 {
440	pinctrl-names = "default";
441	pinctrl-0 = <&uart0_pb_pins>;
442	status = "okay";
443};
444
445&usb_otg {
446	dr_mode = "otg";
447	status = "okay";
448};
449
450&usb_power_supply {
451	status = "okay";
452};
453
454&usbphy {
455	usb0_id_det-gpios = <&pio 7 9 GPIO_ACTIVE_HIGH>; /* PH9 */
456	usb0_vbus_power-supply = <&usb_power_supply>;
457	usb0_vbus-supply = <&reg_drivevbus>;
458	usb1_vbus-supply = <&reg_ldo_io0>;
459	status = "okay";
460};
461