1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2017 BayLibre, SAS.
4 * Author: Neil Armstrong <narmstrong@baylibre.com>
5 * Author: Jerome Brunet <jbrunet@baylibre.com>
6 */
7
8/dts-v1/;
9
10#include <dt-bindings/input/input.h>
11#include <dt-bindings/sound/meson-aiu.h>
12
13#include "meson-gxl-s905x.dtsi"
14
15/ {
16	compatible = "libretech,aml-s905x-cc", "amlogic,s905x",
17		     "amlogic,meson-gxl";
18	model = "Libre Computer AML-S905X-CC";
19
20	aliases {
21		serial0 = &uart_AO;
22		ethernet0 = &ethmac;
23	};
24
25	chosen {
26		stdout-path = "serial0:115200n8";
27	};
28
29	cvbs-connector {
30		compatible = "composite-video-connector";
31
32		port {
33			cvbs_connector_in: endpoint {
34				remote-endpoint = <&cvbs_vdac_out>;
35			};
36		};
37	};
38
39	emmc_pwrseq: emmc-pwrseq {
40		compatible = "mmc-pwrseq-emmc";
41		reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>;
42	};
43
44	hdmi-connector {
45		compatible = "hdmi-connector";
46		type = "a";
47
48		port {
49			hdmi_connector_in: endpoint {
50				remote-endpoint = <&hdmi_tx_tmds_out>;
51			};
52		};
53	};
54
55	leds {
56		compatible = "gpio-leds";
57
58		led-system {
59			label = "librecomputer:system-status";
60			gpios = <&gpio GPIODV_24 GPIO_ACTIVE_HIGH>;
61			default-state = "on";
62			panic-indicator;
63		};
64
65		led-blue {
66			label = "librecomputer:blue";
67			gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>;
68			linux,default-trigger = "heartbeat";
69		};
70	};
71
72	memory@0 {
73		device_type = "memory";
74		reg = <0x0 0x0 0x0 0x80000000>;
75	};
76
77	hdmi_5v: regulator-hdmi-5v {
78		compatible = "regulator-fixed";
79
80		regulator-name = "HDMI_5V";
81		regulator-min-microvolt = <5000000>;
82		regulator-max-microvolt = <5000000>;
83
84		gpio = <&gpio GPIOH_3 GPIO_ACTIVE_HIGH>;
85		enable-active-high;
86		regulator-always-on;
87	};
88
89	vcc_3v3: regulator-vcc_3v3 {
90		compatible = "regulator-fixed";
91		regulator-name = "VCC_3V3";
92		regulator-min-microvolt = <3300000>;
93		regulator-max-microvolt = <3300000>;
94	};
95
96	vcc_card: regulator-vcc-card {
97		compatible = "regulator-gpio";
98
99		regulator-name = "VCC_CARD";
100		regulator-min-microvolt = <1800000>;
101		regulator-max-microvolt = <3300000>;
102
103		gpios = <&gpio_ao GPIOAO_3 GPIO_ACTIVE_HIGH>;
104		gpios-states = <0>;
105
106		states = <3300000 0>,
107			 <1800000 1>;
108
109		regulator-settling-time-up-us = <200>;
110		regulator-settling-time-down-us = <50000>;
111	};
112
113	vddio_ao18: regulator-vddio_ao18 {
114		compatible = "regulator-fixed";
115		regulator-name = "VDDIO_AO18";
116		regulator-min-microvolt = <1800000>;
117		regulator-max-microvolt = <1800000>;
118	};
119
120	/* This is provided by LDOs on the eMMC daugther card */
121	vddio_boot: regulator-vddio_boot {
122		compatible = "regulator-fixed";
123		regulator-name = "VDDIO_BOOT";
124		regulator-min-microvolt = <1800000>;
125		regulator-max-microvolt = <1800000>;
126		vin-supply = <&vcc_3v3>;
127	};
128
129	sound {
130		compatible = "amlogic,gx-sound-card";
131		model = "GXL-LIBRETECH-S905X-CC";
132		assigned-clocks = <&clkc CLKID_MPLL0>,
133				  <&clkc CLKID_MPLL1>,
134				  <&clkc CLKID_MPLL2>;
135		assigned-clock-parents = <0>, <0>, <0>;
136		assigned-clock-rates = <294912000>,
137				       <270950400>,
138				       <393216000>;
139		status = "okay";
140
141		dai-link-0 {
142			sound-dai = <&aiu AIU_CPU CPU_I2S_FIFO>;
143		};
144
145		dai-link-1 {
146			sound-dai = <&aiu AIU_CPU CPU_I2S_ENCODER>;
147			dai-format = "i2s";
148			mclk-fs = <256>;
149
150			codec-0 {
151				sound-dai = <&aiu AIU_HDMI CTRL_I2S>;
152			};
153		};
154
155		dai-link-2 {
156			sound-dai = <&aiu AIU_HDMI CTRL_OUT>;
157
158			codec-0 {
159				sound-dai = <&hdmi_tx>;
160			};
161		};
162	};
163};
164
165&aiu {
166	status = "okay";
167};
168
169&cec_AO {
170	status = "okay";
171	pinctrl-0 = <&ao_cec_pins>;
172	pinctrl-names = "default";
173	hdmi-phandle = <&hdmi_tx>;
174};
175
176&cvbs_vdac_port {
177	cvbs_vdac_out: endpoint {
178		remote-endpoint = <&cvbs_connector_in>;
179	};
180};
181
182&ethmac {
183	status = "okay";
184};
185
186&internal_phy {
187	pinctrl-0 = <&eth_link_led_pins>, <&eth_act_led_pins>;
188	pinctrl-names = "default";
189};
190
191&ir {
192	status = "okay";
193	pinctrl-0 = <&remote_input_ao_pins>;
194	pinctrl-names = "default";
195};
196
197&hdmi_tx {
198	status = "okay";
199	pinctrl-0 = <&hdmi_hpd_pins>, <&hdmi_i2c_pins>;
200	pinctrl-names = "default";
201	hdmi-supply = <&hdmi_5v>;
202};
203
204&hdmi_tx_tmds_port {
205	hdmi_tx_tmds_out: endpoint {
206		remote-endpoint = <&hdmi_connector_in>;
207	};
208};
209
210&gpio_ao {
211	gpio-line-names = "UART TX",
212			  "UART RX",
213			  "Blue LED",
214			  "SDCard Voltage Switch",
215			  "7J1 Header Pin5",
216			  "7J1 Header Pin3",
217			  "7J1 Header Pin12",
218			  "IR In",
219			  "9J3 Switch HDMI CEC/7J1 Header Pin11",
220			  "7J1 Header Pin13",
221			  /* GPIO_TEST_N */
222			  "7J1 Header Pin15";
223};
224
225&gpio {
226	gpio-line-names = /* Bank GPIOZ */
227			  "", "", "", "", "", "", "",
228			  "", "", "", "", "", "", "",
229			  "Eth Link LED", "Eth Activity LED",
230			  /* Bank GPIOH */
231			  "HDMI HPD", "HDMI SDA", "HDMI SCL",
232			  "HDMI_5V_EN", "9J1 Header Pin2",
233			  "Analog Audio Mute",
234			  "2J3 Header Pin6",
235			  "2J3 Header Pin5",
236			  "2J3 Header Pin4",
237			  "2J3 Header Pin3",
238			  /* Bank BOOT */
239			  "eMMC D0", "eMMC D1", "eMMC D2", "eMMC D3",
240			  "eMMC D4", "eMMC D5", "eMMC D6", "eMMC D7",
241			  "eMMC Clk", "eMMC Reset", "eMMC CMD",
242			  "ALT BOOT MODE", "", "", "", "eMMC Data Strobe",
243			  /* Bank CARD */
244			  "SDCard D1", "SDCard D0", "SDCard CLK", "SDCard CMD",
245			  "SDCard D3", "SDCard D2", "SDCard Det",
246			  /* Bank GPIODV */
247			  "", "", "", "", "", "", "", "", "", "", "", "",
248			  "", "", "", "", "", "", "", "", "", "", "", "",
249			  "Green LED", "VCCK Enable",
250			  "7J1 Header Pin27", "7J1 Header Pin28",
251			  "VCCK Regulator", "VDDEE Regulator",
252			  /* Bank GPIOX */
253			  "7J1 Header Pin22", "7J1 Header Pin26",
254			  "7J1 Header Pin36", "7J1 Header Pin38",
255			  "7J1 Header Pin40", "7J1 Header Pin37",
256			  "7J1 Header Pin33", "7J1 Header Pin35",
257			  "7J1 Header Pin19", "7J1 Header Pin21",
258			  "7J1 Header Pin24", "7J1 Header Pin23",
259			  "7J1 Header Pin8", "7J1 Header Pin10",
260			  "7J1 Header Pin16", "7J1 Header Pin18",
261			  "7J1 Header Pin32", "7J1 Header Pin29",
262			  "7J1 Header Pin31",
263			  /* Bank GPIOCLK */
264			  "7J1 Header Pin7", "";
265};
266
267&saradc {
268	status = "okay";
269	vref-supply = <&vddio_ao18>;
270};
271
272/* SD card */
273&sd_emmc_b {
274	status = "okay";
275	pinctrl-0 = <&sdcard_pins>;
276	pinctrl-1 = <&sdcard_clk_gate_pins>;
277	pinctrl-names = "default", "clk-gate";
278
279	bus-width = <4>;
280	cap-sd-highspeed;
281	max-frequency = <50000000>;
282	disable-wp;
283
284	cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_LOW>;
285
286	vmmc-supply = <&vcc_3v3>;
287	vqmmc-supply = <&vcc_card>;
288};
289
290/* eMMC */
291&sd_emmc_c {
292	status = "okay";
293	pinctrl-0 = <&emmc_pins>, <&emmc_ds_pins>;
294	pinctrl-1 = <&emmc_clk_gate_pins>;
295	pinctrl-names = "default", "clk-gate";
296
297	bus-width = <8>;
298	cap-mmc-highspeed;
299	mmc-ddr-1_8v;
300	mmc-hs200-1_8v;
301	max-frequency = <200000000>;
302	disable-wp;
303
304	mmc-pwrseq = <&emmc_pwrseq>;
305	vmmc-supply = <&vcc_3v3>;
306	vqmmc-supply = <&vddio_boot>;
307};
308
309&uart_AO {
310	status = "okay";
311	pinctrl-0 = <&uart_ao_a_pins>;
312	pinctrl-names = "default";
313};
314
315&usb {
316	status = "okay";
317	dr_mode = "host";
318};
319
320&usb2_phy0 {
321	/*
322	 * even though the schematics don't show it:
323	 * HDMI_5V is also used as supply for the USB VBUS.
324	 */
325	phy-supply = <&hdmi_5v>;
326};
327