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-min-microvolt = <1100000>;
289				regulator-max-microvolt = <1100000>;
290				regulator-initial-mode = <0x2>;
291				regulator-name = "vcc_ddr";
292				regulator-state-mem {
293					regulator-on-in-suspend;
294				};
295			};
296
297			vcc_3v3: DCDC_REG4 {
298				regulator-always-on;
299				regulator-boot-on;
300				regulator-min-microvolt = <3300000>;
301				regulator-max-microvolt = <3300000>;
302				regulator-initial-mode = <0x2>;
303				regulator-name = "vcc_3v3";
304				regulator-state-mem {
305					regulator-off-in-suspend;
306				};
307			};
308
309			vcca1v8_pmu: LDO_REG1 {
310				regulator-always-on;
311				regulator-boot-on;
312				regulator-min-microvolt = <1800000>;
313				regulator-max-microvolt = <1800000>;
314				regulator-name = "vcca1v8_pmu";
315				regulator-state-mem {
316					regulator-on-in-suspend;
317					regulator-suspend-microvolt = <1800000>;
318				};
319			};
320
321			vdda_0v9: LDO_REG2 {
322				regulator-always-on;
323				regulator-boot-on;
324				regulator-min-microvolt = <900000>;
325				regulator-max-microvolt = <900000>;
326				regulator-name = "vdda_0v9";
327				regulator-state-mem {
328					regulator-off-in-suspend;
329				};
330			};
331
332			vdda0v9_pmu: LDO_REG3 {
333				regulator-always-on;
334				regulator-boot-on;
335				regulator-min-microvolt = <900000>;
336				regulator-max-microvolt = <900000>;
337				regulator-name = "vdda0v9_pmu";
338				regulator-state-mem {
339					regulator-on-in-suspend;
340					regulator-suspend-microvolt = <900000>;
341				};
342			};
343
344			vccio_acodec: LDO_REG4 {
345				regulator-always-on;
346				regulator-boot-on;
347				regulator-min-microvolt = <3300000>;
348				regulator-max-microvolt = <3300000>;
349				regulator-name = "vccio_acodec";
350				regulator-state-mem {
351					regulator-off-in-suspend;
352				};
353			};
354
355			vccio_sd: LDO_REG5 {
356				regulator-always-on;
357				regulator-boot-on;
358				regulator-min-microvolt = <1800000>;
359				regulator-max-microvolt = <3300000>;
360				regulator-name = "vccio_sd";
361				regulator-state-mem {
362					regulator-off-in-suspend;
363				};
364			};
365
366			vcc3v3_pmu: LDO_REG6 {
367				regulator-always-on;
368				regulator-boot-on;
369				regulator-min-microvolt = <3300000>;
370				regulator-max-microvolt = <3300000>;
371				regulator-name = "vcc3v3_pmu";
372				regulator-state-mem {
373					regulator-on-in-suspend;
374					regulator-suspend-microvolt = <3300000>;
375				};
376			};
377
378			vcc_1v8: LDO_REG7 {
379				regulator-always-on;
380				regulator-boot-on;
381				regulator-min-microvolt = <1800000>;
382				regulator-max-microvolt = <1800000>;
383				regulator-name = "vcc_1v8";
384				regulator-state-mem {
385					regulator-off-in-suspend;
386				};
387			};
388
389			vcc1v8_dvp: LDO_REG8 {
390				regulator-always-on;
391				regulator-boot-on;
392				regulator-min-microvolt = <1800000>;
393				regulator-max-microvolt = <1800000>;
394				regulator-name = "vcc1v8_dvp";
395				regulator-state-mem {
396					regulator-off-in-suspend;
397				};
398			};
399
400			vcc2v8_dvp: LDO_REG9 {
401				regulator-always-on;
402				regulator-boot-on;
403				regulator-min-microvolt = <2800000>;
404				regulator-max-microvolt = <2800000>;
405				regulator-name = "vcc2v8_dvp";
406				regulator-state-mem {
407					regulator-off-in-suspend;
408				};
409			};
410
411			dcdc_boost: BOOST {
412				regulator-always-on;
413				regulator-boot-on;
414				regulator-min-microvolt = <5000000>;
415				regulator-max-microvolt = <5000000>;
416				regulator-name = "boost";
417				regulator-state-mem {
418					regulator-off-in-suspend;
419				};
420			};
421
422			otg_switch: OTG_SWITCH {
423				regulator-name = "otg_switch";
424				regulator-state-mem {
425					regulator-off-in-suspend;
426				};
427			};
428		};
429	};
430};
431
432&i2s1_8ch {
433	pinctrl-names = "default";
434	pinctrl-0 = <&i2s1m0_sclktx
435		     &i2s1m0_lrcktx
436		     &i2s1m0_sdi0
437		     &i2s1m0_sdo0>;
438	rockchip,trcm-sync-tx-only;
439	status = "okay";
440};
441
442&mdio1 {
443	rgmii_phy1: ethernet-phy@0 {
444		compatible = "ethernet-phy-ieee802.3-c22";
445		reg = <0>;
446	};
447};
448
449&pinctrl {
450	bt {
451		bt_enable_h: bt-enable-h {
452			rockchip,pins = <2 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>;
453		};
454
455		bt_host_wake_l: bt-host-wake-l {
456			rockchip,pins = <2 RK_PC0 RK_FUNC_GPIO &pcfg_pull_down>;
457		};
458
459		bt_wake_l: bt-wake-l {
460			rockchip,pins = <2 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>;
461		};
462	};
463
464	leds {
465		work_led_enable_h: work-led-enable-h {
466			rockchip,pins = <0 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
467		};
468
469		diy_led_enable_h: diy-led-enable-h {
470			rockchip,pins = <0 RK_PD4 RK_FUNC_GPIO &pcfg_pull_none>;
471		};
472	};
473
474	pmic {
475		pmic_int_l: pmic-int-l {
476			rockchip,pins = <0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>;
477		};
478	};
479
480	vcc_sd {
481		vcc_sd_h: vcc-sd-h {
482			rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_none>;
483		};
484	};
485};
486
487&sdhci {
488	bus-width = <8>;
489	mmc-hs200-1_8v;
490	non-removable;
491	vmmc-supply = <&vcc_3v3>;
492	vqmmc-supply = <&vcc_1v8>;
493	status = "okay";
494};
495
496&sdmmc0 {
497	bus-width = <4>;
498	cap-sd-highspeed;
499	cd-gpios = <&gpio0 RK_PA4 GPIO_ACTIVE_LOW>;
500	disable-wp;
501	pinctrl-names = "default";
502	pinctrl-0 = <&sdmmc0_bus4 &sdmmc0_clk &sdmmc0_cmd &sdmmc0_det>;
503	vmmc-supply = <&vcc3v3_sd>;
504	vqmmc-supply = <&vccio_sd>;
505	status = "okay";
506};
507
508&spdif {
509	status = "okay";
510};
511
512&tsadc {
513	/* tshut mode 0:CRU 1:GPIO */
514	rockchip,hw-tshut-mode = <1>;
515	/* tshut polarity 0:LOW 1:HIGH */
516	rockchip,hw-tshut-polarity = <0>;
517	status = "okay";
518};
519
520&uart0 {
521	pinctrl-names = "default";
522	pinctrl-0 = <&uart0_xfer>;
523	status = "okay";
524};
525
526&uart1 {
527	pinctrl-names = "default";
528	pinctrl-0 = <&uart1m0_xfer &uart1m0_ctsn>;
529	status = "okay";
530	uart-has-rtscts;
531
532	bluetooth {
533		compatible = "brcm,bcm43438-bt";
534		clocks = <&rk817 1>;
535		clock-names = "lpo";
536		device-wake-gpios = <&gpio2 RK_PC1 GPIO_ACTIVE_HIGH>;
537		host-wake-gpios = <&gpio2 RK_PC0 GPIO_ACTIVE_HIGH>;
538		shutdown-gpios = <&gpio2 RK_PB7 GPIO_ACTIVE_HIGH>;
539		pinctrl-names = "default";
540		pinctrl-0 = <&bt_host_wake_l &bt_wake_l &bt_enable_h>;
541		vbat-supply = <&vcc_sys>;
542		vddio-supply = <&vcca1v8_pmu>;
543	};
544};
545
546&uart2 {
547	status = "okay";
548};
549