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-toacodec.h>
13#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
14
15/ {
16	compatible = "hardkernel,odroid-n2", "amlogic,s922x", "amlogic,g12b";
17	model = "Hardkernel ODROID-N2";
18
19	aliases {
20		serial0 = &uart_AO;
21		ethernet0 = &ethmac;
22	};
23
24	dioo2133: audio-amplifier-0 {
25		compatible = "simple-audio-amplifier";
26		enable-gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>;
27		VCC-supply = <&vcc_5v>;
28		sound-name-prefix = "U19";
29		status = "okay";
30	};
31
32	chosen {
33		stdout-path = "serial0:115200n8";
34	};
35
36	memory@0 {
37		device_type = "memory";
38		reg = <0x0 0x0 0x0 0x40000000>;
39	};
40
41	emmc_pwrseq: emmc-pwrseq {
42		compatible = "mmc-pwrseq-emmc";
43		reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>;
44	};
45
46	leds {
47		compatible = "gpio-leds";
48
49		blue {
50			label = "n2:blue";
51			gpios = <&gpio_ao GPIOAO_11 GPIO_ACTIVE_HIGH>;
52			linux,default-trigger = "heartbeat";
53		};
54	};
55
56	tflash_vdd: regulator-tflash_vdd {
57		compatible = "regulator-fixed";
58
59		regulator-name = "TFLASH_VDD";
60		regulator-min-microvolt = <3300000>;
61		regulator-max-microvolt = <3300000>;
62
63		gpio = <&gpio_ao GPIOAO_8 GPIO_ACTIVE_HIGH>;
64		enable-active-high;
65		regulator-always-on;
66	};
67
68	tf_io: gpio-regulator-tf_io {
69		compatible = "regulator-gpio";
70
71		regulator-name = "TF_IO";
72		regulator-min-microvolt = <1800000>;
73		regulator-max-microvolt = <3300000>;
74
75		gpios = <&gpio_ao GPIOAO_9 GPIO_ACTIVE_HIGH>;
76		gpios-states = <0>;
77
78		states = <3300000 0>,
79			 <1800000 1>;
80	};
81
82	flash_1v8: regulator-flash_1v8 {
83		compatible = "regulator-fixed";
84		regulator-name = "FLASH_1V8";
85		regulator-min-microvolt = <1800000>;
86		regulator-max-microvolt = <1800000>;
87		vin-supply = <&vcc_3v3>;
88		regulator-always-on;
89	};
90
91	main_12v: regulator-main_12v {
92		compatible = "regulator-fixed";
93		regulator-name = "12V";
94		regulator-min-microvolt = <12000000>;
95		regulator-max-microvolt = <12000000>;
96		regulator-always-on;
97	};
98
99	vcc_5v: regulator-vcc_5v {
100		compatible = "regulator-fixed";
101		regulator-name = "5V";
102		regulator-min-microvolt = <5000000>;
103		regulator-max-microvolt = <5000000>;
104		regulator-always-on;
105		vin-supply = <&main_12v>;
106	};
107
108	vcc_1v8: regulator-vcc_1v8 {
109		compatible = "regulator-fixed";
110		regulator-name = "VCC_1V8";
111		regulator-min-microvolt = <1800000>;
112		regulator-max-microvolt = <1800000>;
113		vin-supply = <&vcc_3v3>;
114		regulator-always-on;
115	};
116
117	vcc_3v3: regulator-vcc_3v3 {
118		compatible = "regulator-fixed";
119		regulator-name = "VCC_3V3";
120		regulator-min-microvolt = <3300000>;
121		regulator-max-microvolt = <3300000>;
122		vin-supply = <&vddao_3v3>;
123		regulator-always-on;
124		/* FIXME: actually controlled by VDDCPU_B_EN */
125	};
126
127	vddcpu_a: regulator-vddcpu-a {
128		/*
129		 * MP8756GD Regulator.
130		 */
131		compatible = "pwm-regulator";
132
133		regulator-name = "VDDCPU_A";
134		regulator-min-microvolt = <721000>;
135		regulator-max-microvolt = <1022000>;
136
137		vin-supply = <&main_12v>;
138
139		pwms = <&pwm_ab 0 1250 0>;
140		pwm-dutycycle-range = <100 0>;
141
142		regulator-boot-on;
143		regulator-always-on;
144	};
145
146	vddcpu_b: regulator-vddcpu-b {
147		/*
148		 * Silergy SY8120B1ABC Regulator.
149		 */
150		compatible = "pwm-regulator";
151
152		regulator-name = "VDDCPU_B";
153		regulator-min-microvolt = <721000>;
154		regulator-max-microvolt = <1022000>;
155
156		vin-supply = <&main_12v>;
157
158		pwms = <&pwm_AO_cd 1 1250 0>;
159		pwm-dutycycle-range = <100 0>;
160
161		regulator-boot-on;
162		regulator-always-on;
163	};
164
165	hub_5v: regulator-hub_5v {
166		compatible = "regulator-fixed";
167		regulator-name = "HUB_5V";
168		regulator-min-microvolt = <5000000>;
169		regulator-max-microvolt = <5000000>;
170		vin-supply = <&vcc_5v>;
171
172		/* Connected to the Hub CHIPENABLE, LOW sets low power state */
173		gpio = <&gpio GPIOH_5 GPIO_ACTIVE_HIGH>;
174		enable-active-high;
175	};
176
177	usb_pwr_en: regulator-usb_pwr_en {
178		compatible = "regulator-fixed";
179		regulator-name = "USB_PWR_EN";
180		regulator-min-microvolt = <5000000>;
181		regulator-max-microvolt = <5000000>;
182		vin-supply = <&vcc_5v>;
183
184		/* Connected to the microUSB port power enable */
185		gpio = <&gpio GPIOH_6 GPIO_ACTIVE_HIGH>;
186		enable-active-high;
187	};
188
189	vddao_1v8: regulator-vddao_1v8 {
190		compatible = "regulator-fixed";
191		regulator-name = "VDDAO_1V8";
192		regulator-min-microvolt = <1800000>;
193		regulator-max-microvolt = <1800000>;
194		vin-supply = <&vddao_3v3>;
195		regulator-always-on;
196	};
197
198	vddao_3v3: regulator-vddao_3v3 {
199		compatible = "regulator-fixed";
200		regulator-name = "VDDAO_3V3";
201		regulator-min-microvolt = <3300000>;
202		regulator-max-microvolt = <3300000>;
203		vin-supply = <&main_12v>;
204		regulator-always-on;
205	};
206
207	hdmi-connector {
208		compatible = "hdmi-connector";
209		type = "a";
210
211		port {
212			hdmi_connector_in: endpoint {
213				remote-endpoint = <&hdmi_tx_tmds_out>;
214			};
215		};
216	};
217
218	sound {
219		compatible = "amlogic,axg-sound-card";
220		model = "G12B-ODROID-N2";
221		audio-widgets = "Line", "Lineout";
222		audio-aux-devs = <&tdmout_b>, <&tdmout_c>, <&tdmin_a>,
223				 <&tdmin_b>, <&tdmin_c>, <&tdmin_lb>,
224				 <&dioo2133>;
225		audio-routing = "TDMOUT_B IN 0", "FRDDR_A OUT 1",
226				"TDMOUT_B IN 1", "FRDDR_B OUT 1",
227				"TDMOUT_B IN 2", "FRDDR_C OUT 1",
228				"TDM_B Playback", "TDMOUT_B OUT",
229				"TDMOUT_C IN 0", "FRDDR_A OUT 2",
230				"TDMOUT_C IN 1", "FRDDR_B OUT 2",
231				"TDMOUT_C IN 2", "FRDDR_C OUT 2",
232				"TDM_C Playback", "TDMOUT_C OUT",
233				"TDMIN_A IN 4", "TDM_B Loopback",
234				"TDMIN_B IN 4", "TDM_B Loopback",
235				"TDMIN_C IN 4", "TDM_B Loopback",
236				"TDMIN_LB IN 1", "TDM_B Loopback",
237				"TDMIN_A IN 5", "TDM_C Loopback",
238				"TDMIN_B IN 5", "TDM_C Loopback",
239				"TDMIN_C IN 5", "TDM_C Loopback",
240				"TDMIN_LB IN 2", "TDM_C Loopback",
241				"TODDR_A IN 0", "TDMIN_A OUT",
242				"TODDR_B IN 0", "TDMIN_A OUT",
243				"TODDR_C IN 0", "TDMIN_A OUT",
244				"TODDR_A IN 1", "TDMIN_B OUT",
245				"TODDR_B IN 1", "TDMIN_B OUT",
246				"TODDR_C IN 1", "TDMIN_B OUT",
247				"TODDR_A IN 2", "TDMIN_C OUT",
248				"TODDR_B IN 2", "TDMIN_C OUT",
249				"TODDR_C IN 2", "TDMIN_C OUT",
250				"TODDR_A IN 6", "TDMIN_LB OUT",
251				"TODDR_B IN 6", "TDMIN_LB OUT",
252				"TODDR_C IN 6", "TDMIN_LB OUT",
253				"U19 INL", "ACODEC LOLP",
254				"U19 INR", "ACODEC LORP",
255				"Lineout", "U19 OUTL",
256				"Lineout", "U19 OUTR";
257
258		assigned-clocks = <&clkc CLKID_MPLL2>,
259				  <&clkc CLKID_MPLL0>,
260				  <&clkc CLKID_MPLL1>;
261		assigned-clock-parents = <0>, <0>, <0>;
262		assigned-clock-rates = <294912000>,
263				       <270950400>,
264				       <393216000>;
265		status = "okay";
266
267		dai-link-0 {
268			sound-dai = <&frddr_a>;
269		};
270
271		dai-link-1 {
272			sound-dai = <&frddr_b>;
273		};
274
275		dai-link-2 {
276			sound-dai = <&frddr_c>;
277		};
278
279		dai-link-3 {
280			sound-dai = <&toddr_a>;
281		};
282
283		dai-link-4 {
284			sound-dai = <&toddr_b>;
285		};
286
287		dai-link-5 {
288			sound-dai = <&toddr_c>;
289		};
290
291		/* 8ch hdmi interface */
292		dai-link-6 {
293			sound-dai = <&tdmif_b>;
294			dai-format = "i2s";
295			dai-tdm-slot-tx-mask-0 = <1 1>;
296			dai-tdm-slot-tx-mask-1 = <1 1>;
297			dai-tdm-slot-tx-mask-2 = <1 1>;
298			dai-tdm-slot-tx-mask-3 = <1 1>;
299			mclk-fs = <256>;
300
301			codec-0 {
302				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
303			};
304
305			codec-1 {
306				sound-dai = <&toacodec TOACODEC_IN_B>;
307			};
308		};
309
310		/* i2s jack output interface */
311		dai-link-7 {
312			sound-dai = <&tdmif_c>;
313			dai-format = "i2s";
314			dai-tdm-slot-tx-mask-0 = <1 1>;
315			mclk-fs = <256>;
316
317			codec-0 {
318				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_C>;
319			};
320
321			codec-1 {
322				sound-dai = <&toacodec TOACODEC_IN_C>;
323			};
324		};
325
326		/* hdmi glue */
327		dai-link-8 {
328			sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>;
329
330			codec {
331				sound-dai = <&hdmi_tx>;
332			};
333		};
334
335		/* acodec glue */
336		dai-link-9 {
337			sound-dai = <&toacodec TOACODEC_OUT>;
338
339			codec {
340				sound-dai = <&acodec>;
341			};
342		};
343	};
344};
345
346&acodec {
347	AVDD-supply = <&vddao_1v8>;
348	status = "okay";
349};
350
351&arb {
352	status = "okay";
353};
354
355&cec_AO {
356	pinctrl-0 = <&cec_ao_a_h_pins>;
357	pinctrl-names = "default";
358	status = "disabled";
359	hdmi-phandle = <&hdmi_tx>;
360};
361
362&cecb_AO {
363	pinctrl-0 = <&cec_ao_b_h_pins>;
364	pinctrl-names = "default";
365	status = "okay";
366	hdmi-phandle = <&hdmi_tx>;
367};
368
369&clkc_audio {
370	status = "okay";
371};
372
373&cpu0 {
374	cpu-supply = <&vddcpu_b>;
375	operating-points-v2 = <&cpu_opp_table_0>;
376	clocks = <&clkc CLKID_CPU_CLK>;
377	clock-latency = <50000>;
378};
379
380&cpu1 {
381	cpu-supply = <&vddcpu_b>;
382	operating-points-v2 = <&cpu_opp_table_0>;
383	clocks = <&clkc CLKID_CPU_CLK>;
384	clock-latency = <50000>;
385};
386
387&cpu100 {
388	cpu-supply = <&vddcpu_a>;
389	operating-points-v2 = <&cpub_opp_table_1>;
390	clocks = <&clkc CLKID_CPUB_CLK>;
391	clock-latency = <50000>;
392};
393
394&cpu101 {
395	cpu-supply = <&vddcpu_a>;
396	operating-points-v2 = <&cpub_opp_table_1>;
397	clocks = <&clkc CLKID_CPUB_CLK>;
398	clock-latency = <50000>;
399};
400
401&cpu102 {
402	cpu-supply = <&vddcpu_a>;
403	operating-points-v2 = <&cpub_opp_table_1>;
404	clocks = <&clkc CLKID_CPUB_CLK>;
405	clock-latency = <50000>;
406};
407
408&cpu103 {
409	cpu-supply = <&vddcpu_a>;
410	operating-points-v2 = <&cpub_opp_table_1>;
411	clocks = <&clkc CLKID_CPUB_CLK>;
412	clock-latency = <50000>;
413};
414
415&ext_mdio {
416	external_phy: ethernet-phy@0 {
417		/* Realtek RTL8211F (0x001cc916) */
418		reg = <0>;
419		max-speed = <1000>;
420
421		reset-assert-us = <10000>;
422		reset-deassert-us = <30000>;
423		reset-gpios = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
424
425		interrupt-parent = <&gpio_intc>;
426		/* MAC_INTR on GPIOZ_14 */
427		interrupts = <26 IRQ_TYPE_LEVEL_LOW>;
428	};
429};
430
431&ethmac {
432	pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
433	pinctrl-names = "default";
434	status = "okay";
435	phy-mode = "rgmii";
436	phy-handle = <&external_phy>;
437	amlogic,tx-delay-ns = <2>;
438};
439
440&frddr_a {
441	status = "okay";
442};
443
444&frddr_b {
445	status = "okay";
446};
447
448&frddr_c {
449	status = "okay";
450};
451
452&gpio {
453	/*
454	 * WARNING: The USB Hub on the Odroid-N2 needs a reset signal
455	 * to be turned high in order to be detected by the USB Controller
456	 * This signal should be handled by a USB specific power sequence
457	 * in order to reset the Hub when USB bus is powered down.
458	 */
459	usb-hub {
460		gpio-hog;
461		gpios = <GPIOH_4 GPIO_ACTIVE_HIGH>;
462		output-high;
463		line-name = "usb-hub-reset";
464	};
465};
466
467&hdmi_tx {
468	status = "okay";
469	pinctrl-0 = <&hdmitx_hpd_pins>, <&hdmitx_ddc_pins>;
470	pinctrl-names = "default";
471	hdmi-supply = <&vcc_5v>;
472};
473
474&hdmi_tx_tmds_port {
475	hdmi_tx_tmds_out: endpoint {
476		remote-endpoint = <&hdmi_connector_in>;
477	};
478};
479
480&ir {
481	status = "okay";
482	pinctrl-0 = <&remote_input_ao_pins>;
483	pinctrl-names = "default";
484	linux,rc-map-name = "rc-odroid";
485};
486
487&pwm_ab {
488	pinctrl-0 = <&pwm_a_e_pins>;
489	pinctrl-names = "default";
490	clocks = <&xtal>;
491	clock-names = "clkin0";
492	status = "okay";
493};
494
495&pwm_AO_cd {
496	pinctrl-0 = <&pwm_ao_d_e_pins>;
497	pinctrl-names = "default";
498	clocks = <&xtal>;
499	clock-names = "clkin1";
500	status = "okay";
501};
502
503/* SD card */
504&sd_emmc_b {
505	status = "okay";
506	pinctrl-0 = <&sdcard_c_pins>;
507	pinctrl-1 = <&sdcard_clk_gate_c_pins>;
508	pinctrl-names = "default", "clk-gate";
509
510	bus-width = <4>;
511	cap-sd-highspeed;
512	max-frequency = <50000000>;
513	disable-wp;
514
515	cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>;
516	vmmc-supply = <&tflash_vdd>;
517	vqmmc-supply = <&tf_io>;
518
519};
520
521/* eMMC */
522&sd_emmc_c {
523	status = "okay";
524	pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_8b_pins>, <&emmc_ds_pins>;
525	pinctrl-1 = <&emmc_clk_gate_pins>;
526	pinctrl-names = "default", "clk-gate";
527
528	bus-width = <8>;
529	cap-mmc-highspeed;
530	mmc-ddr-1_8v;
531	mmc-hs200-1_8v;
532	max-frequency = <200000000>;
533	disable-wp;
534
535	mmc-pwrseq = <&emmc_pwrseq>;
536	vmmc-supply = <&vcc_3v3>;
537	vqmmc-supply = <&flash_1v8>;
538};
539
540/*
541 * EMMC_D4, EMMC_D5, EMMC_D6 and EMMC_D7 pins are shared between SPI NOR pins
542 * and eMMC Data 4 to 7 pins.
543 * Replace emmc_data_8b_pins to emmc_data_4b_pins from sd_emmc_c pinctrl-0,
544 * and change bus-width to 4 then spifc can be enabled.
545 * The SW1 slide should also be set to the correct position.
546 */
547&spifc {
548	status = "disabled";
549	pinctrl-0 = <&nor_pins>;
550	pinctrl-names = "default";
551
552	mx25u64: spi-flash@0 {
553		#address-cells = <1>;
554		#size-cells = <1>;
555		compatible = "mxicy,mx25u6435f", "jedec,spi-nor";
556		reg = <0>;
557		spi-max-frequency = <104000000>;
558	};
559};
560
561&tdmif_b {
562	status = "okay";
563};
564
565&tdmif_c {
566	status = "okay";
567};
568
569&tdmin_a {
570	status = "okay";
571};
572
573&tdmin_b {
574	status = "okay";
575};
576
577&tdmin_c {
578	status = "okay";
579};
580
581&tdmin_lb {
582	status = "okay";
583};
584
585&tdmout_b {
586	status = "okay";
587};
588
589&tdmout_c {
590	status = "okay";
591};
592
593&toacodec {
594	status = "okay";
595};
596
597&tohdmitx {
598	status = "okay";
599};
600
601&toddr_a {
602	status = "okay";
603};
604
605&toddr_b {
606	status = "okay";
607};
608
609&toddr_c {
610	status = "okay";
611};
612
613&uart_AO {
614	status = "okay";
615	pinctrl-0 = <&uart_ao_a_pins>;
616	pinctrl-names = "default";
617};
618
619&usb {
620	status = "okay";
621	vbus-supply = <&usb_pwr_en>;
622};
623
624&usb2_phy0 {
625	phy-supply = <&vcc_5v>;
626};
627
628&usb2_phy1 {
629	/* Enable the hub which is connected to this port */
630	phy-supply = <&hub_5v>;
631};
632