1/*
2 * Copyright (c) 2017 Andreas Färber
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 * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
43 */
44
45/dts-v1/;
46
47#include "meson-gxbb.dtsi"
48#include <dt-bindings/gpio/gpio.h>
49
50/ {
51	compatible = "friendlyarm,nanopi-k2", "amlogic,meson-gxbb";
52
53	aliases {
54		serial0 = &uart_AO;
55		ethernet0 = &ethmac;
56	};
57
58	chosen {
59		stdout-path = "serial0:115200n8";
60	};
61
62	memory@0 {
63		device_type = "memory";
64		reg = <0x0 0x0 0x0 0x80000000>;
65	};
66
67	leds {
68		compatible = "gpio-leds";
69
70		stat {
71			label = "nanopi-k2:blue:stat";
72			gpios = <&gpio_ao GPIOAO_13 GPIO_ACTIVE_HIGH>;
73			default-state = "on";
74			panic-indicator;
75		};
76	};
77
78	vdd_5v: regulator-vdd-5v {
79		compatible = "regulator-fixed";
80		regulator-name = "VDD_5V";
81		regulator-min-microvolt = <5000000>;
82		regulator-max-microvolt = <5000000>;
83	};
84
85	vddio_ao18: regulator-vddio-ao18 {
86		compatible = "regulator-fixed";
87		regulator-name = "VDDIO_AO18";
88		regulator-min-microvolt = <1800000>;
89		regulator-max-microvolt = <1800000>;
90	};
91
92	vddio_ao3v3: regulator-vddio-ao3v3 {
93		compatible = "regulator-fixed";
94		regulator-name = "VDDIO_AO3.3V";
95		regulator-min-microvolt = <3300000>;
96		regulator-max-microvolt = <3300000>;
97	};
98
99	vddio_tf: regulator-vddio-tf {
100		compatible = "regulator-gpio";
101
102		regulator-name = "VDDIO_TF";
103		regulator-min-microvolt = <1800000>;
104		regulator-max-microvolt = <3300000>;
105
106		gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>;
107		gpios-states = <0>;
108
109		states = <3300000 0>,
110		         <1800000 1>;
111
112		regulator-settling-time-up-us = <100>;
113		regulator-settling-time-down-us = <5000>;
114	};
115
116	wifi_32k: wifi-32k {
117		compatible = "pwm-clock";
118		#clock-cells = <0>;
119		clock-frequency = <32768>;
120		pwms = <&pwm_ef 0 30518 0>; /* PWM_E at 32.768KHz */
121	};
122
123	sdio_pwrseq: sdio-pwrseq {
124		compatible = "mmc-pwrseq-simple";
125		reset-gpios = <&gpio GPIOX_6 GPIO_ACTIVE_LOW>;
126		clocks = <&wifi_32k>;
127		clock-names = "ext_clock";
128	};
129
130	vcc1v8: regulator-vcc1v8 {
131		compatible = "regulator-fixed";
132		regulator-name = "VCC1.8V";
133		regulator-min-microvolt = <1800000>;
134		regulator-max-microvolt = <1800000>;
135	};
136
137	vcc3v3: regulator-vcc3v3 {
138		compatible = "regulator-fixed";
139		regulator-name = "VCC3.3V";
140		regulator-min-microvolt = <3300000>;
141		regulator-max-microvolt = <3300000>;
142	};
143
144	emmc_pwrseq: emmc-pwrseq {
145		compatible = "mmc-pwrseq-emmc";
146		reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>;
147	};
148};
149
150&ethmac {
151	status = "okay";
152	pinctrl-0 = <&eth_rgmii_pins>;
153	pinctrl-names = "default";
154
155	phy-handle = <&eth_phy0>;
156	phy-mode = "rgmii";
157
158	amlogic,tx-delay-ns = <2>;
159
160	snps,reset-gpio = <&gpio GPIOZ_14 0>;
161	snps,reset-delays-us = <0 10000 1000000>;
162	snps,reset-active-low;
163
164	mdio {
165		compatible = "snps,dwmac-mdio";
166		#address-cells = <1>;
167		#size-cells = <0>;
168
169		eth_phy0: ethernet-phy@0 {
170			/* Realtek RTL8211F (0x001cc916) */
171			reg = <0>;
172			interrupt-parent = <&gpio_intc>;
173			/* MAC_INTR on GPIOZ_15 */
174			interrupts = <29 IRQ_TYPE_LEVEL_LOW>;
175		};
176	};
177};
178
179&ir {
180	status = "okay";
181	pinctrl-0 = <&remote_input_ao_pins>;
182	pinctrl-names = "default";
183};
184
185&pinctrl_aobus {
186	gpio-line-names = "UART TX", "UART RX", "Power Control", "Power Key In",
187			  "VCCK En", "CON1 Header Pin31",
188			  "I2S Header Pin6", "IR In", "I2S Header Pin7",
189			  "I2S Header Pin3", "I2S Header Pin4",
190			  "I2S Header Pin5", "HDMI CEC", "SYS LED",
191			  /* GPIO_TEST_N */
192			  "";
193};
194
195&pinctrl_periphs {
196	gpio-line-names = /* Bank GPIOZ */
197			  "Eth MDIO", "Eth MDC", "Eth RGMII RX Clk",
198			  "Eth RX DV", "Eth RX D0", "Eth RX D1", "Eth RX D2",
199			  "Eth RX D3", "Eth RGMII TX Clk", "Eth TX En",
200			  "Eth TX D0", "Eth TX D1", "Eth TX D2", "Eth TX D3",
201			  "Eth PHY nRESET", "Eth PHY Intc",
202			  /* Bank GPIOH */
203			  "HDMI HPD", "HDMI DDC SDA", "HDMI DDC SCL",
204			  "CON1 Header Pin33",
205			  /* Bank BOOT */
206			  "eMMC D0", "eMMC D1", "eMMC D2", "eMMC D3", "eMMC D4",
207			  "eMMC D5", "eMMC D6", "eMMC D7", "eMMC Clk",
208			  "eMMC Reset", "eMMC CMD",
209			  "", "", "", "", "eMMC DS",
210			  "", "",
211			  /* Bank CARD */
212			  "SDCard D1", "SDCard D0", "SDCard CLK", "SDCard CMD",
213			  "SDCard D3", "SDCard D2", "SDCard Det",
214			  /* Bank GPIODV */
215			  "", "", "", "", "", "", "", "", "", "", "", "", "",
216			  "", "", "", "", "", "", "", "", "", "", "",
217			  "I2C A SDA", "I2C A SCK", "I2C B SDA", "I2C B SCK",
218			  "VDDEE Regulator", "VCCK Regulator",
219			  /* Bank GPIOY */
220			  "CON1 Header Pin7", "CON1 Header Pin11",
221			  "CON1 Header Pin13", "CON1 Header Pin15",
222			  "CON1 Header Pin18", "CON1 Header Pin19",
223			  "CON1 Header Pin22", "CON1 Header Pin21",
224			  "CON1 Header Pin24", "CON1 Header Pin23",
225			  "CON1 Header Pin26", "CON1 Header Pin29",
226			  "CON1 Header Pin32", "CON1 Header Pin8",
227			  "CON1 Header Pin10", "CON1 Header Pin16",
228			  "CON1 Header Pin12",
229			  /* Bank GPIOX */
230			  "WIFI SDIO D0", "WIFI SDIO D1", "WIFI SDIO D2",
231			  "WIFI SDIO D3", "WIFI SDIO CLK", "WIFI SDIO CMD",
232			  "WIFI Power Enable", "WIFI WAKE HOST",
233			  "Bluetooth PCM DOUT", "Bluetooth PCM DIN",
234			  "Bluetooth PCM SYNC", "Bluetooth PCM CLK",
235			  "Bluetooth UART TX", "Bluetooth UART RX",
236			  "Bluetooth UART CTS", "Bluetooth UART RTS",
237			  "", "", "", "WIFI 32K", "Bluetooth Enable",
238			  "Bluetooth WAKE HOST", "",
239			  /* Bank GPIOCLK */
240			  "", "CON1 Header Pin35", "", "";
241};
242
243&pwm_ef {
244	status = "okay";
245	pinctrl-0 = <&pwm_e_pins>;
246	pinctrl-names = "default";
247	clocks = <&clkc CLKID_FCLK_DIV4>;
248	clock-names = "clkin0";
249};
250
251&saradc {
252	status = "okay";
253	vref-supply = <&vddio_ao18>;
254};
255
256/* SDIO */
257&sd_emmc_a {
258	status = "okay";
259	pinctrl-0 = <&sdio_pins>, <&sdio_irq_pins>;
260	pinctrl-1 = <&sdio_clk_gate_pins>;
261	pinctrl-names = "default", "clk-gate";
262	#address-cells = <1>;
263	#size-cells = <0>;
264
265	bus-width = <4>;
266	cap-sd-highspeed;
267	max-frequency = <200000000>;
268
269	non-removable;
270	disable-wp;
271
272	mmc-pwrseq = <&sdio_pwrseq>;
273
274	vmmc-supply = <&vddio_ao3v3>;
275	vqmmc-supply = <&vddio_ao18>;
276
277	brcmf: wifi@1 {
278		compatible = "brcm,bcm4329-fmac";
279		reg = <1>;
280	};
281};
282
283/* SD */
284&sd_emmc_b {
285	status = "okay";
286	pinctrl-0 = <&sdcard_pins>;
287	pinctrl-1 = <&sdcard_clk_gate_pins>;
288	pinctrl-names = "default", "clk-gate";
289
290	bus-width = <4>;
291	cap-sd-highspeed;
292	sd-uhs-sdr12;
293	sd-uhs-sdr25;
294	sd-uhs-sdr50;
295	sd-uhs-sdr104;
296	max-frequency = <200000000>;
297	disable-wp;
298
299	cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_HIGH>;
300	cd-inverted;
301
302	vmmc-supply = <&vddio_ao3v3>;
303	vqmmc-supply = <&vddio_tf>;
304};
305
306/* eMMC */
307&sd_emmc_c {
308	status = "disabled";
309	pinctrl-0 = <&emmc_pins>, <&emmc_ds_pins>;
310	pinctrl-1 = <&emmc_clk_gate_pins>;
311	pinctrl-names = "default", "clk-gate";
312
313	bus-width = <8>;
314	max-frequency = <200000000>;
315	non-removable;
316	disable-wp;
317	cap-mmc-highspeed;
318	mmc-ddr-1_8v;
319	mmc-hs200-1_8v;
320
321	mmc-pwrseq = <&emmc_pwrseq>;
322	vmmc-supply = <&vcc3v3>;
323	vqmmc-supply = <&vcc1v8>;
324};
325
326/* DBG_UART */
327&uart_AO {
328	status = "okay";
329	pinctrl-0 = <&uart_ao_a_pins>;
330	pinctrl-names = "default";
331};
332
333/* Bluetooth on AP6212 */
334&uart_A {
335	status = "disabled";
336	pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>;
337	pinctrl-names = "default";
338};
339
340/* 40-pin CON1 */
341&uart_C {
342	status = "disabled";
343	pinctrl-0 = <&uart_c_pins>;
344	pinctrl-names = "default";
345};
346
347&usb0_phy {
348	status = "okay";
349	phy-supply = <&vdd_5v>;
350};
351
352&usb1_phy {
353	status = "okay";
354};
355
356&usb0 {
357	status = "okay";
358};
359
360&usb1 {
361	status = "okay";
362};
363