1/*
2 * Copyright 2014 Chen-Yu Tsai
3 *
4 * Chen-Yu Tsai <wens@csie.org>
5 *
6 * This file is dual-licensed: you can use it either under the terms
7 * of the GPL or the X11 license, at your option. Note that this dual
8 * licensing only applies to this file, and not this project as a
9 * whole.
10 *
11 *  a) This file is free software; you can redistribute it and/or
12 *     modify it under the terms of the GNU General Public License as
13 *     published by the Free Software Foundation; either version 2 of the
14 *     License, or (at your option) any later version.
15 *
16 *     This file is distributed in the hope that it will be useful,
17 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
18 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 *     GNU General Public License for more details.
20 *
21 * Or, alternatively,
22 *
23 *  b) Permission is hereby granted, free of charge, to any person
24 *     obtaining a copy of this software and associated documentation
25 *     files (the "Software"), to deal in the Software without
26 *     restriction, including without limitation the rights to use,
27 *     copy, modify, merge, publish, distribute, sublicense, and/or
28 *     sell copies of the Software, and to permit persons to whom the
29 *     Software is furnished to do so, subject to the following
30 *     conditions:
31 *
32 *     The above copyright notice and this permission notice shall be
33 *     included in all copies or substantial portions of the Software.
34 *
35 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
37 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
38 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
39 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
40 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
41 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
42 *     OTHER DEALINGS IN THE SOFTWARE.
43 */
44
45/dts-v1/;
46#include "sun9i-a80.dtsi"
47
48#include <dt-bindings/gpio/gpio.h>
49
50/ {
51	model = "Merrii A80 Optimus Board";
52	compatible = "merrii,a80-optimus", "allwinner,sun9i-a80";
53
54	aliases {
55		serial0 = &uart0;
56		serial1 = &uart4;
57	};
58
59	chosen {
60		stdout-path = "serial0:115200n8";
61	};
62
63	leds {
64		compatible = "gpio-leds";
65
66		/* The LED names match those found on the board */
67		led2 {
68			label = "optimus:led2:usr";
69			gpios = <&pio 7 1 GPIO_ACTIVE_HIGH>;
70		};
71
72		led3 {
73			label = "optimus:led3:usr";
74			gpios = <&r_pio 1 15 GPIO_ACTIVE_HIGH>; /* PM15 */
75		};
76
77		led4 {
78			label = "optimus:led4:usr";
79			gpios = <&pio 7 0 GPIO_ACTIVE_HIGH>;
80		};
81	};
82
83	reg_usb1_vbus: usb1-vbus {
84		compatible = "regulator-fixed";
85		pinctrl-names = "default";
86		regulator-min-microvolt = <5000000>;
87		regulator-max-microvolt = <5000000>;
88		enable-active-high;
89		gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */
90	};
91
92	reg_usb3_vbus: usb3-vbus {
93		compatible = "regulator-fixed";
94		pinctrl-names = "default";
95		regulator-min-microvolt = <5000000>;
96		regulator-max-microvolt = <5000000>;
97		enable-active-high;
98		gpio = <&pio 7 5 GPIO_ACTIVE_HIGH>; /* PH5 */
99	};
100
101	wifi_pwrseq: wifi-pwrseq {
102		compatible = "mmc-pwrseq-simple";
103		clocks = <&ac100_rtc 1>;
104		clock-names = "ext_clock";
105		/* enables internal regulator and de-asserts reset */
106		reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 WL-PMU-EN */
107	};
108};
109
110&ehci0 {
111	status = "okay";
112};
113
114&ehci1 {
115	/* Enable if HSIC peripheral is connected */
116	status = "disabled";
117};
118
119&ehci2 {
120	status = "okay";
121};
122
123&mmc0 {
124	pinctrl-names = "default";
125	pinctrl-0 = <&mmc0_pins>;
126	vmmc-supply = <&reg_dcdc1>;
127	bus-width = <4>;
128	cd-gpios = <&pio 7 18 GPIO_ACTIVE_LOW>; /* PH8 */
129	status = "okay";
130};
131
132&mmc1 {
133	pinctrl-names = "default";
134	pinctrl-0 = <&mmc1_pins>;
135	vmmc-supply = <&reg_dldo1>;
136	vqmmc-supply = <&reg_cldo3>;
137	mmc-pwrseq = <&wifi_pwrseq>;
138	bus-width = <4>;
139	non-removable;
140	status = "okay";
141};
142
143&mmc1_pins {
144	bias-pull-up;
145};
146
147&mmc2 {
148	pinctrl-names = "default";
149	pinctrl-0 = <&mmc2_8bit_pins>;
150	vmmc-supply = <&reg_dcdc1>;
151	bus-width = <8>;
152	non-removable;
153	cap-mmc-hw-reset;
154	status = "okay";
155};
156
157&mmc2_8bit_pins {
158	/* Increase drive strength for DDR modes */
159	drive-strength = <40>;
160};
161
162&ohci0 {
163	status = "okay";
164};
165
166&ohci2 {
167	status = "okay";
168};
169
170&osc32k {
171	/* osc32k input is from AC100 */
172	clocks = <&ac100_rtc 0>;
173};
174
175&r_ir {
176	status = "okay";
177};
178
179&r_rsb {
180	status = "okay";
181
182	axp809: pmic@3a3 {
183		reg = <0x3a3>;
184		interrupt-parent = <&nmi_intc>;
185		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
186
187		regulators {
188			reg_aldo1: aldo1 {
189				/*
190				 * TODO: This should be handled by the
191				 * USB PHY driver.
192				 */
193				regulator-always-on;
194				regulator-min-microvolt = <3000000>;
195				regulator-max-microvolt = <3000000>;
196				regulator-name = "vcc33-usbh";
197			};
198
199			reg_aldo2: aldo2 {
200				regulator-min-microvolt = <1800000>;
201				regulator-max-microvolt = <1800000>;
202				regulator-name = "vcc-pb-io-cam";
203			};
204
205			aldo3 {
206				/* unused */
207			};
208
209			reg_dc5ldo: dc5ldo {
210				regulator-always-on;
211				regulator-min-microvolt = <800000>;
212				regulator-max-microvolt = <1100000>;
213				regulator-name = "vdd-cpus-09-usbh";
214			};
215
216			reg_dcdc1: dcdc1 {
217				regulator-always-on;
218				regulator-min-microvolt = <3000000>;
219				regulator-max-microvolt = <3000000>;
220				regulator-name = "vcc-3v";
221			};
222
223			reg_dcdc2: dcdc2 {
224				regulator-min-microvolt = <800000>;
225				regulator-max-microvolt = <1100000>;
226				regulator-name = "vdd-gpu";
227			};
228
229			reg_dcdc3: dcdc3 {
230				regulator-always-on;
231				regulator-min-microvolt = <800000>;
232				regulator-max-microvolt = <1100000>;
233				regulator-name = "vdd-cpua";
234			};
235
236			reg_dcdc4: dcdc4 {
237				regulator-always-on;
238				regulator-min-microvolt = <800000>;
239				regulator-max-microvolt = <1100000>;
240				regulator-name = "vdd-sys-usb0-hdmi";
241			};
242
243			reg_dcdc5: dcdc5 {
244				regulator-always-on;
245				regulator-min-microvolt = <1425000>;
246				regulator-max-microvolt = <1575000>;
247				regulator-name = "vcc-dram";
248			};
249
250			reg_dldo1: dldo1 {
251				/*
252				 * The WiFi chip supports a wide range
253				 * (3.0 ~ 4.8V) of voltages, and so does
254				 * this regulator (3.0 ~ 4.2V), but
255				 * Allwinner SDK always sets it to 3.3V.
256				 */
257				regulator-min-microvolt = <3300000>;
258				regulator-max-microvolt = <3300000>;
259				regulator-name = "vcc-wifi";
260			};
261
262			reg_dldo2: dldo2 {
263				regulator-always-on;
264				regulator-min-microvolt = <3000000>;
265				regulator-max-microvolt = <3000000>;
266				regulator-name = "vcc-pl";
267			};
268
269			reg_eldo1: eldo1 {
270				regulator-min-microvolt = <1200000>;
271				regulator-max-microvolt = <1200000>;
272				regulator-name = "vcc-dvdd-cam";
273			};
274
275			reg_eldo2: eldo2 {
276				regulator-min-microvolt = <1800000>;
277				regulator-max-microvolt = <1800000>;
278				regulator-name = "vcc-pe";
279			};
280
281			reg_eldo3: eldo3 {
282				regulator-always-on;
283				regulator-min-microvolt = <3000000>;
284				regulator-max-microvolt = <3000000>;
285				regulator-name = "vcc-pm-codec-io1";
286			};
287
288			reg_ldo_io0: ldo_io0 {
289				regulator-always-on;
290				regulator-min-microvolt = <3000000>;
291				regulator-max-microvolt = <3000000>;
292				regulator-name = "vcc-pg";
293			};
294
295			reg_ldo_io1: ldo_io1 {
296				regulator-min-microvolt = <2500000>;
297				regulator-max-microvolt = <2500000>;
298				regulator-name = "vcc-pa-gmac-2v5";
299			};
300
301			reg_rtc_ldo: rtc_ldo {
302				regulator-name = "vcc-rtc-vdd1v8-io";
303			};
304
305			sw {
306				/* unused */
307			};
308		};
309	};
310
311	axp806: pmic@745 {
312		compatible = "x-powers,axp806";
313		reg = <0x745>;
314		interrupt-parent = <&nmi_intc>;
315		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
316		interrupt-controller;
317		#interrupt-cells = <1>;
318		bldoin-supply = <&reg_dcdce>;
319
320		regulators {
321			reg_s_aldo1: aldo1 {
322				regulator-always-on;
323				regulator-min-microvolt = <3000000>;
324				regulator-max-microvolt = <3000000>;
325				regulator-name = "avcc";
326			};
327
328			aldo2 {
329				/*
330				 * unused, but use a different name to
331				 * avoid name clash with axp809's aldo's
332				 */
333				regulator-name = "s_aldo2";
334			};
335
336			aldo3 {
337				/*
338				 * unused, but use a different name to
339				 * avoid name clash with axp809's aldo's
340				 */
341				regulator-name = "s_aldo3";
342			};
343
344			reg_bldo1: bldo1 {
345				regulator-always-on;
346				regulator-min-microvolt = <1700000>;
347				regulator-max-microvolt = <1900000>;
348				regulator-name = "vcc18-efuse-adc-display-csi";
349			};
350
351			reg_bldo2: bldo2 {
352				regulator-always-on;
353				regulator-min-microvolt = <1700000>;
354				regulator-max-microvolt = <1900000>;
355				regulator-name =
356					"vdd18-drampll-vcc18-pll-cpvdd";
357			};
358
359			bldo3 {
360				/* unused */
361			};
362
363			reg_bldo4: bldo4 {
364				regulator-min-microvolt = <1100000>;
365				regulator-max-microvolt = <1300000>;
366				regulator-name = "vcc12-hsic";
367			};
368
369			reg_cldo1: cldo1 {
370				/*
371				 * This was 3V in the original design, but
372				 * 3.3V is the recommended supply voltage
373				 * for the Ethernet PHY.
374				 */
375				regulator-min-microvolt = <3300000>;
376				regulator-max-microvolt = <3300000>;
377				regulator-name = "vcc-gmac-phy";
378			};
379
380			reg_cldo2: cldo2 {
381				regulator-min-microvolt = <2800000>;
382				regulator-max-microvolt = <2800000>;
383				regulator-name = "afvcc-cam";
384			};
385
386			reg_cldo3: cldo3 {
387				regulator-min-microvolt = <3000000>;
388				regulator-max-microvolt = <3000000>;
389				regulator-name = "vcc-io-wifi-codec-io2";
390			};
391
392			reg_dcdca: dcdca {
393				regulator-always-on;
394				regulator-min-microvolt = <800000>;
395				regulator-max-microvolt = <1100000>;
396				regulator-name = "vdd-cpub";
397			};
398
399			reg_dcdcd: dcdcd {
400				regulator-always-on;
401				regulator-min-microvolt = <800000>;
402				regulator-max-microvolt = <1100000>;
403				regulator-name = "vdd-vpu";
404			};
405
406			reg_dcdce: dcdce {
407				regulator-always-on;
408				regulator-min-microvolt = <2100000>;
409				regulator-max-microvolt = <2100000>;
410				regulator-name = "vcc-bldo-codec-ldoin";
411			};
412
413			sw {
414				/*
415				 * unused, but use a different name to
416				 * avoid name clash with axp809's sw
417				 */
418				regulator-name = "s_sw";
419			};
420		};
421	};
422
423	ac100: codec@e89 {
424		compatible = "x-powers,ac100";
425		reg = <0xe89>;
426
427		ac100_codec: codec {
428			compatible = "x-powers,ac100-codec";
429			interrupt-parent = <&r_pio>;
430			interrupts = <0 9 IRQ_TYPE_LEVEL_LOW>; /* PL9 */
431			#clock-cells = <0>;
432			clock-output-names = "4M_adda";
433		};
434
435		ac100_rtc: rtc {
436			compatible = "x-powers,ac100-rtc";
437			interrupt-parent = <&nmi_intc>;
438			interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
439			clocks = <&ac100_codec>;
440			#clock-cells = <1>;
441			clock-output-names = "cko1_rtc",
442					     "cko2_rtc",
443					     "cko3_rtc";
444		};
445	};
446};
447
448#include "axp809.dtsi"
449
450&uart0 {
451	pinctrl-names = "default";
452	pinctrl-0 = <&uart0_ph_pins>;
453	status = "okay";
454};
455
456&usbphy1 {
457	phy-supply = <&reg_usb1_vbus>;
458	status = "okay";
459};
460
461&usbphy2 {
462	phy-supply = <&reg_bldo4>;
463	/* Enable if HSIC peripheral is connected */
464	status = "disabled";
465};
466
467&usbphy3 {
468	phy-supply = <&reg_usb3_vbus>;
469	status = "okay";
470};
471