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-s922x.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,s922x", "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	vddcpu_a: regulator-vddcpu-a {
119		/*
120		 * MP8756GD Regulator.
121		 */
122		compatible = "pwm-regulator";
123
124		regulator-name = "VDDCPU_A";
125		regulator-min-microvolt = <721000>;
126		regulator-max-microvolt = <1022000>;
127
128		vin-supply = <&main_12v>;
129
130		pwms = <&pwm_ab 0 1250 0>;
131		pwm-dutycycle-range = <100 0>;
132
133		regulator-boot-on;
134		regulator-always-on;
135	};
136
137	vddcpu_b: regulator-vddcpu-b {
138		/*
139		 * Silergy SY8120B1ABC Regulator.
140		 */
141		compatible = "pwm-regulator";
142
143		regulator-name = "VDDCPU_B";
144		regulator-min-microvolt = <721000>;
145		regulator-max-microvolt = <1022000>;
146
147		vin-supply = <&main_12v>;
148
149		pwms = <&pwm_AO_cd 1 1250 0>;
150		pwm-dutycycle-range = <100 0>;
151
152		regulator-boot-on;
153		regulator-always-on;
154	};
155
156	hub_5v: regulator-hub_5v {
157		compatible = "regulator-fixed";
158		regulator-name = "HUB_5V";
159		regulator-min-microvolt = <5000000>;
160		regulator-max-microvolt = <5000000>;
161		vin-supply = <&vcc_5v>;
162
163		/* Connected to the Hub CHIPENABLE, LOW sets low power state */
164		gpio = <&gpio GPIOH_5 GPIO_ACTIVE_HIGH>;
165		enable-active-high;
166	};
167
168	usb_pwr_en: regulator-usb_pwr_en {
169		compatible = "regulator-fixed";
170		regulator-name = "USB_PWR_EN";
171		regulator-min-microvolt = <5000000>;
172		regulator-max-microvolt = <5000000>;
173		vin-supply = <&vcc_5v>;
174
175		/* Connected to the microUSB port power enable */
176		gpio = <&gpio GPIOH_6 GPIO_ACTIVE_HIGH>;
177		enable-active-high;
178	};
179
180	vddao_1v8: regulator-vddao_1v8 {
181		compatible = "regulator-fixed";
182		regulator-name = "VDDAO_1V8";
183		regulator-min-microvolt = <1800000>;
184		regulator-max-microvolt = <1800000>;
185		vin-supply = <&vddao_3v3>;
186		regulator-always-on;
187	};
188
189	vddao_3v3: regulator-vddao_3v3 {
190		compatible = "regulator-fixed";
191		regulator-name = "VDDAO_3V3";
192		regulator-min-microvolt = <3300000>;
193		regulator-max-microvolt = <3300000>;
194		vin-supply = <&main_12v>;
195		regulator-always-on;
196	};
197
198	hdmi-connector {
199		compatible = "hdmi-connector";
200		type = "a";
201
202		port {
203			hdmi_connector_in: endpoint {
204				remote-endpoint = <&hdmi_tx_tmds_out>;
205			};
206		};
207	};
208
209	sound {
210		compatible = "amlogic,axg-sound-card";
211		model = "G12B-ODROID-N2";
212		audio-aux-devs = <&tdmout_b>, <&tdmin_a>, <&tdmin_b>,
213				 <&tdmin_c>, <&tdmin_lb>;
214		audio-routing = "TDMOUT_B IN 0", "FRDDR_A OUT 1",
215				"TDMOUT_B IN 1", "FRDDR_B OUT 1",
216				"TDMOUT_B IN 2", "FRDDR_C OUT 1",
217				"TDM_B Playback", "TDMOUT_B OUT",
218				"TDMIN_A IN 4", "TDM_B Loopback",
219				"TDMIN_B IN 4", "TDM_B Loopback",
220				"TDMIN_C IN 4", "TDM_B Loopback",
221				"TDMIN_LB IN 1", "TDM_B Loopback",
222				"TODDR_A IN 0", "TDMIN_A OUT",
223				"TODDR_B IN 0", "TDMIN_A OUT",
224				"TODDR_C IN 0", "TDMIN_A OUT",
225				"TODDR_A IN 1", "TDMIN_B OUT",
226				"TODDR_B IN 1", "TDMIN_B OUT",
227				"TODDR_C IN 1", "TDMIN_B OUT",
228				"TODDR_A IN 2", "TDMIN_C OUT",
229				"TODDR_B IN 2", "TDMIN_C OUT",
230				"TODDR_C IN 2", "TDMIN_C OUT",
231				"TODDR_A IN 6", "TDMIN_LB OUT",
232				"TODDR_B IN 6", "TDMIN_LB OUT",
233				"TODDR_C IN 6", "TDMIN_LB OUT";
234
235		assigned-clocks = <&clkc CLKID_MPLL2>,
236				  <&clkc CLKID_MPLL0>,
237				  <&clkc CLKID_MPLL1>;
238		assigned-clock-parents = <0>, <0>, <0>;
239		assigned-clock-rates = <294912000>,
240				       <270950400>,
241				       <393216000>;
242		status = "okay";
243
244		dai-link-0 {
245			sound-dai = <&frddr_a>;
246		};
247
248		dai-link-1 {
249			sound-dai = <&frddr_b>;
250		};
251
252		dai-link-2 {
253			sound-dai = <&frddr_c>;
254		};
255
256		dai-link-3 {
257			sound-dai = <&toddr_a>;
258		};
259
260		dai-link-4 {
261			sound-dai = <&toddr_b>;
262		};
263
264		dai-link-5 {
265			sound-dai = <&toddr_c>;
266		};
267
268		/* 8ch hdmi interface */
269		dai-link-6 {
270			sound-dai = <&tdmif_b>;
271			dai-format = "i2s";
272			dai-tdm-slot-tx-mask-0 = <1 1>;
273			dai-tdm-slot-tx-mask-1 = <1 1>;
274			dai-tdm-slot-tx-mask-2 = <1 1>;
275			dai-tdm-slot-tx-mask-3 = <1 1>;
276			mclk-fs = <256>;
277
278			codec {
279				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
280			};
281		};
282
283		/* hdmi glue */
284		dai-link-7 {
285			sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>;
286
287			codec {
288				sound-dai = <&hdmi_tx>;
289			};
290		};
291	};
292};
293
294&arb {
295	status = "okay";
296};
297
298&cec_AO {
299	pinctrl-0 = <&cec_ao_a_h_pins>;
300	pinctrl-names = "default";
301	status = "disabled";
302	hdmi-phandle = <&hdmi_tx>;
303};
304
305&cecb_AO {
306	pinctrl-0 = <&cec_ao_b_h_pins>;
307	pinctrl-names = "default";
308	status = "okay";
309	hdmi-phandle = <&hdmi_tx>;
310};
311
312&clkc_audio {
313	status = "okay";
314};
315
316&cpu0 {
317	cpu-supply = <&vddcpu_b>;
318	operating-points-v2 = <&cpu_opp_table_0>;
319	clocks = <&clkc CLKID_CPU_CLK>;
320	clock-latency = <50000>;
321};
322
323&cpu1 {
324	cpu-supply = <&vddcpu_b>;
325	operating-points-v2 = <&cpu_opp_table_0>;
326	clocks = <&clkc CLKID_CPU_CLK>;
327	clock-latency = <50000>;
328};
329
330&cpu100 {
331	cpu-supply = <&vddcpu_a>;
332	operating-points-v2 = <&cpub_opp_table_1>;
333	clocks = <&clkc CLKID_CPUB_CLK>;
334	clock-latency = <50000>;
335};
336
337&cpu101 {
338	cpu-supply = <&vddcpu_a>;
339	operating-points-v2 = <&cpub_opp_table_1>;
340	clocks = <&clkc CLKID_CPUB_CLK>;
341	clock-latency = <50000>;
342};
343
344&cpu102 {
345	cpu-supply = <&vddcpu_a>;
346	operating-points-v2 = <&cpub_opp_table_1>;
347	clocks = <&clkc CLKID_CPUB_CLK>;
348	clock-latency = <50000>;
349};
350
351&cpu103 {
352	cpu-supply = <&vddcpu_a>;
353	operating-points-v2 = <&cpub_opp_table_1>;
354	clocks = <&clkc CLKID_CPUB_CLK>;
355	clock-latency = <50000>;
356};
357
358&ext_mdio {
359	external_phy: ethernet-phy@0 {
360		/* Realtek RTL8211F (0x001cc916) */
361		reg = <0>;
362		max-speed = <1000>;
363
364		reset-assert-us = <10000>;
365		reset-deassert-us = <30000>;
366		reset-gpios = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
367
368		interrupt-parent = <&gpio_intc>;
369		/* MAC_INTR on GPIOZ_14 */
370		interrupts = <26 IRQ_TYPE_LEVEL_LOW>;
371	};
372};
373
374&ethmac {
375	pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
376	pinctrl-names = "default";
377	status = "okay";
378	phy-mode = "rgmii";
379	phy-handle = <&external_phy>;
380	amlogic,tx-delay-ns = <2>;
381};
382
383&frddr_a {
384	status = "okay";
385};
386
387&frddr_b {
388	status = "okay";
389};
390
391&frddr_c {
392	status = "okay";
393};
394
395&gpio {
396	/*
397	 * WARNING: The USB Hub on the Odroid-N2 needs a reset signal
398	 * to be turned high in order to be detected by the USB Controller
399	 * This signal should be handled by a USB specific power sequence
400	 * in order to reset the Hub when USB bus is powered down.
401	 */
402	usb-hub {
403		gpio-hog;
404		gpios = <GPIOH_4 GPIO_ACTIVE_HIGH>;
405		output-high;
406		line-name = "usb-hub-reset";
407	};
408};
409
410&hdmi_tx {
411	status = "okay";
412	pinctrl-0 = <&hdmitx_hpd_pins>, <&hdmitx_ddc_pins>;
413	pinctrl-names = "default";
414	hdmi-supply = <&vcc_5v>;
415};
416
417&hdmi_tx_tmds_port {
418	hdmi_tx_tmds_out: endpoint {
419		remote-endpoint = <&hdmi_connector_in>;
420	};
421};
422
423&ir {
424	status = "okay";
425	pinctrl-0 = <&remote_input_ao_pins>;
426	pinctrl-names = "default";
427	linux,rc-map-name = "rc-odroid";
428};
429
430&pwm_ab {
431	pinctrl-0 = <&pwm_a_e_pins>;
432	pinctrl-names = "default";
433	clocks = <&xtal>;
434	clock-names = "clkin0";
435	status = "okay";
436};
437
438&pwm_AO_cd {
439	pinctrl-0 = <&pwm_ao_d_e_pins>;
440	pinctrl-names = "default";
441	clocks = <&xtal>;
442	clock-names = "clkin1";
443	status = "okay";
444};
445
446/* SD card */
447&sd_emmc_b {
448	status = "okay";
449	pinctrl-0 = <&sdcard_c_pins>;
450	pinctrl-1 = <&sdcard_clk_gate_c_pins>;
451	pinctrl-names = "default", "clk-gate";
452
453	bus-width = <4>;
454	cap-sd-highspeed;
455	max-frequency = <50000000>;
456	disable-wp;
457
458	cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>;
459	vmmc-supply = <&tflash_vdd>;
460	vqmmc-supply = <&tf_io>;
461
462};
463
464/* eMMC */
465&sd_emmc_c {
466	status = "okay";
467	pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_8b_pins>, <&emmc_ds_pins>;
468	pinctrl-1 = <&emmc_clk_gate_pins>;
469	pinctrl-names = "default", "clk-gate";
470
471	bus-width = <8>;
472	cap-mmc-highspeed;
473	mmc-ddr-1_8v;
474	mmc-hs200-1_8v;
475	max-frequency = <200000000>;
476	disable-wp;
477
478	mmc-pwrseq = <&emmc_pwrseq>;
479	vmmc-supply = <&vcc_3v3>;
480	vqmmc-supply = <&flash_1v8>;
481};
482
483/*
484 * EMMC_D4, EMMC_D5, EMMC_D6 and EMMC_D7 pins are shared between SPI NOR pins
485 * and eMMC Data 4 to 7 pins.
486 * Replace emmc_data_8b_pins to emmc_data_4b_pins from sd_emmc_c pinctrl-0,
487 * and change bus-width to 4 then spifc can be enabled.
488 * The SW1 slide should also be set to the correct position.
489 */
490&spifc {
491	status = "disabled";
492	pinctrl-0 = <&nor_pins>;
493	pinctrl-names = "default";
494
495	mx25u64: spi-flash@0 {
496		#address-cells = <1>;
497		#size-cells = <1>;
498		compatible = "mxicy,mx25u6435f", "jedec,spi-nor";
499		reg = <0>;
500		spi-max-frequency = <104000000>;
501	};
502};
503
504&tdmif_b {
505	status = "okay";
506};
507
508&tdmin_a {
509	status = "okay";
510};
511
512&tdmin_b {
513	status = "okay";
514};
515
516&tdmin_c {
517	status = "okay";
518};
519
520&tdmin_lb {
521	status = "okay";
522};
523
524&tdmout_b {
525	status = "okay";
526};
527
528&tohdmitx {
529	status = "okay";
530};
531
532&toddr_a {
533	status = "okay";
534};
535
536&toddr_b {
537	status = "okay";
538};
539
540&toddr_c {
541	status = "okay";
542};
543
544&uart_AO {
545	status = "okay";
546	pinctrl-0 = <&uart_ao_a_pins>;
547	pinctrl-names = "default";
548};
549
550&usb {
551	status = "okay";
552	vbus-supply = <&usb_pwr_en>;
553};
554
555&usb2_phy0 {
556	phy-supply = <&vcc_5v>;
557};
558
559&usb2_phy1 {
560	/* Enable the hub which is connected to this port */
561	phy-supply = <&hub_5v>;
562};
563