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 = "LIBRETECH-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
153		dai-link-0 {
154			sound-dai = <&aiu AIU_CPU CPU_I2S_FIFO>;
155		};
156
157		dai-link-1 {
158			sound-dai = <&aiu AIU_CPU CPU_I2S_ENCODER>;
159			dai-format = "i2s";
160			mclk-fs = <256>;
161
162			codec-0 {
163				sound-dai = <&aiu AIU_HDMI CTRL_I2S>;
164			};
165
166			codec-1 {
167				sound-dai = <&aiu AIU_ACODEC CTRL_I2S>;
168			};
169		};
170
171		dai-link-2 {
172			sound-dai = <&aiu AIU_HDMI CTRL_OUT>;
173
174			codec-0 {
175				sound-dai = <&hdmi_tx>;
176			};
177		};
178
179		dai-link-3 {
180			sound-dai = <&aiu AIU_ACODEC CTRL_OUT>;
181
182			codec-0 {
183				sound-dai = <&acodec>;
184			};
185		};
186	};
187};
188
189&acodec {
190	AVDD-supply = <&vddio_ao18>;
191	status = "okay";
192};
193
194&aiu {
195	status = "okay";
196};
197
198&cec_AO {
199	status = "okay";
200	pinctrl-0 = <&ao_cec_pins>;
201	pinctrl-names = "default";
202	hdmi-phandle = <&hdmi_tx>;
203};
204
205&cvbs_vdac_port {
206	cvbs_vdac_out: endpoint {
207		remote-endpoint = <&cvbs_connector_in>;
208	};
209};
210
211&ethmac {
212	status = "okay";
213};
214
215&internal_phy {
216	pinctrl-0 = <&eth_link_led_pins>, <&eth_act_led_pins>;
217	pinctrl-names = "default";
218};
219
220&ir {
221	status = "okay";
222	pinctrl-0 = <&remote_input_ao_pins>;
223	pinctrl-names = "default";
224};
225
226&hdmi_tx {
227	status = "okay";
228	pinctrl-0 = <&hdmi_hpd_pins>, <&hdmi_i2c_pins>;
229	pinctrl-names = "default";
230	hdmi-supply = <&hdmi_5v>;
231};
232
233&hdmi_tx_tmds_port {
234	hdmi_tx_tmds_out: endpoint {
235		remote-endpoint = <&hdmi_connector_in>;
236	};
237};
238
239&gpio_ao {
240	gpio-line-names = "UART TX",
241			  "UART RX",
242			  "Blue LED",
243			  "SDCard Voltage Switch",
244			  "7J1 Header Pin5",
245			  "7J1 Header Pin3",
246			  "7J1 Header Pin12",
247			  "IR In",
248			  "9J3 Switch HDMI CEC/7J1 Header Pin11",
249			  "7J1 Header Pin13",
250			  /* GPIO_TEST_N */
251			  "7J1 Header Pin15";
252};
253
254&gpio {
255	gpio-line-names = /* Bank GPIOZ */
256			  "", "", "", "", "", "", "",
257			  "", "", "", "", "", "", "",
258			  "Eth Link LED", "Eth Activity LED",
259			  /* Bank GPIOH */
260			  "HDMI HPD", "HDMI SDA", "HDMI SCL",
261			  "HDMI_5V_EN", "9J1 Header Pin2",
262			  "Analog Audio Mute",
263			  "2J3 Header Pin6",
264			  "2J3 Header Pin5",
265			  "2J3 Header Pin4",
266			  "2J3 Header Pin3",
267			  /* Bank BOOT */
268			  "eMMC D0", "eMMC D1", "eMMC D2", "eMMC D3",
269			  "eMMC D4", "eMMC D5", "eMMC D6", "eMMC D7",
270			  "eMMC Clk", "eMMC Reset", "eMMC CMD",
271			  "ALT BOOT MODE", "", "", "", "eMMC Data Strobe",
272			  /* Bank CARD */
273			  "SDCard D1", "SDCard D0", "SDCard CLK", "SDCard CMD",
274			  "SDCard D3", "SDCard D2", "SDCard Det",
275			  /* Bank GPIODV */
276			  "", "", "", "", "", "", "", "", "", "", "", "",
277			  "", "", "", "", "", "", "", "", "", "", "", "",
278			  "Green LED", "VCCK Enable",
279			  "7J1 Header Pin27", "7J1 Header Pin28",
280			  "VCCK Regulator", "VDDEE Regulator",
281			  /* Bank GPIOX */
282			  "7J1 Header Pin22", "7J1 Header Pin26",
283			  "7J1 Header Pin36", "7J1 Header Pin38",
284			  "7J1 Header Pin40", "7J1 Header Pin37",
285			  "7J1 Header Pin33", "7J1 Header Pin35",
286			  "7J1 Header Pin19", "7J1 Header Pin21",
287			  "7J1 Header Pin24", "7J1 Header Pin23",
288			  "7J1 Header Pin8", "7J1 Header Pin10",
289			  "7J1 Header Pin16", "7J1 Header Pin18",
290			  "7J1 Header Pin32", "7J1 Header Pin29",
291			  "7J1 Header Pin31",
292			  /* Bank GPIOCLK */
293			  "7J1 Header Pin7", "";
294};
295
296&saradc {
297	status = "okay";
298	vref-supply = <&vddio_ao18>;
299};
300
301/* SD card */
302&sd_emmc_b {
303	status = "okay";
304	pinctrl-0 = <&sdcard_pins>;
305	pinctrl-1 = <&sdcard_clk_gate_pins>;
306	pinctrl-names = "default", "clk-gate";
307
308	bus-width = <4>;
309	cap-sd-highspeed;
310	max-frequency = <50000000>;
311	disable-wp;
312
313	cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_LOW>;
314
315	vmmc-supply = <&vcc_3v3>;
316	vqmmc-supply = <&vcc_card>;
317};
318
319/* eMMC */
320&sd_emmc_c {
321	status = "okay";
322	pinctrl-0 = <&emmc_pins>, <&emmc_ds_pins>;
323	pinctrl-1 = <&emmc_clk_gate_pins>;
324	pinctrl-names = "default", "clk-gate";
325
326	bus-width = <8>;
327	cap-mmc-highspeed;
328	mmc-ddr-1_8v;
329	mmc-hs200-1_8v;
330	max-frequency = <200000000>;
331	disable-wp;
332
333	mmc-pwrseq = <&emmc_pwrseq>;
334	vmmc-supply = <&vcc_3v3>;
335	vqmmc-supply = <&vddio_boot>;
336};
337
338&uart_AO {
339	status = "okay";
340	pinctrl-0 = <&uart_ao_a_pins>;
341	pinctrl-names = "default";
342};
343
344&usb {
345	status = "okay";
346	dr_mode = "host";
347};
348
349&usb2_phy0 {
350	/*
351	 * even though the schematics don't show it:
352	 * HDMI_5V is also used as supply for the USB VBUS.
353	 */
354	phy-supply = <&hdmi_5v>;
355};
356