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#include <dt-bindings/input/input.h>
9#include <dt-bindings/gpio/meson-g12a-gpio.h>
10#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
11
12/ {
13	model = "Khadas VIM3";
14
15	aliases {
16		serial0 = &uart_AO;
17		ethernet0 = &ethmac;
18	};
19
20	chosen {
21		stdout-path = "serial0:115200n8";
22	};
23
24	memory@0 {
25		device_type = "memory";
26		reg = <0x0 0x0 0x0 0x80000000>;
27	};
28
29	adc-keys {
30		compatible = "adc-keys";
31		io-channels = <&saradc 2>;
32		io-channel-names = "buttons";
33		keyup-threshold-microvolt = <1710000>;
34
35		button-function {
36			label = "Function";
37			linux,code = <KEY_FN>;
38			press-threshold-microvolt = <10000>;
39		};
40	};
41
42	leds {
43		compatible = "gpio-leds";
44
45		white {
46			label = "vim3:white:sys";
47			gpios = <&gpio_ao GPIOAO_4 GPIO_ACTIVE_LOW>;
48			linux,default-trigger = "heartbeat";
49		};
50
51		red {
52			label = "vim3:red";
53			gpios = <&gpio_expander 5 GPIO_ACTIVE_LOW>;
54		};
55	};
56
57	emmc_pwrseq: emmc-pwrseq {
58		compatible = "mmc-pwrseq-emmc";
59		reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>;
60	};
61
62	gpio-keys-polled {
63		compatible = "gpio-keys-polled";
64		poll-interval = <100>;
65
66		power-button {
67			label = "power";
68			linux,code = <KEY_POWER>;
69			gpios = <&gpio_ao GPIOAO_7 GPIO_ACTIVE_LOW>;
70		};
71	};
72
73	sdio_pwrseq: sdio-pwrseq {
74		compatible = "mmc-pwrseq-simple";
75		reset-gpios = <&gpio GPIOX_6 GPIO_ACTIVE_LOW>;
76		clocks = <&wifi32k>;
77		clock-names = "ext_clock";
78	};
79
80	dc_in: regulator-dc_in {
81		compatible = "regulator-fixed";
82		regulator-name = "DC_IN";
83		regulator-min-microvolt = <5000000>;
84		regulator-max-microvolt = <5000000>;
85		regulator-always-on;
86	};
87
88	vcc_5v: regulator-vcc_5v {
89		compatible = "regulator-fixed";
90		regulator-name = "VCC_5V";
91		regulator-min-microvolt = <5000000>;
92		regulator-max-microvolt = <5000000>;
93		vin-supply = <&dc_in>;
94
95		gpio = <&gpio GPIOH_8 GPIO_OPEN_DRAIN>;
96		enable-active-high;
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 = <&vsys_3v3>;
114		regulator-always-on;
115		/* FIXME: actually controlled by VDDCPU_B_EN */
116	};
117
118	vddcpu_a: regulator-vddcpu-a {
119		/*
120		 * MP8756GD Regulator.
121		 */
122		compatible = "pwm-regulator";
123
124		regulator-name = "VDDCPU_A";
125		regulator-min-microvolt = <690000>;
126		regulator-max-microvolt = <1050000>;
127
128		vin-supply = <&dc_in>;
129
130		pwms = <&pwm_ab 0 1250 0>;
131		pwm-dutycycle-range = <100 0>;
132
133		regulator-boot-on;
134		regulator-always-on;
135	};
136
137	vddcpu_b: regulator-vddcpu-b {
138		/*
139		 * Silergy SY8030DEC Regulator.
140		 */
141		compatible = "pwm-regulator";
142
143		regulator-name = "VDDCPU_B";
144		regulator-min-microvolt = <690000>;
145		regulator-max-microvolt = <1050000>;
146
147		vin-supply = <&vsys_3v3>;
148
149		pwms = <&pwm_AO_cd 1 1250 0>;
150		pwm-dutycycle-range = <100 0>;
151
152		regulator-boot-on;
153		regulator-always-on;
154	};
155
156	vddao_1v8: regulator-vddao_1v8 {
157		compatible = "regulator-fixed";
158		regulator-name = "VDDIO_AO1V8";
159		regulator-min-microvolt = <1800000>;
160		regulator-max-microvolt = <1800000>;
161		vin-supply = <&vsys_3v3>;
162		regulator-always-on;
163	};
164
165	emmc_1v8: regulator-emmc_1v8 {
166		compatible = "regulator-fixed";
167		regulator-name = "EMMC_AO1V8";
168		regulator-min-microvolt = <1800000>;
169		regulator-max-microvolt = <1800000>;
170		vin-supply = <&vcc_3v3>;
171		regulator-always-on;
172	};
173
174	vsys_3v3: regulator-vsys_3v3 {
175		compatible = "regulator-fixed";
176		regulator-name = "VSYS_3V3";
177		regulator-min-microvolt = <3300000>;
178		regulator-max-microvolt = <3300000>;
179		vin-supply = <&dc_in>;
180		regulator-always-on;
181	};
182
183	usb_pwr: regulator-usb_pwr {
184		compatible = "regulator-fixed";
185		regulator-name = "USB_PWR";
186		regulator-min-microvolt = <5000000>;
187		regulator-max-microvolt = <5000000>;
188		vin-supply = <&vcc_5v>;
189
190		gpio = <&gpio GPIOA_6 GPIO_ACTIVE_HIGH>;
191		enable-active-high;
192	};
193
194	hdmi-connector {
195		compatible = "hdmi-connector";
196		type = "a";
197
198		port {
199			hdmi_connector_in: endpoint {
200				remote-endpoint = <&hdmi_tx_tmds_out>;
201			};
202		};
203	};
204
205	wifi32k: wifi32k {
206		compatible = "pwm-clock";
207		#clock-cells = <0>;
208		clock-frequency = <32768>;
209		pwms = <&pwm_ef 0 30518 0>; /* PWM_E at 32.768KHz */
210	};
211
212	sound {
213		compatible = "amlogic,axg-sound-card";
214		model = "G12A-KHADAS-VIM3";
215		audio-aux-devs = <&tdmout_b>;
216		audio-routing = "TDMOUT_B IN 0", "FRDDR_A OUT 1",
217				"TDMOUT_B IN 1", "FRDDR_B OUT 1",
218				"TDMOUT_B IN 2", "FRDDR_C OUT 1",
219				"TDM_B Playback", "TDMOUT_B OUT";
220
221		assigned-clocks = <&clkc CLKID_MPLL2>,
222				  <&clkc CLKID_MPLL0>,
223				  <&clkc CLKID_MPLL1>;
224		assigned-clock-parents = <0>, <0>, <0>;
225		assigned-clock-rates = <294912000>,
226				       <270950400>,
227				       <393216000>;
228		status = "okay";
229
230		dai-link-0 {
231			sound-dai = <&frddr_a>;
232		};
233
234		dai-link-1 {
235			sound-dai = <&frddr_b>;
236		};
237
238		dai-link-2 {
239			sound-dai = <&frddr_c>;
240		};
241
242		/* 8ch hdmi interface */
243		dai-link-3 {
244			sound-dai = <&tdmif_b>;
245			dai-format = "i2s";
246			dai-tdm-slot-tx-mask-0 = <1 1>;
247			dai-tdm-slot-tx-mask-1 = <1 1>;
248			dai-tdm-slot-tx-mask-2 = <1 1>;
249			dai-tdm-slot-tx-mask-3 = <1 1>;
250			mclk-fs = <256>;
251
252			codec {
253				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
254			};
255		};
256
257		/* hdmi glue */
258		dai-link-4 {
259			sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>;
260
261			codec {
262				sound-dai = <&hdmi_tx>;
263			};
264		};
265	};
266};
267
268&arb {
269	status = "okay";
270};
271
272&cec_AO {
273	pinctrl-0 = <&cec_ao_a_h_pins>;
274	pinctrl-names = "default";
275	status = "disabled";
276	hdmi-phandle = <&hdmi_tx>;
277};
278
279&cecb_AO {
280	pinctrl-0 = <&cec_ao_b_h_pins>;
281	pinctrl-names = "default";
282	status = "okay";
283	hdmi-phandle = <&hdmi_tx>;
284};
285
286&clkc_audio {
287	status = "okay";
288};
289
290&cpu0 {
291	cpu-supply = <&vddcpu_b>;
292	operating-points-v2 = <&cpu_opp_table_0>;
293	clocks = <&clkc CLKID_CPU_CLK>;
294	clock-latency = <50000>;
295};
296
297&cpu1 {
298	cpu-supply = <&vddcpu_b>;
299	operating-points-v2 = <&cpu_opp_table_0>;
300	clocks = <&clkc CLKID_CPU_CLK>;
301	clock-latency = <50000>;
302};
303
304&cpu100 {
305	cpu-supply = <&vddcpu_a>;
306	operating-points-v2 = <&cpub_opp_table_1>;
307	clocks = <&clkc CLKID_CPUB_CLK>;
308	clock-latency = <50000>;
309};
310
311&cpu101 {
312	cpu-supply = <&vddcpu_a>;
313	operating-points-v2 = <&cpub_opp_table_1>;
314	clocks = <&clkc CLKID_CPUB_CLK>;
315	clock-latency = <50000>;
316};
317
318&cpu102 {
319	cpu-supply = <&vddcpu_a>;
320	operating-points-v2 = <&cpub_opp_table_1>;
321	clocks = <&clkc CLKID_CPUB_CLK>;
322	clock-latency = <50000>;
323};
324
325&cpu103 {
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&ext_mdio {
333	external_phy: ethernet-phy@0 {
334		/* Realtek RTL8211F (0x001cc916) */
335		reg = <0>;
336		max-speed = <1000>;
337
338		interrupt-parent = <&gpio_intc>;
339		/* MAC_INTR on GPIOZ_14 */
340		interrupts = <26 IRQ_TYPE_LEVEL_LOW>;
341	};
342};
343
344&ethmac {
345        pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
346        pinctrl-names = "default";
347        status = "okay";
348        phy-mode = "rgmii";
349        phy-handle = <&external_phy>;
350        amlogic,tx-delay-ns = <2>;
351};
352
353&frddr_a {
354	status = "okay";
355};
356
357&frddr_b {
358	status = "okay";
359};
360
361&frddr_c {
362	status = "okay";
363};
364
365&hdmi_tx {
366	status = "okay";
367	pinctrl-0 = <&hdmitx_hpd_pins>, <&hdmitx_ddc_pins>;
368	pinctrl-names = "default";
369	hdmi-supply = <&vcc_5v>;
370};
371
372&hdmi_tx_tmds_port {
373	hdmi_tx_tmds_out: endpoint {
374		remote-endpoint = <&hdmi_connector_in>;
375	};
376};
377
378&i2c_AO {
379	status = "okay";
380	pinctrl-0 = <&i2c_ao_sck_pins>, <&i2c_ao_sda_pins>;
381	pinctrl-names = "default";
382
383	gpio_expander: gpio-controller@20 {
384		compatible = "ti,tca6408";
385		reg = <0x20>;
386		vcc-supply = <&vcc_3v3>;
387		gpio-controller;
388		#gpio-cells = <2>;
389	};
390
391	rtc@51 {
392		compatible = "haoyu,hym8563";
393		reg = <0x51>;
394		#clock-cells = <0>;
395	};
396};
397
398&ir {
399	status = "okay";
400	pinctrl-0 = <&remote_input_ao_pins>;
401	pinctrl-names = "default";
402	linux,rc-map-name = "rc-khadas";
403};
404
405&pwm_ab {
406	pinctrl-0 = <&pwm_a_e_pins>;
407	pinctrl-names = "default";
408	clocks = <&xtal>;
409	clock-names = "clkin0";
410	status = "okay";
411};
412
413&pwm_AO_cd {
414	pinctrl-0 = <&pwm_ao_d_e_pins>;
415	pinctrl-names = "default";
416	clocks = <&xtal>;
417	clock-names = "clkin1";
418	status = "okay";
419};
420
421&pwm_ef {
422        status = "okay";
423        pinctrl-0 = <&pwm_e_pins>;
424        pinctrl-names = "default";
425};
426
427&saradc {
428	status = "okay";
429	vref-supply = <&vddao_1v8>;
430};
431
432/* SDIO */
433&sd_emmc_a {
434	status = "okay";
435	pinctrl-0 = <&sdio_pins>;
436	pinctrl-1 = <&sdio_clk_gate_pins>;
437	pinctrl-names = "default", "clk-gate";
438	#address-cells = <1>;
439	#size-cells = <0>;
440
441	bus-width = <4>;
442	cap-sd-highspeed;
443	sd-uhs-sdr50;
444	max-frequency = <100000000>;
445
446	non-removable;
447	disable-wp;
448
449	mmc-pwrseq = <&sdio_pwrseq>;
450
451	vmmc-supply = <&vsys_3v3>;
452	vqmmc-supply = <&vddao_1v8>;
453
454	brcmf: wifi@1 {
455		reg = <1>;
456		compatible = "brcm,bcm4329-fmac";
457	};
458};
459
460/* SD card */
461&sd_emmc_b {
462	status = "okay";
463	pinctrl-0 = <&sdcard_c_pins>;
464	pinctrl-1 = <&sdcard_clk_gate_c_pins>;
465	pinctrl-names = "default", "clk-gate";
466
467	bus-width = <4>;
468	cap-sd-highspeed;
469	max-frequency = <50000000>;
470	disable-wp;
471
472	cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>;
473	vmmc-supply = <&vsys_3v3>;
474	vqmmc-supply = <&vsys_3v3>;
475};
476
477/* eMMC */
478&sd_emmc_c {
479	status = "okay";
480	pinctrl-0 = <&emmc_pins>, <&emmc_ds_pins>;
481	pinctrl-1 = <&emmc_clk_gate_pins>;
482	pinctrl-names = "default", "clk-gate";
483
484	bus-width = <8>;
485	cap-mmc-highspeed;
486	mmc-ddr-1_8v;
487	mmc-hs200-1_8v;
488	max-frequency = <200000000>;
489	disable-wp;
490
491	mmc-pwrseq = <&emmc_pwrseq>;
492	vmmc-supply = <&vcc_3v3>;
493	vqmmc-supply = <&emmc_1v8>;
494};
495
496&tdmif_b {
497	status = "okay";
498};
499
500&tdmout_b {
501	status = "okay";
502};
503
504&tohdmitx {
505	status = "okay";
506};
507
508&uart_A {
509	status = "okay";
510	pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>;
511	pinctrl-names = "default";
512	uart-has-rtscts;
513
514	bluetooth {
515		compatible = "brcm,bcm43438-bt";
516		shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
517		max-speed = <2000000>;
518		clocks = <&wifi32k>;
519		clock-names = "lpo";
520	};
521};
522
523&uart_AO {
524	status = "okay";
525	pinctrl-0 = <&uart_ao_a_pins>;
526	pinctrl-names = "default";
527};
528
529&usb2_phy0 {
530	phy-supply = <&dc_in>;
531};
532
533&usb2_phy1 {
534	phy-supply = <&usb_pwr>;
535};
536
537&usb3_pcie_phy {
538	phy-supply = <&usb_pwr>;
539};
540
541&usb {
542	status = "okay";
543	dr_mode = "peripheral";
544};
545