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#include "meson-g12b-odroid.dtsi"
8
9/ {
10	aliases {
11		rtc0 = &rtc;
12	};
13
14	dio2133: audio-amplifier-0 {
15		compatible = "simple-audio-amplifier";
16		enable-gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>;
17		VCC-supply = <&vcc_5v>;
18		sound-name-prefix = "U19";
19		status = "okay";
20	};
21
22	hub_5v: regulator-hub_5v {
23		compatible = "regulator-fixed";
24		regulator-name = "HUB_5V";
25		regulator-min-microvolt = <5000000>;
26		regulator-max-microvolt = <5000000>;
27		vin-supply = <&vcc_5v>;
28
29		/* Connected to the Hub CHIPENABLE, LOW sets low power state */
30		gpio = <&gpio GPIOH_5 GPIO_ACTIVE_HIGH>;
31		enable-active-high;
32	};
33
34	sound {
35		compatible = "amlogic,axg-sound-card";
36		model = "ODROID-N2";
37		audio-widgets = "Line", "Lineout";
38		audio-aux-devs = <&tdmout_b>, <&tdmout_c>, <&tdmin_a>,
39				 <&tdmin_b>, <&tdmin_c>, <&tdmin_lb>,
40				 <&dio2133>;
41		audio-routing = "TDMOUT_B IN 0", "FRDDR_A OUT 1",
42				"TDMOUT_B IN 1", "FRDDR_B OUT 1",
43				"TDMOUT_B IN 2", "FRDDR_C OUT 1",
44				"TDM_B Playback", "TDMOUT_B OUT",
45				"TDMOUT_C IN 0", "FRDDR_A OUT 2",
46				"TDMOUT_C IN 1", "FRDDR_B OUT 2",
47				"TDMOUT_C IN 2", "FRDDR_C OUT 2",
48				"TDM_C Playback", "TDMOUT_C OUT",
49				"TDMIN_A IN 4", "TDM_B Loopback",
50				"TDMIN_B IN 4", "TDM_B Loopback",
51				"TDMIN_C IN 4", "TDM_B Loopback",
52				"TDMIN_LB IN 1", "TDM_B Loopback",
53				"TDMIN_A IN 5", "TDM_C Loopback",
54				"TDMIN_B IN 5", "TDM_C Loopback",
55				"TDMIN_C IN 5", "TDM_C Loopback",
56				"TDMIN_LB IN 2", "TDM_C Loopback",
57				"TODDR_A IN 0", "TDMIN_A OUT",
58				"TODDR_B IN 0", "TDMIN_A OUT",
59				"TODDR_C IN 0", "TDMIN_A OUT",
60				"TODDR_A IN 1", "TDMIN_B OUT",
61				"TODDR_B IN 1", "TDMIN_B OUT",
62				"TODDR_C IN 1", "TDMIN_B OUT",
63				"TODDR_A IN 2", "TDMIN_C OUT",
64				"TODDR_B IN 2", "TDMIN_C OUT",
65				"TODDR_C IN 2", "TDMIN_C OUT",
66				"TODDR_A IN 6", "TDMIN_LB OUT",
67				"TODDR_B IN 6", "TDMIN_LB OUT",
68				"TODDR_C IN 6", "TDMIN_LB OUT",
69				"U19 INL", "ACODEC LOLP",
70				"U19 INR", "ACODEC LORP",
71				"Lineout", "U19 OUTL",
72				"Lineout", "U19 OUTR";
73
74		assigned-clocks = <&clkc CLKID_MPLL2>,
75				  <&clkc CLKID_MPLL0>,
76				  <&clkc CLKID_MPLL1>;
77		assigned-clock-parents = <0>, <0>, <0>;
78		assigned-clock-rates = <294912000>,
79				       <270950400>,
80				       <393216000>;
81
82		dai-link-0 {
83			sound-dai = <&frddr_a>;
84		};
85
86		dai-link-1 {
87			sound-dai = <&frddr_b>;
88		};
89
90		dai-link-2 {
91			sound-dai = <&frddr_c>;
92		};
93
94		dai-link-3 {
95			sound-dai = <&toddr_a>;
96		};
97
98		dai-link-4 {
99			sound-dai = <&toddr_b>;
100		};
101
102		dai-link-5 {
103			sound-dai = <&toddr_c>;
104		};
105
106		/* 8ch hdmi interface */
107		dai-link-6 {
108			sound-dai = <&tdmif_b>;
109			dai-format = "i2s";
110			dai-tdm-slot-tx-mask-0 = <1 1>;
111			dai-tdm-slot-tx-mask-1 = <1 1>;
112			dai-tdm-slot-tx-mask-2 = <1 1>;
113			dai-tdm-slot-tx-mask-3 = <1 1>;
114			mclk-fs = <256>;
115
116			codec-0 {
117				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
118			};
119
120			codec-1 {
121				sound-dai = <&toacodec TOACODEC_IN_B>;
122			};
123		};
124
125		/* i2s jack output interface */
126		dai-link-7 {
127			sound-dai = <&tdmif_c>;
128			dai-format = "i2s";
129			dai-tdm-slot-tx-mask-0 = <1 1>;
130			mclk-fs = <256>;
131
132			codec-0 {
133				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_C>;
134			};
135
136			codec-1 {
137				sound-dai = <&toacodec TOACODEC_IN_C>;
138			};
139		};
140
141		/* hdmi glue */
142		dai-link-8 {
143			sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>;
144
145			codec {
146				sound-dai = <&hdmi_tx>;
147			};
148		};
149
150		/* acodec glue */
151		dai-link-9 {
152			sound-dai = <&toacodec TOACODEC_OUT>;
153
154			codec {
155				sound-dai = <&acodec>;
156			};
157		};
158	};
159};
160
161&acodec {
162	AVDD-supply = <&vddao_1v8>;
163	status = "okay";
164};
165
166&ethmac {
167	pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
168	pinctrl-names = "default";
169	status = "okay";
170	phy-mode = "rgmii";
171	phy-handle = <&external_phy>;
172	amlogic,tx-delay-ns = <2>;
173};
174
175&ext_mdio {
176	external_phy: ethernet-phy@0 {
177		/* Realtek RTL8211F (0x001cc916) */
178		reg = <0>;
179		max-speed = <1000>;
180
181		reset-assert-us = <10000>;
182		reset-deassert-us = <80000>;
183		reset-gpios = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
184
185		interrupt-parent = <&gpio_intc>;
186		/* MAC_INTR on GPIOZ_14 */
187		interrupts = <IRQID_GPIOZ_14 IRQ_TYPE_LEVEL_LOW>;
188	};
189};
190
191&gpio {
192	gpio-line-names =
193		/* GPIOZ */
194		"", "", "", "", "", "", "", "",
195		"", "", "", "", "", "", "", "",
196		/* GPIOH */
197		"", "", "", "", "", "", "", "",
198		"",
199		/* BOOT */
200		"", "", "", "", "", "", "", "",
201		"", "", "", "", "", "", "", "",
202		/* GPIOC */
203		"", "", "", "", "", "", "", "",
204		/* GPIOA */
205		"PIN_44", /* GPIOA_0 */
206		"PIN_46", /* GPIOA_1 */
207		"PIN_45", /* GPIOA_2 */
208		"PIN_47", /* GPIOA_3 */
209		"PIN_26", /* GPIOA_4 */
210		"", "", "", "", "", "",
211		"PIN_42", /* GPIOA_11 */
212		"PIN_32", /* GPIOA_12 */
213		"PIN_7",  /* GPIOA_13 */
214		"PIN_27", /* GPIOA_14 */
215		"PIN_28", /* GPIOA_15 */
216		/* GPIOX */
217		"PIN_16", /* GPIOX_0 */
218		"PIN_18", /* GPIOX_1 */
219		"PIN_22", /* GPIOX_2 */
220		"PIN_11", /* GPIOX_3 */
221		"PIN_13", /* GPIOX_4 */
222		"PIN_33", /* GPIOX_5 */
223		"PIN_35", /* GPIOX_6 */
224		"PIN_15", /* GPIOX_7 */
225		"PIN_19", /* GPIOX_8 */
226		"PIN_21", /* GPIOX_9 */
227		"PIN_24", /* GPIOX_10 */
228		"PIN_23", /* GPIOX_11 */
229		"PIN_8",  /* GPIOX_12 */
230		"PIN_10", /* GPIOX_13 */
231		"PIN_29", /* GPIOX_14 */
232		"PIN_31", /* GPIOX_15 */
233		"PIN_12", /* GPIOX_16 */
234		"PIN_3",  /* GPIOX_17 */
235		"PIN_5",  /* GPIOX_18 */
236		"PIN_36"; /* GPIOX_19 */
237	/*
238	 * WARNING: The USB Hub on the Odroid-N2 needs a reset signal
239	 * to be turned high in order to be detected by the USB Controller
240	 * This signal should be handled by a USB specific power sequence
241	 * in order to reset the Hub when USB bus is powered down.
242	 */
243	usb-hub-hog {
244		gpio-hog;
245		gpios = <GPIOH_4 GPIO_ACTIVE_HIGH>;
246		output-high;
247		line-name = "usb-hub-reset";
248	};
249};
250
251&i2c3 {
252	status = "okay";
253	pinctrl-0 = <&i2c3_sda_a_pins>, <&i2c3_sck_a_pins>;
254	pinctrl-names = "default";
255
256	rtc: rtc@51 {
257		compatible = "nxp,pcf8563";
258		reg = <0x51>;
259		wakeup-source;
260	};
261};
262
263&ir {
264	status = "okay";
265	pinctrl-0 = <&remote_input_ao_pins>;
266	pinctrl-names = "default";
267	linux,rc-map-name = "rc-odroid";
268};
269
270/*
271 * EMMC_D4, EMMC_D5, EMMC_D6 and EMMC_D7 pins are shared between SPI NOR pins
272 * and eMMC Data 4 to 7 pins.
273 * Replace emmc_data_8b_pins to emmc_data_4b_pins from sd_emmc_c pinctrl-0,
274 * and change bus-width to 4 then spifc can be enabled.
275 * The SW1 slide should also be set to the correct position.
276 */
277&spifc {
278	status = "disabled";
279	pinctrl-0 = <&nor_pins>;
280	pinctrl-names = "default";
281
282	mx25u64: flash@0 {
283		#address-cells = <1>;
284		#size-cells = <1>;
285		compatible = "mxicy,mx25u6435f", "jedec,spi-nor";
286		reg = <0>;
287		spi-max-frequency = <104000000>;
288	};
289};
290
291&toacodec {
292	status = "okay";
293};
294
295&usb {
296	vbus-supply = <&usb_pwr_en>;
297};
298
299&usb2_phy1 {
300	/* Enable the hub which is connected to this port */
301	phy-supply = <&hub_5v>;
302};
303