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