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	aliases {
14		serial0 = &uart_AO;
15		ethernet0 = &ethmac;
16	};
17
18	chosen {
19		stdout-path = "serial0:115200n8";
20	};
21
22	memory@0 {
23		device_type = "memory";
24		reg = <0x0 0x0 0x0 0x80000000>;
25	};
26
27	adc-keys {
28		compatible = "adc-keys";
29		io-channels = <&saradc 2>;
30		io-channel-names = "buttons";
31		keyup-threshold-microvolt = <1710000>;
32
33		button-function {
34			label = "Function";
35			linux,code = <KEY_FN>;
36			press-threshold-microvolt = <10000>;
37		};
38	};
39
40	leds {
41		compatible = "gpio-leds";
42
43		led-white {
44			label = "vim3:white:sys";
45			gpios = <&gpio_ao GPIOAO_4 GPIO_ACTIVE_HIGH>;
46			linux,default-trigger = "heartbeat";
47		};
48
49		led-red {
50			label = "vim3:red";
51			gpios = <&gpio_expander 5 GPIO_ACTIVE_HIGH>;
52		};
53	};
54
55	emmc_pwrseq: emmc-pwrseq {
56		compatible = "mmc-pwrseq-emmc";
57		reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>;
58	};
59
60	gpio-keys-polled {
61		compatible = "gpio-keys-polled";
62		poll-interval = <100>;
63
64		power-button {
65			label = "power";
66			linux,code = <KEY_POWER>;
67			gpios = <&gpio_ao GPIOAO_7 GPIO_ACTIVE_LOW>;
68		};
69	};
70
71	sdio_pwrseq: sdio-pwrseq {
72		compatible = "mmc-pwrseq-simple";
73		reset-gpios = <&gpio GPIOX_6 GPIO_ACTIVE_LOW>;
74		clocks = <&wifi32k>;
75		clock-names = "ext_clock";
76	};
77
78	dc_in: regulator-dc_in {
79		compatible = "regulator-fixed";
80		regulator-name = "DC_IN";
81		regulator-min-microvolt = <5000000>;
82		regulator-max-microvolt = <5000000>;
83		regulator-always-on;
84	};
85
86	vcc_5v: regulator-vcc_5v {
87		compatible = "regulator-fixed";
88		regulator-name = "VCC_5V";
89		regulator-min-microvolt = <5000000>;
90		regulator-max-microvolt = <5000000>;
91		vin-supply = <&dc_in>;
92
93		gpio = <&gpio GPIOH_8 GPIO_OPEN_DRAIN>;
94		enable-active-high;
95	};
96
97	vcc_1v8: regulator-vcc_1v8 {
98		compatible = "regulator-fixed";
99		regulator-name = "VCC_1V8";
100		regulator-min-microvolt = <1800000>;
101		regulator-max-microvolt = <1800000>;
102		vin-supply = <&vcc_3v3>;
103		regulator-always-on;
104	};
105
106	vcc_3v3: regulator-vcc_3v3 {
107		compatible = "regulator-fixed";
108		regulator-name = "VCC_3V3";
109		regulator-min-microvolt = <3300000>;
110		regulator-max-microvolt = <3300000>;
111		vin-supply = <&vsys_3v3>;
112		regulator-always-on;
113		/* FIXME: actually controlled by VDDCPU_B_EN */
114	};
115
116	vddao_1v8: regulator-vddao_1v8 {
117		compatible = "regulator-fixed";
118		regulator-name = "VDDIO_AO1V8";
119		regulator-min-microvolt = <1800000>;
120		regulator-max-microvolt = <1800000>;
121		vin-supply = <&vsys_3v3>;
122		regulator-always-on;
123	};
124
125	emmc_1v8: regulator-emmc_1v8 {
126		compatible = "regulator-fixed";
127		regulator-name = "EMMC_AO1V8";
128		regulator-min-microvolt = <1800000>;
129		regulator-max-microvolt = <1800000>;
130		vin-supply = <&vcc_3v3>;
131		regulator-always-on;
132	};
133
134	vsys_3v3: regulator-vsys_3v3 {
135		compatible = "regulator-fixed";
136		regulator-name = "VSYS_3V3";
137		regulator-min-microvolt = <3300000>;
138		regulator-max-microvolt = <3300000>;
139		vin-supply = <&dc_in>;
140		regulator-always-on;
141	};
142
143	usb_pwr: regulator-usb_pwr {
144		compatible = "regulator-fixed";
145		regulator-name = "USB_PWR";
146		regulator-min-microvolt = <5000000>;
147		regulator-max-microvolt = <5000000>;
148		vin-supply = <&vcc_5v>;
149
150		gpio = <&gpio GPIOA_6 GPIO_ACTIVE_HIGH>;
151		enable-active-high;
152	};
153
154	hdmi-connector {
155		compatible = "hdmi-connector";
156		type = "a";
157
158		port {
159			hdmi_connector_in: endpoint {
160				remote-endpoint = <&hdmi_tx_tmds_out>;
161			};
162		};
163	};
164
165
166	sound {
167		compatible = "amlogic,axg-sound-card";
168		model = "G12B-KHADAS-VIM3";
169		audio-aux-devs = <&tdmout_a>;
170		audio-routing = "TDMOUT_A IN 0", "FRDDR_A OUT 0",
171				"TDMOUT_A IN 1", "FRDDR_B OUT 0",
172				"TDMOUT_A IN 2", "FRDDR_C OUT 0",
173				"TDM_A Playback", "TDMOUT_A 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_a>;
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_A>;
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	wifi32k: wifi32k {
222		compatible = "pwm-clock";
223		#clock-cells = <0>;
224		clock-frequency = <32768>;
225		pwms = <&pwm_ef 0 30518 0>; /* PWM_E at 32.768KHz */
226	};
227};
228
229&arb {
230	status = "okay";
231};
232
233&clkc_audio {
234	status = "okay";
235};
236
237&cec_AO {
238	pinctrl-0 = <&cec_ao_a_h_pins>;
239	pinctrl-names = "default";
240	status = "disabled";
241	hdmi-phandle = <&hdmi_tx>;
242};
243
244&cecb_AO {
245	pinctrl-0 = <&cec_ao_b_h_pins>;
246	pinctrl-names = "default";
247	status = "okay";
248	hdmi-phandle = <&hdmi_tx>;
249};
250
251&cpu_thermal {
252	trips {
253		cpu_active: cpu-active {
254			temperature = <80000>; /* millicelsius */
255			hysteresis = <2000>; /* millicelsius */
256			type = "active";
257		};
258	};
259
260	cooling-maps {
261		map {
262			trip = <&cpu_active>;
263			cooling-device = <&khadas_mcu THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
264		};
265	};
266};
267
268&ext_mdio {
269	external_phy: ethernet-phy@0 {
270		/* Realtek RTL8211F (0x001cc916) */
271		reg = <0>;
272		max-speed = <1000>;
273
274		interrupt-parent = <&gpio_intc>;
275		/* MAC_INTR on GPIOZ_14 */
276		interrupts = <26 IRQ_TYPE_LEVEL_LOW>;
277	};
278};
279
280&ethmac {
281        pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
282        pinctrl-names = "default";
283        status = "okay";
284        phy-mode = "rgmii";
285        phy-handle = <&external_phy>;
286        amlogic,tx-delay-ns = <2>;
287};
288
289&frddr_a {
290	status = "okay";
291};
292
293&frddr_b {
294	status = "okay";
295};
296
297&frddr_c {
298	status = "okay";
299};
300
301&hdmi_tx {
302	status = "okay";
303	pinctrl-0 = <&hdmitx_hpd_pins>, <&hdmitx_ddc_pins>;
304	pinctrl-names = "default";
305	hdmi-supply = <&vcc_5v>;
306};
307
308&hdmi_tx_tmds_port {
309	hdmi_tx_tmds_out: endpoint {
310		remote-endpoint = <&hdmi_connector_in>;
311	};
312};
313
314&i2c_AO {
315	status = "okay";
316	pinctrl-0 = <&i2c_ao_sck_pins>, <&i2c_ao_sda_pins>;
317	pinctrl-names = "default";
318
319	khadas_mcu: system-controller@18 {
320		compatible = "khadas,mcu";
321		reg = <0x18>;
322		#cooling-cells = <2>;
323	};
324
325	gpio_expander: gpio-controller@20 {
326		compatible = "ti,tca6408";
327		reg = <0x20>;
328		vcc-supply = <&vcc_3v3>;
329		gpio-controller;
330		#gpio-cells = <2>;
331	};
332
333	rtc@51 {
334		compatible = "haoyu,hym8563";
335		reg = <0x51>;
336		#clock-cells = <0>;
337	};
338};
339
340&ir {
341	status = "okay";
342	pinctrl-0 = <&remote_input_ao_pins>;
343	pinctrl-names = "default";
344	linux,rc-map-name = "rc-khadas";
345};
346
347&pcie {
348	reset-gpios = <&gpio GPIOA_8 GPIO_ACTIVE_LOW>;
349};
350
351&pwm_ef {
352        status = "okay";
353        pinctrl-0 = <&pwm_e_pins>;
354        pinctrl-names = "default";
355};
356
357&saradc {
358	status = "okay";
359	vref-supply = <&vddao_1v8>;
360};
361
362/* SDIO */
363&sd_emmc_a {
364	status = "okay";
365	pinctrl-0 = <&sdio_pins>;
366	pinctrl-1 = <&sdio_clk_gate_pins>;
367	pinctrl-names = "default", "clk-gate";
368	#address-cells = <1>;
369	#size-cells = <0>;
370
371	bus-width = <4>;
372	cap-sd-highspeed;
373	max-frequency = <100000000>;
374
375	non-removable;
376	disable-wp;
377
378	/* WiFi firmware requires power to be kept while in suspend */
379	keep-power-in-suspend;
380
381	mmc-pwrseq = <&sdio_pwrseq>;
382
383	vmmc-supply = <&vsys_3v3>;
384	vqmmc-supply = <&vddao_1v8>;
385
386	brcmf: wifi@1 {
387		reg = <1>;
388		compatible = "brcm,bcm4329-fmac";
389	};
390};
391
392/* SD card */
393&sd_emmc_b {
394	status = "okay";
395	pinctrl-0 = <&sdcard_c_pins>;
396	pinctrl-1 = <&sdcard_clk_gate_c_pins>;
397	pinctrl-names = "default", "clk-gate";
398
399	bus-width = <4>;
400	cap-sd-highspeed;
401	max-frequency = <50000000>;
402	disable-wp;
403
404	cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>;
405	vmmc-supply = <&vsys_3v3>;
406	vqmmc-supply = <&vsys_3v3>;
407};
408
409/* eMMC */
410&sd_emmc_c {
411	status = "okay";
412	pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_8b_pins>, <&emmc_ds_pins>;
413	pinctrl-1 = <&emmc_clk_gate_pins>;
414	pinctrl-names = "default", "clk-gate";
415
416	bus-width = <8>;
417	cap-mmc-highspeed;
418	mmc-ddr-1_8v;
419	mmc-hs200-1_8v;
420	max-frequency = <200000000>;
421	disable-wp;
422
423	mmc-pwrseq = <&emmc_pwrseq>;
424	vmmc-supply = <&vcc_3v3>;
425	vqmmc-supply = <&emmc_1v8>;
426};
427
428/*
429 * EMMC_D4, EMMC_D5, EMMC_D6 and EMMC_D7 pins are shared between SPI NOR CS
430 * and eMMC Data 4 to 7 pins.
431 * Replace emmc_data_8b_pins to emmc_data_4b_pins from sd_emmc_c pinctrl-0,
432 * and change bus-width to 4 then spifc can be enabled.
433 */
434&spifc {
435	status = "disabled";
436	pinctrl-0 = <&nor_pins>;
437	pinctrl-names = "default";
438
439	w25q128: spi-flash@0 {
440		#address-cells = <1>;
441		#size-cells = <1>;
442		compatible = "winbond,w25q128fw", "jedec,spi-nor";
443		reg = <0>;
444		spi-max-frequency = <104000000>;
445	};
446};
447
448
449&tdmif_a {
450	status = "okay";
451};
452
453&tdmout_a {
454	status = "okay";
455};
456
457&tohdmitx {
458	status = "okay";
459};
460
461&uart_A {
462	status = "okay";
463	pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>;
464	pinctrl-names = "default";
465	uart-has-rtscts;
466
467	bluetooth {
468		compatible = "brcm,bcm43438-bt";
469		shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
470		max-speed = <2000000>;
471		clocks = <&wifi32k>;
472		clock-names = "lpo";
473	};
474};
475
476&uart_AO {
477	status = "okay";
478	pinctrl-0 = <&uart_ao_a_pins>;
479	pinctrl-names = "default";
480};
481
482&usb2_phy0 {
483	phy-supply = <&dc_in>;
484};
485
486&usb2_phy1 {
487	phy-supply = <&usb_pwr>;
488};
489
490&usb3_pcie_phy {
491	phy-supply = <&usb_pwr>;
492};
493
494&usb {
495	status = "okay";
496	dr_mode = "peripheral";
497};
498