1/*
2 * Copyright (C) 2017 Chen-Yu Tsai <wens@csie.org>
3 * Copyright (C) 2017 Icenowy Zheng <icenowy@aosc.io>
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-r40.dtsi"
46
47#include <dt-bindings/gpio/gpio.h>
48
49/ {
50	model = "Banana Pi BPI-M2-Ultra";
51	compatible = "sinovoip,bpi-m2-ultra", "allwinner,sun8i-r40";
52
53	aliases {
54		ethernet0 = &gmac;
55		serial0 = &uart0;
56	};
57
58	chosen {
59		stdout-path = "serial0:115200n8";
60	};
61
62	connector {
63		compatible = "hdmi-connector";
64		type = "a";
65
66		port {
67			hdmi_con_in: endpoint {
68				remote-endpoint = <&hdmi_out_con>;
69			};
70		};
71	};
72
73	leds {
74		compatible = "gpio-leds";
75
76		pwr-led {
77			label = "bananapi:red:pwr";
78			gpios = <&pio 7 20 GPIO_ACTIVE_HIGH>;
79			default-state = "on";
80		};
81
82		user-led-green {
83			label = "bananapi:green:user";
84			gpios = <&pio 7 21 GPIO_ACTIVE_HIGH>;
85		};
86
87		user-led-blue {
88			label = "bananapi:blue:user";
89			gpios = <&pio 7 22 GPIO_ACTIVE_HIGH>;
90		};
91	};
92
93	reg_vcc5v0: vcc5v0 {
94		compatible = "regulator-fixed";
95		regulator-name = "vcc5v0";
96		regulator-min-microvolt = <5000000>;
97		regulator-max-microvolt = <5000000>;
98		gpio = <&pio 7 23 GPIO_ACTIVE_HIGH>; /* PH23 */
99		enable-active-high;
100	};
101
102	wifi_pwrseq: wifi_pwrseq {
103		compatible = "mmc-pwrseq-simple";
104		reset-gpios = <&pio 6 10 GPIO_ACTIVE_LOW>; /* PG10 WIFI_EN */
105		clocks = <&ccu CLK_OUTA>;
106		clock-names = "ext_clock";
107	};
108};
109
110&ahci {
111	ahci-supply = <&reg_dldo4>;
112	phy-supply = <&reg_eldo3>;
113	status = "okay";
114};
115
116&de {
117	status = "okay";
118};
119
120&ehci1 {
121	status = "okay";
122};
123
124&ehci2 {
125	status = "okay";
126};
127
128&gmac {
129	pinctrl-names = "default";
130	pinctrl-0 = <&gmac_rgmii_pins>;
131	phy-handle = <&phy1>;
132	phy-mode = "rgmii";
133	phy-supply = <&reg_dc1sw>;
134	status = "okay";
135};
136
137&gmac_mdio {
138	phy1: ethernet-phy@1 {
139		compatible = "ethernet-phy-ieee802.3-c22";
140		reg = <1>;
141	};
142};
143
144&hdmi {
145	status = "okay";
146};
147
148&hdmi_out {
149	hdmi_out_con: endpoint {
150		remote-endpoint = <&hdmi_con_in>;
151	};
152};
153
154&i2c0 {
155	status = "okay";
156
157	axp22x: pmic@34 {
158		compatible = "x-powers,axp221";
159		reg = <0x34>;
160		interrupt-parent = <&nmi_intc>;
161		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
162	};
163};
164
165#include "axp22x.dtsi"
166
167&mmc0 {
168	vmmc-supply = <&reg_dcdc1>;
169	bus-width = <4>;
170	cd-gpios = <&pio 7 13 GPIO_ACTIVE_LOW>; /* PH13 */
171	status = "okay";
172};
173
174&mmc1 {
175	pinctrl-names = "default";
176	pinctrl-0 = <&mmc1_pg_pins>;
177	vmmc-supply = <&reg_dldo2>;
178	vqmmc-supply = <&reg_dldo1>;
179	mmc-pwrseq = <&wifi_pwrseq>;
180	bus-width = <4>;
181	non-removable;
182	status = "okay";
183};
184
185&mmc2 {
186	vmmc-supply = <&reg_dcdc1>;
187	vqmmc-supply = <&reg_dcdc1>;
188	bus-width = <8>;
189	non-removable;
190	status = "okay";
191};
192
193&ohci1 {
194	status = "okay";
195};
196
197&ohci2 {
198	status = "okay";
199};
200
201&pio {
202	pinctrl-names = "default";
203	pinctrl-0 = <&clk_out_a_pin>;
204	vcc-pa-supply = <&reg_aldo2>;
205	vcc-pc-supply = <&reg_dcdc1>;
206	vcc-pd-supply = <&reg_dcdc1>;
207	vcc-pe-supply = <&reg_eldo1>;
208	vcc-pf-supply = <&reg_dcdc1>;
209	vcc-pg-supply = <&reg_dldo1>;
210};
211
212&reg_aldo2 {
213	regulator-min-microvolt = <2500000>;
214	regulator-max-microvolt = <2500000>;
215	regulator-name = "vcc-pa";
216};
217
218&reg_aldo3 {
219	regulator-always-on;
220	regulator-min-microvolt = <2700000>;
221	regulator-max-microvolt = <3300000>;
222	regulator-name = "avcc";
223};
224
225&reg_dc1sw {
226	regulator-min-microvolt = <3000000>;
227	regulator-max-microvolt = <3000000>;
228	regulator-name = "vcc-gmac-phy";
229};
230
231&reg_dcdc1 {
232	regulator-always-on;
233	regulator-min-microvolt = <3000000>;
234	regulator-max-microvolt = <3000000>;
235	regulator-name = "vcc-3v0";
236};
237
238&reg_dcdc2 {
239	regulator-always-on;
240	regulator-min-microvolt = <1000000>;
241	regulator-max-microvolt = <1300000>;
242	regulator-name = "vdd-cpu";
243};
244
245&reg_dcdc3 {
246	regulator-always-on;
247	regulator-min-microvolt = <1000000>;
248	regulator-max-microvolt = <1300000>;
249	regulator-name = "vdd-sys";
250};
251
252&reg_dcdc5 {
253	regulator-always-on;
254	regulator-min-microvolt = <1500000>;
255	regulator-max-microvolt = <1500000>;
256	regulator-name = "vcc-dram";
257};
258
259&reg_dldo1 {
260	regulator-min-microvolt = <1800000>;
261	regulator-max-microvolt = <3300000>;
262	regulator-name = "vcc-wifi-io";
263};
264
265/*
266 * Our WiFi chip needs both DLDO2 and DLDO3 to be powered at the same
267 * time, with the two being in sync, to be able to meet maximum power
268 * consumption during transmits. Since this is not really supported
269 * right now, just use the two as always on, and we will fix it later.
270 */
271
272&reg_dldo2 {
273	regulator-always-on;
274	regulator-min-microvolt = <3300000>;
275	regulator-max-microvolt = <3300000>;
276	regulator-name = "vcc-wifi";
277};
278
279&reg_dldo3 {
280	regulator-always-on;
281	regulator-min-microvolt = <3300000>;
282	regulator-max-microvolt = <3300000>;
283	regulator-name = "vcc-wifi-2";
284};
285
286&reg_dldo4 {
287	regulator-min-microvolt = <2500000>;
288	regulator-max-microvolt = <2500000>;
289	regulator-name = "vdd2v5-sata";
290};
291
292&reg_eldo3 {
293	regulator-min-microvolt = <1200000>;
294	regulator-max-microvolt = <1200000>;
295	regulator-name = "vdd1v2-sata";
296};
297
298&tcon_tv0 {
299	status = "okay";
300};
301
302&uart0 {
303	pinctrl-names = "default";
304	pinctrl-0 = <&uart0_pb_pins>;
305	status = "okay";
306};
307
308&uart3 {
309	pinctrl-names = "default";
310	pinctrl-0 = <&uart3_pg_pins>, <&uart3_rts_cts_pg_pins>;
311	uart-has-rtscts;
312	status = "okay";
313
314	bluetooth {
315		compatible = "brcm,bcm43438-bt";
316		clocks = <&ccu CLK_OUTA>;
317		clock-names = "lpo";
318		vbat-supply = <&reg_dldo2>;
319		vddio-supply = <&reg_dldo1>;
320		device-wakeup-gpios = <&pio 6 11 GPIO_ACTIVE_HIGH>; /* PG11 */
321		/* TODO host wake line connected to PMIC GPIO pins */
322		shutdown-gpios = <&pio 7 12 GPIO_ACTIVE_HIGH>; /* PH12 */
323		max-speed = <1500000>;
324	};
325};
326
327&usbphy {
328	usb1_vbus-supply = <&reg_vcc5v0>;
329	usb2_vbus-supply = <&reg_vcc5v0>;
330	status = "okay";
331};
332