1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (C) 2017 Icenowy Zheng <icenowy@aosc.io>
4 *
5 * Based on sun8i-h3-bananapi-m2-plus.dts, which is:
6 *   Copyright (C) 2016 Chen-Yu Tsai <wens@csie.org>
7 */
8
9/dts-v1/;
10#include "sun8i-h3.dtsi"
11#include "sunxi-common-regulators.dtsi"
12
13#include <dt-bindings/gpio/gpio.h>
14#include <dt-bindings/input/input.h>
15
16/ {
17	model = "Banana Pi BPI-M2-Zero";
18	compatible = "sinovoip,bpi-m2-zero", "allwinner,sun8i-h2-plus";
19
20	aliases {
21		serial0 = &uart0;
22		serial1 = &uart1;
23	};
24
25	chosen {
26		stdout-path = "serial0:115200n8";
27	};
28
29	leds {
30		compatible = "gpio-leds";
31
32		pwr_led {
33			label = "bananapi-m2-zero:red:pwr";
34			gpios = <&r_pio 0 10 GPIO_ACTIVE_LOW>; /* PL10 */
35			default-state = "on";
36		};
37	};
38
39	gpio_keys {
40		compatible = "gpio-keys";
41
42		sw4 {
43			label = "power";
44			linux,code = <BTN_0>;
45			gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
46		};
47	};
48
49	reg_vdd_cpux: vdd-cpux-regulator {
50		compatible = "regulator-gpio";
51		regulator-name = "vdd-cpux";
52		regulator-type = "voltage";
53		regulator-boot-on;
54		regulator-always-on;
55		regulator-min-microvolt = <1100000>;
56		regulator-max-microvolt = <1300000>;
57		regulator-ramp-delay = <50>; /* 4ms */
58
59		gpios = <&r_pio 0 1 GPIO_ACTIVE_HIGH>; /* PL1 */
60		enable-active-high;
61		gpios-states = <0x1>;
62		states = <1100000 0>, <1300000 1>;
63	};
64
65	reg_vcc_dram: vcc-dram {
66		compatible = "regulator-fixed";
67		regulator-name = "vcc-dram";
68		regulator-min-microvolt = <1500000>;
69		regulator-max-microvolt = <1500000>;
70		regulator-always-on;
71		regulator-boot-on;
72		enable-active-high;
73		gpio = <&r_pio 0 9 GPIO_ACTIVE_HIGH>; /* PL9 */
74		vin-supply = <&reg_vcc5v0>;
75	};
76
77	reg_vcc1v2: vcc1v2 {
78		compatible = "regulator-fixed";
79		regulator-name = "vcc1v2";
80		regulator-min-microvolt = <1200000>;
81		regulator-max-microvolt = <1200000>;
82		regulator-always-on;
83		regulator-boot-on;
84		enable-active-high;
85		gpio = <&r_pio 0 8 GPIO_ACTIVE_HIGH>; /* PL8 */
86		vin-supply = <&reg_vcc5v0>;
87	};
88
89	poweroff {
90		compatible = "regulator-poweroff";
91		cpu-supply = <&reg_vcc1v2>;
92	};
93
94	wifi_pwrseq: wifi_pwrseq {
95		compatible = "mmc-pwrseq-simple";
96		reset-gpios = <&r_pio 0 7 GPIO_ACTIVE_LOW>; /* PL7 */
97		clocks = <&rtc 1>;
98		clock-names = "ext_clock";
99	};
100};
101
102&cpu0 {
103	cpu-supply = <&reg_vdd_cpux>;
104};
105
106&ehci0 {
107	status = "okay";
108};
109
110&mmc0 {
111	vmmc-supply = <&reg_vcc3v3>;
112	bus-width = <4>;
113	/*
114	 * On the production batch of this board the card detect GPIO is
115	 * high active (card inserted), although on the early samples it's
116	 * low active.
117	 */
118	cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
119	status = "okay";
120};
121
122&mmc1 {
123	vmmc-supply = <&reg_vcc3v3>;
124	vqmmc-supply = <&reg_vcc3v3>;
125	mmc-pwrseq = <&wifi_pwrseq>;
126	bus-width = <4>;
127	non-removable;
128	status = "okay";
129
130	brcmf: wifi@1 {
131		reg = <1>;
132		compatible = "brcm,bcm4329-fmac";
133		interrupt-parent = <&pio>;
134		interrupts = <6 10 IRQ_TYPE_LEVEL_LOW>; /* PG10 / EINT10 */
135		interrupt-names = "host-wake";
136	};
137};
138
139&ohci0 {
140	status = "okay";
141};
142
143&uart0 {
144	pinctrl-names = "default";
145	pinctrl-0 = <&uart0_pa_pins>;
146	status = "okay";
147};
148
149&uart1 {
150	pinctrl-names = "default";
151	pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
152	uart-has-rtscts;
153	status = "okay";
154
155	bluetooth {
156		compatible = "brcm,bcm43438-bt";
157		max-speed = <1500000>;
158		clocks = <&rtc 1>;
159		clock-names = "lpo";
160		vbat-supply = <&reg_vcc3v3>;
161		vddio-supply = <&reg_vcc3v3>;
162		device-wakeup-gpios = <&pio 6 13 GPIO_ACTIVE_HIGH>; /* PG13 */
163		host-wakeup-gpios = <&pio 6 11 GPIO_ACTIVE_HIGH>; /* PG11 */
164		shutdown-gpios = <&pio 6 12 GPIO_ACTIVE_HIGH>; /* PG12 */
165	};
166
167};
168
169&pio {
170	gpio-line-names =
171		/* PA */
172		"CON2-P13", "CON2-P11", "CON2-P22", "CON2-P15",
173			"CON3-P03", "CON3-P02", "CON2-P07", "CON2-P29",
174		"CON2-P31", "CON2-P33", "CON2-P35", "CON2-P05",
175			"CON2-P03", "CON2-P08", "CON2-P10", "CON2-P16",
176		"CON2-P12", "CON2-P37", "CON2-P28", "CON2-P27",
177			"CON2-P40", "CON2-P38", "", "",
178		"", "", "", "", "", "", "", "",
179
180		/* PB */
181		"", "", "", "", "", "", "", "",
182		"", "", "", "", "", "", "", "",
183		"", "", "", "", "", "", "", "",
184		"", "", "", "", "", "", "", "",
185
186		/* PC */
187		"CON2-P19", "CON2-P21", "CON2-P23", "CON2-P24",
188			"CON2-P18", "", "", "CON2-P26",
189		"", "", "", "", "", "", "", "",
190		"", "", "", "", "", "", "", "",
191		"", "", "", "", "", "", "", "",
192
193		/* PD */
194		"", "", "", "", "", "", "", "",
195		"", "", "", "", "", "", "CSI-PWR-EN", "",
196		"", "", "", "", "", "", "", "",
197		"", "", "", "", "", "", "", "",
198
199		/* PE */
200		"CN3-P17", "CN3-P13", "CN3-P09", "CN3-P07",
201			"CN3-P19", "CN3-P21", "CN3-P22", "CN3-P20",
202		"CN3-P18", "CN3-P16", "CN3-P14", "CN3-P12",
203			"CN3-P05", "CN3-P03", "CN3-P06", "CN3-P08",
204		"", "", "", "", "", "", "", "",
205		"", "", "", "", "", "", "", "",
206
207		/* PF */
208		"SDC0-D1", "SDC0-D0", "SDC0-CLK", "SDC0-CMD", "SDC0-D3",
209			"SDC0-D2", "SDC0-DET", "",
210		"", "", "", "", "", "", "", "",
211		"", "", "", "", "", "", "", "",
212		"", "", "", "", "", "", "", "",
213
214		/* PG */
215		"WL-SDIO-CLK", "WL-SDIO-CMD", "WL-SDIO-D0", "WL-SDIO-D1",
216			"WL-SDIO-D2", "WL-SDIO-D3", "BT-UART-TX", "BT-UART-RX",
217		"BT-UART-RTS", "BT-UART-CTS", "WL-WAKE-AP", "BT-WAKE-AP",
218			"BT-RST-N", "AP-WAKE-BT", "", "",
219		"", "", "", "", "", "", "", "",
220		"", "", "", "", "", "", "", "";
221};
222
223&r_pio {
224	gpio-line-names =
225		/* PL */
226		"", "CPUX-SET", "CON2-P32", "POWER-KEY", "CON2-P36",
227			"VCC-IO-EN", "USB0-ID", "WL-PWR-EN",
228		"PWR-STB", "PWR-DRAM", "PWR-LED", "IR-RX", "", "", "", "",
229		"", "", "", "", "", "", "", "",
230		"", "", "", "", "", "", "", "";
231};
232
233&usb_otg {
234	dr_mode = "otg";
235	status = "okay";
236};
237
238&usbphy {
239	usb0_id_det-gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */
240	/*
241	 * There're two micro-USB connectors, one is power-only and another is
242	 * OTG. The Vbus of these two connectors are connected together, so
243	 * the external USB device will be powered just by the power input
244	 * from the power-only USB port.
245	 */
246	status = "okay";
247};
248