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/pinctrl/rockchip.h>
7#include "rk3566.dtsi"
8
9/ {
10	model = "Pine64 RK3566 Quartz64-A Board";
11	compatible = "pine64,quartz64-a", "rockchip,rk3566";
12
13	aliases {
14		ethernet0 = &gmac1;
15		mmc0 = &sdmmc0;
16		mmc1 = &sdhci;
17	};
18
19	chosen: chosen {
20		stdout-path = "serial2:1500000n8";
21	};
22
23	gmac1_clkin: external-gmac1-clock {
24		compatible = "fixed-clock";
25		clock-frequency = <125000000>;
26		clock-output-names = "gmac1_clkin";
27		#clock-cells = <0>;
28	};
29
30	fan: gpio_fan {
31		compatible = "gpio-fan";
32		gpios = <&gpio0 RK_PD5 GPIO_ACTIVE_HIGH>;
33		gpio-fan,speed-map = <0    0
34				      4500 1>;
35		#cooling-cells = <2>;
36	};
37
38	leds {
39		compatible = "gpio-leds";
40
41		led-work {
42			label = "work-led";
43			default-state = "off";
44			gpios = <&gpio0 RK_PD3 GPIO_ACTIVE_HIGH>;
45			pinctrl-names = "default";
46			pinctrl-0 = <&work_led_enable_h>;
47			retain-state-suspended;
48		};
49
50		led-diy {
51			label = "diy-led";
52			default-state = "on";
53			gpios = <&gpio0 RK_PD4 GPIO_ACTIVE_HIGH>;
54			linux,default-trigger = "heartbeat";
55			pinctrl-names = "default";
56			pinctrl-0 = <&diy_led_enable_h>;
57			retain-state-suspended;
58		};
59	};
60
61	rk817-sound {
62		compatible = "simple-audio-card";
63		simple-audio-card,format = "i2s";
64		simple-audio-card,name = "Analog RK817";
65		simple-audio-card,mclk-fs = <256>;
66
67		simple-audio-card,cpu {
68			sound-dai = <&i2s1_8ch>;
69		};
70
71		simple-audio-card,codec {
72			sound-dai = <&rk817>;
73		};
74	};
75
76	sdio_pwrseq: sdio-pwrseq {
77		compatible = "mmc-pwrseq-simple";
78		clocks = <&rk817 1>;
79		clock-names = "ext_clock";
80		pinctrl-names = "default";
81		pinctrl-0 = <&wifi_enable_h>;
82		post-power-on-delay-ms = <100>;
83		power-off-delay-us = <5000000>;
84		reset-gpios = <&gpio2 RK_PC2 GPIO_ACTIVE_LOW>;
85	};
86
87	spdif_dit: spdif-dit {
88		compatible = "linux,spdif-dit";
89		#sound-dai-cells = <0>;
90	};
91
92	spdif_sound: spdif-sound {
93		compatible = "simple-audio-card";
94		simple-audio-card,name = "SPDIF";
95
96		simple-audio-card,cpu {
97			sound-dai = <&spdif>;
98		};
99
100		simple-audio-card,codec {
101			sound-dai = <&spdif_dit>;
102		};
103	};
104
105	vcc12v_dcin: vcc12v_dcin {
106		compatible = "regulator-fixed";
107		regulator-name = "vcc12v_dcin";
108		regulator-always-on;
109		regulator-boot-on;
110		regulator-min-microvolt = <12000000>;
111		regulator-max-microvolt = <12000000>;
112	};
113
114	/* vbus feeds the rk817 usb input.
115	 * With no battery attached, also feeds vcc_bat+
116	 * via ON/OFF_BAT jumper
117	 */
118	vbus: vbus {
119		compatible = "regulator-fixed";
120		regulator-name = "vbus";
121		regulator-always-on;
122		regulator-boot-on;
123		regulator-min-microvolt = <5000000>;
124		regulator-max-microvolt = <5000000>;
125		vin-supply = <&vcc12v_dcin>;
126	};
127
128	vcc5v0_usb: vcc5v0_usb {
129		compatible = "regulator-fixed";
130		regulator-name = "vcc5v0_usb";
131		regulator-always-on;
132		regulator-boot-on;
133		regulator-min-microvolt = <5000000>;
134		regulator-max-microvolt = <5000000>;
135		vin-supply = <&vcc12v_dcin>;
136	};
137
138	/* all four ports are controlled by one gpio
139	 * the host ports are sourced from vcc5v0_usb
140	 * the otg port is sourced from vcc5v0_midu
141	 */
142	vcc5v0_usb20_host: vcc5v0_usb20_host {
143		compatible = "regulator-fixed";
144		enable-active-high;
145		gpio = <&gpio4 RK_PB5 GPIO_ACTIVE_HIGH>;
146		pinctrl-names = "default";
147		pinctrl-0 = <&vcc5v0_usb20_host_en>;
148		regulator-name = "vcc5v0_usb20_host";
149		regulator-min-microvolt = <5000000>;
150		regulator-max-microvolt = <5000000>;
151		vin-supply = <&vcc5v0_usb>;
152	};
153
154	vcc5v0_usb20_otg: vcc5v0_usb20_otg {
155		compatible = "regulator-fixed";
156		enable-active-high;
157		gpio = <&gpio4 RK_PB5 GPIO_ACTIVE_HIGH>;
158		regulator-name = "vcc5v0_usb20_otg";
159		regulator-min-microvolt = <5000000>;
160		regulator-max-microvolt = <5000000>;
161		vin-supply = <&dcdc_boost>;
162	};
163
164	vcc3v3_sd: vcc3v3_sd {
165		compatible = "regulator-fixed";
166		enable-active-low;
167		gpio = <&gpio0 RK_PA5 GPIO_ACTIVE_LOW>;
168		pinctrl-names = "default";
169		pinctrl-0 = <&vcc_sd_h>;
170		regulator-boot-on;
171		regulator-name = "vcc3v3_sd";
172		regulator-min-microvolt = <3300000>;
173		regulator-max-microvolt = <3300000>;
174		vin-supply = <&vcc_3v3>;
175	};
176
177	/* sourced from vbus and vcc_bat+ via rk817 sw5 */
178	vcc_sys: vcc_sys {
179		compatible = "regulator-fixed";
180		regulator-name = "vcc_sys";
181		regulator-always-on;
182		regulator-boot-on;
183		regulator-min-microvolt = <4400000>;
184		regulator-max-microvolt = <4400000>;
185		vin-supply = <&vbus>;
186	};
187
188	/* sourced from vcc_sys, sdio module operates internally at 3.3v */
189	vcc_wl: vcc_wl {
190		compatible = "regulator-fixed";
191		regulator-name = "vcc_wl";
192		regulator-always-on;
193		regulator-boot-on;
194		regulator-min-microvolt = <3300000>;
195		regulator-max-microvolt = <3300000>;
196		vin-supply = <&vcc_sys>;
197	};
198};
199
200&combphy1 {
201	status = "okay";
202};
203
204&cpu0 {
205	cpu-supply = <&vdd_cpu>;
206};
207
208&cpu1 {
209	cpu-supply = <&vdd_cpu>;
210};
211
212&cpu2 {
213	cpu-supply = <&vdd_cpu>;
214};
215
216&cpu3 {
217	cpu-supply = <&vdd_cpu>;
218};
219
220&cpu_thermal {
221	trips {
222		cpu_hot: cpu_hot {
223			temperature = <55000>;
224			hysteresis = <2000>;
225			type = "active";
226		};
227	};
228
229	cooling-maps {
230		map1 {
231			trip = <&cpu_hot>;
232			cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
233		};
234	};
235};
236
237&gmac1 {
238	assigned-clocks = <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru SCLK_GMAC1>;
239	assigned-clock-parents = <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru SCLK_GMAC1>, <&gmac1_clkin>;
240	clock_in_out = "input";
241	phy-supply = <&vcc_3v3>;
242	phy-mode = "rgmii";
243	pinctrl-names = "default";
244	pinctrl-0 = <&gmac1m0_miim
245		     &gmac1m0_tx_bus2
246		     &gmac1m0_rx_bus2
247		     &gmac1m0_rgmii_clk
248		     &gmac1m0_clkinout
249		     &gmac1m0_rgmii_bus>;
250	snps,reset-gpio = <&gpio0 RK_PC3 GPIO_ACTIVE_LOW>;
251	snps,reset-active-low;
252	/* Reset time is 20ms, 100ms for rtl8211f */
253	snps,reset-delays-us = <0 20000 100000>;
254	tx_delay = <0x30>;
255	rx_delay = <0x10>;
256	phy-handle = <&rgmii_phy1>;
257	status = "okay";
258};
259
260&gpu {
261	mali-supply = <&vdd_gpu>;
262	status = "okay";
263};
264
265&i2c0 {
266	status = "okay";
267
268	vdd_cpu: regulator@1c {
269		compatible = "tcs,tcs4525";
270		reg = <0x1c>;
271		fcs,suspend-voltage-selector = <1>;
272		regulator-name = "vdd_cpu";
273		regulator-min-microvolt = <800000>;
274		regulator-max-microvolt = <1150000>;
275		regulator-ramp-delay = <2300>;
276		regulator-always-on;
277		regulator-boot-on;
278		vin-supply = <&vcc_sys>;
279
280		regulator-state-mem {
281			regulator-off-in-suspend;
282		};
283	};
284
285	rk817: pmic@20 {
286		compatible = "rockchip,rk817";
287		reg = <0x20>;
288		interrupt-parent = <&gpio0>;
289		interrupts = <RK_PA3 IRQ_TYPE_LEVEL_LOW>;
290		assigned-clocks = <&cru I2S1_MCLKOUT_TX>;
291		assigned-clock-parents = <&cru CLK_I2S1_8CH_TX>;
292		clock-names = "mclk";
293		clocks = <&cru I2S1_MCLKOUT_TX>;
294		clock-output-names = "rk808-clkout1", "rk808-clkout2";
295		#clock-cells = <1>;
296		pinctrl-names = "default";
297		pinctrl-0 = <&pmic_int_l>, <&i2s1m0_mclk>;
298		rockchip,system-power-controller;
299		#sound-dai-cells = <0>;
300		wakeup-source;
301
302		vcc1-supply = <&vcc_sys>;
303		vcc2-supply = <&vcc_sys>;
304		vcc3-supply = <&vcc_sys>;
305		vcc4-supply = <&vcc_sys>;
306		vcc5-supply = <&vcc_sys>;
307		vcc6-supply = <&vcc_sys>;
308		vcc7-supply = <&vcc_sys>;
309		vcc8-supply = <&vcc_sys>;
310		vcc9-supply = <&dcdc_boost>;
311
312		regulators {
313			vdd_logic: DCDC_REG1 {
314				regulator-always-on;
315				regulator-boot-on;
316				regulator-min-microvolt = <500000>;
317				regulator-max-microvolt = <1350000>;
318				regulator-init-microvolt = <900000>;
319				regulator-ramp-delay = <6001>;
320				regulator-initial-mode = <0x2>;
321				regulator-name = "vdd_logic";
322				regulator-state-mem {
323					regulator-on-in-suspend;
324					regulator-suspend-microvolt = <900000>;
325				};
326			};
327
328			vdd_gpu: DCDC_REG2 {
329				regulator-always-on;
330				regulator-boot-on;
331				regulator-min-microvolt = <500000>;
332				regulator-max-microvolt = <1350000>;
333				regulator-init-microvolt = <900000>;
334				regulator-ramp-delay = <6001>;
335				regulator-initial-mode = <0x2>;
336				regulator-name = "vdd_gpu";
337					regulator-state-mem {
338					regulator-off-in-suspend;
339				};
340			};
341
342			vcc_ddr: DCDC_REG3 {
343				regulator-always-on;
344				regulator-boot-on;
345				regulator-initial-mode = <0x2>;
346				regulator-name = "vcc_ddr";
347				regulator-state-mem {
348					regulator-on-in-suspend;
349				};
350			};
351
352			vcc_3v3: DCDC_REG4 {
353				regulator-always-on;
354				regulator-boot-on;
355				regulator-min-microvolt = <3300000>;
356				regulator-max-microvolt = <3300000>;
357				regulator-initial-mode = <0x2>;
358				regulator-name = "vcc_3v3";
359				regulator-state-mem {
360					regulator-off-in-suspend;
361				};
362			};
363
364			vcca1v8_pmu: LDO_REG1 {
365				regulator-always-on;
366				regulator-boot-on;
367				regulator-min-microvolt = <1800000>;
368				regulator-max-microvolt = <1800000>;
369				regulator-name = "vcca1v8_pmu";
370				regulator-state-mem {
371					regulator-on-in-suspend;
372					regulator-suspend-microvolt = <1800000>;
373				};
374			};
375
376			vdda_0v9: LDO_REG2 {
377				regulator-always-on;
378				regulator-boot-on;
379				regulator-min-microvolt = <900000>;
380				regulator-max-microvolt = <900000>;
381				regulator-name = "vdda_0v9";
382				regulator-state-mem {
383					regulator-off-in-suspend;
384				};
385			};
386
387			vdda0v9_pmu: LDO_REG3 {
388				regulator-always-on;
389				regulator-boot-on;
390				regulator-min-microvolt = <900000>;
391				regulator-max-microvolt = <900000>;
392				regulator-name = "vdda0v9_pmu";
393				regulator-state-mem {
394					regulator-on-in-suspend;
395					regulator-suspend-microvolt = <900000>;
396				};
397			};
398
399			vccio_acodec: LDO_REG4 {
400				regulator-always-on;
401				regulator-boot-on;
402				regulator-min-microvolt = <3300000>;
403				regulator-max-microvolt = <3300000>;
404				regulator-name = "vccio_acodec";
405				regulator-state-mem {
406					regulator-off-in-suspend;
407				};
408			};
409
410			vccio_sd: LDO_REG5 {
411				regulator-always-on;
412				regulator-boot-on;
413				regulator-min-microvolt = <1800000>;
414				regulator-max-microvolt = <3300000>;
415				regulator-name = "vccio_sd";
416				regulator-state-mem {
417					regulator-off-in-suspend;
418				};
419			};
420
421			vcc3v3_pmu: LDO_REG6 {
422				regulator-always-on;
423				regulator-boot-on;
424				regulator-min-microvolt = <3300000>;
425				regulator-max-microvolt = <3300000>;
426				regulator-name = "vcc3v3_pmu";
427				regulator-state-mem {
428					regulator-on-in-suspend;
429					regulator-suspend-microvolt = <3300000>;
430				};
431			};
432
433			vcc_1v8: LDO_REG7 {
434				regulator-always-on;
435				regulator-boot-on;
436				regulator-min-microvolt = <1800000>;
437				regulator-max-microvolt = <1800000>;
438				regulator-name = "vcc_1v8";
439				regulator-state-mem {
440					regulator-off-in-suspend;
441				};
442			};
443
444			vcc1v8_dvp: LDO_REG8 {
445				regulator-always-on;
446				regulator-boot-on;
447				regulator-min-microvolt = <1800000>;
448				regulator-max-microvolt = <1800000>;
449				regulator-name = "vcc1v8_dvp";
450				regulator-state-mem {
451					regulator-off-in-suspend;
452				};
453			};
454
455			vcc2v8_dvp: LDO_REG9 {
456				regulator-always-on;
457				regulator-boot-on;
458				regulator-min-microvolt = <2800000>;
459				regulator-max-microvolt = <2800000>;
460				regulator-name = "vcc2v8_dvp";
461				regulator-state-mem {
462					regulator-off-in-suspend;
463				};
464			};
465
466			dcdc_boost: BOOST {
467				regulator-always-on;
468				regulator-boot-on;
469				regulator-min-microvolt = <5000000>;
470				regulator-max-microvolt = <5000000>;
471				regulator-name = "boost";
472				regulator-state-mem {
473					regulator-off-in-suspend;
474				};
475			};
476
477			otg_switch: OTG_SWITCH {
478				regulator-name = "otg_switch";
479				regulator-state-mem {
480					regulator-off-in-suspend;
481				};
482			};
483		};
484	};
485};
486
487/* i2c3 is exposed on con40
488 * pin 3 - i2c3_sda_m0, pullup to vcc_3v3
489 * pin 5 - i2c3_scl_m0, pullup to vcc_3v3
490 */
491&i2c3 {
492	status = "okay";
493};
494
495&i2s1_8ch {
496	pinctrl-names = "default";
497	pinctrl-0 = <&i2s1m0_sclktx
498		     &i2s1m0_lrcktx
499		     &i2s1m0_sdi0
500		     &i2s1m0_sdo0>;
501	rockchip,trcm-sync-tx-only;
502	status = "okay";
503};
504
505&mdio1 {
506	rgmii_phy1: ethernet-phy@0 {
507		compatible = "ethernet-phy-ieee802.3-c22";
508		reg = <0>;
509	};
510};
511
512&pinctrl {
513	bt {
514		bt_enable_h: bt-enable-h {
515			rockchip,pins = <2 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>;
516		};
517
518		bt_host_wake_l: bt-host-wake-l {
519			rockchip,pins = <2 RK_PC0 RK_FUNC_GPIO &pcfg_pull_down>;
520		};
521
522		bt_wake_l: bt-wake-l {
523			rockchip,pins = <2 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>;
524		};
525	};
526
527	leds {
528		work_led_enable_h: work-led-enable-h {
529			rockchip,pins = <0 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
530		};
531
532		diy_led_enable_h: diy-led-enable-h {
533			rockchip,pins = <0 RK_PD4 RK_FUNC_GPIO &pcfg_pull_none>;
534		};
535	};
536
537	pmic {
538		pmic_int_l: pmic-int-l {
539			rockchip,pins = <0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>;
540		};
541	};
542
543	usb2 {
544		vcc5v0_usb20_host_en: vcc5v0-usb20-host-en {
545			rockchip,pins = <4 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>;
546		};
547	};
548
549	sdio-pwrseq {
550		wifi_enable_h: wifi-enable-h {
551			rockchip,pins = <2 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>;
552		};
553	};
554
555	vcc_sd {
556		vcc_sd_h: vcc-sd-h {
557			rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_none>;
558		};
559	};
560};
561
562&pmu_io_domains {
563	pmuio1-supply = <&vcc3v3_pmu>;
564	pmuio2-supply = <&vcc3v3_pmu>;
565	vccio1-supply = <&vccio_acodec>;
566	vccio2-supply = <&vcc_1v8>;
567	vccio3-supply = <&vccio_sd>;
568	vccio4-supply = <&vcc_1v8>;
569	vccio5-supply = <&vcc_3v3>;
570	vccio6-supply = <&vcc1v8_dvp>;
571	vccio7-supply = <&vcc_3v3>;
572	status = "okay";
573};
574
575&sdhci {
576	bus-width = <8>;
577	mmc-hs200-1_8v;
578	non-removable;
579	vmmc-supply = <&vcc_3v3>;
580	vqmmc-supply = <&vcc_1v8>;
581	status = "okay";
582};
583
584&sdmmc0 {
585	bus-width = <4>;
586	cap-sd-highspeed;
587	cd-gpios = <&gpio0 RK_PA4 GPIO_ACTIVE_LOW>;
588	disable-wp;
589	pinctrl-names = "default";
590	pinctrl-0 = <&sdmmc0_bus4 &sdmmc0_clk &sdmmc0_cmd &sdmmc0_det>;
591	vmmc-supply = <&vcc3v3_sd>;
592	vqmmc-supply = <&vccio_sd>;
593	status = "okay";
594};
595
596&sdmmc1 {
597	bus-width = <4>;
598	cap-sd-highspeed;
599	cap-sdio-irq;
600	keep-power-in-suspend;
601	mmc-pwrseq = <&sdio_pwrseq>;
602	non-removable;
603	pinctrl-names = "default";
604	pinctrl-0 = <&sdmmc1_bus4 &sdmmc1_cmd &sdmmc1_clk>;
605	sd-uhs-sdr104;
606	vmmc-supply = <&vcc_wl>;
607	vqmmc-supply = <&vcc_1v8>;
608	status = "okay";
609};
610
611/* spdif is exposed on con40 pin 18 */
612&spdif {
613	status = "okay";
614};
615
616/* spi1 is exposed on con40
617 * pin 11 - spi1_mosi_m1
618 * pin 13 - spi1_miso_m1
619 * pin 15 - spi1_clk_m1
620 * pin 17 - spi1_cs0_m1
621 */
622&spi1 {
623	pinctrl-names = "default";
624	pinctrl-0 = <&spi1m1_cs0 &spi1m1_pins>;
625};
626
627&tsadc {
628	/* tshut mode 0:CRU 1:GPIO */
629	rockchip,hw-tshut-mode = <1>;
630	/* tshut polarity 0:LOW 1:HIGH */
631	rockchip,hw-tshut-polarity = <0>;
632	status = "okay";
633};
634
635/* uart0 is exposed on con40
636 * pin 12 - uart0_tx
637 * pin 14 - uart0_rx
638 */
639&uart0 {
640	pinctrl-names = "default";
641	pinctrl-0 = <&uart0_xfer>;
642	status = "okay";
643};
644
645&uart1 {
646	pinctrl-names = "default";
647	pinctrl-0 = <&uart1m0_xfer &uart1m0_ctsn>;
648	status = "okay";
649	uart-has-rtscts;
650
651	bluetooth {
652		compatible = "brcm,bcm43438-bt";
653		clocks = <&rk817 1>;
654		clock-names = "lpo";
655		device-wakeup-gpios = <&gpio2 RK_PC1 GPIO_ACTIVE_HIGH>;
656		host-wakeup-gpios = <&gpio2 RK_PC0 GPIO_ACTIVE_HIGH>;
657		shutdown-gpios = <&gpio2 RK_PB7 GPIO_ACTIVE_HIGH>;
658		pinctrl-names = "default";
659		pinctrl-0 = <&bt_host_wake_l &bt_wake_l &bt_enable_h>;
660		vbat-supply = <&vcc_sys>;
661		vddio-supply = <&vcca1v8_pmu>;
662	};
663};
664
665/* uart2 is exposed on con40
666 * pin 8 - uart2_tx_m0_debug
667 * pin 10 - uart2_rx_m0_debug
668 */
669&uart2 {
670	status = "okay";
671};
672
673&usb_host0_ehci {
674	status = "okay";
675};
676
677&usb_host0_ohci {
678	status = "okay";
679};
680
681&usb_host1_ehci {
682	status = "okay";
683};
684
685&usb_host1_ohci {
686	status = "okay";
687};
688
689&usb_host0_xhci {
690	status = "okay";
691};
692
693/* usb3 controller is muxed with sata1 */
694&usb_host1_xhci {
695	status = "okay";
696};
697
698&usb2phy0 {
699	status = "okay";
700};
701
702&usb2phy0_host {
703	phy-supply = <&vcc5v0_usb20_host>;
704	status = "okay";
705};
706
707&usb2phy0_otg {
708	phy-supply = <&vcc5v0_usb20_otg>;
709	status = "okay";
710};
711
712&usb2phy1 {
713	status = "okay";
714};
715
716&usb2phy1_host {
717	phy-supply = <&vcc5v0_usb20_host>;
718	status = "okay";
719};
720
721&usb2phy1_otg {
722	phy-supply = <&vcc5v0_usb20_host>;
723	status = "okay";
724};
725