1/*
2 * Copyright (C) 2017 Touchless Biometric Systems AG
3 * Tomas Novotny <tomas@novotny.cz>
4 *
5 * This file is dual-licensed: you can use it either under the terms
6 * of the GPL or the X11 license, at your option. Note that this dual
7 * licensing only applies to this file, and not this project as a
8 * whole.
9 *
10 *  a) This file is free software; you can redistribute it and/or
11 *     modify it under the terms of the GNU General Public License as
12 *     published by the Free Software Foundation; either version 2 of the
13 *     License, or (at your option) any later version.
14 *
15 *     This file is distributed in the hope that it will be useful,
16 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
17 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 *     GNU General Public License for more details.
19 *
20 * Or, alternatively,
21 *
22 *  b) Permission is hereby granted, free of charge, to any person
23 *     obtaining a copy of this software and associated documentation
24 *     files (the "Software"), to deal in the Software without
25 *     restriction, including without limitation the rights to use,
26 *     copy, modify, merge, publish, distribute, sublicense, and/or
27 *     sell copies of the Software, and to permit persons to whom the
28 *     Software is furnished to do so, subject to the following
29 *     conditions:
30 *
31 *     The above copyright notice and this permission notice shall be
32 *     included in all copies or substantial portions of the Software.
33 *
34 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
36 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
38 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
39 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
40 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
41 *     OTHER DEALINGS IN THE SOFTWARE.
42 */
43
44/dts-v1/;
45#include "sun8i-a83t.dtsi"
46
47#include <dt-bindings/gpio/gpio.h>
48#include <dt-bindings/pwm/pwm.h>
49#include <dt-bindings/input/input.h>
50
51/ {
52	model = "TBS A711 Tablet";
53	compatible = "tbs-biometrics,a711", "allwinner,sun8i-a83t";
54
55	aliases {
56		serial0 = &uart0;
57		serial1 = &uart1;
58	};
59
60	chosen {
61		stdout-path = "serial0:115200n8";
62	};
63
64	backlight: backlight {
65		compatible = "pwm-backlight";
66		pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>;
67		enable-gpios = <&pio 3 29 GPIO_ACTIVE_HIGH>;
68		power-supply = <&reg_sw>;
69		brightness-levels = <0 1 2 4 8 16 32 64 128 255>;
70		default-brightness-level = <9>;
71	};
72
73	panel {
74		compatible = "tbs,a711-panel", "panel-lvds";
75		backlight = <&backlight>;
76		power-supply = <&reg_sw>;
77
78		width-mm = <153>;
79		height-mm = <90>;
80		data-mapping = "vesa-24";
81
82		panel-timing {
83			/* 1024x600 @60Hz */
84			clock-frequency = <52000000>;
85			hactive = <1024>;
86			vactive = <600>;
87			hsync-len = <20>;
88			hfront-porch = <180>;
89			hback-porch = <160>;
90			vfront-porch = <12>;
91			vback-porch = <23>;
92			vsync-len = <5>;
93		};
94
95		port {
96			panel_input: endpoint {
97				remote-endpoint = <&tcon0_out_lcd>;
98			};
99		};
100	};
101
102	reg_gps: reg-gps {
103		compatible = "regulator-fixed";
104		regulator-name = "gps";
105		regulator-min-microvolt = <3000000>;
106		regulator-max-microvolt = <3000000>;
107	};
108
109	reg_vbat: reg-vbat {
110		compatible = "regulator-fixed";
111		regulator-name = "vbat";
112		regulator-min-microvolt = <3700000>;
113		regulator-max-microvolt = <3700000>;
114	};
115
116	reg_vmain: reg-vmain {
117		compatible = "regulator-fixed";
118		regulator-name = "vmain";
119		regulator-min-microvolt = <5000000>;
120		regulator-max-microvolt = <5000000>;
121		gpio = <&r_pio 0 9 GPIO_ACTIVE_HIGH>;
122		enable-active-high;
123		vin-supply = <&reg_vbat>;
124	};
125
126	wifi_pwrseq: pwrseq {
127		compatible = "mmc-pwrseq-simple";
128		reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 WL-PMU-EN */
129
130		/*
131		 * This is actually Bluetooth's clock, but we have to
132		 * hook it up somewheere
133		 */
134		clocks = <&ac100_rtc 1>;
135		clock-names = "ext_clock";
136	};
137};
138
139&cpu0 {
140	cpu-supply = <&reg_dcdc2>;
141};
142
143&cpu100 {
144	cpu-supply = <&reg_dcdc3>;
145};
146
147&de {
148	status = "okay";
149};
150
151/*
152 * An USB-2 hub is connected here, which also means we don't need to
153 * enable the OHCI controller.
154 */
155&ehci0 {
156	status = "okay";
157};
158
159/*
160 * There's a modem connected here that needs to be initialised before
161 * being able to be enumerated.
162 */
163&ehci1 {
164	status = "okay";
165};
166
167&i2c0 {
168	clock-frequency = <400000>;
169	status = "okay";
170
171	touchscreen@38 {
172		compatible = "edt,edt-ft5206";
173		reg = <0x38>;
174		interrupt-parent = <&r_pio>;
175		interrupts = <0 7 IRQ_TYPE_EDGE_FALLING>; /* PL7 */
176		reset-gpios = <&pio 3 5 GPIO_ACTIVE_LOW>; /* PD5 */
177		vcc-supply = <&reg_ldo_io0>;
178		touchscreen-size-x = <1024>;
179		touchscreen-size-y = <600>;
180	};
181};
182
183&i2c1 {
184	clock-frequency = <400000>;
185	status = "okay";
186
187	accelerometer@18 {
188		compatible = "bosch,bma250";
189		reg = <0x18>;
190		interrupt-parent = <&pio>;
191		interrupts = <7 10 IRQ_TYPE_EDGE_RISING>; /* PH10 / EINT10 */
192	};
193};
194
195&mmc0 {
196	vmmc-supply = <&reg_dcdc1>;
197	pinctrl-names = "default";
198	pinctrl-0 = <&mmc0_pins>;
199	bus-width = <4>;
200	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;
201	status = "okay";
202};
203
204&mmc1 {
205	mmc-pwrseq = <&wifi_pwrseq>;
206	bus-width = <4>;
207	vmmc-supply = <&reg_dldo1>;
208	vqmmc-supply = <&reg_dldo1>;
209	non-removable;
210	wakeup-source;
211	keep-power-in-suspend;
212	status = "okay";
213
214	brcmf: wifi@1 {
215		reg = <1>;
216		compatible = "brcm,bcm4329-fmac";
217		interrupt-parent = <&r_pio>;
218		interrupts = <0 3 IRQ_TYPE_LEVEL_LOW>; /* PL3 WL_WAKE_UP */
219		interrupt-names = "host-wake";
220	};
221};
222
223&mmc2 {
224	pinctrl-0 = <&mmc2_8bit_emmc_pins>;
225	pinctrl-names = "default";
226	vmmc-supply = <&reg_dcdc1>;
227	vqmmc-supply = <&reg_dcdc1>;
228	bus-width = <8>;
229	non-removable;
230	cap-mmc-hw-reset;
231	status = "okay";
232};
233
234&pwm {
235	pinctrl-names = "default";
236	pinctrl-0 = <&pwm_pin>;
237	status = "okay";
238};
239
240&r_lradc {
241	vref-supply = <&reg_aldo2>;
242	status = "okay";
243
244	button-210 {
245		label = "Volume Up";
246		linux,code = <KEY_VOLUMEUP>;
247		channel = <0>;
248		voltage = <210000>;
249	};
250
251	button-410 {
252		label = "Volume Down";
253		linux,code = <KEY_VOLUMEDOWN>;
254		channel = <0>;
255		voltage = <410000>;
256	};
257};
258
259&r_rsb {
260	status = "okay";
261
262	axp81x: pmic@3a3 {
263		compatible = "x-powers,axp813";
264		reg = <0x3a3>;
265		interrupt-parent = <&r_intc>;
266		interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_LOW>;
267		swin-supply = <&reg_dcdc1>;
268		x-powers,drive-vbus-en;
269	};
270
271	ac100: codec@e89 {
272		compatible = "x-powers,ac100";
273		reg = <0xe89>;
274
275		ac100_codec: codec {
276			compatible = "x-powers,ac100-codec";
277			interrupt-parent = <&r_pio>;
278			interrupts = <0 12 IRQ_TYPE_LEVEL_LOW>; /* PL12 */
279			#clock-cells = <0>;
280			clock-output-names = "4M_adda";
281		};
282
283		ac100_rtc: rtc {
284			compatible = "x-powers,ac100-rtc";
285			interrupt-parent = <&r_intc>;
286			interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_LOW>;
287			clocks = <&ac100_codec>;
288			#clock-cells = <1>;
289			clock-output-names = "cko1_rtc",
290					     "cko2_rtc",
291					     "cko3_rtc";
292		};
293	};
294
295};
296
297#include "axp81x.dtsi"
298
299&battery_power_supply {
300	status = "okay";
301};
302
303&reg_aldo1 {
304	regulator-min-microvolt = <1800000>;
305	regulator-max-microvolt = <1800000>;
306	regulator-name = "vcc-1.8";
307};
308
309&reg_aldo2 {
310	regulator-min-microvolt = <1800000>;
311	regulator-max-microvolt = <1800000>;
312	regulator-always-on;
313	regulator-name = "vdd-drampll";
314};
315
316&reg_aldo3 {
317	regulator-min-microvolt = <3000000>;
318	regulator-max-microvolt = <3000000>;
319	regulator-always-on;
320	regulator-name = "avcc";
321};
322
323&reg_dcdc1 {
324	regulator-min-microvolt = <3100000>;
325	regulator-max-microvolt = <3100000>;
326	regulator-always-on;
327	regulator-name = "vcc-io";
328};
329
330&reg_dcdc2 {
331	regulator-min-microvolt = <700000>;
332	regulator-max-microvolt = <1100000>;
333	regulator-always-on;
334	regulator-name = "vdd-cpu-A";
335};
336
337&reg_dcdc3 {
338	regulator-min-microvolt = <700000>;
339	regulator-max-microvolt = <1100000>;
340	regulator-always-on;
341	regulator-name = "vdd-cpu-B";
342};
343
344&reg_dcdc4 {
345	regulator-min-microvolt = <700000>;
346	regulator-max-microvolt = <1100000>;
347	regulator-name = "vdd-gpu";
348};
349
350&reg_dcdc5 {
351	regulator-min-microvolt = <1200000>;
352	regulator-max-microvolt = <1500000>;
353	regulator-always-on;
354	regulator-name = "vcc-dram";
355};
356
357&reg_dcdc6 {
358	regulator-min-microvolt = <900000>;
359	regulator-max-microvolt = <900000>;
360	regulator-always-on;
361	regulator-name = "vdd-sys";
362};
363
364&reg_dldo1 {
365	regulator-min-microvolt = <3100000>;
366	regulator-max-microvolt = <3100000>;
367	regulator-name = "vcc-wifi-io";
368};
369
370&reg_dldo2 {
371	regulator-min-microvolt = <2800000>;
372	regulator-max-microvolt = <4200000>;
373	regulator-name = "vcc-mipi";
374};
375
376&reg_dldo3 {
377	regulator-min-microvolt = <1800000>;
378	regulator-max-microvolt = <1800000>;
379	regulator-name = "vdd-csi";
380};
381
382&reg_dldo4 {
383	regulator-min-microvolt = <2800000>;
384	regulator-max-microvolt = <2800000>;
385	regulator-name = "avdd-csi";
386};
387
388&reg_drivevbus {
389	regulator-name = "usb0-vbus";
390	status = "okay";
391};
392
393&reg_eldo1 {
394	regulator-min-microvolt = <1200000>;
395	regulator-max-microvolt = <1800000>;
396	regulator-name = "dvdd-csi-r";
397};
398
399&reg_eldo2 {
400	regulator-min-microvolt = <1800000>;
401	regulator-max-microvolt = <1800000>;
402	regulator-name = "vcc-dsi";
403};
404
405&reg_eldo3 {
406	regulator-min-microvolt = <1200000>;
407	regulator-max-microvolt = <1800000>;
408	regulator-name = "dvdd-csi-f";
409};
410
411&reg_fldo1 {
412	regulator-min-microvolt = <1200000>;
413	regulator-max-microvolt = <1200000>;
414	regulator-name = "vcc-hsic";
415};
416
417&reg_fldo2 {
418	regulator-min-microvolt = <700000>;
419	regulator-max-microvolt = <1100000>;
420	regulator-always-on;
421	regulator-name = "vdd-cpus";
422};
423
424&reg_ldo_io0 {
425	regulator-min-microvolt = <3100000>;
426	regulator-max-microvolt = <3100000>;
427	regulator-name = "vcc-ctp";
428	status = "okay";
429};
430
431&reg_ldo_io1 {
432	regulator-min-microvolt = <3100000>;
433	regulator-max-microvolt = <3100000>;
434	regulator-name = "vcc-vb";
435	status = "okay";
436};
437
438&reg_sw {
439	regulator-min-microvolt = <3100000>;
440	regulator-max-microvolt = <3100000>;
441	regulator-name = "vcc-lcd";
442};
443
444&tcon0 {
445	pinctrl-names = "default";
446	pinctrl-0 = <&lcd_lvds_pins>;
447};
448
449&tcon0_out {
450	tcon0_out_lcd: endpoint {
451		remote-endpoint = <&panel_input>;
452	};
453};
454
455&uart0 {
456	pinctrl-names = "default";
457	pinctrl-0 = <&uart0_pb_pins>;
458	status = "okay";
459};
460
461/* There's the BT part of the AP6210 connected to that UART */
462&uart1 {
463	pinctrl-names = "default";
464	pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
465	uart-has-rtscts;
466	status = "okay";
467
468	bluetooth {
469		compatible = "brcm,bcm20702a1";
470		clocks = <&ac100_rtc 1>;
471		clock-names = "lpo";
472		vbat-supply = <&reg_vbat>;
473		vddio-supply = <&reg_dldo1>;
474		device-wakeup-gpios = <&pio 7 5 GPIO_ACTIVE_HIGH>; /* PH5 */
475		host-wakeup-gpios = <&r_pio 0 5 GPIO_ACTIVE_HIGH>; /* PL5 */
476		shutdown-gpios = <&r_pio 0 4 GPIO_ACTIVE_HIGH>; /* PL4 */
477		max-speed = <1500000>;
478	};
479};
480
481&uart2 {
482	pinctrl-names = "default";
483	pinctrl-0 = <&uart2_pb_pins>;
484	status = "okay";
485
486	gnss {
487		compatible = "u-blox,neo-6m";
488
489		v-bckp-supply = <&reg_rtc_ldo>;
490		vcc-supply = <&reg_gps>;
491		current-speed = <9600>;
492	};
493};
494
495&usb_otg {
496	status = "okay";
497};
498
499&usbphy {
500	usb0_id_det-gpios = <&pio 7 11 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; /* PH11 */
501	usb0_vbus_power-supply = <&usb_power_supply>;
502	usb0_vbus-supply = <&reg_drivevbus>;
503	usb1_vbus-supply = <&reg_vmain>;
504	usb2_vbus-supply = <&reg_vmain>;
505	status = "okay";
506};
507