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
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: wifi_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&i2c1 {
168	clock-frequency = <400000>;
169	status = "okay";
170
171	accelerometer@18 {
172		compatible = "bosch,bma250";
173		reg = <0x18>;
174		interrupt-parent = <&pio>;
175		interrupts = <7 10 IRQ_TYPE_EDGE_RISING>; /* PH10 / EINT10 */
176	};
177};
178
179&mmc0 {
180	vmmc-supply = <&reg_dcdc1>;
181	pinctrl-names = "default";
182	pinctrl-0 = <&mmc0_pins>;
183	bus-width = <4>;
184	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;
185	status = "okay";
186};
187
188&mmc1 {
189	mmc-pwrseq = <&wifi_pwrseq>;
190	bus-width = <4>;
191	vmmc-supply = <&reg_dldo1>;
192	vqmmc-supply = <&reg_dldo1>;
193	non-removable;
194	wakeup-source;
195	keep-power-in-suspend;
196	status = "okay";
197
198	brcmf: wifi@1 {
199		reg = <1>;
200		compatible = "brcm,bcm4329-fmac";
201		interrupt-parent = <&r_pio>;
202		interrupts = <0 3 IRQ_TYPE_LEVEL_LOW>; /* PL3 WL_WAKE_UP */
203		interrupt-names = "host-wake";
204	};
205};
206
207&mmc2 {
208	pinctrl-0 = <&mmc2_8bit_emmc_pins>;
209	pinctrl-names = "default";
210	vmmc-supply = <&reg_dcdc1>;
211	vqmmc-supply = <&reg_dcdc1>;
212	bus-width = <8>;
213	non-removable;
214	cap-mmc-hw-reset;
215	status = "okay";
216};
217
218&pwm {
219	pinctrl-names = "default";
220	pinctrl-0 = <&pwm_pin>;
221	status = "okay";
222};
223
224&r_lradc {
225	vref-supply = <&reg_aldo2>;
226	status = "okay";
227
228	button-210 {
229		label = "Volume Up";
230		linux,code = <KEY_VOLUMEUP>;
231		channel = <0>;
232		voltage = <210000>;
233	};
234
235	button-410 {
236		label = "Volume Down";
237		linux,code = <KEY_VOLUMEDOWN>;
238		channel = <0>;
239		voltage = <410000>;
240	};
241};
242
243&r_rsb {
244	status = "okay";
245
246	axp81x: pmic@3a3 {
247		compatible = "x-powers,axp813";
248		reg = <0x3a3>;
249		interrupt-parent = <&r_intc>;
250		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
251		swin-supply = <&reg_dcdc1>;
252		x-powers,drive-vbus-en;
253	};
254
255	ac100: codec@e89 {
256		compatible = "x-powers,ac100";
257		reg = <0xe89>;
258
259		ac100_codec: codec {
260			compatible = "x-powers,ac100-codec";
261			interrupt-parent = <&r_pio>;
262			interrupts = <0 12 IRQ_TYPE_LEVEL_LOW>; /* PL12 */
263			#clock-cells = <0>;
264			clock-output-names = "4M_adda";
265		};
266
267		ac100_rtc: rtc {
268			compatible = "x-powers,ac100-rtc";
269			interrupt-parent = <&r_intc>;
270			interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
271			clocks = <&ac100_codec>;
272			#clock-cells = <1>;
273			clock-output-names = "cko1_rtc",
274					     "cko2_rtc",
275					     "cko3_rtc";
276		};
277	};
278
279};
280
281#include "axp81x.dtsi"
282
283&battery_power_supply {
284	status = "okay";
285};
286
287&reg_aldo1 {
288	regulator-min-microvolt = <1800000>;
289	regulator-max-microvolt = <1800000>;
290	regulator-name = "vcc-1.8";
291};
292
293&reg_aldo2 {
294	regulator-min-microvolt = <1800000>;
295	regulator-max-microvolt = <1800000>;
296	regulator-always-on;
297	regulator-name = "vdd-drampll";
298};
299
300&reg_aldo3 {
301	regulator-min-microvolt = <3000000>;
302	regulator-max-microvolt = <3000000>;
303	regulator-always-on;
304	regulator-name = "avcc";
305};
306
307&reg_dcdc1 {
308	regulator-min-microvolt = <3100000>;
309	regulator-max-microvolt = <3100000>;
310	regulator-always-on;
311	regulator-name = "vcc-io";
312};
313
314&reg_dcdc2 {
315	regulator-min-microvolt = <700000>;
316	regulator-max-microvolt = <1100000>;
317	regulator-always-on;
318	regulator-name = "vdd-cpu-A";
319};
320
321&reg_dcdc3 {
322	regulator-min-microvolt = <700000>;
323	regulator-max-microvolt = <1100000>;
324	regulator-always-on;
325	regulator-name = "vdd-cpu-B";
326};
327
328&reg_dcdc4 {
329	regulator-min-microvolt = <700000>;
330	regulator-max-microvolt = <1100000>;
331	regulator-name = "vdd-gpu";
332};
333
334&reg_dcdc5 {
335	regulator-min-microvolt = <1200000>;
336	regulator-max-microvolt = <1500000>;
337	regulator-always-on;
338	regulator-name = "vcc-dram";
339};
340
341&reg_dcdc6 {
342	regulator-min-microvolt = <900000>;
343	regulator-max-microvolt = <900000>;
344	regulator-always-on;
345	regulator-name = "vdd-sys";
346};
347
348&reg_dldo1 {
349	regulator-min-microvolt = <3100000>;
350	regulator-max-microvolt = <3100000>;
351	regulator-name = "vcc-wifi-io";
352};
353
354&reg_dldo2 {
355	regulator-min-microvolt = <2800000>;
356	regulator-max-microvolt = <4200000>;
357	regulator-name = "vcc-mipi";
358};
359
360&reg_dldo3 {
361	regulator-min-microvolt = <2800000>;
362	regulator-max-microvolt = <2800000>;
363	regulator-name = "vdd-csi";
364};
365
366&reg_dldo4 {
367	regulator-min-microvolt = <2800000>;
368	regulator-max-microvolt = <2800000>;
369	regulator-name = "avdd-csi";
370};
371
372&reg_drivevbus {
373	regulator-name = "usb0-vbus";
374	status = "okay";
375};
376
377&reg_eldo1 {
378	regulator-min-microvolt = <1200000>;
379	regulator-max-microvolt = <1800000>;
380	regulator-name = "dvdd-csi-r";
381};
382
383&reg_eldo2 {
384	regulator-min-microvolt = <1800000>;
385	regulator-max-microvolt = <1800000>;
386	regulator-name = "vcc-dsi";
387};
388
389&reg_eldo3 {
390	regulator-min-microvolt = <1200000>;
391	regulator-max-microvolt = <1800000>;
392	regulator-name = "dvdd-csi-f";
393};
394
395&reg_fldo1 {
396	regulator-min-microvolt = <1200000>;
397	regulator-max-microvolt = <1200000>;
398	regulator-name = "vcc-hsic";
399};
400
401&reg_fldo2 {
402	regulator-min-microvolt = <700000>;
403	regulator-max-microvolt = <1100000>;
404	regulator-always-on;
405	regulator-name = "vdd-cpus";
406};
407
408&reg_ldo_io0 {
409	regulator-min-microvolt = <3100000>;
410	regulator-max-microvolt = <3100000>;
411	regulator-name = "vcc-ctp";
412	status = "okay";
413};
414
415&reg_ldo_io1 {
416	regulator-min-microvolt = <3100000>;
417	regulator-max-microvolt = <3100000>;
418	regulator-name = "vcc-vb";
419	status = "okay";
420};
421
422&reg_sw {
423	regulator-min-microvolt = <3100000>;
424	regulator-max-microvolt = <3100000>;
425	regulator-name = "vcc-lcd";
426};
427
428&tcon0 {
429	pinctrl-names = "default";
430	pinctrl-0 = <&lcd_lvds_pins>;
431};
432
433&tcon0_out {
434	tcon0_out_lcd: endpoint {
435		remote-endpoint = <&panel_input>;
436	};
437};
438
439&uart0 {
440	pinctrl-names = "default";
441	pinctrl-0 = <&uart0_pb_pins>;
442	status = "okay";
443};
444
445/* There's the BT part of the AP6210 connected to that UART */
446&uart1 {
447	pinctrl-names = "default";
448	pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
449	uart-has-rtscts;
450	status = "okay";
451
452	bluetooth {
453		compatible = "brcm,bcm20702a1";
454		clocks = <&ac100_rtc 1>;
455		clock-names = "lpo";
456		vbat-supply = <&reg_vbat>;
457		vddio-supply = <&reg_dldo1>;
458		device-wakeup-gpios = <&pio 7 5 GPIO_ACTIVE_HIGH>; /* PH5 */
459		host-wakeup-gpios = <&r_pio 0 5 GPIO_ACTIVE_HIGH>; /* PL5 */
460		shutdown-gpios = <&r_pio 0 4 GPIO_ACTIVE_HIGH>; /* PL4 */
461		max-speed = <1500000>;
462	};
463};
464
465&uart2 {
466	pinctrl-names = "default";
467	pinctrl-0 = <&uart2_pb_pins>;
468	status = "okay";
469
470	gnss {
471		compatible = "u-blox,neo-6m";
472
473		v-bckp-supply = <&reg_rtc_ldo>;
474		vcc-supply = <&reg_gps>;
475		current-speed = <9600>;
476	};
477};
478
479&usb_otg {
480	dr_mode = "otg";
481	status = "okay";
482};
483
484&usbphy {
485	usb0_id_det-gpios = <&pio 7 11 GPIO_ACTIVE_HIGH>; /* PH11 */
486	usb0_vbus-supply = <&reg_drivevbus>;
487	usb1_vbus-supply = <&reg_vmain>;
488	usb2_vbus-supply = <&reg_vmain>;
489	status = "okay";
490};
491