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	};
56
57	chosen {
58		stdout-path = "serial0:115200n8";
59	};
60
61	memory@0 {
62		device_type = "memory";
63		reg = <0x0 0x0 0x0 0x80000000>;
64	};
65
66	leds {
67		compatible = "gpio-leds";
68
69		stat {
70			label = "nanopi-k2:blue:stat";
71			gpios = <&gpio_ao GPIOAO_13 GPIO_ACTIVE_HIGH>;
72			default-state = "on";
73			panic-indicator;
74		};
75	};
76
77	vdd_5v: regulator-vdd-5v {
78		compatible = "regulator-fixed";
79		regulator-name = "VDD_5V";
80		regulator-min-microvolt = <5000000>;
81		regulator-max-microvolt = <5000000>;
82	};
83
84	vddio_ao18: regulator-vddio-ao18 {
85		compatible = "regulator-fixed";
86		regulator-name = "VDDIO_AO18";
87		regulator-min-microvolt = <1800000>;
88		regulator-max-microvolt = <1800000>;
89	};
90
91	vddio_ao3v3: regulator-vddio-ao3v3 {
92		compatible = "regulator-fixed";
93		regulator-name = "VDDIO_AO3.3V";
94		regulator-min-microvolt = <3300000>;
95		regulator-max-microvolt = <3300000>;
96	};
97
98	vddio_tf: regulator-vddio-tf {
99		compatible = "regulator-gpio";
100
101		regulator-name = "VDDIO_TF";
102		regulator-min-microvolt = <1800000>;
103		regulator-max-microvolt = <3300000>;
104
105		gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>;
106		gpios-states = <0>;
107
108		states = <3300000 0>,
109		         <1800000 1>;
110	};
111
112	wifi_32k: wifi-32k {
113		compatible = "pwm-clock";
114		#clock-cells = <0>;
115		clock-frequency = <32768>;
116		pwms = <&pwm_ef 0 30518 0>; /* PWM_E at 32.768KHz */
117	};
118
119	sdio_pwrseq: sdio-pwrseq {
120		compatible = "mmc-pwrseq-simple";
121		reset-gpios = <&gpio GPIOX_6 GPIO_ACTIVE_LOW>;
122		clocks = <&wifi_32k>;
123		clock-names = "ext_clock";
124	};
125
126	vcc1v8: regulator-vcc1v8 {
127		compatible = "regulator-fixed";
128		regulator-name = "VCC1.8V";
129		regulator-min-microvolt = <1800000>;
130		regulator-max-microvolt = <1800000>;
131	};
132
133	vcc3v3: regulator-vcc3v3 {
134		compatible = "regulator-fixed";
135		regulator-name = "VCC3.3V";
136		regulator-min-microvolt = <3300000>;
137		regulator-max-microvolt = <3300000>;
138	};
139
140	emmc_pwrseq: emmc-pwrseq {
141		compatible = "mmc-pwrseq-emmc";
142		reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>;
143	};
144};
145
146&ethmac {
147	status = "okay";
148	pinctrl-0 = <&eth_rgmii_pins>;
149	pinctrl-names = "default";
150
151	phy-handle = <&eth_phy0>;
152	phy-mode = "rgmii";
153
154	amlogic,tx-delay-ns = <2>;
155
156	snps,reset-gpio = <&gpio GPIOZ_14 0>;
157	snps,reset-delays-us = <0 10000 1000000>;
158	snps,reset-active-low;
159
160	mdio {
161		compatible = "snps,dwmac-mdio";
162		#address-cells = <1>;
163		#size-cells = <0>;
164
165		eth_phy0: ethernet-phy@0 {
166			/* Realtek RTL8211F (0x001cc916) */
167			reg = <0>;
168		};
169	};
170};
171
172&ir {
173	status = "okay";
174	pinctrl-0 = <&remote_input_ao_pins>;
175	pinctrl-names = "default";
176};
177
178&pwm_ef {
179	status = "okay";
180	pinctrl-0 = <&pwm_e_pins>;
181	pinctrl-names = "default";
182	clocks = <&clkc CLKID_FCLK_DIV4>;
183	clock-names = "clkin0";
184};
185
186&saradc {
187	status = "okay";
188	vref-supply = <&vddio_ao18>;
189};
190
191/* SDIO */
192&sd_emmc_a {
193	status = "okay";
194	pinctrl-0 = <&sdio_pins>, <&sdio_irq_pins>;
195	pinctrl-names = "default";
196	#address-cells = <1>;
197	#size-cells = <0>;
198
199	bus-width = <4>;
200	cap-sd-highspeed;
201	max-frequency = <200000000>;
202
203	non-removable;
204	disable-wp;
205
206	mmc-pwrseq = <&sdio_pwrseq>;
207
208	vmmc-supply = <&vddio_ao3v3>;
209	vqmmc-supply = <&vddio_ao18>;
210
211	brcmf: wifi@1 {
212		compatible = "brcm,bcm4329-fmac";
213		reg = <1>;
214	};
215};
216
217/* SD */
218&sd_emmc_b {
219	status = "okay";
220	pinctrl-0 = <&sdcard_pins>;
221	pinctrl-names = "default";
222
223	bus-width = <4>;
224	cap-sd-highspeed;
225	max-frequency = <100000000>;
226	disable-wp;
227
228	cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_HIGH>;
229	cd-inverted;
230
231	vmmc-supply = <&vddio_ao3v3>;
232	vqmmc-supply = <&vddio_tf>;
233};
234
235/* eMMC */
236&sd_emmc_c {
237	status = "disabled";
238	pinctrl-0 = <&emmc_pins>;
239	pinctrl-names = "default";
240
241	bus-width = <8>;
242	cap-sd-highspeed;
243	max-frequency = <200000000>;
244	non-removable;
245	disable-wp;
246	cap-mmc-highspeed;
247	mmc-ddr-1_8v;
248	mmc-hs200-1_8v;
249
250	mmc-pwrseq = <&emmc_pwrseq>;
251	vmmc-supply = <&vcc3v3>;
252	vqmmc-supply = <&vcc1v8>;
253};
254
255/* DBG_UART */
256&uart_AO {
257	status = "okay";
258	pinctrl-0 = <&uart_ao_a_pins>;
259	pinctrl-names = "default";
260};
261
262/* Bluetooth on AP6212 */
263&uart_A {
264	status = "disabled";
265	pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>;
266	pinctrl-names = "default";
267};
268
269/* 40-pin CON1 */
270&uart_C {
271	status = "disabled";
272	pinctrl-0 = <&uart_c_pins>;
273	pinctrl-names = "default";
274};
275
276&usb0_phy {
277	status = "okay";
278	phy-supply = <&vdd_5v>;
279};
280
281&usb1_phy {
282	status = "okay";
283};
284
285&usb0 {
286	status = "okay";
287};
288
289&usb1 {
290	status = "okay";
291};
292