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
11/ {
12	model = "Khadas VIM3";
13
14	aliases {
15		serial0 = &uart_AO;
16		ethernet0 = &ethmac;
17	};
18
19	chosen {
20		stdout-path = "serial0:115200n8";
21	};
22
23	memory@0 {
24		device_type = "memory";
25		reg = <0x0 0x0 0x0 0x80000000>;
26	};
27
28	adc-keys {
29		compatible = "adc-keys";
30		io-channels = <&saradc 2>;
31		io-channel-names = "buttons";
32		keyup-threshold-microvolt = <1710000>;
33
34		button-function {
35			label = "Function";
36			linux,code = <KEY_FN>;
37			press-threshold-microvolt = <10000>;
38		};
39	};
40
41	leds {
42		compatible = "gpio-leds";
43
44		white {
45			label = "vim3:white:sys";
46			gpios = <&gpio_ao GPIOAO_4 GPIO_ACTIVE_LOW>;
47			linux,default-trigger = "heartbeat";
48		};
49
50		red {
51			label = "vim3:red";
52			gpios = <&gpio_expander 5 GPIO_ACTIVE_LOW>;
53		};
54	};
55
56	emmc_pwrseq: emmc-pwrseq {
57		compatible = "mmc-pwrseq-emmc";
58		reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>;
59	};
60
61	gpio-keys-polled {
62		compatible = "gpio-keys-polled";
63		poll-interval = <100>;
64
65		power-button {
66			label = "power";
67			linux,code = <KEY_POWER>;
68			gpios = <&gpio_ao GPIOAO_7 GPIO_ACTIVE_LOW>;
69		};
70	};
71
72	sdio_pwrseq: sdio-pwrseq {
73		compatible = "mmc-pwrseq-simple";
74		reset-gpios = <&gpio GPIOX_6 GPIO_ACTIVE_LOW>;
75		clocks = <&wifi32k>;
76		clock-names = "ext_clock";
77	};
78
79	dc_in: regulator-dc_in {
80		compatible = "regulator-fixed";
81		regulator-name = "DC_IN";
82		regulator-min-microvolt = <5000000>;
83		regulator-max-microvolt = <5000000>;
84		regulator-always-on;
85	};
86
87	vcc_5v: regulator-vcc_5v {
88		compatible = "regulator-fixed";
89		regulator-name = "VCC_5V";
90		regulator-min-microvolt = <5000000>;
91		regulator-max-microvolt = <5000000>;
92		vin-supply = <&dc_in>;
93
94		gpio = <&gpio GPIOH_8 GPIO_OPEN_DRAIN>;
95		enable-active-high;
96	};
97
98	vcc_1v8: regulator-vcc_1v8 {
99		compatible = "regulator-fixed";
100		regulator-name = "VCC_1V8";
101		regulator-min-microvolt = <1800000>;
102		regulator-max-microvolt = <1800000>;
103		vin-supply = <&vcc_3v3>;
104		regulator-always-on;
105	};
106
107	vcc_3v3: regulator-vcc_3v3 {
108		compatible = "regulator-fixed";
109		regulator-name = "VCC_3V3";
110		regulator-min-microvolt = <3300000>;
111		regulator-max-microvolt = <3300000>;
112		vin-supply = <&vsys_3v3>;
113		regulator-always-on;
114		/* FIXME: actually controlled by VDDCPU_B_EN */
115	};
116
117	vddao_1v8: regulator-vddao_1v8 {
118		compatible = "regulator-fixed";
119		regulator-name = "VDDIO_AO1V8";
120		regulator-min-microvolt = <1800000>;
121		regulator-max-microvolt = <1800000>;
122		vin-supply = <&vsys_3v3>;
123		regulator-always-on;
124	};
125
126	emmc_1v8: regulator-emmc_1v8 {
127		compatible = "regulator-fixed";
128		regulator-name = "EMMC_AO1V8";
129		regulator-min-microvolt = <1800000>;
130		regulator-max-microvolt = <1800000>;
131		vin-supply = <&vcc_3v3>;
132		regulator-always-on;
133	};
134
135	vsys_3v3: regulator-vsys_3v3 {
136		compatible = "regulator-fixed";
137		regulator-name = "VSYS_3V3";
138		regulator-min-microvolt = <3300000>;
139		regulator-max-microvolt = <3300000>;
140		vin-supply = <&dc_in>;
141		regulator-always-on;
142	};
143
144	usb_pwr: regulator-usb_pwr {
145		compatible = "regulator-fixed";
146		regulator-name = "USB_PWR";
147		regulator-min-microvolt = <5000000>;
148		regulator-max-microvolt = <5000000>;
149		vin-supply = <&vcc_5v>;
150
151		gpio = <&gpio GPIOA_6 GPIO_ACTIVE_HIGH>;
152		enable-active-high;
153	};
154
155	hdmi-connector {
156		compatible = "hdmi-connector";
157		type = "a";
158
159		port {
160			hdmi_connector_in: endpoint {
161				remote-endpoint = <&hdmi_tx_tmds_out>;
162			};
163		};
164	};
165
166	wifi32k: wifi32k {
167		compatible = "pwm-clock";
168		#clock-cells = <0>;
169		clock-frequency = <32768>;
170		pwms = <&pwm_ef 0 30518 0>; /* PWM_E at 32.768KHz */
171	};
172};
173
174&cec_AO {
175	pinctrl-0 = <&cec_ao_a_h_pins>;
176	pinctrl-names = "default";
177	status = "disabled";
178	hdmi-phandle = <&hdmi_tx>;
179};
180
181&cecb_AO {
182	pinctrl-0 = <&cec_ao_b_h_pins>;
183	pinctrl-names = "default";
184	status = "okay";
185	hdmi-phandle = <&hdmi_tx>;
186};
187
188&ext_mdio {
189	external_phy: ethernet-phy@0 {
190		/* Realtek RTL8211F (0x001cc916) */
191		reg = <0>;
192		max-speed = <1000>;
193
194		interrupt-parent = <&gpio_intc>;
195		/* MAC_INTR on GPIOZ_14 */
196		interrupts = <26 IRQ_TYPE_LEVEL_LOW>;
197	};
198};
199
200&ethmac {
201        pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
202        pinctrl-names = "default";
203        status = "okay";
204        phy-mode = "rgmii";
205        phy-handle = <&external_phy>;
206        amlogic,tx-delay-ns = <2>;
207};
208
209&hdmi_tx {
210	status = "okay";
211	pinctrl-0 = <&hdmitx_hpd_pins>, <&hdmitx_ddc_pins>;
212	pinctrl-names = "default";
213	hdmi-supply = <&vcc_5v>;
214};
215
216&hdmi_tx_tmds_port {
217	hdmi_tx_tmds_out: endpoint {
218		remote-endpoint = <&hdmi_connector_in>;
219	};
220};
221
222&i2c_AO {
223	status = "okay";
224	pinctrl-0 = <&i2c_ao_sck_pins>, <&i2c_ao_sda_pins>;
225	pinctrl-names = "default";
226
227	gpio_expander: gpio-controller@20 {
228		compatible = "ti,tca6408";
229		reg = <0x20>;
230		vcc-supply = <&vcc_3v3>;
231		gpio-controller;
232		#gpio-cells = <2>;
233	};
234
235	rtc@51 {
236		compatible = "haoyu,hym8563";
237		reg = <0x51>;
238		#clock-cells = <0>;
239	};
240};
241
242&ir {
243	status = "okay";
244	pinctrl-0 = <&remote_input_ao_pins>;
245	pinctrl-names = "default";
246	linux,rc-map-name = "rc-khadas";
247};
248
249&pwm_ef {
250        status = "okay";
251        pinctrl-0 = <&pwm_e_pins>;
252        pinctrl-names = "default";
253};
254
255&saradc {
256	status = "okay";
257	vref-supply = <&vddao_1v8>;
258};
259
260/* SDIO */
261&sd_emmc_a {
262	status = "okay";
263	pinctrl-0 = <&sdio_pins>;
264	pinctrl-1 = <&sdio_clk_gate_pins>;
265	pinctrl-names = "default", "clk-gate";
266	#address-cells = <1>;
267	#size-cells = <0>;
268
269	bus-width = <4>;
270	cap-sd-highspeed;
271	sd-uhs-sdr50;
272	max-frequency = <100000000>;
273
274	non-removable;
275	disable-wp;
276
277	/* WiFi firmware requires power to be kept while in suspend */
278	keep-power-in-suspend;
279
280	mmc-pwrseq = <&sdio_pwrseq>;
281
282	vmmc-supply = <&vsys_3v3>;
283	vqmmc-supply = <&vddao_1v8>;
284
285	brcmf: wifi@1 {
286		reg = <1>;
287		compatible = "brcm,bcm4329-fmac";
288	};
289};
290
291/* SD card */
292&sd_emmc_b {
293	status = "okay";
294	pinctrl-0 = <&sdcard_c_pins>;
295	pinctrl-1 = <&sdcard_clk_gate_c_pins>;
296	pinctrl-names = "default", "clk-gate";
297
298	bus-width = <4>;
299	cap-sd-highspeed;
300	max-frequency = <50000000>;
301	disable-wp;
302
303	cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>;
304	vmmc-supply = <&vsys_3v3>;
305	vqmmc-supply = <&vsys_3v3>;
306};
307
308/* eMMC */
309&sd_emmc_c {
310	status = "okay";
311	pinctrl-0 = <&emmc_pins>, <&emmc_ds_pins>;
312	pinctrl-1 = <&emmc_clk_gate_pins>;
313	pinctrl-names = "default", "clk-gate";
314
315	bus-width = <8>;
316	cap-mmc-highspeed;
317	mmc-ddr-1_8v;
318	mmc-hs200-1_8v;
319	max-frequency = <200000000>;
320	disable-wp;
321
322	mmc-pwrseq = <&emmc_pwrseq>;
323	vmmc-supply = <&vcc_3v3>;
324	vqmmc-supply = <&emmc_1v8>;
325};
326
327&uart_A {
328	status = "okay";
329	pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>;
330	pinctrl-names = "default";
331	uart-has-rtscts;
332
333	bluetooth {
334		compatible = "brcm,bcm43438-bt";
335		shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
336		max-speed = <2000000>;
337		clocks = <&wifi32k>;
338		clock-names = "lpo";
339	};
340};
341
342&uart_AO {
343	status = "okay";
344	pinctrl-0 = <&uart_ao_a_pins>;
345	pinctrl-names = "default";
346};
347
348&usb2_phy0 {
349	phy-supply = <&dc_in>;
350};
351
352&usb2_phy1 {
353	phy-supply = <&usb_pwr>;
354};
355
356&usb3_pcie_phy {
357	phy-supply = <&usb_pwr>;
358};
359
360&usb {
361	status = "okay";
362	dr_mode = "peripheral";
363};
364