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	vcc3v3_sd: vcc3v3_sd {
155		compatible = "regulator-fixed";
156		enable-active-low;
157		gpio = <&gpio0 RK_PA5 GPIO_ACTIVE_LOW>;
158		pinctrl-names = "default";
159		pinctrl-0 = <&vcc_sd_h>;
160		regulator-boot-on;
161		regulator-name = "vcc3v3_sd";
162		regulator-min-microvolt = <3300000>;
163		regulator-max-microvolt = <3300000>;
164		vin-supply = <&vcc_3v3>;
165	};
166
167	/* sourced from vbus and vcc_bat+ via rk817 sw5 */
168	vcc_sys: vcc_sys {
169		compatible = "regulator-fixed";
170		regulator-name = "vcc_sys";
171		regulator-always-on;
172		regulator-boot-on;
173		regulator-min-microvolt = <4400000>;
174		regulator-max-microvolt = <4400000>;
175		vin-supply = <&vbus>;
176	};
177
178	/* sourced from vcc_sys, sdio module operates internally at 3.3v */
179	vcc_wl: vcc_wl {
180		compatible = "regulator-fixed";
181		regulator-name = "vcc_wl";
182		regulator-always-on;
183		regulator-boot-on;
184		regulator-min-microvolt = <3300000>;
185		regulator-max-microvolt = <3300000>;
186		vin-supply = <&vcc_sys>;
187	};
188};
189
190&cpu0 {
191	cpu-supply = <&vdd_cpu>;
192};
193
194&cpu1 {
195	cpu-supply = <&vdd_cpu>;
196};
197
198&cpu2 {
199	cpu-supply = <&vdd_cpu>;
200};
201
202&cpu3 {
203	cpu-supply = <&vdd_cpu>;
204};
205
206&cpu_thermal {
207	trips {
208		cpu_hot: cpu_hot {
209			temperature = <55000>;
210			hysteresis = <2000>;
211			type = "active";
212		};
213	};
214
215	cooling-maps {
216		map1 {
217			trip = <&cpu_hot>;
218			cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
219		};
220	};
221};
222
223&gmac1 {
224	assigned-clocks = <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru SCLK_GMAC1>;
225	assigned-clock-parents = <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru SCLK_GMAC1>, <&gmac1_clkin>;
226	clock_in_out = "input";
227	phy-supply = <&vcc_3v3>;
228	phy-mode = "rgmii";
229	pinctrl-names = "default";
230	pinctrl-0 = <&gmac1m0_miim
231		     &gmac1m0_tx_bus2
232		     &gmac1m0_rx_bus2
233		     &gmac1m0_rgmii_clk
234		     &gmac1m0_clkinout
235		     &gmac1m0_rgmii_bus>;
236	snps,reset-gpio = <&gpio0 RK_PC3 GPIO_ACTIVE_LOW>;
237	snps,reset-active-low;
238	/* Reset time is 20ms, 100ms for rtl8211f */
239	snps,reset-delays-us = <0 20000 100000>;
240	tx_delay = <0x30>;
241	rx_delay = <0x10>;
242	phy-handle = <&rgmii_phy1>;
243	status = "okay";
244};
245
246&gpu {
247	mali-supply = <&vdd_gpu>;
248	status = "okay";
249};
250
251&i2c0 {
252	status = "okay";
253
254	vdd_cpu: regulator@1c {
255		compatible = "tcs,tcs4525";
256		reg = <0x1c>;
257		fcs,suspend-voltage-selector = <1>;
258		regulator-name = "vdd_cpu";
259		regulator-min-microvolt = <800000>;
260		regulator-max-microvolt = <1150000>;
261		regulator-ramp-delay = <2300>;
262		regulator-always-on;
263		regulator-boot-on;
264		vin-supply = <&vcc_sys>;
265
266		regulator-state-mem {
267			regulator-off-in-suspend;
268		};
269	};
270
271	rk817: pmic@20 {
272		compatible = "rockchip,rk817";
273		reg = <0x20>;
274		interrupt-parent = <&gpio0>;
275		interrupts = <RK_PA3 IRQ_TYPE_LEVEL_LOW>;
276		assigned-clocks = <&cru I2S1_MCLKOUT_TX>;
277		assigned-clock-parents = <&cru CLK_I2S1_8CH_TX>;
278		clock-names = "mclk";
279		clocks = <&cru I2S1_MCLKOUT_TX>;
280		clock-output-names = "rk808-clkout1", "rk808-clkout2";
281		#clock-cells = <1>;
282		pinctrl-names = "default";
283		pinctrl-0 = <&pmic_int_l>, <&i2s1m0_mclk>;
284		rockchip,system-power-controller;
285		#sound-dai-cells = <0>;
286		wakeup-source;
287
288		vcc1-supply = <&vcc_sys>;
289		vcc2-supply = <&vcc_sys>;
290		vcc3-supply = <&vcc_sys>;
291		vcc4-supply = <&vcc_sys>;
292		vcc5-supply = <&vcc_sys>;
293		vcc6-supply = <&vcc_sys>;
294		vcc7-supply = <&vcc_sys>;
295		vcc8-supply = <&vcc_sys>;
296		vcc9-supply = <&dcdc_boost>;
297
298		regulators {
299			vdd_logic: DCDC_REG1 {
300				regulator-always-on;
301				regulator-boot-on;
302				regulator-min-microvolt = <500000>;
303				regulator-max-microvolt = <1350000>;
304				regulator-init-microvolt = <900000>;
305				regulator-ramp-delay = <6001>;
306				regulator-initial-mode = <0x2>;
307				regulator-name = "vdd_logic";
308				regulator-state-mem {
309					regulator-on-in-suspend;
310					regulator-suspend-microvolt = <900000>;
311				};
312			};
313
314			vdd_gpu: DCDC_REG2 {
315				regulator-always-on;
316				regulator-boot-on;
317				regulator-min-microvolt = <500000>;
318				regulator-max-microvolt = <1350000>;
319				regulator-init-microvolt = <900000>;
320				regulator-ramp-delay = <6001>;
321				regulator-initial-mode = <0x2>;
322				regulator-name = "vdd_gpu";
323					regulator-state-mem {
324					regulator-off-in-suspend;
325				};
326			};
327
328			vcc_ddr: DCDC_REG3 {
329				regulator-always-on;
330				regulator-boot-on;
331				regulator-initial-mode = <0x2>;
332				regulator-name = "vcc_ddr";
333				regulator-state-mem {
334					regulator-on-in-suspend;
335				};
336			};
337
338			vcc_3v3: DCDC_REG4 {
339				regulator-always-on;
340				regulator-boot-on;
341				regulator-min-microvolt = <3300000>;
342				regulator-max-microvolt = <3300000>;
343				regulator-initial-mode = <0x2>;
344				regulator-name = "vcc_3v3";
345				regulator-state-mem {
346					regulator-off-in-suspend;
347				};
348			};
349
350			vcca1v8_pmu: LDO_REG1 {
351				regulator-always-on;
352				regulator-boot-on;
353				regulator-min-microvolt = <1800000>;
354				regulator-max-microvolt = <1800000>;
355				regulator-name = "vcca1v8_pmu";
356				regulator-state-mem {
357					regulator-on-in-suspend;
358					regulator-suspend-microvolt = <1800000>;
359				};
360			};
361
362			vdda_0v9: LDO_REG2 {
363				regulator-always-on;
364				regulator-boot-on;
365				regulator-min-microvolt = <900000>;
366				regulator-max-microvolt = <900000>;
367				regulator-name = "vdda_0v9";
368				regulator-state-mem {
369					regulator-off-in-suspend;
370				};
371			};
372
373			vdda0v9_pmu: LDO_REG3 {
374				regulator-always-on;
375				regulator-boot-on;
376				regulator-min-microvolt = <900000>;
377				regulator-max-microvolt = <900000>;
378				regulator-name = "vdda0v9_pmu";
379				regulator-state-mem {
380					regulator-on-in-suspend;
381					regulator-suspend-microvolt = <900000>;
382				};
383			};
384
385			vccio_acodec: LDO_REG4 {
386				regulator-always-on;
387				regulator-boot-on;
388				regulator-min-microvolt = <3300000>;
389				regulator-max-microvolt = <3300000>;
390				regulator-name = "vccio_acodec";
391				regulator-state-mem {
392					regulator-off-in-suspend;
393				};
394			};
395
396			vccio_sd: LDO_REG5 {
397				regulator-always-on;
398				regulator-boot-on;
399				regulator-min-microvolt = <1800000>;
400				regulator-max-microvolt = <3300000>;
401				regulator-name = "vccio_sd";
402				regulator-state-mem {
403					regulator-off-in-suspend;
404				};
405			};
406
407			vcc3v3_pmu: LDO_REG6 {
408				regulator-always-on;
409				regulator-boot-on;
410				regulator-min-microvolt = <3300000>;
411				regulator-max-microvolt = <3300000>;
412				regulator-name = "vcc3v3_pmu";
413				regulator-state-mem {
414					regulator-on-in-suspend;
415					regulator-suspend-microvolt = <3300000>;
416				};
417			};
418
419			vcc_1v8: LDO_REG7 {
420				regulator-always-on;
421				regulator-boot-on;
422				regulator-min-microvolt = <1800000>;
423				regulator-max-microvolt = <1800000>;
424				regulator-name = "vcc_1v8";
425				regulator-state-mem {
426					regulator-off-in-suspend;
427				};
428			};
429
430			vcc1v8_dvp: LDO_REG8 {
431				regulator-always-on;
432				regulator-boot-on;
433				regulator-min-microvolt = <1800000>;
434				regulator-max-microvolt = <1800000>;
435				regulator-name = "vcc1v8_dvp";
436				regulator-state-mem {
437					regulator-off-in-suspend;
438				};
439			};
440
441			vcc2v8_dvp: LDO_REG9 {
442				regulator-always-on;
443				regulator-boot-on;
444				regulator-min-microvolt = <2800000>;
445				regulator-max-microvolt = <2800000>;
446				regulator-name = "vcc2v8_dvp";
447				regulator-state-mem {
448					regulator-off-in-suspend;
449				};
450			};
451
452			dcdc_boost: BOOST {
453				regulator-always-on;
454				regulator-boot-on;
455				regulator-min-microvolt = <5000000>;
456				regulator-max-microvolt = <5000000>;
457				regulator-name = "boost";
458				regulator-state-mem {
459					regulator-off-in-suspend;
460				};
461			};
462
463			otg_switch: OTG_SWITCH {
464				regulator-name = "otg_switch";
465				regulator-state-mem {
466					regulator-off-in-suspend;
467				};
468			};
469		};
470	};
471};
472
473/* i2c3 is exposed on con40
474 * pin 3 - i2c3_sda_m0, pullup to vcc_3v3
475 * pin 5 - i2c3_scl_m0, pullup to vcc_3v3
476 */
477&i2c3 {
478	status = "okay";
479};
480
481&i2s1_8ch {
482	pinctrl-names = "default";
483	pinctrl-0 = <&i2s1m0_sclktx
484		     &i2s1m0_lrcktx
485		     &i2s1m0_sdi0
486		     &i2s1m0_sdo0>;
487	rockchip,trcm-sync-tx-only;
488	status = "okay";
489};
490
491&mdio1 {
492	rgmii_phy1: ethernet-phy@0 {
493		compatible = "ethernet-phy-ieee802.3-c22";
494		reg = <0>;
495	};
496};
497
498&pinctrl {
499	bt {
500		bt_enable_h: bt-enable-h {
501			rockchip,pins = <2 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>;
502		};
503
504		bt_host_wake_l: bt-host-wake-l {
505			rockchip,pins = <2 RK_PC0 RK_FUNC_GPIO &pcfg_pull_down>;
506		};
507
508		bt_wake_l: bt-wake-l {
509			rockchip,pins = <2 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>;
510		};
511	};
512
513	leds {
514		work_led_enable_h: work-led-enable-h {
515			rockchip,pins = <0 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
516		};
517
518		diy_led_enable_h: diy-led-enable-h {
519			rockchip,pins = <0 RK_PD4 RK_FUNC_GPIO &pcfg_pull_none>;
520		};
521	};
522
523	pmic {
524		pmic_int_l: pmic-int-l {
525			rockchip,pins = <0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>;
526		};
527	};
528
529	usb2 {
530		vcc5v0_usb20_host_en: vcc5v0-usb20-host-en {
531			rockchip,pins = <4 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>;
532		};
533	};
534
535	sdio-pwrseq {
536		wifi_enable_h: wifi-enable-h {
537			rockchip,pins = <2 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>;
538		};
539	};
540
541	vcc_sd {
542		vcc_sd_h: vcc-sd-h {
543			rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_none>;
544		};
545	};
546};
547
548&pmu_io_domains {
549	pmuio1-supply = <&vcc3v3_pmu>;
550	pmuio2-supply = <&vcc3v3_pmu>;
551	vccio1-supply = <&vccio_acodec>;
552	vccio2-supply = <&vcc_1v8>;
553	vccio3-supply = <&vccio_sd>;
554	vccio4-supply = <&vcc_1v8>;
555	vccio5-supply = <&vcc_3v3>;
556	vccio6-supply = <&vcc1v8_dvp>;
557	vccio7-supply = <&vcc_3v3>;
558	status = "okay";
559};
560
561&sdhci {
562	bus-width = <8>;
563	mmc-hs200-1_8v;
564	non-removable;
565	vmmc-supply = <&vcc_3v3>;
566	vqmmc-supply = <&vcc_1v8>;
567	status = "okay";
568};
569
570&sdmmc0 {
571	bus-width = <4>;
572	cap-sd-highspeed;
573	cd-gpios = <&gpio0 RK_PA4 GPIO_ACTIVE_LOW>;
574	disable-wp;
575	pinctrl-names = "default";
576	pinctrl-0 = <&sdmmc0_bus4 &sdmmc0_clk &sdmmc0_cmd &sdmmc0_det>;
577	vmmc-supply = <&vcc3v3_sd>;
578	vqmmc-supply = <&vccio_sd>;
579	status = "okay";
580};
581
582&sdmmc1 {
583	bus-width = <4>;
584	cap-sd-highspeed;
585	cap-sdio-irq;
586	keep-power-in-suspend;
587	mmc-pwrseq = <&sdio_pwrseq>;
588	non-removable;
589	pinctrl-names = "default";
590	pinctrl-0 = <&sdmmc1_bus4 &sdmmc1_cmd &sdmmc1_clk>;
591	sd-uhs-sdr104;
592	vmmc-supply = <&vcc_wl>;
593	vqmmc-supply = <&vcc_1v8>;
594	status = "okay";
595};
596
597/* spdif is exposed on con40 pin 18 */
598&spdif {
599	status = "okay";
600};
601
602/* spi1 is exposed on con40
603 * pin 11 - spi1_mosi_m1
604 * pin 13 - spi1_miso_m1
605 * pin 15 - spi1_clk_m1
606 * pin 17 - spi1_cs0_m1
607 */
608&spi1 {
609	pinctrl-names = "default";
610	pinctrl-0 = <&spi1m1_cs0 &spi1m1_pins>;
611};
612
613&tsadc {
614	/* tshut mode 0:CRU 1:GPIO */
615	rockchip,hw-tshut-mode = <1>;
616	/* tshut polarity 0:LOW 1:HIGH */
617	rockchip,hw-tshut-polarity = <0>;
618	status = "okay";
619};
620
621/* uart0 is exposed on con40
622 * pin 12 - uart0_tx
623 * pin 14 - uart0_rx
624 */
625&uart0 {
626	pinctrl-names = "default";
627	pinctrl-0 = <&uart0_xfer>;
628	status = "okay";
629};
630
631&uart1 {
632	pinctrl-names = "default";
633	pinctrl-0 = <&uart1m0_xfer &uart1m0_ctsn>;
634	status = "okay";
635	uart-has-rtscts;
636
637	bluetooth {
638		compatible = "brcm,bcm43438-bt";
639		clocks = <&rk817 1>;
640		clock-names = "lpo";
641		device-wake-gpios = <&gpio2 RK_PC1 GPIO_ACTIVE_HIGH>;
642		host-wake-gpios = <&gpio2 RK_PC0 GPIO_ACTIVE_HIGH>;
643		shutdown-gpios = <&gpio2 RK_PB7 GPIO_ACTIVE_HIGH>;
644		pinctrl-names = "default";
645		pinctrl-0 = <&bt_host_wake_l &bt_wake_l &bt_enable_h>;
646		vbat-supply = <&vcc_sys>;
647		vddio-supply = <&vcca1v8_pmu>;
648	};
649};
650
651/* uart2 is exposed on con40
652 * pin 8 - uart2_tx_m0_debug
653 * pin 10 - uart2_rx_m0_debug
654 */
655&uart2 {
656	status = "okay";
657};
658
659&usb_host0_ehci {
660	status = "okay";
661};
662
663&usb_host0_ohci {
664	status = "okay";
665};
666
667&usb_host1_ehci {
668	status = "okay";
669};
670
671&usb_host1_ohci {
672	status = "okay";
673};
674
675&usb2phy1 {
676	status = "okay";
677};
678
679&usb2phy1_host {
680	phy-supply = <&vcc5v0_usb20_host>;
681	status = "okay";
682};
683
684&usb2phy1_otg {
685	phy-supply = <&vcc5v0_usb20_host>;
686	status = "okay";
687};
688