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