1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2017 T-Chip Intelligent Technology Co., Ltd
4 */
5
6/dts-v1/;
7#include <dt-bindings/input/linux-event-codes.h>
8#include <dt-bindings/pwm/pwm.h>
9#include "rk3399.dtsi"
10#include "rk3399-opp.dtsi"
11
12/ {
13	model = "Firefly ROC-RK3399-PC Board";
14	compatible = "firefly,roc-rk3399-pc", "rockchip,rk3399";
15
16	chosen {
17		stdout-path = "serial2:1500000n8";
18	};
19
20	backlight: backlight {
21		compatible = "pwm-backlight";
22		pwms = <&pwm0 0 25000 0>;
23	};
24
25	clkin_gmac: external-gmac-clock {
26		compatible = "fixed-clock";
27		clock-frequency = <125000000>;
28		clock-output-names = "clkin_gmac";
29		#clock-cells = <0>;
30	};
31
32	adc-keys {
33		compatible = "adc-keys";
34		io-channels = <&saradc 1>;
35		io-channel-names = "buttons";
36		keyup-threshold-microvolt = <1500000>;
37		poll-interval = <100>;
38
39		recovery {
40			label = "Recovery";
41			linux,code = <KEY_VENDOR>;
42			press-threshold-microvolt = <18000>;
43		};
44	};
45
46	gpio-keys {
47		compatible = "gpio-keys";
48		autorepeat;
49		pinctrl-names = "default";
50		pinctrl-0 = <&pwr_key_l>;
51
52		power {
53			label = "GPIO Key Power";
54			debounce-interval = <100>;
55			gpios = <&gpio0 RK_PA5 GPIO_ACTIVE_LOW>;
56			linux,code = <KEY_POWER>;
57			wakeup-source;
58		};
59	};
60
61	leds {
62		compatible = "gpio-leds";
63		pinctrl-names = "default";
64		pinctrl-0 = <&work_led_gpio>, <&diy_led_gpio>, <&yellow_led_gpio>;
65
66		work-led {
67			label = "green:work";
68			gpios = <&gpio2 RK_PD3 GPIO_ACTIVE_HIGH>;
69			default-state = "on";
70			linux,default-trigger = "heartbeat";
71		};
72
73		diy-led {
74			label = "red:diy";
75			gpios = <&gpio0 RK_PB5 GPIO_ACTIVE_HIGH>;
76			default-state = "off";
77			linux,default-trigger = "mmc1";
78		};
79
80		yellow-led {
81			label = "yellow:yellow-led";
82			gpios = <&gpio0 RK_PA2 GPIO_ACTIVE_HIGH>;
83			default-state = "off";
84			linux,default-trigger = "mmc0";
85		};
86	};
87
88	sdio_pwrseq: sdio-pwrseq {
89		compatible = "mmc-pwrseq-simple";
90		clocks = <&rk808 1>;
91		clock-names = "ext_clock";
92		pinctrl-names = "default";
93		pinctrl-0 = <&wifi_enable_h>;
94
95		/*
96		 * On the module itself this is one of these (depending
97		 * on the actual card populated):
98		 * - SDIO_RESET_L_WL_REG_ON
99		 * - PDN (power down when low)
100		 */
101		reset-gpios = <&gpio0 RK_PB2 GPIO_ACTIVE_LOW>;
102	};
103
104	vcc_vbus_typec0: vcc-vbus-typec0 {
105		compatible = "regulator-fixed";
106		regulator-name = "vcc_vbus_typec0";
107		regulator-always-on;
108		regulator-boot-on;
109		regulator-min-microvolt = <5000000>;
110		regulator-max-microvolt = <5000000>;
111	};
112
113	/*
114	 * should be placed inside mp8859, but not until mp8859 has
115	 * its own dt-binding.
116	 */
117	dc_12v: mp8859-dcdc1 {
118		compatible = "regulator-fixed";
119		regulator-name = "dc_12v";
120		regulator-always-on;
121		regulator-boot-on;
122		regulator-min-microvolt = <12000000>;
123		regulator-max-microvolt = <12000000>;
124		vin-supply = <&vcc_vbus_typec0>;
125	};
126
127	/* switched by pmic_sleep */
128	vcc1v8_s3: vcca1v8_s3: vcc1v8-s3 {
129		compatible = "regulator-fixed";
130		regulator-name = "vcc1v8_s3";
131		regulator-always-on;
132		regulator-boot-on;
133		regulator-min-microvolt = <1800000>;
134		regulator-max-microvolt = <1800000>;
135		vin-supply = <&vcc_1v8>;
136	};
137
138	vcc3v3_sys: vcc3v3-sys {
139		compatible = "regulator-fixed";
140		regulator-name = "vcc3v3_sys";
141		regulator-always-on;
142		regulator-boot-on;
143		regulator-min-microvolt = <3300000>;
144		regulator-max-microvolt = <3300000>;
145		vin-supply = <&dc_12v>;
146	};
147
148	/* Actually 3 regulators (host0, 1, 2) controlled by the same gpio */
149	vcc5v0_host: vcc5v0-host-regulator {
150		compatible = "regulator-fixed";
151		enable-active-high;
152		gpio = <&gpio1 RK_PA0 GPIO_ACTIVE_HIGH>;
153		pinctrl-names = "default";
154		pinctrl-0 = <&vcc5v0_host_en &hub_rst>;
155		regulator-name = "vcc5v0_host";
156		regulator-always-on;
157		vin-supply = <&vcc_sys>;
158	};
159
160	vcc_vbus_typec1: vcc-vbus-typec1 {
161		compatible = "regulator-fixed";
162		enable-active-high;
163		gpio = <&gpio1 RK_PB5 GPIO_ACTIVE_HIGH>;
164		pinctrl-names = "default";
165		pinctrl-0 = <&vcc_vbus_typec1_en>;
166		regulator-name = "vcc_vbus_typec1";
167		regulator-always-on;
168		vin-supply = <&vcc_sys>;
169	};
170
171	vcc_sys: vcc-sys {
172		compatible = "regulator-fixed";
173		enable-active-high;
174		gpio = <&gpio2 RK_PA6 GPIO_ACTIVE_HIGH>;
175		pinctrl-names = "default";
176		pinctrl-0 = <&vcc_sys_en>;
177		regulator-name = "vcc_sys";
178		regulator-always-on;
179		regulator-boot-on;
180		regulator-min-microvolt = <5000000>;
181		regulator-max-microvolt = <5000000>;
182		vin-supply = <&dc_12v>;
183	};
184
185	vdd_log: vdd-log {
186		compatible = "pwm-regulator";
187		pwms = <&pwm2 0 25000 1>;
188		regulator-name = "vdd_log";
189		regulator-always-on;
190		regulator-boot-on;
191		regulator-min-microvolt = <800000>;
192		regulator-max-microvolt = <1400000>;
193		vin-supply = <&vcc3v3_sys>;
194	};
195};
196
197&cpu_l0 {
198	cpu-supply = <&vdd_cpu_l>;
199};
200
201&cpu_l1 {
202	cpu-supply = <&vdd_cpu_l>;
203};
204
205&cpu_l2 {
206	cpu-supply = <&vdd_cpu_l>;
207};
208
209&cpu_l3 {
210	cpu-supply = <&vdd_cpu_l>;
211};
212
213&cpu_b0 {
214	cpu-supply = <&vdd_cpu_b>;
215};
216
217&cpu_b1 {
218	cpu-supply = <&vdd_cpu_b>;
219};
220
221&emmc_phy {
222	status = "okay";
223};
224
225&gmac {
226	assigned-clocks = <&cru SCLK_RMII_SRC>;
227	assigned-clock-parents = <&clkin_gmac>;
228	clock_in_out = "input";
229	phy-supply = <&vcc_lan>;
230	phy-mode = "rgmii";
231	pinctrl-names = "default";
232	pinctrl-0 = <&rgmii_pins>;
233	snps,reset-gpio = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
234	snps,reset-active-low;
235	snps,reset-delays-us = <0 10000 50000>;
236	tx_delay = <0x28>;
237	rx_delay = <0x11>;
238	status = "okay";
239};
240
241&hdmi {
242	ddc-i2c-bus = <&i2c3>;
243	pinctrl-names = "default";
244	pinctrl-0 = <&hdmi_cec>;
245	status = "okay";
246};
247
248&i2c0 {
249	clock-frequency = <400000>;
250	i2c-scl-rising-time-ns = <168>;
251	i2c-scl-falling-time-ns = <4>;
252	status = "okay";
253
254	rk808: pmic@1b {
255		compatible = "rockchip,rk808";
256		reg = <0x1b>;
257		interrupt-parent = <&gpio1>;
258		interrupts = <21 IRQ_TYPE_LEVEL_LOW>;
259		#clock-cells = <1>;
260		clock-output-names = "xin32k", "rk808-clkout2";
261		pinctrl-names = "default";
262		pinctrl-0 = <&pmic_int_l>;
263		rockchip,system-power-controller;
264		wakeup-source;
265
266		vcc1-supply = <&vcc3v3_sys>;
267		vcc2-supply = <&vcc3v3_sys>;
268		vcc3-supply = <&vcc3v3_sys>;
269		vcc4-supply = <&vcc3v3_sys>;
270		vcc6-supply = <&vcc3v3_sys>;
271		vcc7-supply = <&vcc3v3_sys>;
272		vcc8-supply = <&vcc3v3_sys>;
273		vcc9-supply = <&vcc3v3_sys>;
274		vcc10-supply = <&vcc3v3_sys>;
275		vcc11-supply = <&vcc3v3_sys>;
276		vcc12-supply = <&vcc3v3_sys>;
277		vcc13-supply = <&vcc3v3_sys>;
278		vcc14-supply = <&vcc3v3_sys>;
279		vddio-supply = <&vcc_3v0>;
280
281		regulators {
282			vdd_center: DCDC_REG1 {
283				regulator-name = "vdd_center";
284				regulator-always-on;
285				regulator-boot-on;
286				regulator-min-microvolt = <750000>;
287				regulator-max-microvolt = <1350000>;
288				regulator-ramp-delay = <6001>;
289				regulator-state-mem {
290					regulator-off-in-suspend;
291				};
292			};
293
294			vdd_cpu_l: DCDC_REG2 {
295				regulator-name = "vdd_cpu_l";
296				regulator-always-on;
297				regulator-boot-on;
298				regulator-min-microvolt = <750000>;
299				regulator-max-microvolt = <1350000>;
300				regulator-ramp-delay = <6001>;
301				regulator-state-mem {
302					regulator-off-in-suspend;
303				};
304			};
305
306			vcc_ddr: DCDC_REG3 {
307				regulator-name = "vcc_ddr";
308				regulator-always-on;
309				regulator-boot-on;
310				regulator-state-mem {
311					regulator-on-in-suspend;
312				};
313			};
314
315			vcc_1v8: DCDC_REG4 {
316				regulator-name = "vcc_1v8";
317				regulator-always-on;
318				regulator-boot-on;
319				regulator-min-microvolt = <1800000>;
320				regulator-max-microvolt = <1800000>;
321				regulator-state-mem {
322					regulator-on-in-suspend;
323					regulator-suspend-microvolt = <1800000>;
324				};
325			};
326
327			vcca1v8_codec: LDO_REG1 {
328				regulator-name = "vcca1v8_codec";
329				regulator-always-on;
330				regulator-boot-on;
331				regulator-min-microvolt = <1800000>;
332				regulator-max-microvolt = <1800000>;
333				regulator-state-mem {
334					regulator-off-in-suspend;
335				};
336			};
337
338			vcc1v8_hdmi: LDO_REG2 {
339				regulator-name = "vcc1v8_hdmi";
340				regulator-always-on;
341				regulator-boot-on;
342				regulator-min-microvolt = <1800000>;
343				regulator-max-microvolt = <1800000>;
344				regulator-state-mem {
345					regulator-off-in-suspend;
346				};
347			};
348
349			vcc1v8_pmu: LDO_REG3 {
350				regulator-name = "vcc1v8_pmu";
351				regulator-always-on;
352				regulator-boot-on;
353				regulator-min-microvolt = <1800000>;
354				regulator-max-microvolt = <1800000>;
355				regulator-state-mem {
356					regulator-on-in-suspend;
357					regulator-suspend-microvolt = <1800000>;
358				};
359			};
360
361			vcc_sdio: LDO_REG4 {
362				regulator-name = "vcc_sdio";
363				regulator-always-on;
364				regulator-boot-on;
365				regulator-min-microvolt = <1800000>;
366				regulator-max-microvolt = <3000000>;
367				regulator-state-mem {
368					regulator-on-in-suspend;
369					regulator-suspend-microvolt = <3000000>;
370				};
371			};
372
373			vcca3v0_codec: LDO_REG5 {
374				regulator-name = "vcca3v0_codec";
375				regulator-always-on;
376				regulator-boot-on;
377				regulator-min-microvolt = <3000000>;
378				regulator-max-microvolt = <3000000>;
379				regulator-state-mem {
380					regulator-off-in-suspend;
381				};
382			};
383
384			vcc_1v5: LDO_REG6 {
385				regulator-name = "vcc_1v5";
386				regulator-always-on;
387				regulator-boot-on;
388				regulator-min-microvolt = <1500000>;
389				regulator-max-microvolt = <1500000>;
390				regulator-state-mem {
391					regulator-on-in-suspend;
392					regulator-suspend-microvolt = <1500000>;
393				};
394			};
395
396			vcca0v9_hdmi: LDO_REG7 {
397				regulator-name = "vcca0v9_hdmi";
398				regulator-always-on;
399				regulator-boot-on;
400				regulator-min-microvolt = <900000>;
401				regulator-max-microvolt = <900000>;
402				regulator-state-mem {
403					regulator-off-in-suspend;
404				};
405			};
406
407			vcc_3v0: LDO_REG8 {
408				regulator-name = "vcc_3v0";
409				regulator-always-on;
410				regulator-boot-on;
411				regulator-min-microvolt = <3000000>;
412				regulator-max-microvolt = <3000000>;
413				regulator-state-mem {
414					regulator-on-in-suspend;
415					regulator-suspend-microvolt = <3000000>;
416				};
417			};
418
419			vcc3v3_s3: vcc_lan: SWITCH_REG1 {
420				regulator-name = "vcc3v3_s3";
421				regulator-always-on;
422				regulator-boot-on;
423				regulator-state-mem {
424					regulator-off-in-suspend;
425				};
426			};
427
428			vcc3v3_s0: SWITCH_REG2 {
429				regulator-name = "vcc3v3_s0";
430				regulator-always-on;
431				regulator-boot-on;
432				regulator-state-mem {
433					regulator-off-in-suspend;
434				};
435			};
436		};
437	};
438
439	vdd_cpu_b: regulator@40 {
440		compatible = "silergy,syr827";
441		reg = <0x40>;
442		fcs,suspend-voltage-selector = <1>;
443		pinctrl-names = "default";
444		pinctrl-0 = <&vsel1_gpio>;
445		regulator-name = "vdd_cpu_b";
446		regulator-min-microvolt = <712500>;
447		regulator-max-microvolt = <1500000>;
448		regulator-ramp-delay = <1000>;
449		regulator-always-on;
450		regulator-boot-on;
451		vin-supply = <&vcc3v3_sys>;
452
453		regulator-state-mem {
454			regulator-off-in-suspend;
455		};
456	};
457
458	vdd_gpu: regulator@41 {
459		compatible = "silergy,syr828";
460		reg = <0x41>;
461		fcs,suspend-voltage-selector = <1>;
462		pinctrl-names = "default";
463		pinctrl-0 = <&vsel2_gpio>;
464		regulator-name = "vdd_gpu";
465		regulator-min-microvolt = <712500>;
466		regulator-max-microvolt = <1500000>;
467		regulator-ramp-delay = <1000>;
468		regulator-always-on;
469		regulator-boot-on;
470		vin-supply = <&vcc3v3_sys>;
471
472		regulator-state-mem {
473			regulator-off-in-suspend;
474		};
475	};
476};
477
478&i2c1 {
479	i2c-scl-rising-time-ns = <300>;
480	i2c-scl-falling-time-ns = <15>;
481	status = "okay";
482};
483
484&i2c3 {
485	i2c-scl-rising-time-ns = <450>;
486	i2c-scl-falling-time-ns = <15>;
487	status = "okay";
488};
489
490&i2c4 {
491	i2c-scl-rising-time-ns = <600>;
492	i2c-scl-falling-time-ns = <20>;
493	status = "okay";
494
495	fusb1: usb-typec@22 {
496		compatible = "fcs,fusb302";
497		reg = <0x22>;
498		interrupt-parent = <&gpio1>;
499		interrupts = <1 IRQ_TYPE_LEVEL_LOW>;
500		pinctrl-names = "default";
501		pinctrl-0 = <&fusb1_int>;
502		vbus-supply = <&vcc_vbus_typec1>;
503		status = "okay";
504	};
505};
506
507&i2c7 {
508	i2c-scl-rising-time-ns = <600>;
509	i2c-scl-falling-time-ns = <20>;
510	status = "okay";
511
512	fusb0: usb-typec@22 {
513		compatible = "fcs,fusb302";
514		reg = <0x22>;
515		interrupt-parent = <&gpio1>;
516		interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
517		pinctrl-names = "default";
518		pinctrl-0 = <&fusb0_int>;
519		vbus-supply = <&vcc_vbus_typec0>;
520		status = "okay";
521	};
522};
523
524&i2s0 {
525	rockchip,playback-channels = <8>;
526	rockchip,capture-channels = <8>;
527	status = "okay";
528};
529
530&i2s1 {
531	rockchip,playback-channels = <2>;
532	rockchip,capture-channels = <2>;
533	status = "okay";
534};
535
536&i2s2 {
537	status = "okay";
538};
539
540&io_domains {
541	audio-supply = <&vcca1v8_codec>;
542	bt656-supply = <&vcc_3v0>;
543	gpio1830-supply = <&vcc_3v0>;
544	sdmmc-supply = <&vcc_sdio>;
545	status = "okay";
546};
547
548&pmu_io_domains {
549	pmu1830-supply = <&vcc_3v0>;
550	status = "okay";
551};
552
553&pinctrl {
554	buttons {
555		pwr_key_l: pwr-key-l {
556			rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>;
557		};
558	};
559
560	lcd-panel {
561		lcd_panel_reset: lcd-panel-reset {
562			rockchip,pins = <4 RK_PD6 RK_FUNC_GPIO &pcfg_pull_up>;
563		};
564	};
565
566	leds {
567		diy_led_gpio: diy_led-gpio {
568			rockchip,pins = <0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>;
569		};
570
571		work_led_gpio: work_led-gpio {
572			rockchip,pins = <2 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
573		};
574
575		yellow_led_gpio: yellow_led-gpio {
576			rockchip,pins = <0 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>;
577		};
578	};
579
580	pmic {
581		vsel1_gpio: vsel1-gpio {
582			rockchip,pins = <1 RK_PC2 RK_FUNC_GPIO &pcfg_pull_down>;
583		};
584
585		vsel2_gpio: vsel2-gpio {
586			rockchip,pins = <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_down>;
587		};
588	};
589
590	sdio-pwrseq {
591		wifi_enable_h: wifi-enable-h {
592			rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>;
593		};
594	};
595
596	pmic {
597		pmic_int_l: pmic-int-l {
598			rockchip,pins = <1 RK_PC5 RK_FUNC_GPIO &pcfg_pull_up>;
599		};
600	};
601
602	usb2 {
603		vcc5v0_host_en: vcc5v0-host-en {
604			rockchip,pins = <1 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>;
605		};
606
607		vcc_sys_en: vcc-sys-en {
608			rockchip,pins = <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>;
609		};
610
611		hub_rst: hub-rst {
612			rockchip,pins = <2 RK_PA4 RK_FUNC_GPIO &pcfg_output_high>;
613		};
614	};
615
616	usb-typec {
617		vcc_vbus_typec1_en: vcc-vbus-typec1-en {
618			rockchip,pins = <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>;
619		};
620	};
621
622	fusb30x {
623		fusb0_int: fusb0-int {
624			rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>;
625		};
626
627		fusb1_int: fusb1-int {
628			rockchip,pins = <1 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>;
629		};
630	};
631};
632
633&pwm0 {
634	status = "okay";
635};
636
637&pwm2 {
638	status = "okay";
639};
640
641&saradc {
642	vref-supply = <&vcca1v8_s3>;
643	status = "okay";
644};
645
646&sdmmc {
647	bus-width = <4>;
648	cap-mmc-highspeed;
649	cap-sd-highspeed;
650	cd-gpios = <&gpio0 RK_PA7 GPIO_ACTIVE_LOW>;
651	disable-wp;
652	max-frequency = <150000000>;
653	pinctrl-names = "default";
654	pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_bus4>;
655	status = "okay";
656};
657
658&sdhci {
659	bus-width = <8>;
660	mmc-hs400-1_8v;
661	mmc-hs400-enhanced-strobe;
662	non-removable;
663	status = "okay";
664};
665
666&tcphy0 {
667	status = "okay";
668};
669
670&tcphy1 {
671	status = "okay";
672};
673
674&tsadc {
675	/* tshut mode 0:CRU 1:GPIO */
676	rockchip,hw-tshut-mode = <1>;
677	/* tshut polarity 0:LOW 1:HIGH */
678	rockchip,hw-tshut-polarity = <1>;
679	status = "okay";
680};
681
682&u2phy0 {
683	status = "okay";
684
685	u2phy0_otg: otg-port {
686		phy-supply = <&vcc_vbus_typec0>;
687		status = "okay";
688	};
689
690	u2phy0_host: host-port {
691		phy-supply = <&vcc5v0_host>;
692		status = "okay";
693	};
694};
695
696&u2phy1 {
697	status = "okay";
698
699	u2phy1_otg: otg-port {
700		phy-supply = <&vcc_vbus_typec1>;
701		status = "okay";
702	};
703
704	u2phy1_host: host-port {
705		phy-supply = <&vcc5v0_host>;
706		status = "okay";
707	};
708};
709
710&uart0 {
711	pinctrl-names = "default";
712	pinctrl-0 = <&uart0_xfer &uart0_cts>;
713	status = "okay";
714};
715
716&uart2 {
717	status = "okay";
718};
719
720&usb_host0_ehci {
721	status = "okay";
722};
723
724&usb_host0_ohci {
725	status = "okay";
726};
727
728&usb_host1_ehci {
729	status = "okay";
730};
731
732&usb_host1_ohci {
733	status = "okay";
734};
735
736&usbdrd3_0 {
737	status = "okay";
738};
739
740&usbdrd_dwc3_0 {
741	status = "okay";
742};
743
744&usbdrd3_1 {
745	status = "okay";
746};
747
748&usbdrd_dwc3_1 {
749	status = "okay";
750	dr_mode = "host";
751};
752
753&vopb {
754	status = "okay";
755};
756
757&vopb_mmu {
758	status = "okay";
759};
760
761&vopl {
762	status = "okay";
763};
764
765&vopl_mmu {
766	status = "okay";
767};
768