1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2020 Dongjin Kim <tobetter@gmail.com>
4 */
5
6/dts-v1/;
7
8#include "meson-sm1.dtsi"
9#include <dt-bindings/gpio/meson-g12a-gpio.h>
10#include <dt-bindings/leds/common.h>
11#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
12
13/ {
14	compatible = "hardkernel,odroid-c4", "amlogic,sm1";
15	model = "Hardkernel ODROID-C4";
16
17	aliases {
18		serial0 = &uart_AO;
19		ethernet0 = &ethmac;
20	};
21
22	chosen {
23		stdout-path = "serial0:115200n8";
24	};
25
26	memory@0 {
27		device_type = "memory";
28		reg = <0x0 0x0 0x0 0x40000000>;
29	};
30
31	emmc_pwrseq: emmc-pwrseq {
32		compatible = "mmc-pwrseq-emmc";
33		reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>;
34	};
35
36	leds {
37		compatible = "gpio-leds";
38
39		led-blue {
40			color = <LED_COLOR_ID_BLUE>;
41			function = LED_FUNCTION_STATUS;
42			gpios = <&gpio_ao GPIOAO_11 GPIO_ACTIVE_HIGH>;
43			linux,default-trigger = "heartbeat";
44			panic-indicator;
45		};
46	};
47
48	tflash_vdd: regulator-tflash_vdd {
49		compatible = "regulator-fixed";
50
51		regulator-name = "TFLASH_VDD";
52		regulator-min-microvolt = <3300000>;
53		regulator-max-microvolt = <3300000>;
54
55		gpio = <&gpio_ao GPIOAO_3 GPIO_OPEN_DRAIN>;
56		enable-active-high;
57		regulator-always-on;
58	};
59
60	tf_io: gpio-regulator-tf_io {
61		compatible = "regulator-gpio";
62
63		regulator-name = "TF_IO";
64		regulator-min-microvolt = <1800000>;
65		regulator-max-microvolt = <3300000>;
66
67		gpios = <&gpio_ao GPIOAO_6 GPIO_ACTIVE_HIGH>;
68		gpios-states = <0>;
69
70		states = <3300000 0>,
71			 <1800000 1>;
72	};
73
74	flash_1v8: regulator-flash_1v8 {
75		compatible = "regulator-fixed";
76		regulator-name = "FLASH_1V8";
77		regulator-min-microvolt = <1800000>;
78		regulator-max-microvolt = <1800000>;
79		vin-supply = <&vcc_3v3>;
80		regulator-always-on;
81	};
82
83	main_12v: regulator-main_12v {
84		compatible = "regulator-fixed";
85		regulator-name = "12V";
86		regulator-min-microvolt = <12000000>;
87		regulator-max-microvolt = <12000000>;
88		regulator-always-on;
89	};
90
91	vcc_5v: regulator-vcc_5v {
92		compatible = "regulator-fixed";
93		regulator-name = "5V";
94		regulator-min-microvolt = <5000000>;
95		regulator-max-microvolt = <5000000>;
96		regulator-always-on;
97		vin-supply = <&main_12v>;
98	};
99
100	vcc_1v8: regulator-vcc_1v8 {
101		compatible = "regulator-fixed";
102		regulator-name = "VCC_1V8";
103		regulator-min-microvolt = <1800000>;
104		regulator-max-microvolt = <1800000>;
105		vin-supply = <&vcc_3v3>;
106		regulator-always-on;
107	};
108
109	vcc_3v3: regulator-vcc_3v3 {
110		compatible = "regulator-fixed";
111		regulator-name = "VCC_3V3";
112		regulator-min-microvolt = <3300000>;
113		regulator-max-microvolt = <3300000>;
114		vin-supply = <&vddao_3v3>;
115		regulator-always-on;
116		/* FIXME: actually controlled by VDDCPU_B_EN */
117	};
118
119	vddcpu: regulator-vddcpu {
120		/*
121		 * MP8756GD Regulator.
122		 */
123		compatible = "pwm-regulator";
124
125		regulator-name = "VDDCPU";
126		regulator-min-microvolt = <721000>;
127		regulator-max-microvolt = <1022000>;
128
129		vin-supply = <&main_12v>;
130
131		pwms = <&pwm_AO_cd 1 1250 0>;
132		pwm-dutycycle-range = <100 0>;
133
134		regulator-boot-on;
135		regulator-always-on;
136	};
137
138	hub_5v: regulator-hub_5v {
139		compatible = "regulator-fixed";
140		regulator-name = "HUB_5V";
141		regulator-min-microvolt = <5000000>;
142		regulator-max-microvolt = <5000000>;
143		vin-supply = <&vcc_5v>;
144
145		/* Connected to the Hub CHIPENABLE, LOW sets low power state */
146		gpio = <&gpio GPIOH_4 GPIO_ACTIVE_HIGH>;
147		enable-active-high;
148	};
149
150	usb_pwr_en: regulator-usb_pwr_en {
151		compatible = "regulator-fixed";
152		regulator-name = "USB_PWR_EN";
153		regulator-min-microvolt = <5000000>;
154		regulator-max-microvolt = <5000000>;
155		vin-supply = <&vcc_5v>;
156
157		/* Connected to the microUSB port power enable */
158		gpio = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>;
159		enable-active-high;
160	};
161
162	vddao_1v8: regulator-vddao_1v8 {
163		compatible = "regulator-fixed";
164		regulator-name = "VDDAO_1V8";
165		regulator-min-microvolt = <1800000>;
166		regulator-max-microvolt = <1800000>;
167		vin-supply = <&vddao_3v3>;
168		regulator-always-on;
169	};
170
171	vddao_3v3: regulator-vddao_3v3 {
172		compatible = "regulator-fixed";
173		regulator-name = "VDDAO_3V3";
174		regulator-min-microvolt = <3300000>;
175		regulator-max-microvolt = <3300000>;
176		vin-supply = <&main_12v>;
177		regulator-always-on;
178	};
179
180	hdmi-connector {
181		compatible = "hdmi-connector";
182		type = "a";
183
184		port {
185			hdmi_connector_in: endpoint {
186				remote-endpoint = <&hdmi_tx_tmds_out>;
187			};
188		};
189	};
190
191	sound {
192		compatible = "amlogic,axg-sound-card";
193		model = "SM1-ODROID-C4";
194		audio-aux-devs = <&tdmout_b>;
195		audio-routing = "TDMOUT_B IN 0", "FRDDR_A OUT 1",
196				"TDMOUT_B IN 1", "FRDDR_B OUT 1",
197				"TDMOUT_B IN 2", "FRDDR_C OUT 1",
198				"TDM_B Playback", "TDMOUT_B OUT";
199
200		assigned-clocks = <&clkc CLKID_MPLL2>,
201				  <&clkc CLKID_MPLL0>,
202				  <&clkc CLKID_MPLL1>;
203		assigned-clock-parents = <0>, <0>, <0>;
204		assigned-clock-rates = <294912000>,
205				       <270950400>,
206				       <393216000>;
207		status = "okay";
208
209		dai-link-0 {
210			sound-dai = <&frddr_a>;
211		};
212
213		dai-link-1 {
214			sound-dai = <&frddr_b>;
215		};
216
217		dai-link-2 {
218			sound-dai = <&frddr_c>;
219		};
220
221		/* 8ch hdmi interface */
222		dai-link-3 {
223			sound-dai = <&tdmif_b>;
224			dai-format = "i2s";
225			dai-tdm-slot-tx-mask-0 = <1 1>;
226			dai-tdm-slot-tx-mask-1 = <1 1>;
227			dai-tdm-slot-tx-mask-2 = <1 1>;
228			dai-tdm-slot-tx-mask-3 = <1 1>;
229			mclk-fs = <256>;
230
231			codec {
232				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
233			};
234		};
235
236		/* hdmi glue */
237		dai-link-4 {
238			sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>;
239
240			codec {
241				sound-dai = <&hdmi_tx>;
242			};
243		};
244	};
245};
246
247&arb {
248	status = "okay";
249};
250
251&clkc_audio {
252	status = "okay";
253};
254
255&cpu0 {
256	cpu-supply = <&vddcpu>;
257	operating-points-v2 = <&cpu_opp_table>;
258	clocks = <&clkc CLKID_CPU_CLK>;
259	clock-latency = <50000>;
260};
261
262&cpu1 {
263	cpu-supply = <&vddcpu>;
264	operating-points-v2 = <&cpu_opp_table>;
265	clocks = <&clkc CLKID_CPU1_CLK>;
266	clock-latency = <50000>;
267};
268
269&cpu2 {
270	cpu-supply = <&vddcpu>;
271	operating-points-v2 = <&cpu_opp_table>;
272	clocks = <&clkc CLKID_CPU2_CLK>;
273	clock-latency = <50000>;
274};
275
276&cpu3 {
277	cpu-supply = <&vddcpu>;
278	operating-points-v2 = <&cpu_opp_table>;
279	clocks = <&clkc CLKID_CPU3_CLK>;
280	clock-latency = <50000>;
281};
282
283&ext_mdio {
284	external_phy: ethernet-phy@0 {
285		/* Realtek RTL8211F (0x001cc916) */
286		reg = <0>;
287		max-speed = <1000>;
288
289		interrupt-parent = <&gpio_intc>;
290		/* MAC_INTR on GPIOZ_14 */
291		interrupts = <26 IRQ_TYPE_LEVEL_LOW>;
292	};
293};
294
295&ethmac {
296	pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
297	pinctrl-names = "default";
298	status = "okay";
299	phy-mode = "rgmii";
300	phy-handle = <&external_phy>;
301	amlogic,tx-delay-ns = <2>;
302};
303
304&frddr_a {
305	status = "okay";
306};
307
308&frddr_b {
309	status = "okay";
310};
311
312&frddr_c {
313	status = "okay";
314};
315
316&gpio {
317	gpio-line-names =
318		/* GPIOZ */
319		"", "", "", "", "", "", "", "",
320		"", "", "", "", "", "", "", "",
321		/* GPIOH */
322		"", "", "", "", "",
323		"PIN_36", /* GPIOH_5 */
324		"PIN_26", /* GPIOH_6 */
325		"PIN_32", /* GPIOH_7 */
326		"",
327		/* BOOT */
328		"", "", "", "", "", "", "", "",
329		"", "", "", "", "", "", "", "",
330		/* GPIOC */
331		"", "", "", "", "", "", "", "",
332		/* GPIOA */
333		"", "", "", "", "", "", "", "",
334		"", "", "", "", "", "",
335		"PIN_27", /* GPIOA_14 */
336		"PIN_28", /* GPIOA_15 */
337		/* GPIOX */
338		"PIN_16", /* GPIOX_0 */
339		"PIN_18", /* GPIOX_1 */
340		"PIN_22", /* GPIOX_2 */
341		"PIN_11", /* GPIOX_3 */
342		"PIN_13", /* GPIOX_4 */
343		"PIN_7",  /* GPIOX_5 */
344		"PIN_33", /* GPIOX_6 */
345		"PIN_15", /* GPIOX_7 */
346		"PIN_19", /* GPIOX_8 */
347		"PIN_21", /* GPIOX_9 */
348		"PIN_24", /* GPIOX_10 */
349		"PIN_23", /* GPIOX_11 */
350		"PIN_8",  /* GPIOX_12 */
351		"PIN_10", /* GPIOX_13 */
352		"PIN_29", /* GPIOX_14 */
353		"PIN_31", /* GPIOX_15 */
354		"PIN_12", /* GPIOX_16 */
355		"PIN_3",  /* GPIOX_17 */
356		"PIN_5",  /* GPIOX_18 */
357		"PIN_35"; /* GPIOX_19 */
358
359	/*
360	 * WARNING: The USB Hub on the Odroid-C4 needs a reset signal
361	 * to be turned high in order to be detected by the USB Controller
362	 * This signal should be handled by a USB specific power sequence
363	 * in order to reset the Hub when USB bus is powered down.
364	 */
365	usb-hub {
366		gpio-hog;
367		gpios = <GPIOH_4 GPIO_ACTIVE_HIGH>;
368		output-high;
369		line-name = "usb-hub-reset";
370	};
371};
372
373&gpio_ao {
374	gpio-line-names =
375		/* GPIOAO */
376		"", "", "", "",
377		"PIN_47", /* GPIOAO_4 */
378		"", "",
379		"PIN_45", /* GPIOAO_7 */
380		"PIN_46", /* GPIOAO_8 */
381		"PIN_44", /* GPIOAO_9 */
382		"PIN_42", /* GPIOAO_10 */
383		"",
384		/* GPIOE */
385		"", "", "";
386};
387
388&hdmi_tx {
389	status = "okay";
390	pinctrl-0 = <&hdmitx_hpd_pins>, <&hdmitx_ddc_pins>;
391	pinctrl-names = "default";
392	hdmi-supply = <&vcc_5v>;
393};
394
395&hdmi_tx_tmds_port {
396	hdmi_tx_tmds_out: endpoint {
397		remote-endpoint = <&hdmi_connector_in>;
398	};
399};
400
401&ir {
402	status = "okay";
403	pinctrl-0 = <&remote_input_ao_pins>;
404	pinctrl-names = "default";
405	linux,rc-map-name = "rc-odroid";
406};
407
408&pwm_AO_cd {
409	pinctrl-0 = <&pwm_ao_d_e_pins>;
410	pinctrl-names = "default";
411	clocks = <&xtal>;
412	clock-names = "clkin1";
413	status = "okay";
414};
415
416&saradc {
417	status = "okay";
418};
419
420/* SD card */
421&sd_emmc_b {
422	status = "okay";
423	pinctrl-0 = <&sdcard_c_pins>;
424	pinctrl-1 = <&sdcard_clk_gate_c_pins>;
425	pinctrl-names = "default", "clk-gate";
426
427	bus-width = <4>;
428	cap-sd-highspeed;
429	max-frequency = <200000000>;
430	sd-uhs-sdr12;
431	sd-uhs-sdr25;
432	sd-uhs-sdr50;
433	sd-uhs-sdr104;
434	disable-wp;
435
436	cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>;
437	vmmc-supply = <&tflash_vdd>;
438	vqmmc-supply = <&tf_io>;
439};
440
441/* eMMC */
442&sd_emmc_c {
443	status = "okay";
444	pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_8b_pins>, <&emmc_ds_pins>;
445	pinctrl-1 = <&emmc_clk_gate_pins>;
446	pinctrl-names = "default", "clk-gate";
447
448	bus-width = <8>;
449	cap-mmc-highspeed;
450	mmc-ddr-1_8v;
451	mmc-hs200-1_8v;
452	max-frequency = <200000000>;
453	disable-wp;
454
455	mmc-pwrseq = <&emmc_pwrseq>;
456	vmmc-supply = <&vcc_3v3>;
457	vqmmc-supply = <&flash_1v8>;
458};
459
460&tdmif_b {
461	status = "okay";
462};
463
464&tdmout_b {
465	status = "okay";
466};
467
468&tohdmitx {
469	status = "okay";
470};
471
472&uart_AO {
473	status = "okay";
474	pinctrl-0 = <&uart_ao_a_pins>;
475	pinctrl-names = "default";
476};
477
478&usb {
479	status = "okay";
480	vbus-supply = <&usb_pwr_en>;
481};
482
483&usb2_phy0 {
484	phy-supply = <&vcc_5v>;
485};
486
487&usb2_phy1 {
488	/* Enable the hub which is connected to this port */
489	phy-supply = <&hub_5v>;
490};
491