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