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