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