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
50/ {
51	model = "TBS A711 Tablet";
52	compatible = "tbs-biometrics,a711", "allwinner,sun8i-a83t";
53
54	aliases {
55		serial0 = &uart0;
56		serial1 = &uart1;
57	};
58
59	chosen {
60		stdout-path = "serial0:115200n8";
61	};
62
63	backlight: backlight {
64		compatible = "pwm-backlight";
65		pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>;
66		enable-gpios = <&pio 3 29 GPIO_ACTIVE_HIGH>;
67
68		brightness-levels = <0 1 2 4 8 16 32 64 128 255>;
69		default-brightness-level = <9>;
70	};
71
72	panel {
73		compatible = "tbs,a711-panel", "panel-lvds";
74		backlight = <&backlight>;
75		power-supply = <&reg_sw>;
76
77		width-mm = <153>;
78		height-mm = <90>;
79		data-mapping = "vesa-24";
80
81		panel-timing {
82			/* 1024x600 @60Hz */
83			clock-frequency = <52000000>;
84			hactive = <1024>;
85			vactive = <600>;
86			hsync-len = <20>;
87			hfront-porch = <180>;
88			hback-porch = <160>;
89			vfront-porch = <12>;
90			vback-porch = <23>;
91			vsync-len = <5>;
92		};
93
94		port {
95			panel_input: endpoint {
96				remote-endpoint = <&tcon0_out_lcd>;
97			};
98		};
99	};
100
101	reg_vbat: reg-vbat {
102		compatible = "regulator-fixed";
103		regulator-name = "vbat";
104		regulator-min-microvolt = <3700000>;
105		regulator-max-microvolt = <3700000>;
106	};
107
108	reg_vmain: reg-vmain {
109		compatible = "regulator-fixed";
110		regulator-name = "vmain";
111		regulator-min-microvolt = <5000000>;
112		regulator-max-microvolt = <5000000>;
113		gpio = <&r_pio 0 9 GPIO_ACTIVE_HIGH>;
114		enable-active-high;
115		vin-supply = <&reg_vbat>;
116	};
117
118	wifi_pwrseq: wifi_pwrseq {
119		compatible = "mmc-pwrseq-simple";
120		reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 WL-PMU-EN */
121
122		/*
123		 * This is actually Bluetooth's clock, but we have to
124		 * hook it up somewheere
125		 */
126		clocks = <&ac100_rtc 1>;
127		clock-names = "ext_clock";
128	};
129};
130
131&cpu0 {
132	cpu-supply = <&reg_dcdc2>;
133};
134
135&cpu100 {
136	cpu-supply = <&reg_dcdc3>;
137};
138
139&de {
140	status = "okay";
141};
142
143/*
144 * An USB-2 hub is connected here, which also means we don't need to
145 * enable the OHCI controller.
146 */
147&ehci0 {
148	status = "okay";
149};
150
151/*
152 * There's a modem connected here that needs to be initialised before
153 * being able to be enumerated.
154 */
155&ehci1 {
156	status = "okay";
157};
158
159&mmc0 {
160	vmmc-supply = <&reg_dcdc1>;
161	pinctrl-names = "default";
162	pinctrl-0 = <&mmc0_pins>;
163	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;
164	status = "okay";
165};
166
167&mmc1 {
168	mmc-pwrseq = <&wifi_pwrseq>;
169	bus-width = <4>;
170	vmmc-supply = <&reg_dldo1>;
171	vqmmc-supply = <&reg_dldo1>;
172	non-removable;
173	wakeup-source;
174	status = "okay";
175
176	brcmf: wifi@1 {
177		reg = <1>;
178		compatible = "brcm,bcm4329-fmac";
179		interrupt-parent = <&r_pio>;
180		interrupts = <0 3 IRQ_TYPE_LEVEL_LOW>; /* PL3 WL_WAKE_UP */
181		interrupt-names = "host-wake";
182	};
183};
184
185&mmc2 {
186	pinctrl-0 = <&mmc2_8bit_emmc_pins>;
187	pinctrl-names = "default";
188	vmmc-supply = <&reg_dcdc1>;
189	vqmmc-supply = <&reg_dcdc1>;
190	bus-width = <8>;
191	non-removable;
192	cap-mmc-hw-reset;
193	status = "okay";
194};
195
196&pwm {
197	pinctrl-names = "default";
198	pinctrl-0 = <&pwm_pin>;
199	status = "okay";
200};
201
202&r_rsb {
203	status = "okay";
204
205	axp81x: pmic@3a3 {
206		compatible = "x-powers,axp813";
207		reg = <0x3a3>;
208		interrupt-parent = <&r_intc>;
209		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
210		swin-supply = <&reg_dcdc1>;
211		x-powers,drive-vbus-en;
212	};
213
214	ac100: codec@e89 {
215		compatible = "x-powers,ac100";
216		reg = <0xe89>;
217
218		ac100_codec: codec {
219			compatible = "x-powers,ac100-codec";
220			interrupt-parent = <&r_pio>;
221			interrupts = <0 12 IRQ_TYPE_LEVEL_LOW>; /* PL12 */
222			#clock-cells = <0>;
223			clock-output-names = "4M_adda";
224		};
225
226		ac100_rtc: rtc {
227			compatible = "x-powers,ac100-rtc";
228			interrupt-parent = <&r_intc>;
229			interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
230			clocks = <&ac100_codec>;
231			#clock-cells = <1>;
232			clock-output-names = "cko1_rtc",
233					     "cko2_rtc",
234					     "cko3_rtc";
235		};
236	};
237
238};
239
240#include "axp81x.dtsi"
241
242&battery_power_supply {
243	status = "okay";
244};
245
246&reg_aldo1 {
247	regulator-min-microvolt = <1800000>;
248	regulator-max-microvolt = <1800000>;
249	regulator-name = "vcc-1.8";
250};
251
252&reg_aldo2 {
253	regulator-min-microvolt = <1800000>;
254	regulator-max-microvolt = <1800000>;
255	regulator-always-on;
256	regulator-name = "vdd-drampll";
257};
258
259&reg_aldo3 {
260	regulator-min-microvolt = <3000000>;
261	regulator-max-microvolt = <3000000>;
262	regulator-always-on;
263	regulator-name = "avcc";
264};
265
266&reg_dcdc1 {
267	regulator-min-microvolt = <3100000>;
268	regulator-max-microvolt = <3100000>;
269	regulator-always-on;
270	regulator-name = "vcc-io";
271};
272
273&reg_dcdc2 {
274	regulator-min-microvolt = <700000>;
275	regulator-max-microvolt = <1100000>;
276	regulator-always-on;
277	regulator-name = "vdd-cpu-A";
278};
279
280&reg_dcdc3 {
281	regulator-min-microvolt = <700000>;
282	regulator-max-microvolt = <1100000>;
283	regulator-always-on;
284	regulator-name = "vdd-cpu-B";
285};
286
287&reg_dcdc4 {
288	regulator-min-microvolt = <700000>;
289	regulator-max-microvolt = <1100000>;
290	regulator-name = "vdd-gpu";
291};
292
293&reg_dcdc5 {
294	regulator-min-microvolt = <1200000>;
295	regulator-max-microvolt = <1500000>;
296	regulator-always-on;
297	regulator-name = "vcc-dram";
298};
299
300&reg_dcdc6 {
301	regulator-min-microvolt = <900000>;
302	regulator-max-microvolt = <900000>;
303	regulator-always-on;
304	regulator-name = "vdd-sys";
305};
306
307&reg_dldo1 {
308	regulator-min-microvolt = <3100000>;
309	regulator-max-microvolt = <3100000>;
310	regulator-name = "vcc-wifi-io";
311};
312
313&reg_dldo2 {
314	regulator-min-microvolt = <2800000>;
315	regulator-max-microvolt = <4200000>;
316	regulator-name = "vcc-mipi";
317};
318
319&reg_dldo3 {
320	regulator-min-microvolt = <2800000>;
321	regulator-max-microvolt = <2800000>;
322	regulator-name = "vdd-csi";
323};
324
325&reg_dldo4 {
326	regulator-min-microvolt = <2800000>;
327	regulator-max-microvolt = <2800000>;
328	regulator-name = "avdd-csi";
329};
330
331&reg_drivevbus {
332	regulator-name = "usb0-vbus";
333	status = "okay";
334};
335
336&reg_eldo1 {
337	regulator-min-microvolt = <1200000>;
338	regulator-max-microvolt = <1800000>;
339	regulator-name = "dvdd-csi-r";
340};
341
342&reg_eldo2 {
343	regulator-min-microvolt = <1800000>;
344	regulator-max-microvolt = <1800000>;
345	regulator-name = "vcc-dsi";
346};
347
348&reg_eldo3 {
349	regulator-min-microvolt = <1200000>;
350	regulator-max-microvolt = <1800000>;
351	regulator-name = "dvdd-csi-f";
352};
353
354&reg_fldo1 {
355	regulator-min-microvolt = <1200000>;
356	regulator-max-microvolt = <1200000>;
357	regulator-name = "vcc-hsic";
358};
359
360&reg_fldo2 {
361	regulator-min-microvolt = <700000>;
362	regulator-max-microvolt = <1100000>;
363	regulator-always-on;
364	regulator-name = "vdd-cpus";
365};
366
367&reg_ldo_io0 {
368	regulator-min-microvolt = <3100000>;
369	regulator-max-microvolt = <3100000>;
370	regulator-name = "vcc-ctp";
371	status = "okay";
372};
373
374&reg_ldo_io1 {
375	regulator-min-microvolt = <3100000>;
376	regulator-max-microvolt = <3100000>;
377	regulator-name = "vcc-vb";
378	status = "okay";
379};
380
381&reg_sw {
382	regulator-min-microvolt = <3100000>;
383	regulator-max-microvolt = <3100000>;
384	regulator-name = "vcc-lcd";
385};
386
387&tcon0 {
388	pinctrl-names = "default";
389	pinctrl-0 = <&lcd_lvds_pins>;
390};
391
392&tcon0_out {
393	tcon0_out_lcd: endpoint@0 {
394		reg = <0>;
395		remote-endpoint = <&panel_input>;
396	};
397};
398
399&uart0 {
400	pinctrl-names = "default";
401	pinctrl-0 = <&uart0_pb_pins>;
402	status = "okay";
403};
404
405/* There's the BT part of the AP6210 connected to that UART */
406&uart1 {
407	pinctrl-names = "default";
408	pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
409	status = "okay";
410};
411
412&usb_otg {
413	dr_mode = "otg";
414	status = "okay";
415};
416
417&usbphy {
418	usb0_id_det-gpios = <&pio 7 11 GPIO_ACTIVE_HIGH>; /* PH11 */
419	usb0_vbus-supply = <&reg_drivevbus>;
420	usb1_vbus_supply = <&reg_vmain>;
421	usb2_vbus_supply = <&reg_vmain>;
422	status = "okay";
423};
424