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