1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2
3/dts-v1/;
4
5#include <dt-bindings/gpio/gpio.h>
6#include <dt-bindings/input/input.h>
7#include <dt-bindings/leds/common.h>
8#include <dt-bindings/pinctrl/rockchip.h>
9#include <dt-bindings/pwm/pwm.h>
10#include <dt-bindings/soc/rockchip,vop2.h>
11#include "dt-bindings/usb/pd.h"
12
13#include "rk3588-firefly-core-3588j.dtsi"
14
15/ {
16	model = "Firefly ITX-3588J";
17	compatible = "firefly,itx-3588j", "firefly,core-3588j", "rockchip,rk3588";
18
19	aliases {
20		ethernet0 = &gmac0;
21		ethernet1 = &gmac1;
22	};
23
24	chosen {
25		stdout-path = "serial2:1500000n8";
26	};
27
28	/*
29	 * there are also a "Reset" and "Mask ROM" button, but the needed
30	 * settings are unknown at this time
31	 */
32	adc-keys-0 {
33		compatible = "adc-keys";
34		io-channels = <&saradc 1>;
35		io-channel-names = "buttons";
36		keyup-threshold-microvolt = <1800000>;
37		poll-interval = <100>;
38
39		button-recovery {
40			label = "Recovery";
41			linux,code = <KEY_VENDOR>;
42			press-threshold-microvolt = <2000>;
43		};
44	};
45
46	analog-sound {
47		compatible = "simple-audio-card";
48		pinctrl-0 = <&hp_detect>;
49		pinctrl-names = "default";
50		simple-audio-card,aux-devs = <&amp_headphones>, <&amp_speaker>;
51		simple-audio-card,format = "i2s";
52		simple-audio-card,hp-det-gpios = <&gpio1 RK_PC4 GPIO_ACTIVE_LOW>;
53		simple-audio-card,mclk-fs = <384>;
54		simple-audio-card,name = "rockchip_es8323";
55		simple-audio-card,pin-switches = "Headphones", "Speaker";
56		simple-audio-card,routing =
57			"Speaker Amplifier INL", "LOUT2",
58			"Speaker Amplifier INR", "ROUT2",
59			"Speaker", "Speaker Amplifier OUTL",
60			"Speaker", "Speaker Amplifier OUTR",
61			"Headphones Amplifier INL", "LOUT1",
62			"Headphones Amplifier INR", "ROUT1",
63			"Headphones", "Headphones Amplifier OUTL",
64			"Headphones", "Headphones Amplifier OUTR",
65			"LINPUT1", "Microphone Jack",
66			"RINPUT1", "Microphone Jack",
67			"LINPUT2", "Onboard Microphone",
68			"RINPUT2", "Onboard Microphone";
69		simple-audio-card,widgets =
70			"Microphone", "Microphone Jack",
71			"Microphone", "Onboard Microphone",
72			"Headphone", "Headphones",
73			"Speaker", "Speaker";
74
75		simple-audio-card,cpu {
76			sound-dai = <&i2s0_8ch>;
77		};
78
79		simple-audio-card,codec {
80			sound-dai = <&es8323>;
81			system-clock-frequency = <12288000>;
82		};
83	};
84
85	/*
86	 * this does not seem to be a proper "amplifier" but is just
87	 * a way to control the GPIO pins to switch on or off the given
88	 * sound output device
89	 */
90	amp_headphones: headphones-audio-amplifier {
91		compatible = "simple-audio-amplifier";
92		enable-gpios = <&gpio4 RK_PB0 GPIO_ACTIVE_HIGH>;
93		pinctrl-names = "default";
94		pinctrl-0 = <&headphone_amplifier_en>;
95		sound-name-prefix = "Headphones Amplifier";
96	};
97
98	amp_speaker: speaker-audio-amplifier {
99		compatible = "simple-audio-amplifier";
100		enable-gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_HIGH>;
101		pinctrl-names = "default";
102		pinctrl-0 = <&speaker_amplifier_en>;
103		sound-name-prefix = "Speaker Amplifier";
104	};
105
106	fan: pwm-fan {
107		compatible = "pwm-fan";
108		#cooling-cells = <2>;
109		cooling-levels = <0 120 150 180 210 240 255>;
110		fan-supply = <&vcc12v_dcin>;
111		pwms = <&pwm15 0 50000 1>;
112	};
113
114	hdmi0-con {
115		compatible = "hdmi-connector";
116		type = "a";
117
118		port {
119			hdmi0_con_in: endpoint {
120				remote-endpoint = <&hdmi0_out_con>;
121			};
122		};
123	};
124
125	leds {
126		compatible = "gpio-leds";
127
128		/*
129		 * There is also a Power LED control @ RK_PB3 on
130		 * GPIO1 but for some reason it doesn't seem to work right
131		 */
132
133		user_led: led-1 {
134			gpios = <&pca9555 3 GPIO_ACTIVE_HIGH>;
135			linux,default-trigger = "disk-activity";
136		};
137	};
138
139	pcie30_avdd0v75: regulator-pcie30-avdd0v75 {
140		compatible = "regulator-fixed";
141		regulator-always-on;
142		regulator-boot-on;
143		regulator-min-microvolt = <750000>;
144		regulator-max-microvolt = <750000>;
145		regulator-name = "pcie30_avdd0v75";
146		vin-supply = <&avdd_0v75_s0>;
147	};
148
149	vbus5v0_typec_pwr_en: regulator-vbus5v0-typec-pwr-en {
150		compatible = "regulator-fixed";
151		enable-active-high;
152		gpios = <&pca9555 12 GPIO_ACTIVE_HIGH>;
153		regulator-min-microvolt = <5000000>;
154		regulator-max-microvolt = <5000000>;
155		regulator-name = "vbus5v0_typec_pwr_en";
156	};
157
158	vcc12v_dcin: regulator-vcc12v-dcin {
159		compatible = "regulator-fixed";
160		regulator-always-on;
161		regulator-boot-on;
162		regulator-min-microvolt = <12000000>;
163		regulator-max-microvolt = <12000000>;
164		regulator-name = "vcc12v_dcin";
165	};
166
167	vcc3v3_pcie30: regulator-vcc3v3-pcie30 {
168		compatible = "regulator-fixed";
169		enable-active-high;
170		gpios = <&gpio2 RK_PC5 GPIO_ACTIVE_HIGH>;
171		pinctrl-names = "default";
172		pinctrl-0 = <&pcie3_vcc3v3_en>;
173		regulator-min-microvolt = <3300000>;
174		regulator-max-microvolt = <3300000>;
175		regulator-name = "vcc3v3_pcie30";
176		startup-delay-us = <5000>;
177		vin-supply = <&vcc12v_dcin>;
178	};
179
180	vcc5v0_host: regulator-vcc5v0-host {
181		compatible = "regulator-fixed";
182		enable-active-high;
183		gpios = <&pca9555 5 GPIO_ACTIVE_HIGH>;
184		regulator-always-on;
185		regulator-boot-on;
186		regulator-min-microvolt = <5000000>;
187		regulator-max-microvolt = <5000000>;
188		regulator-name = "vcc5v0_host";
189		vin-supply = <&vcc5v0_usb>;
190	};
191
192	vcc5v0_host3: regulator-vcc5v0-host3 {
193		compatible = "regulator-fixed";
194		enable-active-high;
195		gpios = <&pca9555 7 GPIO_ACTIVE_HIGH>;
196		regulator-name = "vcc5v0_host3";
197		regulator-boot-on;
198		regulator-always-on;
199		regulator-min-microvolt = <5000000>;
200		regulator-max-microvolt = <5000000>;
201		vin-supply = <&vcc5v0_usb>;
202	};
203
204	vcc5v0_sys: regulator-vcc5v0-sys {
205		compatible = "regulator-fixed";
206		regulator-always-on;
207		regulator-boot-on;
208		regulator-min-microvolt = <5000000>;
209		regulator-max-microvolt = <5000000>;
210		regulator-name = "vcc5v0_sys";
211		vin-supply = <&vcc12v_dcin>;
212	};
213
214	vcc5v0_usb: regulator-vcc5v0-usb {
215		compatible = "regulator-fixed";
216		regulator-always-on;
217		regulator-boot-on;
218		regulator-min-microvolt = <5000000>;
219		regulator-max-microvolt = <5000000>;
220		regulator-name = "vcc5v0_usb";
221		vin-supply = <&vcc12v_dcin>;
222	};
223
224	vcc_1v1_nldo_s3: regulator-vcc-1v1-nldo-s3 {
225		compatible = "regulator-fixed";
226		regulator-always-on;
227		regulator-boot-on;
228		regulator-min-microvolt = <1100000>;
229		regulator-max-microvolt = <1100000>;
230		regulator-name = "vcc_1v1_nldo_s3";
231		vin-supply = <&vcc5v0_sys>;
232	};
233
234	vcc_fan_pwr_en: regulator-vcc-fan-pwr-en {
235		compatible = "regulator-fixed";
236		enable-active-high;
237		gpios = <&pca9555 11 GPIO_ACTIVE_HIGH>;
238		regulator-always-on;
239		regulator-boot-on;
240		regulator-name = "vcc_fan_pwr_en";
241	};
242
243	vcc_hub_reset: regulator-vcc-hub-reset {
244		compatible = "regulator-fixed";
245		enable-active-high;
246		gpios = <&pca9555 4 GPIO_ACTIVE_HIGH>;
247		regulator-always-on;
248		regulator-boot-on;
249		regulator-name = "vcc_hub_reset";
250	};
251
252	vcc_hub3_reset: regulator-vcc-hub3-reset {
253		compatible = "regulator-fixed";
254		enable-active-high;
255		gpios = <&pca9555 6 GPIO_ACTIVE_HIGH>;
256		regulator-always-on;
257		regulator-name = "vcc_hub3_reset";
258	};
259
260	vcc_sata_pwr_en: regulator-vcc-sata-pwr-en {
261		compatible = "regulator-fixed";
262		enable-active-high;
263		gpios = <&pca9555 10 GPIO_ACTIVE_HIGH>;
264		regulator-always-on;
265		regulator-boot-on;
266		regulator-name = "vcc_sata_pwr_en";
267	};
268};
269
270&avcc_1v8_s0 {
271	regulator-state-mem {
272		regulator-on-in-suspend;
273	};
274};
275
276&combphy0_ps {
277	status = "okay";
278};
279
280&combphy1_ps {
281	status = "okay";
282};
283
284&combphy2_psu {
285	status = "okay";
286};
287
288&gmac0 {
289	clock_in_out = "output";
290	phy-handle = <&rgmii_phy0>;
291	phy-mode = "rgmii-rxid";
292	pinctrl-names = "default";
293	pinctrl-0 = <&gmac0_miim
294		     &gmac0_tx_bus2
295		     &gmac0_rx_bus2
296		     &gmac0_rgmii_clk
297		     &gmac0_rgmii_bus>;
298	tx_delay = <0x45>;
299	rx_delay = <0x4a>;
300	status = "okay";
301};
302
303&gmac1 {
304	clock_in_out = "output";
305	phy-handle = <&rgmii_phy1>;
306	phy-mode = "rgmii-rxid";
307	pinctrl-names = "default";
308	pinctrl-0 = <&gmac1_miim
309		     &gmac1_tx_bus2
310		     &gmac1_rx_bus2
311		     &gmac1_rgmii_clk
312		     &gmac1_rgmii_bus>;
313	tx_delay = <0x42>;
314	rx_delay = <0x4f>;
315	status = "okay";
316};
317
318&gpu {
319	mali-supply = <&vdd_gpu_s0>;
320	sram-supply = <&vdd_gpu_mem_s0>;
321	status = "okay";
322};
323
324&hdmi0 {
325	status = "okay";
326};
327
328&hdmi0_in {
329	hdmi0_in_vp0: endpoint {
330		remote-endpoint = <&vp0_out_hdmi0>;
331	};
332};
333
334&hdmi0_out {
335	hdmi0_out_con: endpoint {
336		remote-endpoint = <&hdmi0_con_in>;
337	};
338};
339
340&hdptxphy_hdmi0 {
341	status = "okay";
342};
343
344&i2c3 {
345	status = "okay";
346
347	/*
348	 * in the Firefly BSP source this was confusingly called an
349	 * "ES8388" - it actually seems to be an ES8323 and the drivers
350	 * for that work best
351	 */
352	es8323: audio-codec@11 {
353		compatible = "everest,es8323";
354		reg = <0x11>;
355		assigned-clocks = <&cru I2S0_8CH_MCLKOUT>;
356		assigned-clock-rates = <12288000>;
357		clocks = <&cru I2S0_8CH_MCLKOUT>;
358		clock-names = "mclk";
359		#sound-dai-cells = <0>;
360	};
361};
362
363&i2c6 {
364	pinctrl-names = "default";
365	pinctrl-0 = <&i2c6m0_xfer>;
366	status = "okay";
367
368	pca9555: gpio@21 {
369		compatible = "nxp,pca9555";
370		reg = <0x21>;
371		gpio-controller;
372		#gpio-cells = <2>;
373	};
374
375	usbc0: usb-typec@22 {
376		compatible = "fcs,fusb302";
377		reg = <0x22>;
378		interrupt-parent = <&gpio0>;
379		interrupts = <RK_PD3 IRQ_TYPE_LEVEL_LOW>;
380		pinctrl-names = "default";
381		pinctrl-0 = <&usbc0_int>;
382		vbus-supply = <&vbus5v0_typec_pwr_en>;
383
384		usb_con: connector {
385			compatible = "usb-c-connector";
386			label = "USB-C";
387			data-role = "dual";
388			op-sink-microwatt = <1000000>;
389			power-role = "dual";
390			sink-pdos =
391				<PDO_FIXED(5000, 1000, PDO_FIXED_USB_COMM)>;
392			source-pdos =
393				<PDO_FIXED(5000, 3000, PDO_FIXED_USB_COMM)>;
394			try-power-role = "source";
395
396			ports {
397				#address-cells = <1>;
398				#size-cells = <0>;
399
400				port@0 {
401					reg = <0>;
402
403					usbc0_orien_sw: endpoint {
404						remote-endpoint = <&usbdp_phy0_orientation_switch>;
405					};
406				};
407
408				port@1 {
409					reg = <1>;
410
411					usbc0_role_sw: endpoint {
412						remote-endpoint = <&dwc3_0_role_switch>;
413					};
414				};
415
416				port@2 {
417					reg = <2>;
418
419					dp_altmode_mux: endpoint {
420						remote-endpoint = <&usbdp_phy0_dp_altmode_mux>;
421					};
422				};
423			};
424		};
425	};
426
427	hym8563: rtc@51 {
428		compatible = "haoyu,hym8563";
429		reg = <0x51>;
430		interrupt-parent = <&gpio0>;
431		interrupts = <RK_PB0 IRQ_TYPE_LEVEL_LOW>;
432		#clock-cells = <0>;
433		clock-output-names = "hym8563";
434		pinctrl-names = "default";
435		pinctrl-0 = <&hym8563_int>;
436		wakeup-source;
437	};
438};
439
440&i2s0_8ch {
441	pinctrl-names = "default";
442	pinctrl-0 = <&i2s0_lrck
443		     &i2s0_mclk
444		     &i2s0_sclk
445		     &i2s0_sdi0
446		     &i2s0_sdo0>;
447	status = "okay";
448};
449
450&mdio0 {
451	rgmii_phy0: ethernet-phy@1 {
452		compatible = "ethernet-phy-ieee802.3-c22";
453		reg = <0x1>;
454	};
455};
456
457&mdio1 {
458	rgmii_phy1: ethernet-phy@1 {
459		compatible = "ethernet-phy-ieee802.3-c22";
460		reg = <0x1>;
461	};
462};
463
464&pcie2x1l0 {
465	pinctrl-names = "default";
466	pinctrl-0 = <&pcie2_0_rst>;
467	reset-gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_HIGH>;
468	status = "okay";
469};
470
471&pcie30phy {
472	status = "okay";
473};
474
475&pcie3x4 {
476	pinctrl-names = "default";
477	pinctrl-0 = <&pcie3_rst>;
478	reset-gpios = <&gpio4 RK_PB6 GPIO_ACTIVE_HIGH>;
479	vpcie3v3-supply = <&vcc3v3_pcie30>;
480	status = "okay";
481};
482
483&pinctrl {
484	dp {
485		dp1_hpd: dp1-hpd {
486			 rockchip,pins = <1 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>;
487		};
488	};
489
490	hym8563 {
491		hym8563_int: hym8563-int {
492			rockchip,pins = <0 RK_PB0 RK_FUNC_GPIO &pcfg_pull_up>;
493		};
494	};
495
496	gpio-leds {
497		sys_led_pin: sys-led-pin {
498			rockchip,pins =
499				<1 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>;
500		};
501	};
502
503	pcie2 {
504		pcie2_0_rst: pcie2-0-rst {
505			rockchip,pins = <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_none>;
506		};
507	};
508
509	pcie3 {
510		pcie3_rst: pcie3-rst {
511			rockchip,pins = <4 RK_PB6 RK_FUNC_GPIO &pcfg_pull_none>;
512		};
513
514		pcie3_vcc3v3_en: pcie3-vcc3v3-en {
515			rockchip,pins = <2 RK_PC5 RK_FUNC_GPIO &pcfg_pull_none>;
516		};
517	};
518
519	sound {
520		hp_detect: hp-detect {
521			rockchip,pins = <1 RK_PC4 RK_FUNC_GPIO &pcfg_pull_none>;
522		};
523
524		headphone_amplifier_en: headphone-amplifier-en {
525			rockchip,pins = <4 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>;
526		};
527
528		speaker_amplifier_en: speaker-amplifier-en {
529			rockchip,pins = <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>;
530		};
531	};
532
533	usb {
534		usbc0_int: usbc0-int {
535			rockchip,pins = <0 RK_PD3 RK_FUNC_GPIO &pcfg_pull_up>;
536		};
537	};
538};
539
540&pwm15 {
541	pinctrl-names = "default";
542	pinctrl-0 = <&pwm15m2_pins>;
543	status = "okay";
544};
545
546&sata0 {
547	status = "okay";
548};
549
550&sata1 {
551	status = "okay";
552};
553
554&sata2 {
555	status = "okay";
556};
557
558/* uart/232/485 */
559&uart0 {
560	pinctrl-0 = <&uart0m2_xfer>;
561	status = "okay";
562};
563
564&uart1 {
565	pinctrl-0 = <&uart1m1_xfer>;
566	status = "okay";
567};
568
569/* usb enable */
570&u2phy0 {
571	status = "okay";
572};
573
574&u2phy0_otg {
575	status = "okay";
576};
577
578&u2phy1 {
579	status = "okay";
580};
581
582&u2phy1_otg {
583	phy-supply = <&vcc5v0_host>;
584	status = "okay";
585};
586
587&u2phy2 {
588	status = "okay";
589};
590
591&u2phy2_host {
592	phy-supply = <&vcc5v0_host>;
593	status = "okay";
594};
595
596&u2phy3 {
597	status = "okay";
598};
599
600&u2phy3_host {
601	phy-supply = <&vcc5v0_host>;
602	status = "okay";
603};
604
605&usb_host0_ehci {
606	status = "okay";
607};
608
609&usb_host0_ohci {
610	status = "okay";
611};
612
613&usb_host1_ehci {
614	status = "okay";
615};
616
617&usb_host1_ohci {
618	status = "okay";
619};
620
621&usb_host0_xhci {
622	usb-role-switch;
623	dr_mode = "otg";
624	status = "okay";
625
626	port {
627		#address-cells = <1>;
628		#size-cells = <0>;
629
630		dwc3_0_role_switch: endpoint@0 {
631			reg = <0>;
632			remote-endpoint = <&usbc0_role_sw>;
633		};
634	};
635};
636
637&usb_host1_xhci {
638	dr_mode = "host";
639	status = "okay";
640};
641
642&usb_host2_xhci {
643	status = "okay";
644};
645
646&usbdp_phy0 {
647	orientation-switch;
648	sbu1-dc-gpios = <&gpio4 RK_PA6 GPIO_ACTIVE_HIGH>;
649	sbu2-dc-gpios = <&gpio4 RK_PA7 GPIO_ACTIVE_HIGH>;
650	status = "okay";
651
652	port {
653		#address-cells = <1>;
654		#size-cells = <0>;
655
656		usbdp_phy0_orientation_switch: endpoint@0 {
657			reg = <0>;
658			remote-endpoint = <&usbc0_orien_sw>;
659		};
660
661		usbdp_phy0_dp_altmode_mux: endpoint@1 {
662			reg = <1>;
663			remote-endpoint = <&dp_altmode_mux>;
664		};
665	};
666};
667
668&usbdp_phy1 {
669	rockchip,dp-lane-mux = <2 3>;
670	status = "okay";
671};
672
673&vcc_1v8_s0 {
674	regulator-state-mem {
675		regulator-on-in-suspend;
676		regulator-suspend-microvolt = <1800000>;
677	};
678};
679
680/* for fan when deep sleep */
681&vdd_log_s0 {
682	regulator-state-mem {
683		regulator-on-in-suspend;
684		regulator-suspend-microvolt = <750000>;
685	};
686};
687
688/* display generator */
689&vop_mmu {
690	status = "okay";
691};
692
693&vop {
694	status = "okay";
695};
696
697&vp0 {
698	vp0_out_hdmi0: endpoint@ROCKCHIP_VOP2_EP_HDMI0 {
699		reg = <ROCKCHIP_VOP2_EP_HDMI0>;
700		remote-endpoint = <&hdmi0_in_vp0>;
701	};
702};
703