1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2017 Martin Blumenstingl <martin.blumenstingl@googlemail.com>.
4 * Copyright (c) 2017 BayLibre, SAS
5 * Author: Neil Armstrong <narmstrong@baylibre.com>
6 */
7
8/dts-v1/;
9
10#include "meson-gxm.dtsi"
11#include <dt-bindings/input/input.h>
12#include <dt-bindings/sound/meson-aiu.h>
13
14/ {
15	compatible = "khadas,vim2", "amlogic,s912", "amlogic,meson-gxm";
16	model = "Khadas VIM2";
17
18	aliases {
19		serial0 = &uart_AO;
20		serial2 = &uart_AO_B;
21	};
22
23	chosen {
24		stdout-path = "serial0:115200n8";
25	};
26
27	memory@0 {
28		device_type = "memory";
29		reg = <0x0 0x0 0x0 0x80000000>;
30	};
31
32	adc-keys {
33		compatible = "adc-keys";
34		io-channels = <&saradc 0>;
35		io-channel-names = "buttons";
36		keyup-threshold-microvolt = <1710000>;
37
38		button-function {
39			label = "Function";
40			linux,code = <KEY_FN>;
41			press-threshold-microvolt = <10000>;
42		};
43	};
44
45	emmc_pwrseq: emmc-pwrseq {
46		compatible = "mmc-pwrseq-emmc";
47		reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>;
48	};
49
50	gpio_fan: gpio-fan {
51		compatible = "gpio-fan";
52		gpios = <&gpio GPIODV_14 GPIO_ACTIVE_HIGH
53			 &gpio GPIODV_15 GPIO_ACTIVE_HIGH>;
54		/* Dummy RPM values since fan is optional */
55		gpio-fan,speed-map =
56				<0 0>,
57				<1 1>,
58				<2 2>,
59				<3 3>;
60		#cooling-cells = <2>;
61	};
62
63	gpio-keys-polled {
64		compatible = "gpio-keys-polled";
65		poll-interval = <100>;
66
67		power-button {
68			label = "power";
69			linux,code = <KEY_POWER>;
70			gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_LOW>;
71		};
72	};
73
74	hdmi-connector {
75		compatible = "hdmi-connector";
76		type = "a";
77
78		port {
79			hdmi_connector_in: endpoint {
80				remote-endpoint = <&hdmi_tx_tmds_out>;
81			};
82		};
83	};
84
85	led-controller {
86		compatible = "pwm-leds";
87
88		led-1 {
89			label = "vim:red:power";
90			pwms = <&pwm_AO_ab 1 7812500 0>;
91			max-brightness = <255>;
92			linux,default-trigger = "default-on";
93		};
94	};
95
96	sdio_pwrseq: sdio-pwrseq {
97		compatible = "mmc-pwrseq-simple";
98		reset-gpios = <&gpio GPIOX_6 GPIO_ACTIVE_LOW>;
99		clocks = <&wifi32k>;
100		clock-names = "ext_clock";
101	};
102
103	hdmi_5v: regulator-hdmi-5v {
104		compatible = "regulator-fixed";
105
106		regulator-name = "HDMI_5V";
107		regulator-min-microvolt = <5000000>;
108		regulator-max-microvolt = <5000000>;
109
110		gpio = <&gpio GPIOH_3 GPIO_ACTIVE_HIGH>;
111		enable-active-high;
112		regulator-always-on;
113	};
114
115	vcc_3v3: regulator-vcc_3v3 {
116		compatible = "regulator-fixed";
117		regulator-name = "VCC_3V3";
118		regulator-min-microvolt = <3300000>;
119		regulator-max-microvolt = <3300000>;
120	};
121
122	vddio_ao18: regulator-vddio_ao18 {
123		compatible = "regulator-fixed";
124		regulator-name = "VDDIO_AO18";
125		regulator-min-microvolt = <1800000>;
126		regulator-max-microvolt = <1800000>;
127	};
128
129	vddio_boot: regulator-vddio_boot {
130		compatible = "regulator-fixed";
131		regulator-name = "VDDIO_BOOT";
132		regulator-min-microvolt = <1800000>;
133		regulator-max-microvolt = <1800000>;
134	};
135
136	vddao_3v3: regulator-vddao_3v3 {
137		compatible = "regulator-fixed";
138		regulator-name = "VDDAO_3V3";
139		regulator-min-microvolt = <3300000>;
140		regulator-max-microvolt = <3300000>;
141	};
142
143	wifi32k: wifi32k {
144		compatible = "pwm-clock";
145		#clock-cells = <0>;
146		clock-frequency = <32768>;
147		pwms = <&pwm_ef 0 30518 0>; /* PWM_E at 32.768KHz */
148	};
149
150	sound {
151		compatible = "amlogic,gx-sound-card";
152		model = "KHADAS-VIM2";
153		assigned-clocks = <&clkc CLKID_MPLL0>,
154				  <&clkc CLKID_MPLL1>,
155				  <&clkc CLKID_MPLL2>;
156		assigned-clock-parents = <0>, <0>, <0>;
157		assigned-clock-rates = <294912000>,
158				       <270950400>,
159				       <393216000>;
160		status = "okay";
161
162		dai-link-0 {
163			sound-dai = <&aiu AIU_CPU CPU_I2S_FIFO>;
164		};
165
166		dai-link-1 {
167			sound-dai = <&aiu AIU_CPU CPU_I2S_ENCODER>;
168			dai-format = "i2s";
169			mclk-fs = <256>;
170
171			codec-0 {
172				sound-dai = <&aiu AIU_HDMI CTRL_I2S>;
173			};
174		};
175
176		dai-link-2 {
177			sound-dai = <&aiu AIU_HDMI CTRL_OUT>;
178
179			codec-0 {
180				sound-dai = <&hdmi_tx>;
181			};
182		};
183	};
184};
185
186&aiu {
187	status = "okay";
188};
189
190&cec_AO {
191	status = "okay";
192	pinctrl-0 = <&ao_cec_pins>;
193	pinctrl-names = "default";
194	hdmi-phandle = <&hdmi_tx>;
195};
196
197&cpu_cooling_maps {
198	map0 {
199		cooling-device = <&gpio_fan THERMAL_NO_LIMIT 1>;
200	};
201
202	map1 {
203		cooling-device = <&gpio_fan 2 THERMAL_NO_LIMIT>,
204				 <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
205				 <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
206				 <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
207				 <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
208				 <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
209				 <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
210				 <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
211				 <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
212	};
213};
214
215&ethmac {
216	pinctrl-0 = <&eth_pins>;
217	pinctrl-names = "default";
218
219	/* Select external PHY by default */
220	phy-handle = <&external_phy>;
221
222	amlogic,tx-delay-ns = <2>;
223
224	/* External PHY is in RGMII */
225	phy-mode = "rgmii";
226
227	status = "okay";
228};
229
230&external_mdio {
231	external_phy: ethernet-phy@0 {
232		/* Realtek RTL8211F (0x001cc916) */
233		reg = <0>;
234
235		reset-assert-us = <10000>;
236		reset-deassert-us = <80000>;
237		reset-gpios = <&gpio GPIOZ_14 GPIO_ACTIVE_LOW>;
238
239		interrupt-parent = <&gpio_intc>;
240		/* MAC_INTR on GPIOZ_15 */
241		interrupts = <25 IRQ_TYPE_LEVEL_LOW>;
242	};
243};
244
245&hdmi_tx {
246	status = "okay";
247	pinctrl-0 = <&hdmi_hpd_pins>, <&hdmi_i2c_pins>;
248	pinctrl-names = "default";
249	hdmi-supply = <&hdmi_5v>;
250};
251
252&hdmi_tx_tmds_port {
253	hdmi_tx_tmds_out: endpoint {
254		remote-endpoint = <&hdmi_connector_in>;
255	};
256};
257
258&i2c_A {
259	status = "okay";
260	pinctrl-0 = <&i2c_a_pins>;
261	pinctrl-names = "default";
262};
263
264&i2c_B {
265	status = "okay";
266	pinctrl-0 = <&i2c_b_pins>;
267	pinctrl-names = "default";
268
269	rtc: rtc@51 {
270		status = "okay";
271		compatible = "haoyu,hym8563";
272		reg = <0x51>;
273		#clock-cells = <0>;
274		clock-output-names = "xin32k";
275	};
276};
277
278&ir {
279	status = "okay";
280	pinctrl-0 = <&remote_input_ao_pins>;
281	pinctrl-names = "default";
282	linux,rc-map-name = "rc-khadas";
283};
284
285&pwm_AO_ab {
286	status = "okay";
287	pinctrl-0 = <&pwm_ao_a_3_pins>, <&pwm_ao_b_pins>;
288	pinctrl-names = "default";
289	clocks = <&clkc CLKID_FCLK_DIV4>;
290	clock-names = "clkin0";
291};
292
293&pwm_ef {
294	status = "okay";
295	pinctrl-0 = <&pwm_e_pins>, <&pwm_f_clk_pins>;
296	pinctrl-names = "default";
297	clocks = <&clkc CLKID_FCLK_DIV4>;
298	clock-names = "clkin0";
299};
300
301&sd_emmc_a {
302	status = "okay";
303	pinctrl-0 = <&sdio_pins>;
304	pinctrl-1 = <&sdio_clk_gate_pins>;
305	pinctrl-names = "default", "clk-gate";
306	#address-cells = <1>;
307	#size-cells = <0>;
308
309	bus-width = <4>;
310	cap-sd-highspeed;
311	max-frequency = <100000000>;
312
313	non-removable;
314	disable-wp;
315
316	/* WiFi firmware requires power to be kept while in suspend */
317	keep-power-in-suspend;
318
319	mmc-pwrseq = <&sdio_pwrseq>;
320
321	vmmc-supply = <&vddao_3v3>;
322	vqmmc-supply = <&vddio_boot>;
323
324	brcmf: wifi@1 {
325		reg = <1>;
326		compatible = "brcm,bcm4329-fmac";
327	};
328};
329
330/* SD card */
331&sd_emmc_b {
332	status = "okay";
333	pinctrl-0 = <&sdcard_pins>;
334	pinctrl-1 = <&sdcard_clk_gate_pins>;
335	pinctrl-names = "default", "clk-gate";
336
337	bus-width = <4>;
338	cap-sd-highspeed;
339	max-frequency = <50000000>;
340	disable-wp;
341
342	cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_LOW>;
343
344	vmmc-supply = <&vddao_3v3>;
345	vqmmc-supply = <&vddio_boot>;
346};
347
348/* eMMC */
349&sd_emmc_c {
350	status = "okay";
351	pinctrl-0 = <&emmc_pins>, <&emmc_ds_pins>;
352	pinctrl-1 = <&emmc_clk_gate_pins>;
353	pinctrl-names = "default", "clk-gate";
354
355	bus-width = <8>;
356	cap-mmc-highspeed;
357	max-frequency = <200000000>;
358	non-removable;
359	disable-wp;
360	mmc-ddr-1_8v;
361	mmc-hs200-1_8v;
362
363	mmc-pwrseq = <&emmc_pwrseq>;
364	vmmc-supply = <&vcc_3v3>;
365	vqmmc-supply = <&vddio_boot>;
366};
367
368/*
369 * EMMC_DS pin is shared between SPI NOR CS and eMMC Data Strobe
370 * Remove emmc_ds_pins from sd_emmc_c pinctrl-0 then spifc can be enabled
371 */
372&spifc {
373	status = "disabled";
374	pinctrl-0 = <&nor_pins>;
375	pinctrl-names = "default";
376
377	w25q32: flash@0 {
378		#address-cells = <1>;
379		#size-cells = <1>;
380		compatible = "winbond,w25q16", "jedec,spi-nor";
381		reg = <0>;
382		spi-max-frequency = <104000000>;
383	};
384};
385
386/* This one is connected to the Bluetooth module */
387&uart_A {
388	status = "okay";
389	pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>;
390	pinctrl-names = "default";
391	uart-has-rtscts;
392
393	bluetooth {
394		compatible = "brcm,bcm43438-bt";
395		shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
396		max-speed = <2000000>;
397		clocks = <&wifi32k>;
398		clock-names = "lpo";
399	};
400};
401
402/* This is brought out on the Linux_RX (18) and Linux_TX (19) pins: */
403&uart_AO {
404	status = "okay";
405	pinctrl-0 = <&uart_ao_a_pins>;
406	pinctrl-names = "default";
407};
408
409/* This is brought out on the UART_RX_AO_B (15) and UART_TX_AO_B (16) pins: */
410&uart_AO_B {
411	status = "okay";
412	pinctrl-0 = <&uart_ao_b_pins>;
413	pinctrl-names = "default";
414};
415
416&saradc {
417	status = "okay";
418	vref-supply = <&vddio_ao18>;
419};
420
421&usb {
422	status = "okay";
423	dr_mode = "peripheral";
424};
425