1/*
2 * Copyright (c) 2016 ARM Ltd.
3 *
4 * This file is dual-licensed: you can use it either under the terms
5 * of the GPL or the X11 license, at your option. Note that this dual
6 * licensing only applies to this file, and not this project as a
7 * whole.
8 *
9 *  a) This library is free software; you can redistribute it and/or
10 *     modify it under the terms of the GNU General Public License as
11 *     published by the Free Software Foundation; either version 2 of the
12 *     License, or (at your option) any later version.
13 *
14 *     This library is distributed in the hope that it will be useful,
15 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *     GNU General Public License for more details.
18 *
19 * Or, alternatively,
20 *
21 *  b) Permission is hereby granted, free of charge, to any person
22 *     obtaining a copy of this software and associated documentation
23 *     files (the "Software"), to deal in the Software without
24 *     restriction, including without limitation the rights to use,
25 *     copy, modify, merge, publish, distribute, sublicense, and/or
26 *     sell copies of the Software, and to permit persons to whom the
27 *     Software is furnished to do so, subject to the following
28 *     conditions:
29 *
30 *     The above copyright notice and this permission notice shall be
31 *     included in all copies or substantial portions of the Software.
32 *
33 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
34 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
35 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
36 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
37 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
38 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
39 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
40 *     OTHER DEALINGS IN THE SOFTWARE.
41 */
42
43/dts-v1/;
44
45#include "sun50i-a64.dtsi"
46
47#include <dt-bindings/gpio/gpio.h>
48
49/ {
50	model = "BananaPi-M64";
51	compatible = "sinovoip,bananapi-m64", "allwinner,sun50i-a64";
52
53	aliases {
54		ethernet0 = &emac;
55		serial0 = &uart0;
56		serial1 = &uart1;
57	};
58
59	chosen {
60		stdout-path = "serial0:115200n8";
61	};
62
63	hdmi-connector {
64		compatible = "hdmi-connector";
65		type = "a";
66
67		port {
68			hdmi_con_in: endpoint {
69				remote-endpoint = <&hdmi_out_con>;
70			};
71		};
72	};
73
74	leds {
75		compatible = "gpio-leds";
76
77		pwr-led {
78			label = "bananapi-m64:red:pwr";
79			gpios = <&pio 3 24 GPIO_ACTIVE_HIGH>; /* PD24 */
80			default-state = "on";
81		};
82
83		green {
84			label = "bananapi-m64:green:user";
85			gpios = <&pio 4 14 GPIO_ACTIVE_HIGH>; /* PE14 */
86		};
87
88		blue {
89			label = "bananapi-m64:blue:user";
90			gpios = <&pio 4 15 GPIO_ACTIVE_HIGH>; /* PE15 */
91		};
92	};
93
94	wifi_pwrseq: wifi_pwrseq {
95		compatible = "mmc-pwrseq-simple";
96		reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 */
97	};
98};
99
100&codec {
101	status = "okay";
102};
103
104&codec_analog {
105	hpvcc-supply = <&reg_eldo1>;
106	status = "okay";
107};
108
109&dai {
110	status = "okay";
111};
112
113&de {
114	status = "okay";
115};
116
117&ehci0 {
118	status = "okay";
119};
120
121&ehci1 {
122	status = "okay";
123};
124
125&emac {
126	pinctrl-names = "default";
127	pinctrl-0 = <&rgmii_pins>;
128	phy-mode = "rgmii";
129	phy-handle = <&ext_rgmii_phy>;
130	phy-supply = <&reg_dc1sw>;
131	status = "okay";
132};
133
134&hdmi {
135	hvcc-supply = <&reg_dldo1>;
136	status = "okay";
137};
138
139&hdmi_out {
140	hdmi_out_con: endpoint {
141		remote-endpoint = <&hdmi_con_in>;
142	};
143};
144
145&i2c1 {
146	pinctrl-names = "default";
147	pinctrl-0 = <&i2c1_pins>;
148	status = "okay";
149};
150
151&i2c1_pins {
152	bias-pull-up;
153};
154
155&mdio {
156	ext_rgmii_phy: ethernet-phy@1 {
157		compatible = "ethernet-phy-ieee802.3-c22";
158		reg = <1>;
159	};
160};
161
162&mmc0 {
163	pinctrl-names = "default";
164	pinctrl-0 = <&mmc0_pins>;
165	vmmc-supply = <&reg_dcdc1>;
166	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;
167	disable-wp;
168	bus-width = <4>;
169	status = "okay";
170};
171
172&mmc1 {
173	pinctrl-names = "default";
174	pinctrl-0 = <&mmc1_pins>;
175	vmmc-supply = <&reg_dldo2>;
176	vqmmc-supply = <&reg_dldo4>;
177	mmc-pwrseq = <&wifi_pwrseq>;
178	bus-width = <4>;
179	non-removable;
180	status = "okay";
181
182	brcmf: wifi@1 {
183		reg = <1>;
184		compatible = "brcm,bcm4329-fmac";
185		interrupt-parent = <&r_pio>;
186		interrupts = <0 3 IRQ_TYPE_LEVEL_LOW>; /* PL3 */
187		interrupt-names = "host-wake";
188	};
189};
190
191&mmc2 {
192	pinctrl-names = "default";
193	pinctrl-0 = <&mmc2_pins>, <&mmc2_ds_pin>;
194	vmmc-supply = <&reg_dcdc1>;
195	bus-width = <8>;
196	non-removable;
197	cap-mmc-hw-reset;
198	status = "okay";
199};
200
201&ohci0 {
202	status = "okay";
203};
204
205&ohci1 {
206	status = "okay";
207};
208
209&r_rsb {
210	status = "okay";
211
212	axp803: pmic@3a3 {
213		compatible = "x-powers,axp803";
214		reg = <0x3a3>;
215		interrupt-parent = <&r_intc>;
216		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
217		x-powers,drive-vbus-en; /* set N_VBUSEN as output pin */
218	};
219};
220
221#include "axp803.dtsi"
222
223&reg_aldo1 {
224	/*
225	 * This regulator also drives the PE pingroup GPIOs,
226	 * which also controls two LEDs.
227	 */
228	regulator-always-on;
229	regulator-min-microvolt = <2800000>;
230	regulator-max-microvolt = <2800000>;
231	regulator-name = "afvcc-csi";
232};
233
234&reg_aldo2 {
235	regulator-always-on;
236	regulator-min-microvolt = <1800000>;
237	regulator-max-microvolt = <3300000>;
238	regulator-name = "vcc-pl";
239};
240
241&reg_aldo3 {
242	regulator-always-on;
243	regulator-min-microvolt = <3000000>;
244	regulator-max-microvolt = <3000000>;
245	regulator-name = "vcc-pll-avcc";
246};
247
248&reg_dc1sw {
249	/*
250	 * This regulator also indirectly drives the PD pingroup GPIOs,
251	 * which also controls the power LED.
252	 */
253	regulator-always-on;
254	regulator-name = "vcc-phy";
255};
256
257&reg_dcdc1 {
258	regulator-always-on;
259	regulator-min-microvolt = <3300000>;
260	regulator-max-microvolt = <3300000>;
261	regulator-name = "vcc-3v3";
262};
263
264&reg_dcdc2 {
265	regulator-always-on;
266	regulator-min-microvolt = <1040000>;
267	regulator-max-microvolt = <1300000>;
268	regulator-name = "vdd-cpux";
269};
270
271/* DCDC3 is polyphased with DCDC2 */
272
273&reg_dcdc5 {
274	regulator-always-on;
275	regulator-min-microvolt = <1500000>;
276	regulator-max-microvolt = <1500000>;
277	regulator-name = "vcc-dram";
278};
279
280&reg_dcdc6 {
281	regulator-always-on;
282	regulator-min-microvolt = <1100000>;
283	regulator-max-microvolt = <1100000>;
284	regulator-name = "vdd-sys";
285};
286
287&reg_dldo1 {
288	regulator-min-microvolt = <3300000>;
289	regulator-max-microvolt = <3300000>;
290	regulator-name = "vcc-hdmi-dsi";
291};
292
293&reg_dldo2 {
294	regulator-min-microvolt = <3300000>;
295	regulator-max-microvolt = <3300000>;
296	regulator-name = "vcc-wifi";
297};
298
299&reg_dldo4 {
300	regulator-min-microvolt = <1800000>;
301	regulator-max-microvolt = <3300000>;
302	regulator-name = "vcc-wifi-io";
303};
304
305&reg_drivevbus {
306	regulator-name = "usb0-vbus";
307	status = "okay";
308};
309
310&reg_eldo1 {
311	regulator-min-microvolt = <1800000>;
312	regulator-max-microvolt = <1800000>;
313	regulator-name = "cpvdd";
314};
315
316&reg_fldo1 {
317	regulator-min-microvolt = <1200000>;
318	regulator-max-microvolt = <1200000>;
319	regulator-name = "vcc-1v2-hsic";
320};
321
322/*
323 * The A64 chip cannot work without this regulator off, although
324 * it seems to be only driving the AR100 core.
325 * Maybe we don't still know well about CPUs domain.
326 */
327&reg_fldo2 {
328	regulator-always-on;
329	regulator-min-microvolt = <1100000>;
330	regulator-max-microvolt = <1100000>;
331	regulator-name = "vdd-cpus";
332};
333
334&reg_rtc_ldo {
335	regulator-name = "vcc-rtc";
336};
337
338&simplefb_hdmi {
339	vcc-hdmi-supply = <&reg_dldo1>;
340};
341
342&sound {
343	status = "okay";
344	simple-audio-card,widgets = "Headphone", "Headphone Jack",
345				    "Microphone", "Microphone Jack",
346				    "Microphone", "Onboard Microphone";
347	simple-audio-card,routing =
348			"Left DAC", "AIF1 Slot 0 Left",
349			"Right DAC", "AIF1 Slot 0 Right",
350			"AIF1 Slot 0 Left ADC", "Left ADC",
351			"AIF1 Slot 0 Right ADC", "Right ADC",
352			"Headphone Jack", "HP",
353			"MIC2", "Microphone Jack",
354			"Onboard Microphone", "MBIAS",
355			"MIC1", "Onboard Microphone";
356};
357
358&uart0 {
359	pinctrl-names = "default";
360	pinctrl-0 = <&uart0_pb_pins>;
361	status = "okay";
362};
363
364&uart1 {
365	pinctrl-names = "default";
366	pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
367	status = "okay";
368};
369
370&usb_otg {
371	dr_mode = "otg";
372	status = "okay";
373};
374
375&usbphy {
376	usb0_id_det-gpios = <&pio 7 9 GPIO_ACTIVE_HIGH>; /* PH9 */
377	usb0_vbus-supply = <&reg_drivevbus>;
378	status = "okay";
379};
380