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