1/*
2 * Copyright (C) 2017 Jagan Teki <jteki@openedev.com>
3 * Copyright (C) 2017-2018 Samuel Holland <samuel@sholland.org>
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 library 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 library 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
46#include "sun50i-a64.dtsi"
47
48#include <dt-bindings/gpio/gpio.h>
49
50/ {
51	model = "OrangePi Win/Win Plus";
52	compatible = "xunlong,orangepi-win", "allwinner,sun50i-a64";
53
54	aliases {
55		ethernet0 = &emac;
56		serial0 = &uart0;
57		serial1 = &uart1;
58		serial2 = &uart2;
59		serial3 = &uart3;
60		serial4 = &uart4;
61	};
62
63	chosen {
64		stdout-path = "serial0:115200n8";
65	};
66
67	hdmi-connector {
68		compatible = "hdmi-connector";
69		type = "a";
70
71		port {
72			hdmi_con_in: endpoint {
73				remote-endpoint = <&hdmi_out_con>;
74			};
75		};
76	};
77
78	leds {
79		compatible = "gpio-leds";
80
81		status {
82			label = "orangepi:green:status";
83			gpios = <&pio 7 11 GPIO_ACTIVE_HIGH>; /* PH11 */
84		};
85	};
86
87	reg_gmac_3v3: gmac-3v3 {
88		compatible = "regulator-fixed";
89		regulator-name = "gmac-3v3";
90		regulator-min-microvolt = <3300000>;
91		regulator-max-microvolt = <3300000>;
92		regulator-boot-on;
93		enable-active-high;
94		gpio = <&pio 3 14 GPIO_ACTIVE_HIGH>; /* PD14 */
95		status = "okay";
96	};
97
98	reg_usb1_vbus: usb1-vbus {
99		compatible = "regulator-fixed";
100		regulator-name = "usb1-vbus";
101		regulator-min-microvolt = <5000000>;
102		regulator-max-microvolt = <5000000>;
103		regulator-boot-on;
104		enable-active-high;
105		gpio = <&pio 3 7 GPIO_ACTIVE_HIGH>; /* PD7 */
106		status = "okay";
107	};
108
109	wifi_pwrseq: wifi_pwrseq {
110		compatible = "mmc-pwrseq-simple";
111		reset-gpios = <&r_pio 0 8 GPIO_ACTIVE_LOW>; /* PL8 */
112		clocks = <&rtc 1>;
113		clock-names = "ext_clock";
114	};
115};
116
117&codec {
118	status = "okay";
119};
120
121&codec_analog {
122	cpvdd-supply = <&reg_eldo1>;
123	status = "okay";
124};
125
126&dai {
127	status = "okay";
128};
129
130&de {
131	status = "okay";
132};
133
134&ehci0 {
135	status = "okay";
136};
137
138&ehci1 {
139	status = "okay";
140};
141
142&emac {
143	pinctrl-names = "default";
144	pinctrl-0 = <&rgmii_pins>;
145	phy-mode = "rgmii";
146	phy-handle = <&ext_rgmii_phy>;
147	phy-supply = <&reg_gmac_3v3>;
148	status = "okay";
149};
150
151&hdmi {
152	hvcc-supply = <&reg_dldo1>;
153	status = "okay";
154};
155
156&hdmi_out {
157	hdmi_out_con: endpoint {
158		remote-endpoint = <&hdmi_con_in>;
159	};
160};
161
162&mdio {
163	ext_rgmii_phy: ethernet-phy@1 {
164		compatible = "ethernet-phy-ieee802.3-c22";
165		reg = <1>;
166	};
167};
168
169&mmc0 {
170	pinctrl-names = "default";
171	pinctrl-0 = <&mmc0_pins>;
172	vmmc-supply = <&reg_dcdc1>;
173	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
174	disable-wp;
175	bus-width = <4>;
176	status = "okay";
177};
178
179&mmc1 {
180	pinctrl-names = "default";
181	pinctrl-0 = <&mmc1_pins>;
182	vmmc-supply = <&reg_dldo2>;
183	vqmmc-supply = <&reg_dldo4>;
184	mmc-pwrseq = <&wifi_pwrseq>;
185	bus-width = <4>;
186	non-removable;
187	status = "okay";
188
189	brcmf: wifi@1 {
190		reg = <1>;
191		compatible = "brcm,bcm4329-fmac";
192		interrupt-parent = <&r_pio>;
193		interrupts = <0 7 IRQ_TYPE_LEVEL_LOW>; /* PL7 */
194		interrupt-names = "host-wake";
195	};
196};
197
198&ohci0 {
199	status = "okay";
200};
201
202&ohci1 {
203	status = "okay";
204};
205
206&r_ir {
207	status = "okay";
208};
209
210&r_rsb {
211	status = "okay";
212
213	axp803: pmic@3a3 {
214		compatible = "x-powers,axp803";
215		reg = <0x3a3>;
216		interrupt-parent = <&r_intc>;
217		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
218		x-powers,drive-vbus-en; /* set N_VBUSEN as output pin */
219	};
220};
221
222#include "axp803.dtsi"
223
224&ac_power_supply {
225	status = "okay";
226};
227
228&battery_power_supply {
229	status = "okay";
230};
231
232&reg_aldo1 {
233	regulator-min-microvolt = <2800000>;
234	regulator-max-microvolt = <2800000>;
235	regulator-name = "afvcc-csi";
236};
237
238&reg_aldo2 {
239	regulator-always-on;
240	regulator-min-microvolt = <1800000>;
241	regulator-max-microvolt = <3300000>;
242	regulator-name = "vcc-pl";
243};
244
245&reg_aldo3 {
246	regulator-always-on;
247	regulator-min-microvolt = <3000000>;
248	regulator-max-microvolt = <3000000>;
249	regulator-name = "vcc-pll-avcc";
250};
251
252&reg_dcdc1 {
253	regulator-always-on;
254	regulator-min-microvolt = <3300000>;
255	regulator-max-microvolt = <3300000>;
256	regulator-name = "vcc-3v3";
257};
258
259&reg_dcdc2 {
260	regulator-always-on;
261	regulator-min-microvolt = <1040000>;
262	regulator-max-microvolt = <1300000>;
263	regulator-name = "vdd-cpux";
264};
265
266/* DCDC3 is polyphased with DCDC2 */
267
268&reg_dcdc5 {
269	regulator-always-on;
270	regulator-min-microvolt = <1500000>;
271	regulator-max-microvolt = <1500000>;
272	regulator-name = "vcc-dram";
273};
274
275&reg_dcdc6 {
276	regulator-always-on;
277	regulator-min-microvolt = <1100000>;
278	regulator-max-microvolt = <1100000>;
279	regulator-name = "vdd-sys";
280};
281
282&reg_dldo1 {
283	regulator-min-microvolt = <3300000>;
284	regulator-max-microvolt = <3300000>;
285	regulator-name = "vcc-hdmi-dsi";
286};
287
288&reg_dldo2 {
289	regulator-min-microvolt = <3300000>;
290	regulator-max-microvolt = <3300000>;
291	regulator-name = "vcc-wifi";
292};
293
294&reg_dldo3 {
295	regulator-min-microvolt = <3300000>;
296	regulator-max-microvolt = <3300000>;
297	regulator-name = "avdd-csi";
298};
299
300&reg_dldo4 {
301	regulator-min-microvolt = <3300000>;
302	regulator-max-microvolt = <3300000>;
303	regulator-name = "vcc-wifi-io";
304};
305
306&reg_drivevbus {
307	regulator-name = "usb0-vbus";
308	status = "okay";
309};
310
311&reg_eldo1 {
312	regulator-min-microvolt = <1800000>;
313	regulator-max-microvolt = <1800000>;
314	regulator-name = "cpvdd";
315};
316
317&reg_eldo3 {
318	regulator-min-microvolt = <1500000>;
319	regulator-max-microvolt = <1800000>;
320	regulator-name = "dvdd-csi";
321};
322
323&reg_fldo1 {
324	regulator-min-microvolt = <1200000>;
325	regulator-max-microvolt = <1200000>;
326	regulator-name = "vcc-1v2-hsic";
327};
328
329/*
330 * The A64 chip cannot work without this regulator off, although
331 * it seems to be only driving the AR100 core.
332 * Maybe we don't still know well about CPUs domain.
333 */
334&reg_fldo2 {
335	regulator-always-on;
336	regulator-min-microvolt = <1100000>;
337	regulator-max-microvolt = <1100000>;
338	regulator-name = "vdd-cpus";
339};
340
341&reg_rtc_ldo {
342	regulator-name = "vcc-rtc";
343};
344
345&simplefb_hdmi {
346	vcc-hdmi-supply = <&reg_dldo1>;
347};
348
349&sound {
350	status = "okay";
351	simple-audio-card,widgets = "Headphone", "Headphone Jack",
352				    "Microphone", "Microphone Jack",
353				    "Microphone", "Onboard Microphone";
354	simple-audio-card,routing =
355			"Left DAC", "AIF1 Slot 0 Left",
356			"Right DAC", "AIF1 Slot 0 Right",
357			"AIF1 Slot 0 Left ADC", "Left ADC",
358			"AIF1 Slot 0 Right ADC", "Right ADC",
359			"Headphone Jack", "HP",
360			"MIC2", "Microphone Jack",
361			"Onboard Microphone", "MBIAS",
362			"MIC1", "Onboard Microphone";
363};
364
365&spi0 {
366	status = "okay";
367
368	spi-flash@0 {
369		compatible = "mxicy,mx25l1606e", "jedec,spi-nor";
370		reg = <0>;
371		spi-max-frequency = <80000000>;
372		m25p,fast-read;
373		status = "okay";
374	};
375};
376
377/* On debug connector */
378&uart0 {
379	pinctrl-names = "default";
380	pinctrl-0 = <&uart0_pb_pins>;
381	status = "okay";
382};
383
384/* Bluetooth */
385&uart1 {
386	pinctrl-names = "default";
387	pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
388	uart-has-rtscts;
389	status = "okay";
390
391	bluetooth {
392		compatible = "brcm,bcm43438-bt";
393		max-speed = <1500000>;
394		clocks = <&rtc 1>;
395		clock-names = "lpo";
396		vbat-supply = <&reg_dldo2>;
397		vddio-supply = <&reg_dldo4>;
398		device-wakeup-gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */
399		host-wakeup-gpios = <&r_pio 0 5 GPIO_ACTIVE_HIGH>; /* PL5 */
400		shutdown-gpios = <&r_pio 0 4 GPIO_ACTIVE_HIGH>; /* PL4 */
401	};
402};
403
404/* On Pi-2 connector, RTS/CTS optional */
405&uart2 {
406	pinctrl-names = "default";
407	pinctrl-0 = <&uart2_pins>;
408	status = "disabled";
409};
410
411/* On Pi-2 connector, RTS/CTS optional */
412&uart3 {
413	pinctrl-names = "default";
414	pinctrl-0 = <&uart3_pins>;
415	status = "disabled";
416};
417
418/* On Pi-2 connector (labeled for SPI1), RTS/CTS optional */
419&uart4 {
420	pinctrl-names = "default";
421	pinctrl-0 = <&uart4_pins>;
422	status = "disabled";
423};
424
425&usb_otg {
426	dr_mode = "otg";
427	status = "okay";
428};
429
430&usbphy {
431	usb0_id_det-gpios = <&pio 7 9 GPIO_ACTIVE_HIGH>; /* PH9 */
432	usb0_vbus-supply = <&reg_drivevbus>;
433	usb1_vbus-supply = <&reg_usb1_vbus>;
434	status = "okay";
435};
436