1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2023 Ondřej Jirman <[email protected]>
4 */
5
6/dts-v1/;
7
8#include <dt-bindings/gpio/gpio.h>
9#include <dt-bindings/leds/common.h>
10#include <dt-bindings/input/input.h>
11#include <dt-bindings/pinctrl/rockchip.h>
12#include <dt-bindings/usb/pd.h>
13#include "rk3588.dtsi"
14
15/ {
16	aliases {
17		mmc0 = &sdhci;
18		mmc1 = &sdmmc;
19	};
20
21	chosen {
22		stdout-path = "serial2:1500000n8";
23	};
24
25	adc-keys-0 {
26		compatible = "adc-keys";
27		io-channels = <&saradc 0>;
28		io-channel-names = "buttons";
29		keyup-threshold-microvolt = <1800000>;
30		poll-interval = <100>;
31
32		button-maskrom {
33			label = "Mask Rom";
34			linux,code = <KEY_SETUP>;
35			press-threshold-microvolt = <2000>;
36		};
37	};
38
39	recovery_button: adc-keys-1 {
40		compatible = "adc-keys";
41		io-channels = <&saradc 1>;
42		io-channel-names = "buttons";
43		keyup-threshold-microvolt = <1800000>;
44		poll-interval = <100>;
45		status = "disabled";
46
47		button-recovery {
48			label = "Recovery";
49			linux,code = <KEY_VENDOR>;
50			press-threshold-microvolt = <2000>;
51		};
52	};
53
54	speaker_amp: speaker-audio-amplifier {
55		compatible = "simple-audio-amplifier";
56		sound-name-prefix = "Speaker Amp";
57		status = "disabled";
58	};
59
60	headphone_amp: headphones-audio-amplifier {
61		compatible = "simple-audio-amplifier";
62		sound-name-prefix = "Headphones Amp";
63	};
64
65	gpio-leds {
66		compatible = "gpio-leds";
67
68		led_blue_gpio: led {
69			color = <LED_COLOR_ID_BLUE>;
70			function = LED_FUNCTION_INDICATOR;
71			function-enumerator = <1>;
72			status = "disabled";
73		};
74	};
75
76	fan: pwm-fan {
77		compatible = "pwm-fan";
78		cooling-levels = <0 70 75 80 100>;
79		fan-supply = <&vcc5v0_sys>;
80		#cooling-cells = <2>;
81	};
82
83	pwm-leds {
84		compatible = "pwm-leds";
85
86		led_blue_pwm: led-1 {
87			color = <LED_COLOR_ID_BLUE>;
88			function = LED_FUNCTION_STATUS;
89			linux,default-trigger = "heartbeat";
90			max-brightness = <255>;
91			status = "disabled";
92		};
93
94		led_green_pwm: led-2 {
95			color = <LED_COLOR_ID_GREEN>;
96			function = LED_FUNCTION_INDICATOR;
97			function-enumerator = <2>;
98			max-brightness = <255>;
99		};
100	};
101
102	rfkill {
103		compatible = "rfkill-gpio";
104		label = "rfkill-pcie-wlan";
105		radio-type = "wlan";
106		shutdown-gpios = <&gpio0 RK_PC4 GPIO_ACTIVE_HIGH>;
107	};
108
109	analog_sound: sound {
110		compatible = "simple-audio-card";
111		simple-audio-card,name = "Analog";
112		simple-audio-card,format = "i2s";
113		simple-audio-card,mclk-fs = <256>;
114		simple-audio-card,bitclock-master = <&daicpu>;
115		simple-audio-card,frame-master = <&daicpu>;
116		/*TODO: SARADC_IN3 is used as MIC detection / key input */
117
118		daicpu: simple-audio-card,cpu {
119			sound-dai = <&i2s0_8ch>;
120			system-clock-frequency = <12288000>;
121		};
122
123		daicodec: simple-audio-card,codec {
124			sound-dai = <&es8388>;
125			system-clock-frequency = <12288000>;
126		};
127	};
128
129	vcc3v3_pcie30: regulator-vcc3v3-pcie30 {
130		compatible = "regulator-fixed";
131		enable-active-high;
132		gpios = <&gpio2 RK_PB6 GPIO_ACTIVE_HIGH>;
133		regulator-name = "vcc3v3_pcie30";
134		regulator-min-microvolt = <3300000>;
135		regulator-max-microvolt = <3300000>;
136		startup-delay-us = <5000>;
137		vin-supply = <&vcc5v0_sys>;
138	};
139
140	vcc3v3_pcie_eth: regulator-vcc3v3-pcie-eth {
141		compatible = "regulator-fixed";
142		regulator-name = "vcc3v3_pcie_eth";
143		regulator-min-microvolt = <3300000>;
144		regulator-max-microvolt = <3300000>;
145		startup-delay-us = <50000>;
146		vin-supply = <&vcc_3v3_s3>;
147	};
148
149	vcc3v3_wf: regulator-vcc3v3-wf {
150		compatible = "regulator-fixed";
151		enable-active-high;
152		gpios = <&gpio2 RK_PC5 GPIO_ACTIVE_HIGH>;
153		regulator-name = "vcc3v3_wf";
154		regulator-min-microvolt = <3300000>;
155		regulator-max-microvolt = <3300000>;
156		startup-delay-us = <50000>;
157		vin-supply = <&vcc5v0_sys>;
158		status = "disabled";
159	};
160
161	vcc5v0_sys: regulator-vcc5v0-sys {
162		compatible = "regulator-fixed";
163		regulator-name = "vcc5v0_sys";
164		regulator-always-on;
165		regulator-boot-on;
166		regulator-min-microvolt = <5000000>;
167		regulator-max-microvolt = <5000000>;
168	};
169
170	vcc5v0_usb20: regulator-vcc5v0-usb20 {
171		compatible = "regulator-fixed";
172		enable-active-high;
173		regulator-name = "vcc5v0_usb20";
174		regulator-min-microvolt = <5000000>;
175		regulator-max-microvolt = <5000000>;
176		vin-supply = <&vcc5v0_sys>;
177	};
178};
179
180&combphy2_psu {
181	status = "okay";
182};
183
184&cpu_b0 {
185	cpu-supply = <&vdd_cpu_big0_s0>;
186};
187
188&cpu_b1 {
189	cpu-supply = <&vdd_cpu_big0_s0>;
190};
191
192&cpu_b2 {
193	cpu-supply = <&vdd_cpu_big1_s0>;
194};
195
196&cpu_b3 {
197	cpu-supply = <&vdd_cpu_big1_s0>;
198};
199
200&cpu_l0 {
201	cpu-supply = <&vdd_cpu_lit_s0>;
202};
203
204&cpu_l1 {
205	cpu-supply = <&vdd_cpu_lit_s0>;
206};
207
208&cpu_l2 {
209	cpu-supply = <&vdd_cpu_lit_s0>;
210};
211
212&cpu_l3 {
213	cpu-supply = <&vdd_cpu_lit_s0>;
214};
215
216&gpu {
217	mali-supply = <&vdd_gpu_s0>;
218	status = "okay";
219};
220
221&i2c0 {
222	pinctrl-names = "default";
223	pinctrl-0 = <&i2c0m2_xfer>;
224	status = "okay";
225
226	vdd_cpu_big0_s0: regulator@42 {
227		compatible = "rockchip,rk8602";
228		reg = <0x42>;
229		fcs,suspend-voltage-selector = <1>;
230		regulator-name = "vdd_cpu_big0_s0";
231		regulator-always-on;
232		regulator-boot-on;
233		regulator-min-microvolt = <550000>;
234		regulator-max-microvolt = <1050000>;
235		regulator-ramp-delay = <2300>;
236		vin-supply = <&vcc5v0_sys>;
237
238		regulator-state-mem {
239			regulator-off-in-suspend;
240		};
241	};
242
243	vdd_cpu_big1_s0: regulator@43 {
244		compatible = "rockchip,rk8603", "rockchip,rk8602";
245		reg = <0x43>;
246		fcs,suspend-voltage-selector = <1>;
247		regulator-name = "vdd_cpu_big1_s0";
248		regulator-always-on;
249		regulator-boot-on;
250		regulator-min-microvolt = <550000>;
251		regulator-max-microvolt = <1050000>;
252		regulator-ramp-delay = <2300>;
253		vin-supply = <&vcc5v0_sys>;
254
255		regulator-state-mem {
256			regulator-off-in-suspend;
257		};
258	};
259};
260
261&i2c6 {
262	clock-frequency = <400000>;
263	status = "okay";
264
265	hym8563: rtc@51 {
266		compatible = "haoyu,hym8563";
267		reg = <0x51>;
268		#clock-cells = <0>;
269		clock-output-names = "hym8563";
270		wakeup-source;
271	};
272};
273
274&i2c7 {
275	status = "okay";
276
277	/* PLDO2 vcca 1.8V, BUCK8 gated by PLDO2 being enabled */
278	es8388: audio-codec@11 {
279		compatible = "everest,es8388";
280		reg = <0x11>;
281		clocks = <&cru I2S0_8CH_MCLKOUT>;
282		AVDD-supply = <&vcc_3v3_s0>;
283		DVDD-supply = <&vcc_1v8_s0>;
284		HPVDD-supply = <&vcc_3v3_s0>;
285		PVDD-supply = <&vcc_1v8_s0>;
286		assigned-clocks = <&cru I2S0_8CH_MCLKOUT>;
287		assigned-clock-rates = <12288000>;
288		#sound-dai-cells = <0>;
289	};
290};
291
292&i2s0_8ch {
293	pinctrl-names = "default";
294	pinctrl-0 = <&i2s0_lrck
295		     &i2s0_mclk
296		     &i2s0_sclk
297		     &i2s0_sdi0
298		     &i2s0_sdo0>;
299	status = "okay";
300};
301
302&i2s2_2ch {
303	pinctrl-names = "default";
304	pinctrl-0 = <&i2s2m0_lrck
305		     &i2s2m0_sclk
306		     &i2s2m0_sdi
307		     &i2s2m0_sdo>;
308	status = "okay";
309};
310
311&package_thermal {
312	polling-delay = <1000>;
313
314	cooling-maps {
315		map0 {
316			trip = <&package_fan0>;
317			cooling-device = <&fan THERMAL_NO_LIMIT 1>;
318		};
319
320		map1 {
321			trip = <&package_fan1>;
322			cooling-device = <&fan 2 THERMAL_NO_LIMIT>;
323		};
324	};
325
326	trips {
327		package_fan0: package-fan0 {
328			temperature = <55000>;
329			hysteresis = <2000>;
330			type = "active";
331		};
332
333		package_fan1: package-fan1 {
334			temperature = <65000>;
335			hysteresis = <2000>;
336			type = "active";
337		};
338	};
339};
340
341&pcie30phy {
342	status = "okay";
343};
344
345&pcie3x4 {
346	reset-gpios = <&gpio4 RK_PB6 GPIO_ACTIVE_HIGH>;
347	vpcie3v3-supply = <&vcc3v3_pcie30>;
348	status = "okay";
349};
350
351&saradc {
352	vref-supply = <&vcc_1v8_s0>;
353	status = "okay";
354};
355
356&sdhci {
357	bus-width = <8>;
358	no-sdio;
359	no-sd;
360	non-removable;
361	max-frequency = <200000000>;
362	mmc-hs400-1_8v;
363	mmc-hs400-enhanced-strobe;
364	status = "okay";
365};
366
367&sdmmc {
368	bus-width = <4>;
369	cap-sd-highspeed;
370	cd-gpios = <&gpio0 RK_PA4 GPIO_ACTIVE_LOW>;
371	disable-wp;
372	max-frequency = <150000000>;
373	no-sdio;
374	no-mmc;
375	sd-uhs-sdr104;
376	vmmc-supply = <&vcc_3v3_s3>;
377	vqmmc-supply = <&vccio_sd_s0>;
378	status = "okay";
379};
380
381&sfc {
382	status = "okay";
383
384	spi_flash: flash@0 {
385		compatible = "jedec,spi-nor";
386		reg = <0x0>;
387		spi-max-frequency = <100000000>;
388		spi-rx-bus-width = <4>;
389		spi-tx-bus-width = <1>;
390	};
391};
392
393&spi2 {
394	assigned-clocks = <&cru CLK_SPI2>;
395	assigned-clock-rates = <200000000>;
396	num-cs = <1>;
397	pinctrl-names = "default";
398	pinctrl-0 = <&spi2m2_cs0 &spi2m2_pins>;
399	status = "okay";
400
401	pmic@0 {
402		compatible = "rockchip,rk806";
403		reg = <0x0>;
404		interrupt-parent = <&gpio0>;
405		interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
406		pinctrl-names = "default";
407		pinctrl-0 = <&pmic_pins>, <&rk806_dvs1_null>,
408			    <&rk806_dvs2_null>, <&rk806_dvs3_null>;
409		spi-max-frequency = <1000000>;
410		system-power-controller;
411
412		vcc1-supply = <&vcc5v0_sys>;
413		vcc2-supply = <&vcc5v0_sys>;
414		vcc3-supply = <&vcc5v0_sys>;
415		vcc4-supply = <&vcc5v0_sys>;
416		vcc5-supply = <&vcc5v0_sys>;
417		vcc6-supply = <&vcc5v0_sys>;
418		vcc7-supply = <&vcc5v0_sys>;
419		vcc8-supply = <&vcc5v0_sys>;
420		vcc9-supply = <&vcc5v0_sys>;
421		vcc10-supply = <&vcc5v0_sys>;
422		vcc11-supply = <&vcc_2v0_pldo_s3>;
423		vcc12-supply = <&vcc5v0_sys>;
424		vcc13-supply = <&vdd2_ddr_s3>;
425		vcc14-supply = <&vdd2_ddr_s3>;
426		vcca-supply = <&vcc5v0_sys>;
427
428		gpio-controller;
429		#gpio-cells = <2>;
430
431		rk806_dvs1_null: dvs1-null-pins {
432			pins = "gpio_pwrctrl1";
433			function = "pin_fun0";
434		};
435
436		rk806_dvs2_null: dvs2-null-pins {
437			pins = "gpio_pwrctrl2";
438			function = "pin_fun0";
439		};
440
441		rk806_dvs3_null: dvs3-null-pins {
442			pins = "gpio_pwrctrl3";
443			function = "pin_fun0";
444		};
445
446		regulators {
447			vdd_gpu_s0: dcdc-reg1 {
448				regulator-name = "vdd_gpu_s0";
449				regulator-boot-on;
450				regulator-enable-ramp-delay = <400>;
451				regulator-min-microvolt = <550000>;
452				regulator-max-microvolt = <950000>;
453				regulator-ramp-delay = <12500>;
454
455				regulator-state-mem {
456					regulator-off-in-suspend;
457				};
458			};
459
460			vdd_cpu_lit_s0: dcdc-reg2 {
461				regulator-name = "vdd_cpu_lit_s0";
462				regulator-always-on;
463				regulator-boot-on;
464				regulator-min-microvolt = <550000>;
465				regulator-max-microvolt = <950000>;
466				regulator-ramp-delay = <12500>;
467
468				regulator-state-mem {
469					regulator-off-in-suspend;
470				};
471			};
472
473			vdd_log_s0: dcdc-reg3 {
474				regulator-name = "vdd_log_s0";
475				regulator-always-on;
476				regulator-boot-on;
477				regulator-min-microvolt = <675000>;
478				regulator-max-microvolt = <825000>;
479				regulator-ramp-delay = <12500>;
480
481				regulator-state-mem {
482					regulator-off-in-suspend;
483					regulator-suspend-microvolt = <750000>;
484				};
485			};
486
487			vdd_vdenc_s0: dcdc-reg4 {
488				regulator-name = "vdd_vdenc_s0";
489				regulator-always-on;
490				regulator-boot-on;
491				regulator-min-microvolt = <550000>;
492				regulator-max-microvolt = <825000>;
493				regulator-ramp-delay = <12500>;
494
495				regulator-state-mem {
496					regulator-off-in-suspend;
497				};
498			};
499
500			vdd_ddr_s0: dcdc-reg5 {
501				regulator-name = "vdd_ddr_s0";
502				regulator-always-on;
503				regulator-boot-on;
504				regulator-min-microvolt = <675000>;
505				regulator-max-microvolt = <900000>;
506				regulator-ramp-delay = <12500>;
507
508				regulator-state-mem {
509					regulator-off-in-suspend;
510					regulator-suspend-microvolt = <850000>;
511				};
512			};
513
514			vdd2_ddr_s3: dcdc-reg6 {
515				regulator-name = "vdd2_ddr_s3";
516				regulator-always-on;
517				regulator-boot-on;
518
519				regulator-state-mem {
520					regulator-on-in-suspend;
521				};
522			};
523
524			vcc_2v0_pldo_s3: dcdc-reg7 {
525				regulator-name = "vdd_2v0_pldo_s3";
526				regulator-always-on;
527				regulator-boot-on;
528				regulator-min-microvolt = <2000000>;
529				regulator-max-microvolt = <2000000>;
530				regulator-ramp-delay = <12500>;
531
532				regulator-state-mem {
533					regulator-on-in-suspend;
534					regulator-suspend-microvolt = <2000000>;
535				};
536			};
537
538			vcc_3v3_s3: dcdc-reg8 {
539				regulator-name = "vcc_3v3_s3";
540				regulator-always-on;
541				regulator-boot-on;
542				regulator-min-microvolt = <3300000>;
543				regulator-max-microvolt = <3300000>;
544
545				regulator-state-mem {
546					regulator-on-in-suspend;
547					regulator-suspend-microvolt = <3300000>;
548				};
549			};
550
551			vddq_ddr_s0: dcdc-reg9 {
552				regulator-name = "vddq_ddr_s0";
553				regulator-always-on;
554				regulator-boot-on;
555
556				regulator-state-mem {
557					regulator-off-in-suspend;
558				};
559			};
560
561			vcc_1v8_s3: dcdc-reg10 {
562				regulator-name = "vcc_1v8_s3";
563				regulator-always-on;
564				regulator-boot-on;
565				regulator-min-microvolt = <1800000>;
566				regulator-max-microvolt = <1800000>;
567
568				regulator-state-mem {
569					regulator-on-in-suspend;
570					regulator-suspend-microvolt = <1800000>;
571				};
572			};
573
574			avcc_1v8_s0: pldo-reg1 {
575				regulator-name = "avcc_1v8_s0";
576				regulator-always-on;
577				regulator-boot-on;
578				regulator-min-microvolt = <1800000>;
579				regulator-max-microvolt = <1800000>;
580
581				regulator-state-mem {
582					regulator-off-in-suspend;
583					regulator-suspend-microvolt = <1800000>;
584				};
585			};
586
587			/* shorted to avcc_1v8_s0 on the board */
588			vcc_1v8_s0: pldo-reg2 {
589				regulator-name = "vcc_1v8_s0";
590				regulator-always-on;
591				regulator-boot-on;
592				regulator-min-microvolt = <1800000>;
593				regulator-max-microvolt = <1800000>;
594
595				regulator-state-mem {
596					regulator-off-in-suspend;
597					regulator-suspend-microvolt = <1800000>;
598				};
599			};
600
601			avdd_1v2_s0: pldo-reg3 {
602				regulator-name = "avdd_1v2_s0";
603				regulator-always-on;
604				regulator-boot-on;
605				regulator-min-microvolt = <1200000>;
606				regulator-max-microvolt = <1200000>;
607
608				regulator-state-mem {
609					regulator-off-in-suspend;
610				};
611			};
612
613			vcc_3v3_s0: pldo-reg4 {
614				regulator-name = "vcc_3v3_s0";
615				regulator-always-on;
616				regulator-boot-on;
617				regulator-min-microvolt = <3300000>;
618				regulator-max-microvolt = <3300000>;
619				regulator-ramp-delay = <12500>;
620
621				regulator-state-mem {
622					regulator-off-in-suspend;
623				};
624			};
625
626			vccio_sd_s0: pldo-reg5 {
627				regulator-name = "vccio_sd_s0";
628				regulator-always-on;
629				regulator-boot-on;
630				regulator-min-microvolt = <1800000>;
631				regulator-max-microvolt = <3300000>;
632				regulator-ramp-delay = <12500>;
633
634				regulator-state-mem {
635					regulator-off-in-suspend;
636				};
637			};
638
639			pldo6_s3: pldo-reg6 {
640				regulator-name = "pldo6_s3";
641				regulator-always-on;
642				regulator-boot-on;
643				regulator-min-microvolt = <1800000>;
644				regulator-max-microvolt = <1800000>;
645
646				regulator-state-mem {
647					regulator-on-in-suspend;
648					regulator-suspend-microvolt = <1800000>;
649				};
650			};
651
652			vdd_0v75_s3: nldo-reg1 {
653				regulator-name = "vdd_0v75_s3";
654				regulator-always-on;
655				regulator-boot-on;
656				regulator-min-microvolt = <750000>;
657				regulator-max-microvolt = <750000>;
658
659				regulator-state-mem {
660					regulator-on-in-suspend;
661					regulator-suspend-microvolt = <750000>;
662				};
663			};
664
665			vdd_ddr_pll_s0: nldo-reg2 {
666				regulator-name = "vdd_ddr_pll_s0";
667				regulator-always-on;
668				regulator-boot-on;
669				regulator-min-microvolt = <850000>;
670				regulator-max-microvolt = <850000>;
671
672				regulator-state-mem {
673					regulator-off-in-suspend;
674					regulator-suspend-microvolt = <850000>;
675				};
676			};
677
678			avdd_0v75_s0: nldo-reg3 {
679				regulator-name = "avdd_0v75_s0";
680				regulator-always-on;
681				regulator-boot-on;
682				/*
683				 * The schematic mentions that actual setting
684				 * should be 0.8375V. RK3588 datasheet specifies
685				 * maximum as 0.825V. So we set datasheet max
686				 * here.
687				 */
688				regulator-min-microvolt = <825000>;
689				regulator-max-microvolt = <825000>;
690
691				regulator-state-mem {
692					regulator-off-in-suspend;
693				};
694			};
695
696			vdd_0v85_s0: nldo-reg4 {
697				regulator-name = "vdd_0v85_s0";
698				regulator-always-on;
699				regulator-boot-on;
700				regulator-min-microvolt = <850000>;
701				regulator-max-microvolt = <850000>;
702
703				regulator-state-mem {
704					regulator-off-in-suspend;
705				};
706			};
707
708			vdd_0v75_s0: nldo-reg5 {
709				regulator-name = "vdd_0v75_s0";
710				regulator-always-on;
711				regulator-boot-on;
712				regulator-min-microvolt = <750000>;
713				regulator-max-microvolt = <750000>;
714
715				regulator-state-mem {
716					regulator-off-in-suspend;
717				};
718			};
719		};
720	};
721};
722
723&tsadc {
724	status = "okay";
725};
726
727&u2phy0 {
728	status = "okay";
729};
730
731&u2phy0_otg {
732	status = "okay";
733};
734
735&u2phy1 {
736	status = "okay";
737};
738
739&u2phy1_otg {
740	status = "okay";
741};
742
743&u2phy2 {
744	status = "okay";
745};
746
747&u2phy3 {
748	status = "okay";
749};
750
751&u2phy2_host {
752	phy-supply = <&vcc5v0_usb20>;
753	status = "okay";
754};
755
756&u2phy3_host {
757	phy-supply = <&vcc5v0_usb20>;
758	status = "okay";
759};
760
761&uart2 {
762	pinctrl-0 = <&uart2m0_xfer>;
763	status = "okay";
764};
765
766&usbdp_phy0 {
767	status = "okay";
768};
769
770&usbdp_phy1 {
771	status = "okay";
772};
773
774&usb_host0_ehci {
775	status = "okay";
776};
777
778&usb_host0_ohci {
779	status = "okay";
780};
781
782&usb_host0_xhci {
783	status = "okay";
784};
785
786&usb_host1_ehci {
787	status = "okay";
788};
789
790&usb_host1_ohci {
791	status = "okay";
792};
793
794&usb_host1_xhci {
795	dr_mode = "host";
796	status = "okay";
797};
798
799&vop_mmu {
800	status = "okay";
801};
802
803&vop {
804	status = "okay";
805};
806