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
12/ {
13	compatible = "hardkernel,odroid-c4", "amlogic,sm1";
14	model = "Hardkernel ODROID-C4";
15
16	aliases {
17		serial0 = &uart_AO;
18		ethernet0 = &ethmac;
19	};
20
21	chosen {
22		stdout-path = "serial0:115200n8";
23	};
24
25	memory@0 {
26		device_type = "memory";
27		reg = <0x0 0x0 0x0 0x40000000>;
28	};
29
30	emmc_pwrseq: emmc-pwrseq {
31		compatible = "mmc-pwrseq-emmc";
32		reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>;
33	};
34
35	leds {
36		compatible = "gpio-leds";
37
38		led-blue {
39			color = <LED_COLOR_ID_BLUE>;
40			function = LED_FUNCTION_STATUS;
41			gpios = <&gpio_ao GPIOAO_11 GPIO_ACTIVE_HIGH>;
42			linux,default-trigger = "heartbeat";
43			panic-indicator;
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_3 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_6 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: regulator-vddcpu {
119		/*
120		 * MP8756GD Regulator.
121		 */
122		compatible = "pwm-regulator";
123
124		regulator-name = "VDDCPU";
125		regulator-min-microvolt = <721000>;
126		regulator-max-microvolt = <1022000>;
127
128		vin-supply = <&main_12v>;
129
130		pwms = <&pwm_AO_cd 1 1250 0>;
131		pwm-dutycycle-range = <100 0>;
132
133		regulator-boot-on;
134		regulator-always-on;
135	};
136
137	hub_5v: regulator-hub_5v {
138		compatible = "regulator-fixed";
139		regulator-name = "HUB_5V";
140		regulator-min-microvolt = <5000000>;
141		regulator-max-microvolt = <5000000>;
142		vin-supply = <&vcc_5v>;
143
144		/* Connected to the Hub CHIPENABLE, LOW sets low power state */
145		gpio = <&gpio GPIOH_4 GPIO_ACTIVE_HIGH>;
146		enable-active-high;
147	};
148
149	usb_pwr_en: regulator-usb_pwr_en {
150		compatible = "regulator-fixed";
151		regulator-name = "USB_PWR_EN";
152		regulator-min-microvolt = <5000000>;
153		regulator-max-microvolt = <5000000>;
154		vin-supply = <&vcc_5v>;
155
156		/* Connected to the microUSB port power enable */
157		gpio = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>;
158		enable-active-high;
159	};
160
161	vddao_1v8: regulator-vddao_1v8 {
162		compatible = "regulator-fixed";
163		regulator-name = "VDDAO_1V8";
164		regulator-min-microvolt = <1800000>;
165		regulator-max-microvolt = <1800000>;
166		vin-supply = <&vddao_3v3>;
167		regulator-always-on;
168	};
169
170	vddao_3v3: regulator-vddao_3v3 {
171		compatible = "regulator-fixed";
172		regulator-name = "VDDAO_3V3";
173		regulator-min-microvolt = <3300000>;
174		regulator-max-microvolt = <3300000>;
175		vin-supply = <&main_12v>;
176		regulator-always-on;
177	};
178
179	hdmi-connector {
180		compatible = "hdmi-connector";
181		type = "a";
182
183		port {
184			hdmi_connector_in: endpoint {
185				remote-endpoint = <&hdmi_tx_tmds_out>;
186			};
187		};
188	};
189};
190
191&cpu0 {
192	cpu-supply = <&vddcpu>;
193	operating-points-v2 = <&cpu_opp_table>;
194	clocks = <&clkc CLKID_CPU_CLK>;
195	clock-latency = <50000>;
196};
197
198&cpu1 {
199	cpu-supply = <&vddcpu>;
200	operating-points-v2 = <&cpu_opp_table>;
201	clocks = <&clkc CLKID_CPU1_CLK>;
202	clock-latency = <50000>;
203};
204
205&cpu2 {
206	cpu-supply = <&vddcpu>;
207	operating-points-v2 = <&cpu_opp_table>;
208	clocks = <&clkc CLKID_CPU2_CLK>;
209	clock-latency = <50000>;
210};
211
212&cpu3 {
213	cpu-supply = <&vddcpu>;
214	operating-points-v2 = <&cpu_opp_table>;
215	clocks = <&clkc CLKID_CPU3_CLK>;
216	clock-latency = <50000>;
217};
218
219&ext_mdio {
220	external_phy: ethernet-phy@0 {
221		/* Realtek RTL8211F (0x001cc916) */
222		reg = <0>;
223		max-speed = <1000>;
224
225		interrupt-parent = <&gpio_intc>;
226		/* MAC_INTR on GPIOZ_14 */
227		interrupts = <26 IRQ_TYPE_LEVEL_LOW>;
228	};
229};
230
231&ethmac {
232	pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
233	pinctrl-names = "default";
234	status = "okay";
235	phy-mode = "rgmii";
236	phy-handle = <&external_phy>;
237	amlogic,tx-delay-ns = <2>;
238};
239
240&gpio {
241	gpio-line-names =
242		/* GPIOZ */
243		"", "", "", "", "", "", "", "",
244		"", "", "", "", "", "", "", "",
245		/* GPIOH */
246		"", "", "", "", "",
247		"PIN_36", /* GPIOH_5 */
248		"PIN_26", /* GPIOH_6 */
249		"PIN_32", /* GPIOH_7 */
250		"",
251		/* BOOT */
252		"", "", "", "", "", "", "", "",
253		"", "", "", "", "", "", "", "",
254		/* GPIOC */
255		"", "", "", "", "", "", "", "",
256		/* GPIOA */
257		"", "", "", "", "", "", "", "",
258		"", "", "", "", "", "",
259		"PIN_27", /* GPIOA_14 */
260		"PIN_28", /* GPIOA_15 */
261		/* GPIOX */
262		"PIN_16", /* GPIOX_0 */
263		"PIN_18", /* GPIOX_1 */
264		"PIN_22", /* GPIOX_2 */
265		"PIN_11", /* GPIOX_3 */
266		"PIN_13", /* GPIOX_4 */
267		"PIN_7",  /* GPIOX_5 */
268		"PIN_33", /* GPIOX_6 */
269		"PIN_15", /* GPIOX_7 */
270		"PIN_19", /* GPIOX_8 */
271		"PIN_21", /* GPIOX_9 */
272		"PIN_24", /* GPIOX_10 */
273		"PIN_23", /* GPIOX_11 */
274		"PIN_8",  /* GPIOX_12 */
275		"PIN_10", /* GPIOX_13 */
276		"PIN_29", /* GPIOX_14 */
277		"PIN_31", /* GPIOX_15 */
278		"PIN_12", /* GPIOX_16 */
279		"PIN_3",  /* GPIOX_17 */
280		"PIN_5",  /* GPIOX_18 */
281		"PIN_35"; /* GPIOX_19 */
282
283	/*
284	 * WARNING: The USB Hub on the Odroid-C4 needs a reset signal
285	 * to be turned high in order to be detected by the USB Controller
286	 * This signal should be handled by a USB specific power sequence
287	 * in order to reset the Hub when USB bus is powered down.
288	 */
289	usb-hub {
290		gpio-hog;
291		gpios = <GPIOH_4 GPIO_ACTIVE_HIGH>;
292		output-high;
293		line-name = "usb-hub-reset";
294	};
295};
296
297&gpio_ao {
298	gpio-line-names =
299		/* GPIOAO */
300		"", "", "", "",
301		"PIN_47", /* GPIOAO_4 */
302		"", "",
303		"PIN_45", /* GPIOAO_7 */
304		"PIN_46", /* GPIOAO_8 */
305		"PIN_44", /* GPIOAO_9 */
306		"PIN_42", /* GPIOAO_10 */
307		"",
308		/* GPIOE */
309		"", "", "";
310};
311
312&hdmi_tx {
313	status = "okay";
314	pinctrl-0 = <&hdmitx_hpd_pins>, <&hdmitx_ddc_pins>;
315	pinctrl-names = "default";
316	hdmi-supply = <&vcc_5v>;
317};
318
319&hdmi_tx_tmds_port {
320	hdmi_tx_tmds_out: endpoint {
321		remote-endpoint = <&hdmi_connector_in>;
322	};
323};
324
325&ir {
326	status = "okay";
327	pinctrl-0 = <&remote_input_ao_pins>;
328	pinctrl-names = "default";
329	linux,rc-map-name = "rc-odroid";
330};
331
332&pwm_AO_cd {
333	pinctrl-0 = <&pwm_ao_d_e_pins>;
334	pinctrl-names = "default";
335	clocks = <&xtal>;
336	clock-names = "clkin1";
337	status = "okay";
338};
339
340&saradc {
341	status = "okay";
342};
343
344/* SD card */
345&sd_emmc_b {
346	status = "okay";
347	pinctrl-0 = <&sdcard_c_pins>;
348	pinctrl-1 = <&sdcard_clk_gate_c_pins>;
349	pinctrl-names = "default", "clk-gate";
350
351	bus-width = <4>;
352	cap-sd-highspeed;
353	max-frequency = <200000000>;
354	sd-uhs-sdr12;
355	sd-uhs-sdr25;
356	sd-uhs-sdr50;
357	sd-uhs-sdr104;
358	disable-wp;
359
360	cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>;
361	vmmc-supply = <&tflash_vdd>;
362	vqmmc-supply = <&tf_io>;
363};
364
365/* eMMC */
366&sd_emmc_c {
367	status = "okay";
368	pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_8b_pins>, <&emmc_ds_pins>;
369	pinctrl-1 = <&emmc_clk_gate_pins>;
370	pinctrl-names = "default", "clk-gate";
371
372	bus-width = <8>;
373	cap-mmc-highspeed;
374	mmc-ddr-1_8v;
375	mmc-hs200-1_8v;
376	max-frequency = <200000000>;
377	disable-wp;
378
379	mmc-pwrseq = <&emmc_pwrseq>;
380	vmmc-supply = <&vcc_3v3>;
381	vqmmc-supply = <&flash_1v8>;
382};
383
384&uart_AO {
385	status = "okay";
386	pinctrl-0 = <&uart_ao_a_pins>;
387	pinctrl-names = "default";
388};
389
390&usb {
391	status = "okay";
392	vbus-supply = <&usb_pwr_en>;
393};
394
395&usb2_phy0 {
396	phy-supply = <&vcc_5v>;
397};
398
399&usb2_phy1 {
400	/* Enable the hub which is connected to this port */
401	phy-supply = <&hub_5v>;
402};
403