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