1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2019 BayLibre, SAS
4 * Author: Neil Armstrong <narmstrong@baylibre.com>
5 */
6
7/dts-v1/;
8
9#include "meson-g12b.dtsi"
10#include <dt-bindings/input/input.h>
11#include <dt-bindings/gpio/meson-g12a-gpio.h>
12#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
13
14/ {
15	compatible = "hardkernel,odroid-n2", "amlogic,g12b";
16	model = "Hardkernel ODROID-N2";
17
18	aliases {
19		serial0 = &uart_AO;
20		ethernet0 = &ethmac;
21	};
22
23	chosen {
24		stdout-path = "serial0:115200n8";
25	};
26
27	memory@0 {
28		device_type = "memory";
29		reg = <0x0 0x0 0x0 0x40000000>;
30	};
31
32	emmc_pwrseq: emmc-pwrseq {
33		compatible = "mmc-pwrseq-emmc";
34		reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>;
35	};
36
37	leds {
38		compatible = "gpio-leds";
39
40		blue {
41			label = "n2:blue";
42			gpios = <&gpio_ao GPIOAO_11 GPIO_ACTIVE_HIGH>;
43			linux,default-trigger = "heartbeat";
44		};
45	};
46
47	tflash_vdd: regulator-tflash_vdd {
48		compatible = "regulator-fixed";
49
50		regulator-name = "TFLASH_VDD";
51		regulator-min-microvolt = <3300000>;
52		regulator-max-microvolt = <3300000>;
53
54		gpio = <&gpio_ao GPIOAO_8 GPIO_ACTIVE_HIGH>;
55		enable-active-high;
56		regulator-always-on;
57	};
58
59	tf_io: gpio-regulator-tf_io {
60		compatible = "regulator-gpio";
61
62		regulator-name = "TF_IO";
63		regulator-min-microvolt = <1800000>;
64		regulator-max-microvolt = <3300000>;
65
66		gpios = <&gpio_ao GPIOAO_9 GPIO_ACTIVE_HIGH>;
67		gpios-states = <0>;
68
69		states = <3300000 0
70			  1800000 1>;
71	};
72
73	flash_1v8: regulator-flash_1v8 {
74		compatible = "regulator-fixed";
75		regulator-name = "FLASH_1V8";
76		regulator-min-microvolt = <1800000>;
77		regulator-max-microvolt = <1800000>;
78		vin-supply = <&vcc_3v3>;
79		regulator-always-on;
80	};
81
82	main_12v: regulator-main_12v {
83		compatible = "regulator-fixed";
84		regulator-name = "12V";
85		regulator-min-microvolt = <12000000>;
86		regulator-max-microvolt = <12000000>;
87		regulator-always-on;
88	};
89
90	vcc_5v: regulator-vcc_5v {
91		compatible = "regulator-fixed";
92		regulator-name = "5V";
93		regulator-min-microvolt = <5000000>;
94		regulator-max-microvolt = <5000000>;
95		regulator-always-on;
96		vin-supply = <&main_12v>;
97	};
98
99	vcc_1v8: regulator-vcc_1v8 {
100		compatible = "regulator-fixed";
101		regulator-name = "VCC_1V8";
102		regulator-min-microvolt = <1800000>;
103		regulator-max-microvolt = <1800000>;
104		vin-supply = <&vcc_3v3>;
105		regulator-always-on;
106	};
107
108	vcc_3v3: regulator-vcc_3v3 {
109		compatible = "regulator-fixed";
110		regulator-name = "VCC_3V3";
111		regulator-min-microvolt = <3300000>;
112		regulator-max-microvolt = <3300000>;
113		vin-supply = <&vddao_3v3>;
114		regulator-always-on;
115		/* FIXME: actually controlled by VDDCPU_B_EN */
116	};
117
118	hub_5v: regulator-hub_5v {
119		compatible = "regulator-fixed";
120		regulator-name = "HUB_5V";
121		regulator-min-microvolt = <5000000>;
122		regulator-max-microvolt = <5000000>;
123		vin-supply = <&vcc_5v>;
124
125		/* Connected to the Hub CHIPENABLE, LOW sets low power state */
126		gpio = <&gpio GPIOH_5 GPIO_ACTIVE_HIGH>;
127		enable-active-high;
128	};
129
130	usb_pwr_en: regulator-usb_pwr_en {
131		compatible = "regulator-fixed";
132		regulator-name = "USB_PWR_EN";
133		regulator-min-microvolt = <5000000>;
134		regulator-max-microvolt = <5000000>;
135		vin-supply = <&vcc_5v>;
136
137		/* Connected to the microUSB port power enable */
138		gpio = <&gpio GPIOH_6 GPIO_ACTIVE_HIGH>;
139		enable-active-high;
140	};
141
142	vddao_1v8: regulator-vddao_1v8 {
143		compatible = "regulator-fixed";
144		regulator-name = "VDDAO_1V8";
145		regulator-min-microvolt = <1800000>;
146		regulator-max-microvolt = <1800000>;
147		vin-supply = <&vddao_3v3>;
148		regulator-always-on;
149	};
150
151	vddao_3v3: regulator-vddao_3v3 {
152		compatible = "regulator-fixed";
153		regulator-name = "VDDAO_3V3";
154		regulator-min-microvolt = <3300000>;
155		regulator-max-microvolt = <3300000>;
156		vin-supply = <&main_12v>;
157		regulator-always-on;
158	};
159
160	hdmi-connector {
161		compatible = "hdmi-connector";
162		type = "a";
163
164		port {
165			hdmi_connector_in: endpoint {
166				remote-endpoint = <&hdmi_tx_tmds_out>;
167			};
168		};
169	};
170
171	sound {
172		compatible = "amlogic,axg-sound-card";
173		model = "G12A-ODROIDN2";
174		audio-aux-devs = <&tdmout_b>;
175		audio-routing = "TDMOUT_B IN 0", "FRDDR_A OUT 1",
176				"TDMOUT_B IN 1", "FRDDR_B OUT 1",
177				"TDMOUT_B IN 2", "FRDDR_C OUT 1",
178				"TDM_B Playback", "TDMOUT_B OUT";
179
180		assigned-clocks = <&clkc CLKID_MPLL2>,
181				  <&clkc CLKID_MPLL0>,
182				  <&clkc CLKID_MPLL1>;
183		assigned-clock-parents = <0>, <0>, <0>;
184		assigned-clock-rates = <294912000>,
185				       <270950400>,
186				       <393216000>;
187		status = "okay";
188
189		dai-link-0 {
190			sound-dai = <&frddr_a>;
191		};
192
193		dai-link-1 {
194			sound-dai = <&frddr_b>;
195		};
196
197		dai-link-2 {
198			sound-dai = <&frddr_c>;
199		};
200
201		/* 8ch hdmi interface */
202		dai-link-3 {
203			sound-dai = <&tdmif_b>;
204			dai-format = "i2s";
205			dai-tdm-slot-tx-mask-0 = <1 1>;
206			dai-tdm-slot-tx-mask-1 = <1 1>;
207			dai-tdm-slot-tx-mask-2 = <1 1>;
208			dai-tdm-slot-tx-mask-3 = <1 1>;
209			mclk-fs = <256>;
210
211			codec {
212				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
213			};
214		};
215
216		/* hdmi glue */
217		dai-link-4 {
218			sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>;
219
220			codec {
221				sound-dai = <&hdmi_tx>;
222			};
223		};
224	};
225};
226
227&arb {
228	status = "okay";
229};
230
231&cec_AO {
232	pinctrl-0 = <&cec_ao_a_h_pins>;
233	pinctrl-names = "default";
234	status = "disabled";
235	hdmi-phandle = <&hdmi_tx>;
236};
237
238&cecb_AO {
239	pinctrl-0 = <&cec_ao_b_h_pins>;
240	pinctrl-names = "default";
241	status = "okay";
242	hdmi-phandle = <&hdmi_tx>;
243};
244
245&clkc_audio {
246	status = "okay";
247};
248
249&ext_mdio {
250	external_phy: ethernet-phy@0 {
251		/* Realtek RTL8211F (0x001cc916) */
252		reg = <0>;
253		max-speed = <1000>;
254
255		reset-assert-us = <10000>;
256		reset-deassert-us = <30000>;
257		reset-gpios = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
258
259		interrupt-parent = <&gpio_intc>;
260		/* MAC_INTR on GPIOZ_14 */
261		interrupts = <26 IRQ_TYPE_LEVEL_LOW>;
262	};
263};
264
265&ethmac {
266	pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
267	pinctrl-names = "default";
268	status = "okay";
269	phy-mode = "rgmii";
270	phy-handle = <&external_phy>;
271	amlogic,tx-delay-ns = <2>;
272};
273
274&frddr_a {
275	status = "okay";
276};
277
278&frddr_b {
279	status = "okay";
280};
281
282&frddr_c {
283	status = "okay";
284};
285
286&gpio {
287	/*
288	 * WARNING: The USB Hub on the Odroid-N2 needs a reset signal
289	 * to be turned high in order to be detected by the USB Controller
290	 * This signal should be handled by a USB specific power sequence
291	 * in order to reset the Hub when USB bus is powered down.
292	 */
293	usb-hub {
294		gpio-hog;
295		gpios = <GPIOH_4 GPIO_ACTIVE_HIGH>;
296		output-high;
297		line-name = "usb-hub-reset";
298	};
299};
300
301&hdmi_tx {
302	status = "okay";
303	pinctrl-0 = <&hdmitx_hpd_pins>, <&hdmitx_ddc_pins>;
304	pinctrl-names = "default";
305	hdmi-supply = <&vcc_5v>;
306};
307
308&hdmi_tx_tmds_port {
309	hdmi_tx_tmds_out: endpoint {
310		remote-endpoint = <&hdmi_connector_in>;
311	};
312};
313
314&ir {
315	status = "okay";
316	pinctrl-0 = <&remote_input_ao_pins>;
317	pinctrl-names = "default";
318};
319
320/* SD card */
321&sd_emmc_b {
322	status = "okay";
323	pinctrl-0 = <&sdcard_c_pins>;
324	pinctrl-1 = <&sdcard_clk_gate_c_pins>;
325	pinctrl-names = "default", "clk-gate";
326
327	bus-width = <4>;
328	cap-sd-highspeed;
329	max-frequency = <50000000>;
330	disable-wp;
331
332	cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>;
333	vmmc-supply = <&tflash_vdd>;
334	vqmmc-supply = <&tf_io>;
335
336};
337
338/* eMMC */
339&sd_emmc_c {
340	status = "okay";
341	pinctrl-0 = <&emmc_pins>, <&emmc_ds_pins>;
342	pinctrl-1 = <&emmc_clk_gate_pins>;
343	pinctrl-names = "default", "clk-gate";
344
345	bus-width = <8>;
346	cap-mmc-highspeed;
347	mmc-ddr-1_8v;
348	mmc-hs200-1_8v;
349	max-frequency = <200000000>;
350	disable-wp;
351
352	mmc-pwrseq = <&emmc_pwrseq>;
353	vmmc-supply = <&vcc_3v3>;
354	vqmmc-supply = <&flash_1v8>;
355};
356
357&tdmif_b {
358	status = "okay";
359};
360
361&tdmout_b {
362	status = "okay";
363};
364
365&tohdmitx {
366	status = "okay";
367};
368
369&uart_AO {
370	status = "okay";
371	pinctrl-0 = <&uart_ao_a_pins>;
372	pinctrl-names = "default";
373};
374
375&usb {
376	status = "okay";
377	vbus-supply = <&usb_pwr_en>;
378};
379
380&usb2_phy0 {
381	phy-supply = <&vcc_5v>;
382};
383
384&usb2_phy1 {
385	/* Enable the hub which is connected to this port */
386	phy-supply = <&hub_5v>;
387};
388