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