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&pcie {
250	reset-gpios = <&gpio GPIOA_8 GPIO_ACTIVE_LOW>;
251};
252
253&pwm_ef {
254        status = "okay";
255        pinctrl-0 = <&pwm_e_pins>;
256        pinctrl-names = "default";
257};
258
259&saradc {
260	status = "okay";
261	vref-supply = <&vddao_1v8>;
262};
263
264/* SDIO */
265&sd_emmc_a {
266	status = "okay";
267	pinctrl-0 = <&sdio_pins>;
268	pinctrl-1 = <&sdio_clk_gate_pins>;
269	pinctrl-names = "default", "clk-gate";
270	#address-cells = <1>;
271	#size-cells = <0>;
272
273	bus-width = <4>;
274	cap-sd-highspeed;
275	sd-uhs-sdr50;
276	max-frequency = <100000000>;
277
278	non-removable;
279	disable-wp;
280
281	mmc-pwrseq = <&sdio_pwrseq>;
282
283	vmmc-supply = <&vsys_3v3>;
284	vqmmc-supply = <&vddao_1v8>;
285
286	brcmf: wifi@1 {
287		reg = <1>;
288		compatible = "brcm,bcm4329-fmac";
289	};
290};
291
292/* SD card */
293&sd_emmc_b {
294	status = "okay";
295	pinctrl-0 = <&sdcard_c_pins>;
296	pinctrl-1 = <&sdcard_clk_gate_c_pins>;
297	pinctrl-names = "default", "clk-gate";
298
299	bus-width = <4>;
300	cap-sd-highspeed;
301	max-frequency = <50000000>;
302	disable-wp;
303
304	cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>;
305	vmmc-supply = <&vsys_3v3>;
306	vqmmc-supply = <&vsys_3v3>;
307};
308
309/* eMMC */
310&sd_emmc_c {
311	status = "okay";
312	pinctrl-0 = <&emmc_pins>, <&emmc_ds_pins>;
313	pinctrl-1 = <&emmc_clk_gate_pins>;
314	pinctrl-names = "default", "clk-gate";
315
316	bus-width = <8>;
317	cap-mmc-highspeed;
318	mmc-ddr-1_8v;
319	mmc-hs200-1_8v;
320	max-frequency = <200000000>;
321	disable-wp;
322
323	mmc-pwrseq = <&emmc_pwrseq>;
324	vmmc-supply = <&vcc_3v3>;
325	vqmmc-supply = <&emmc_1v8>;
326};
327
328&uart_A {
329	status = "okay";
330	pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>;
331	pinctrl-names = "default";
332	uart-has-rtscts;
333
334	bluetooth {
335		compatible = "brcm,bcm43438-bt";
336		shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
337		max-speed = <2000000>;
338		clocks = <&wifi32k>;
339		clock-names = "lpo";
340	};
341};
342
343&uart_AO {
344	status = "okay";
345	pinctrl-0 = <&uart_ao_a_pins>;
346	pinctrl-names = "default";
347};
348
349&usb2_phy0 {
350	phy-supply = <&dc_in>;
351};
352
353&usb2_phy1 {
354	phy-supply = <&usb_pwr>;
355};
356
357&usb3_pcie_phy {
358	phy-supply = <&usb_pwr>;
359};
360
361&usb {
362	status = "okay";
363	dr_mode = "peripheral";
364};
365