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	spdif_dit: spdif-dit {
77		compatible = "linux,spdif-dit";
78		#sound-dai-cells = <0>;
79	};
80
81	spdif_sound: spdif-sound {
82		compatible = "simple-audio-card";
83		simple-audio-card,name = "SPDIF";
84
85		simple-audio-card,cpu {
86			sound-dai = <&spdif>;
87		};
88
89		simple-audio-card,codec {
90			sound-dai = <&spdif_dit>;
91		};
92	};
93
94	vcc12v_dcin: vcc12v_dcin {
95		compatible = "regulator-fixed";
96		regulator-name = "vcc12v_dcin";
97		regulator-always-on;
98		regulator-boot-on;
99		regulator-min-microvolt = <12000000>;
100		regulator-max-microvolt = <12000000>;
101	};
102
103	/* vbus feeds the rk817 usb input.
104	 * With no battery attached, also feeds vcc_bat+
105	 * via ON/OFF_BAT jumper
106	 */
107	vbus: vbus {
108		compatible = "regulator-fixed";
109		regulator-name = "vbus";
110		regulator-always-on;
111		regulator-boot-on;
112		regulator-min-microvolt = <5000000>;
113		regulator-max-microvolt = <5000000>;
114		vin-supply = <&vcc12v_dcin>;
115	};
116
117	vcc5v0_usb: vcc5v0_usb {
118		compatible = "regulator-fixed";
119		regulator-name = "vcc5v0_usb";
120		regulator-always-on;
121		regulator-boot-on;
122		regulator-min-microvolt = <5000000>;
123		regulator-max-microvolt = <5000000>;
124		vin-supply = <&vcc12v_dcin>;
125	};
126
127	vcc3v3_sd: vcc3v3_sd {
128		compatible = "regulator-fixed";
129		enable-active-low;
130		gpio = <&gpio0 RK_PA5 GPIO_ACTIVE_LOW>;
131		pinctrl-names = "default";
132		pinctrl-0 = <&vcc_sd_h>;
133		regulator-boot-on;
134		regulator-name = "vcc3v3_sd";
135		regulator-min-microvolt = <3300000>;
136		regulator-max-microvolt = <3300000>;
137		vin-supply = <&vcc_3v3>;
138	};
139
140	/* sourced from vbus and vcc_bat+ via rk817 sw5 */
141	vcc_sys: vcc_sys {
142		compatible = "regulator-fixed";
143		regulator-name = "vcc_sys";
144		regulator-always-on;
145		regulator-boot-on;
146		regulator-min-microvolt = <4400000>;
147		regulator-max-microvolt = <4400000>;
148		vin-supply = <&vbus>;
149	};
150};
151
152&cpu0 {
153	cpu-supply = <&vdd_cpu>;
154};
155
156&cpu1 {
157	cpu-supply = <&vdd_cpu>;
158};
159
160&cpu2 {
161	cpu-supply = <&vdd_cpu>;
162};
163
164&cpu3 {
165	cpu-supply = <&vdd_cpu>;
166};
167
168&cpu_thermal {
169	trips {
170		cpu_hot: cpu_hot {
171			temperature = <55000>;
172			hysteresis = <2000>;
173			type = "active";
174		};
175	};
176
177	cooling-maps {
178		map1 {
179			trip = <&cpu_hot>;
180			cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
181		};
182	};
183};
184
185&gmac1 {
186	assigned-clocks = <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru SCLK_GMAC1>;
187	assigned-clock-parents = <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru SCLK_GMAC1>, <&gmac1_clkin>;
188	clock_in_out = "input";
189	phy-supply = <&vcc_3v3>;
190	phy-mode = "rgmii";
191	pinctrl-names = "default";
192	pinctrl-0 = <&gmac1m0_miim
193		     &gmac1m0_tx_bus2
194		     &gmac1m0_rx_bus2
195		     &gmac1m0_rgmii_clk
196		     &gmac1m0_clkinout
197		     &gmac1m0_rgmii_bus>;
198	snps,reset-gpio = <&gpio0 RK_PC3 GPIO_ACTIVE_LOW>;
199	snps,reset-active-low;
200	/* Reset time is 20ms, 100ms for rtl8211f */
201	snps,reset-delays-us = <0 20000 100000>;
202	tx_delay = <0x30>;
203	rx_delay = <0x10>;
204	phy-handle = <&rgmii_phy1>;
205	status = "okay";
206};
207
208&i2c0 {
209	status = "okay";
210
211	vdd_cpu: regulator@1c {
212		compatible = "tcs,tcs4525";
213		reg = <0x1c>;
214		fcs,suspend-voltage-selector = <1>;
215		regulator-name = "vdd_cpu";
216		regulator-min-microvolt = <800000>;
217		regulator-max-microvolt = <1150000>;
218		regulator-ramp-delay = <2300>;
219		regulator-always-on;
220		regulator-boot-on;
221		vin-supply = <&vcc_sys>;
222
223		regulator-state-mem {
224			regulator-off-in-suspend;
225		};
226	};
227
228	rk817: pmic@20 {
229		compatible = "rockchip,rk817";
230		reg = <0x20>;
231		interrupt-parent = <&gpio0>;
232		interrupts = <RK_PA3 IRQ_TYPE_LEVEL_LOW>;
233		assigned-clocks = <&cru I2S1_MCLKOUT_TX>;
234		assigned-clock-parents = <&cru CLK_I2S1_8CH_TX>;
235		clock-names = "mclk";
236		clocks = <&cru I2S1_MCLKOUT_TX>;
237		clock-output-names = "rk808-clkout1", "rk808-clkout2";
238		#clock-cells = <1>;
239		pinctrl-names = "default";
240		pinctrl-0 = <&pmic_int_l>, <&i2s1m0_mclk>;
241		rockchip,system-power-controller;
242		#sound-dai-cells = <0>;
243		wakeup-source;
244
245		vcc1-supply = <&vcc_sys>;
246		vcc2-supply = <&vcc_sys>;
247		vcc3-supply = <&vcc_sys>;
248		vcc4-supply = <&vcc_sys>;
249		vcc5-supply = <&vcc_sys>;
250		vcc6-supply = <&vcc_sys>;
251		vcc7-supply = <&vcc_sys>;
252		vcc8-supply = <&vcc_sys>;
253		vcc9-supply = <&dcdc_boost>;
254
255		regulators {
256			vdd_logic: DCDC_REG1 {
257				regulator-always-on;
258				regulator-boot-on;
259				regulator-min-microvolt = <500000>;
260				regulator-max-microvolt = <1350000>;
261				regulator-init-microvolt = <900000>;
262				regulator-ramp-delay = <6001>;
263				regulator-initial-mode = <0x2>;
264				regulator-name = "vdd_logic";
265				regulator-state-mem {
266					regulator-on-in-suspend;
267					regulator-suspend-microvolt = <900000>;
268				};
269			};
270
271			vdd_gpu: DCDC_REG2 {
272				regulator-always-on;
273				regulator-boot-on;
274				regulator-min-microvolt = <500000>;
275				regulator-max-microvolt = <1350000>;
276				regulator-init-microvolt = <900000>;
277				regulator-ramp-delay = <6001>;
278				regulator-initial-mode = <0x2>;
279				regulator-name = "vdd_gpu";
280					regulator-state-mem {
281					regulator-off-in-suspend;
282				};
283			};
284
285			vcc_ddr: DCDC_REG3 {
286				regulator-always-on;
287				regulator-boot-on;
288				regulator-initial-mode = <0x2>;
289				regulator-name = "vcc_ddr";
290				regulator-state-mem {
291					regulator-on-in-suspend;
292				};
293			};
294
295			vcc_3v3: DCDC_REG4 {
296				regulator-always-on;
297				regulator-boot-on;
298				regulator-min-microvolt = <3300000>;
299				regulator-max-microvolt = <3300000>;
300				regulator-initial-mode = <0x2>;
301				regulator-name = "vcc_3v3";
302				regulator-state-mem {
303					regulator-off-in-suspend;
304				};
305			};
306
307			vcca1v8_pmu: LDO_REG1 {
308				regulator-always-on;
309				regulator-boot-on;
310				regulator-min-microvolt = <1800000>;
311				regulator-max-microvolt = <1800000>;
312				regulator-name = "vcca1v8_pmu";
313				regulator-state-mem {
314					regulator-on-in-suspend;
315					regulator-suspend-microvolt = <1800000>;
316				};
317			};
318
319			vdda_0v9: LDO_REG2 {
320				regulator-always-on;
321				regulator-boot-on;
322				regulator-min-microvolt = <900000>;
323				regulator-max-microvolt = <900000>;
324				regulator-name = "vdda_0v9";
325				regulator-state-mem {
326					regulator-off-in-suspend;
327				};
328			};
329
330			vdda0v9_pmu: LDO_REG3 {
331				regulator-always-on;
332				regulator-boot-on;
333				regulator-min-microvolt = <900000>;
334				regulator-max-microvolt = <900000>;
335				regulator-name = "vdda0v9_pmu";
336				regulator-state-mem {
337					regulator-on-in-suspend;
338					regulator-suspend-microvolt = <900000>;
339				};
340			};
341
342			vccio_acodec: LDO_REG4 {
343				regulator-always-on;
344				regulator-boot-on;
345				regulator-min-microvolt = <3300000>;
346				regulator-max-microvolt = <3300000>;
347				regulator-name = "vccio_acodec";
348				regulator-state-mem {
349					regulator-off-in-suspend;
350				};
351			};
352
353			vccio_sd: LDO_REG5 {
354				regulator-always-on;
355				regulator-boot-on;
356				regulator-min-microvolt = <1800000>;
357				regulator-max-microvolt = <3300000>;
358				regulator-name = "vccio_sd";
359				regulator-state-mem {
360					regulator-off-in-suspend;
361				};
362			};
363
364			vcc3v3_pmu: LDO_REG6 {
365				regulator-always-on;
366				regulator-boot-on;
367				regulator-min-microvolt = <3300000>;
368				regulator-max-microvolt = <3300000>;
369				regulator-name = "vcc3v3_pmu";
370				regulator-state-mem {
371					regulator-on-in-suspend;
372					regulator-suspend-microvolt = <3300000>;
373				};
374			};
375
376			vcc_1v8: LDO_REG7 {
377				regulator-always-on;
378				regulator-boot-on;
379				regulator-min-microvolt = <1800000>;
380				regulator-max-microvolt = <1800000>;
381				regulator-name = "vcc_1v8";
382				regulator-state-mem {
383					regulator-off-in-suspend;
384				};
385			};
386
387			vcc1v8_dvp: LDO_REG8 {
388				regulator-always-on;
389				regulator-boot-on;
390				regulator-min-microvolt = <1800000>;
391				regulator-max-microvolt = <1800000>;
392				regulator-name = "vcc1v8_dvp";
393				regulator-state-mem {
394					regulator-off-in-suspend;
395				};
396			};
397
398			vcc2v8_dvp: LDO_REG9 {
399				regulator-always-on;
400				regulator-boot-on;
401				regulator-min-microvolt = <2800000>;
402				regulator-max-microvolt = <2800000>;
403				regulator-name = "vcc2v8_dvp";
404				regulator-state-mem {
405					regulator-off-in-suspend;
406				};
407			};
408
409			dcdc_boost: BOOST {
410				regulator-always-on;
411				regulator-boot-on;
412				regulator-min-microvolt = <5000000>;
413				regulator-max-microvolt = <5000000>;
414				regulator-name = "boost";
415				regulator-state-mem {
416					regulator-off-in-suspend;
417				};
418			};
419
420			otg_switch: OTG_SWITCH {
421				regulator-name = "otg_switch";
422				regulator-state-mem {
423					regulator-off-in-suspend;
424				};
425			};
426		};
427	};
428};
429
430&i2s1_8ch {
431	pinctrl-names = "default";
432	pinctrl-0 = <&i2s1m0_sclktx
433		     &i2s1m0_lrcktx
434		     &i2s1m0_sdi0
435		     &i2s1m0_sdo0>;
436	rockchip,trcm-sync-tx-only;
437	status = "okay";
438};
439
440&mdio1 {
441	rgmii_phy1: ethernet-phy@0 {
442		compatible = "ethernet-phy-ieee802.3-c22";
443		reg = <0>;
444	};
445};
446
447&pinctrl {
448	bt {
449		bt_enable_h: bt-enable-h {
450			rockchip,pins = <2 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>;
451		};
452
453		bt_host_wake_l: bt-host-wake-l {
454			rockchip,pins = <2 RK_PC0 RK_FUNC_GPIO &pcfg_pull_down>;
455		};
456
457		bt_wake_l: bt-wake-l {
458			rockchip,pins = <2 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>;
459		};
460	};
461
462	leds {
463		work_led_enable_h: work-led-enable-h {
464			rockchip,pins = <0 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
465		};
466
467		diy_led_enable_h: diy-led-enable-h {
468			rockchip,pins = <0 RK_PD4 RK_FUNC_GPIO &pcfg_pull_none>;
469		};
470	};
471
472	pmic {
473		pmic_int_l: pmic-int-l {
474			rockchip,pins = <0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>;
475		};
476	};
477
478	vcc_sd {
479		vcc_sd_h: vcc-sd-h {
480			rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_none>;
481		};
482	};
483};
484
485&sdhci {
486	bus-width = <8>;
487	mmc-hs200-1_8v;
488	non-removable;
489	vmmc-supply = <&vcc_3v3>;
490	vqmmc-supply = <&vcc_1v8>;
491	status = "okay";
492};
493
494&sdmmc0 {
495	bus-width = <4>;
496	cap-sd-highspeed;
497	cd-gpios = <&gpio0 RK_PA4 GPIO_ACTIVE_LOW>;
498	disable-wp;
499	pinctrl-names = "default";
500	pinctrl-0 = <&sdmmc0_bus4 &sdmmc0_clk &sdmmc0_cmd &sdmmc0_det>;
501	vmmc-supply = <&vcc3v3_sd>;
502	vqmmc-supply = <&vccio_sd>;
503	status = "okay";
504};
505
506&spdif {
507	status = "okay";
508};
509
510&spi1 {
511	pinctrl-names = "default";
512	pinctrl-0 = <&spi1m1_cs0 &spi1m1_pins>;
513};
514
515&tsadc {
516	/* tshut mode 0:CRU 1:GPIO */
517	rockchip,hw-tshut-mode = <1>;
518	/* tshut polarity 0:LOW 1:HIGH */
519	rockchip,hw-tshut-polarity = <0>;
520	status = "okay";
521};
522
523&uart0 {
524	pinctrl-names = "default";
525	pinctrl-0 = <&uart0_xfer>;
526	status = "okay";
527};
528
529&uart1 {
530	pinctrl-names = "default";
531	pinctrl-0 = <&uart1m0_xfer &uart1m0_ctsn>;
532	status = "okay";
533	uart-has-rtscts;
534
535	bluetooth {
536		compatible = "brcm,bcm43438-bt";
537		clocks = <&rk817 1>;
538		clock-names = "lpo";
539		device-wake-gpios = <&gpio2 RK_PC1 GPIO_ACTIVE_HIGH>;
540		host-wake-gpios = <&gpio2 RK_PC0 GPIO_ACTIVE_HIGH>;
541		shutdown-gpios = <&gpio2 RK_PB7 GPIO_ACTIVE_HIGH>;
542		pinctrl-names = "default";
543		pinctrl-0 = <&bt_host_wake_l &bt_wake_l &bt_enable_h>;
544		vbat-supply = <&vcc_sys>;
545		vddio-supply = <&vcca1v8_pmu>;
546	};
547};
548
549&uart2 {
550	status = "okay";
551};
552