1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2019 BayLibre, SAS
4 * Author: Neil Armstrong <narmstrong@baylibre.com>
5 * Copyright (c) 2019 Christian Hewitt <christianshewitt@gmail.com>
6 */
7
8/dts-v1/;
9
10#include "meson-g12b.dtsi"
11#include "meson-g12b-s922x.dtsi"
12#include <dt-bindings/input/input.h>
13#include <dt-bindings/gpio/meson-g12a-gpio.h>
14#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
15
16/ {
17	compatible = "ugoos,am6", "amlogic,g12b";
18	model = "Ugoos AM6";
19
20	aliases {
21		serial0 = &uart_AO;
22		ethernet0 = &ethmac;
23	};
24
25	chosen {
26		stdout-path = "serial0:115200n8";
27	};
28
29	memory@0 {
30		device_type = "memory";
31		reg = <0x0 0x0 0x0 0x40000000>;
32	};
33
34	emmc_pwrseq: emmc-pwrseq {
35		compatible = "mmc-pwrseq-emmc";
36		reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>;
37	};
38
39	sdio_pwrseq: sdio-pwrseq {
40		compatible = "mmc-pwrseq-simple";
41		reset-gpios = <&gpio GPIOX_6 GPIO_ACTIVE_LOW>;
42		clocks = <&wifi32k>;
43		clock-names = "ext_clock";
44	};
45
46	spdif_dit: audio-codec-1 {
47		#sound-dai-cells = <0>;
48		compatible = "linux,spdif-dit";
49		status = "okay";
50		sound-name-prefix = "DIT";
51	};
52
53	flash_1v8: regulator-flash_1v8 {
54		compatible = "regulator-fixed";
55		regulator-name = "FLASH_1V8";
56		regulator-min-microvolt = <1800000>;
57		regulator-max-microvolt = <1800000>;
58		vin-supply = <&vcc_3v3>;
59		regulator-always-on;
60	};
61
62	main_12v: regulator-main_12v {
63		compatible = "regulator-fixed";
64		regulator-name = "12V";
65		regulator-min-microvolt = <12000000>;
66		regulator-max-microvolt = <12000000>;
67		regulator-always-on;
68	};
69
70	vcc_5v: regulator-vcc_5v {
71		compatible = "regulator-fixed";
72		regulator-name = "VCC_5V";
73		regulator-min-microvolt = <5000000>;
74		regulator-max-microvolt = <5000000>;
75		vin-supply = <&main_12v>;
76
77		gpio = <&gpio GPIOH_8 GPIO_OPEN_DRAIN>;
78		enable-active-high;
79	};
80
81	vcc_1v8: regulator-vcc_1v8 {
82		compatible = "regulator-fixed";
83		regulator-name = "VCC_1V8";
84		regulator-min-microvolt = <1800000>;
85		regulator-max-microvolt = <1800000>;
86		vin-supply = <&vcc_3v3>;
87		regulator-always-on;
88	};
89
90	vcc_3v3: regulator-vcc_3v3 {
91		compatible = "regulator-fixed";
92		regulator-name = "VCC_3V3";
93		regulator-min-microvolt = <3300000>;
94		regulator-max-microvolt = <3300000>;
95		vin-supply = <&vddao_3v3>;
96		regulator-always-on;
97		/* FIXME: actually controlled by VDDCPU_B_EN */
98	};
99
100	vddcpu_a: regulator-vddcpu-a {
101		/*
102		 * MP1653 Regulator.
103		 */
104		compatible = "pwm-regulator";
105
106		regulator-name = "VDDCPU_A";
107		regulator-min-microvolt = <721000>;
108		regulator-max-microvolt = <1022000>;
109
110		vin-supply = <&main_12v>;
111
112		pwms = <&pwm_ab 0 1250 0>;
113		pwm-dutycycle-range = <100 0>;
114
115		regulator-boot-on;
116		regulator-always-on;
117	};
118
119	vddcpu_b: regulator-vddcpu-b {
120		/*
121		 * MP1652 Regulator.
122		 */
123		compatible = "pwm-regulator";
124
125		regulator-name = "VDDCPU_B";
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	usb1_pow: regulator-usb1-pow {
139		compatible = "regulator-fixed";
140		regulator-name = "USB1_POW";
141		regulator-min-microvolt = <5000000>;
142		regulator-max-microvolt = <5000000>;
143		vin-supply = <&vcc_5v>;
144
145		/* connected to SY6280A Power Switch */
146		gpio = <&gpio GPIOA_8 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 USB3 Type-A Port power enable */
158		gpio = <&gpio GPIOAO_7 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	cvbs-connector {
181		compatible = "composite-video-connector";
182
183		port {
184			cvbs_connector_in: endpoint {
185				remote-endpoint = <&cvbs_vdac_out>;
186			};
187		};
188	};
189
190	hdmi-connector {
191		compatible = "hdmi-connector";
192		type = "a";
193
194		port {
195			hdmi_connector_in: endpoint {
196				remote-endpoint = <&hdmi_tx_tmds_out>;
197			};
198		};
199	};
200
201	sound {
202		compatible = "amlogic,axg-sound-card";
203		model = "G12B-UGOOS-AM6";
204		audio-aux-devs = <&tdmout_b>;
205		audio-routing = "TDMOUT_B IN 0", "FRDDR_A OUT 1",
206				"TDMOUT_B IN 1", "FRDDR_B OUT 1",
207				"TDMOUT_B IN 2", "FRDDR_C OUT 1",
208				"TDM_B Playback", "TDMOUT_B OUT",
209				"SPDIFOUT IN 0", "FRDDR_A OUT 3",
210				"SPDIFOUT IN 1", "FRDDR_B OUT 3",
211				"SPDIFOUT IN 2", "FRDDR_C OUT 3";
212
213		assigned-clocks = <&clkc CLKID_MPLL2>,
214				  <&clkc CLKID_MPLL0>,
215				  <&clkc CLKID_MPLL1>;
216		assigned-clock-parents = <0>, <0>, <0>;
217		assigned-clock-rates = <294912000>,
218				       <270950400>,
219				       <393216000>;
220		status = "okay";
221
222		dai-link-0 {
223			sound-dai = <&frddr_a>;
224		};
225
226		dai-link-1 {
227			sound-dai = <&frddr_b>;
228		};
229
230		dai-link-2 {
231			sound-dai = <&frddr_c>;
232		};
233
234		/* 8ch hdmi interface */
235		dai-link-3 {
236			sound-dai = <&tdmif_b>;
237			dai-format = "i2s";
238			dai-tdm-slot-tx-mask-0 = <1 1>;
239			dai-tdm-slot-tx-mask-1 = <1 1>;
240			dai-tdm-slot-tx-mask-2 = <1 1>;
241			dai-tdm-slot-tx-mask-3 = <1 1>;
242			mclk-fs = <256>;
243
244			codec {
245				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
246			};
247		};
248
249		/* spdif hdmi or toslink interface */
250		dai-link-4 {
251			sound-dai = <&spdifout>;
252
253			codec-0 {
254				sound-dai = <&spdif_dit>;
255			};
256
257			codec-1 {
258				sound-dai = <&tohdmitx TOHDMITX_SPDIF_IN_A>;
259			};
260		};
261
262		/* spdif hdmi interface */
263		dai-link-5 {
264			sound-dai = <&spdifout_b>;
265
266			codec {
267				sound-dai = <&tohdmitx TOHDMITX_SPDIF_IN_B>;
268			};
269		};
270
271		/* hdmi glue */
272		dai-link-6 {
273			sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>;
274
275			codec {
276				sound-dai = <&hdmi_tx>;
277			};
278		};
279	};
280
281	wifi32k: wifi32k {
282		compatible = "pwm-clock";
283		#clock-cells = <0>;
284		clock-frequency = <32768>;
285		pwms = <&pwm_ef 0 30518 0>; /* PWM_E at 32.768KHz */
286	};
287};
288
289&arb {
290	status = "okay";
291};
292
293&cec_AO {
294	pinctrl-0 = <&cec_ao_a_h_pins>;
295	pinctrl-names = "default";
296	status = "disabled";
297	hdmi-phandle = <&hdmi_tx>;
298};
299
300&cecb_AO {
301	pinctrl-0 = <&cec_ao_b_h_pins>;
302	pinctrl-names = "default";
303	status = "okay";
304	hdmi-phandle = <&hdmi_tx>;
305};
306
307&clkc_audio {
308	status = "okay";
309};
310
311&cpu0 {
312	cpu-supply = <&vddcpu_b>;
313	operating-points-v2 = <&cpu_opp_table_0>;
314	clocks = <&clkc CLKID_CPU_CLK>;
315	clock-latency = <50000>;
316};
317
318&cpu1 {
319	cpu-supply = <&vddcpu_b>;
320	operating-points-v2 = <&cpu_opp_table_0>;
321	clocks = <&clkc CLKID_CPU_CLK>;
322	clock-latency = <50000>;
323};
324
325&cpu100 {
326	cpu-supply = <&vddcpu_a>;
327	operating-points-v2 = <&cpub_opp_table_1>;
328	clocks = <&clkc CLKID_CPUB_CLK>;
329	clock-latency = <50000>;
330};
331
332&cpu101 {
333	cpu-supply = <&vddcpu_a>;
334	operating-points-v2 = <&cpub_opp_table_1>;
335	clocks = <&clkc CLKID_CPUB_CLK>;
336	clock-latency = <50000>;
337};
338
339&cpu102 {
340	cpu-supply = <&vddcpu_a>;
341	operating-points-v2 = <&cpub_opp_table_1>;
342	clocks = <&clkc CLKID_CPUB_CLK>;
343	clock-latency = <50000>;
344};
345
346&cpu103 {
347	cpu-supply = <&vddcpu_a>;
348	operating-points-v2 = <&cpub_opp_table_1>;
349	clocks = <&clkc CLKID_CPUB_CLK>;
350	clock-latency = <50000>;
351};
352
353&cvbs_vdac_port {
354	cvbs_vdac_out: endpoint {
355		remote-endpoint = <&cvbs_connector_in>;
356	};
357};
358
359&ext_mdio {
360	external_phy: ethernet-phy@0 {
361		/* Realtek RTL8211F (0x001cc916) */
362		reg = <0>;
363		max-speed = <1000>;
364
365		reset-assert-us = <10000>;
366		reset-deassert-us = <30000>;
367		reset-gpios = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
368
369		interrupt-parent = <&gpio_intc>;
370		/* MAC_INTR on GPIOZ_14 */
371		interrupts = <26 IRQ_TYPE_LEVEL_LOW>;
372	};
373};
374
375&ethmac {
376	pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
377	pinctrl-names = "default";
378	status = "okay";
379	phy-mode = "rgmii";
380	phy-handle = <&external_phy>;
381	amlogic,tx-delay-ns = <2>;
382};
383
384&frddr_a {
385	status = "okay";
386};
387
388&frddr_b {
389	status = "okay";
390};
391
392&frddr_c {
393	status = "okay";
394};
395
396&hdmi_tx {
397	status = "okay";
398	pinctrl-0 = <&hdmitx_hpd_pins>, <&hdmitx_ddc_pins>;
399	pinctrl-names = "default";
400	hdmi-supply = <&vcc_5v>;
401};
402
403&hdmi_tx_tmds_port {
404	hdmi_tx_tmds_out: endpoint {
405		remote-endpoint = <&hdmi_connector_in>;
406	};
407};
408
409&ir {
410	status = "okay";
411	pinctrl-0 = <&remote_input_ao_pins>;
412	pinctrl-names = "default";
413	linux,rc-map-name = "rc-khadas";
414};
415
416&pwm_ab {
417	pinctrl-0 = <&pwm_a_e_pins>;
418	pinctrl-names = "default";
419	clocks = <&xtal>;
420	clock-names = "clkin0";
421	status = "okay";
422};
423
424&pwm_AO_cd {
425	pinctrl-0 = <&pwm_ao_d_e_pins>;
426	pinctrl-names = "default";
427	clocks = <&xtal>;
428	clock-names = "clkin1";
429	status = "okay";
430};
431
432&pwm_ef {
433	pinctrl-0 = <&pwm_e_pins>;
434	pinctrl-names = "default";
435	clocks = <&xtal>;
436	clock-names = "clkin0";
437	status = "okay";
438};
439
440/* SDIO */
441&sd_emmc_a {
442	status = "okay";
443	pinctrl-0 = <&sdio_pins>;
444	pinctrl-1 = <&sdio_clk_gate_pins>;
445	pinctrl-names = "default", "clk-gate";
446	#address-cells = <1>;
447	#size-cells = <0>;
448
449	bus-width = <4>;
450	cap-sd-highspeed;
451	sd-uhs-sdr50;
452	max-frequency = <100000000>;
453
454	non-removable;
455	disable-wp;
456
457	mmc-pwrseq = <&sdio_pwrseq>;
458
459	vmmc-supply = <&vddao_3v3>;
460	vqmmc-supply = <&vddao_1v8>;
461
462	brcmf: wifi@1 {
463		reg = <1>;
464		compatible = "brcm,bcm4329-fmac";
465	};
466};
467
468/* SD card */
469&sd_emmc_b {
470	status = "okay";
471	pinctrl-0 = <&sdcard_c_pins>;
472	pinctrl-1 = <&sdcard_clk_gate_c_pins>;
473	pinctrl-names = "default", "clk-gate";
474
475	bus-width = <4>;
476	cap-sd-highspeed;
477	max-frequency = <50000000>;
478	disable-wp;
479
480	cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>;
481	vmmc-supply = <&vddao_3v3>;
482	vqmmc-supply = <&vddao_3v3>;
483};
484
485/* eMMC */
486&sd_emmc_c {
487	status = "okay";
488	pinctrl-0 = <&emmc_pins>, <&emmc_ds_pins>;
489	pinctrl-1 = <&emmc_clk_gate_pins>;
490	pinctrl-names = "default", "clk-gate";
491
492	bus-width = <8>;
493	cap-mmc-highspeed;
494	max-frequency = <100000000>;
495	disable-wp;
496
497	mmc-pwrseq = <&emmc_pwrseq>;
498	vmmc-supply = <&vcc_3v3>;
499	vqmmc-supply = <&flash_1v8>;
500};
501
502&spdifout {
503	pinctrl-0 = <&spdif_out_h_pins>;
504	pinctrl-names = "default";
505	status = "okay";
506};
507
508&spdifout_b {
509	status = "okay";
510};
511
512&tdmif_b {
513	status = "okay";
514};
515
516&tdmout_b {
517	status = "okay";
518};
519
520&tohdmitx {
521	status = "okay";
522};
523
524&uart_A {
525	status = "okay";
526	pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>;
527	pinctrl-names = "default";
528	uart-has-rtscts;
529
530	bluetooth {
531		compatible = "brcm,bcm43438-bt";
532		shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
533		max-speed = <2000000>;
534		clocks = <&wifi32k>;
535	clock-names = "lpo";
536	};
537};
538
539&uart_AO {
540	status = "okay";
541	pinctrl-0 = <&uart_ao_a_pins>;
542	pinctrl-names = "default";
543};
544
545&usb {
546	status = "okay";
547	dr_mode = "host";
548	vbus-regulator = <&usb_pwr_en>;
549};
550
551&usb2_phy0 {
552	phy-supply = <&usb1_pow>;
553};
554
555&usb2_phy1 {
556	phy-supply = <&usb1_pow>;
557};
558