1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2017 Fuzhou Rockchip Electronics Co., Ltd.
4 */
5
6#include "dt-bindings/pwm/pwm.h"
7#include "dt-bindings/input/input.h"
8#include "rk3399.dtsi"
9#include "rk3399-opp.dtsi"
10
11/ {
12	compatible = "rockchip,rk3399-sapphire", "rockchip,rk3399";
13
14	chosen {
15		stdout-path = "serial2:1500000n8";
16	};
17
18	clkin_gmac: external-gmac-clock {
19		compatible = "fixed-clock";
20		clock-frequency = <125000000>;
21		clock-output-names = "clkin_gmac";
22		#clock-cells = <0>;
23	};
24
25	dc_12v: dc-12v {
26		compatible = "regulator-fixed";
27		regulator-name = "dc_12v";
28		regulator-always-on;
29		regulator-boot-on;
30		regulator-min-microvolt = <12000000>;
31		regulator-max-microvolt = <12000000>;
32	};
33
34	/*
35	 * The fan power supply comes from the baseboard.
36	 * For the standalone Sapphire one option is to connect a wire
37	 * from  R90030 DNP R0805 pin2  to  C90002 10uF C0805 pin1 (vcc_sys).
38	 */
39	fan0: gpio-fan {
40		#cooling-cells = <2>;
41		compatible = "gpio-fan";
42		gpio-fan,speed-map = <0 0 3000 1>;
43		gpios = <&gpio1 RK_PC2 GPIO_ACTIVE_HIGH>;
44		status = "okay";
45	};
46
47	keys: gpio-keys {
48		compatible = "gpio-keys";
49		autorepeat;
50
51		power {
52			debounce-interval = <100>;
53			gpios = <&gpio0 RK_PA5 GPIO_ACTIVE_LOW>;
54			label = "GPIO Power";
55			linux,code = <KEY_POWER>;
56			linux,input-type = <1>;
57			pinctrl-names = "default";
58			pinctrl-0 = <&pwr_btn>;
59			wakeup-source;
60		};
61	};
62
63	/* switched by pmic_sleep */
64	vcc1v8_s3: vcca1v8_s3: vcc1v8-s3 {
65		compatible = "regulator-fixed";
66		regulator-name = "vcc1v8_s3";
67		regulator-always-on;
68		regulator-boot-on;
69		regulator-min-microvolt = <1800000>;
70		regulator-max-microvolt = <1800000>;
71		vin-supply = <&vcc_1v8>;
72	};
73
74	vcc3v0_sd: vcc3v0-sd {
75		compatible = "regulator-fixed";
76		enable-active-high;
77		gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>;
78		pinctrl-names = "default";
79		pinctrl-0 = <&sdmmc0_pwr_h>;
80		regulator-always-on;
81		regulator-max-microvolt = <3000000>;
82		regulator-min-microvolt = <3000000>;
83		regulator-name = "vcc3v0_sd";
84		vin-supply = <&vcc3v3_sys>;
85	};
86
87	vcc3v3_sys: vcc3v3-sys {
88		compatible = "regulator-fixed";
89		regulator-name = "vcc3v3_sys";
90		regulator-always-on;
91		regulator-boot-on;
92		regulator-min-microvolt = <3300000>;
93		regulator-max-microvolt = <3300000>;
94		vin-supply = <&vcc_sys>;
95	};
96
97	vcc5v0_host: vcc5v0-host-regulator {
98		compatible = "regulator-fixed";
99		enable-active-high;
100		gpio = <&gpio4 RK_PD1 GPIO_ACTIVE_HIGH>;
101		pinctrl-names = "default";
102		pinctrl-0 = <&vcc5v0_host_en>;
103		regulator-name = "vcc5v0_host";
104		regulator-always-on;
105		vin-supply = <&vcc_sys>;
106	};
107
108	vcc5v0_typec0: vcc5v0-typec0-regulator {
109		compatible = "regulator-fixed";
110		enable-active-high;
111		gpio = <&gpio2 RK_PA0 GPIO_ACTIVE_HIGH>;
112		pinctrl-names = "default";
113		pinctrl-0 = <&vcc5v0_typec0_en>;
114		regulator-name = "vcc5v0_typec0";
115		vin-supply = <&vcc_sys>;
116	};
117
118	vcc_sys: vcc-sys {
119		compatible = "regulator-fixed";
120		regulator-name = "vcc_sys";
121		regulator-always-on;
122		regulator-boot-on;
123		regulator-min-microvolt = <5000000>;
124		regulator-max-microvolt = <5000000>;
125		vin-supply = <&dc_12v>;
126	};
127
128	vdd_log: vdd-log {
129		compatible = "pwm-regulator";
130		pwms = <&pwm2 0 25000 1>;
131		regulator-name = "vdd_log";
132		regulator-always-on;
133		regulator-boot-on;
134		regulator-min-microvolt = <800000>;
135		regulator-max-microvolt = <1400000>;
136		vin-supply = <&vcc_sys>;
137	};
138};
139
140&cpu_l0 {
141	cpu-supply = <&vdd_cpu_l>;
142};
143
144&cpu_l1 {
145	cpu-supply = <&vdd_cpu_l>;
146};
147
148&cpu_l2 {
149	cpu-supply = <&vdd_cpu_l>;
150};
151
152&cpu_l3 {
153	cpu-supply = <&vdd_cpu_l>;
154};
155
156&cpu_b0 {
157	cpu-supply = <&vdd_cpu_b>;
158};
159
160&cpu_b1 {
161	cpu-supply = <&vdd_cpu_b>;
162};
163
164&cpu_thermal {
165	trips {
166		cpu_hot: cpu_hot {
167			hysteresis = <10000>;
168			temperature = <55000>;
169			type = "active";
170		};
171	};
172
173	cooling-maps {
174		map2 {
175			cooling-device =
176				<&fan0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
177			trip = <&cpu_hot>;
178		};
179	};
180};
181
182&emmc_phy {
183	status = "okay";
184};
185
186&gmac {
187	assigned-clocks = <&cru SCLK_RMII_SRC>;
188	assigned-clock-parents = <&clkin_gmac>;
189	clock_in_out = "input";
190	phy-supply = <&vcc_lan>;
191	phy-mode = "rgmii";
192	pinctrl-names = "default";
193	pinctrl-0 = <&rgmii_pins>;
194	snps,reset-gpio = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
195	snps,reset-active-low;
196	snps,reset-delays-us = <0 10000 50000>;
197	tx_delay = <0x28>;
198	rx_delay = <0x11>;
199	status = "okay";
200};
201
202&gpu {
203	mali-supply = <&vdd_gpu>;
204	status = "okay";
205};
206
207&hdmi {
208	ddc-i2c-bus = <&i2c3>;
209	status = "okay";
210};
211
212&hdmi_sound {
213	status = "okay";
214};
215
216&i2c0 {
217	clock-frequency = <400000>;
218	i2c-scl-rising-time-ns = <168>;
219	i2c-scl-falling-time-ns = <4>;
220	status = "okay";
221
222	rk808: pmic@1b {
223		compatible = "rockchip,rk808";
224		reg = <0x1b>;
225		interrupt-parent = <&gpio1>;
226		interrupts = <21 IRQ_TYPE_LEVEL_LOW>;
227		#clock-cells = <1>;
228		clock-output-names = "xin32k", "rk808-clkout2";
229		pinctrl-names = "default";
230		pinctrl-0 = <&pmic_int_l>;
231		rockchip,system-power-controller;
232		wakeup-source;
233
234		vcc1-supply = <&vcc_sys>;
235		vcc2-supply = <&vcc_sys>;
236		vcc3-supply = <&vcc_sys>;
237		vcc4-supply = <&vcc_sys>;
238		vcc6-supply = <&vcc_sys>;
239		vcc7-supply = <&vcc_sys>;
240		vcc8-supply = <&vcc3v3_sys>;
241		vcc9-supply = <&vcc_sys>;
242		vcc10-supply = <&vcc_sys>;
243		vcc11-supply = <&vcc_sys>;
244		vcc12-supply = <&vcc3v3_sys>;
245		vddio-supply = <&vcc1v8_pmu>;
246
247		regulators {
248			vdd_center: DCDC_REG1 {
249				regulator-name = "vdd_center";
250				regulator-always-on;
251				regulator-boot-on;
252				regulator-min-microvolt = <750000>;
253				regulator-max-microvolt = <1350000>;
254				regulator-ramp-delay = <6001>;
255				regulator-state-mem {
256					regulator-off-in-suspend;
257				};
258			};
259
260			vdd_cpu_l: DCDC_REG2 {
261				regulator-name = "vdd_cpu_l";
262				regulator-always-on;
263				regulator-boot-on;
264				regulator-min-microvolt = <750000>;
265				regulator-max-microvolt = <1350000>;
266				regulator-ramp-delay = <6001>;
267				regulator-state-mem {
268					regulator-off-in-suspend;
269				};
270			};
271
272			vcc_ddr: DCDC_REG3 {
273				regulator-name = "vcc_ddr";
274				regulator-always-on;
275				regulator-boot-on;
276				regulator-state-mem {
277					regulator-on-in-suspend;
278				};
279			};
280
281			vcc_1v8: DCDC_REG4 {
282				regulator-name = "vcc_1v8";
283				regulator-always-on;
284				regulator-boot-on;
285				regulator-min-microvolt = <1800000>;
286				regulator-max-microvolt = <1800000>;
287				regulator-state-mem {
288					regulator-on-in-suspend;
289					regulator-suspend-microvolt = <1800000>;
290				};
291			};
292
293			vcc1v8_dvp: LDO_REG1 {
294				regulator-name = "vcc1v8_dvp";
295				regulator-always-on;
296				regulator-boot-on;
297				regulator-min-microvolt = <1800000>;
298				regulator-max-microvolt = <1800000>;
299				regulator-state-mem {
300					regulator-off-in-suspend;
301				};
302			};
303
304			vcc3v0_tp: LDO_REG2 {
305				regulator-name = "vcc3v0_tp";
306				regulator-always-on;
307				regulator-boot-on;
308				regulator-min-microvolt = <3000000>;
309				regulator-max-microvolt = <3000000>;
310				regulator-state-mem {
311					regulator-off-in-suspend;
312				};
313			};
314
315			vcc1v8_pmu: LDO_REG3 {
316				regulator-name = "vcc1v8_pmu";
317				regulator-always-on;
318				regulator-boot-on;
319				regulator-min-microvolt = <1800000>;
320				regulator-max-microvolt = <1800000>;
321				regulator-state-mem {
322					regulator-on-in-suspend;
323					regulator-suspend-microvolt = <1800000>;
324				};
325			};
326
327			vcc_sdio: LDO_REG4 {
328				regulator-name = "vcc_sdio";
329				regulator-always-on;
330				regulator-boot-on;
331				regulator-min-microvolt = <1800000>;
332				regulator-max-microvolt = <3300000>;
333				regulator-state-mem {
334					regulator-on-in-suspend;
335					regulator-suspend-microvolt = <3000000>;
336				};
337			};
338
339			vcca3v0_codec: LDO_REG5 {
340				regulator-name = "vcca3v0_codec";
341				regulator-always-on;
342				regulator-boot-on;
343				regulator-min-microvolt = <3000000>;
344				regulator-max-microvolt = <3000000>;
345				regulator-state-mem {
346					regulator-off-in-suspend;
347				};
348			};
349
350			vcc_1v5: LDO_REG6 {
351				regulator-name = "vcc_1v5";
352				regulator-always-on;
353				regulator-boot-on;
354				regulator-min-microvolt = <1500000>;
355				regulator-max-microvolt = <1500000>;
356				regulator-state-mem {
357					regulator-on-in-suspend;
358					regulator-suspend-microvolt = <1500000>;
359				};
360			};
361
362			vcca1v8_codec: LDO_REG7 {
363				regulator-name = "vcca1v8_codec";
364				regulator-always-on;
365				regulator-boot-on;
366				regulator-min-microvolt = <1800000>;
367				regulator-max-microvolt = <1800000>;
368				regulator-state-mem {
369					regulator-off-in-suspend;
370				};
371			};
372
373			vcc_3v0: LDO_REG8 {
374				regulator-name = "vcc_3v0";
375				regulator-always-on;
376				regulator-boot-on;
377				regulator-min-microvolt = <3000000>;
378				regulator-max-microvolt = <3000000>;
379				regulator-state-mem {
380					regulator-on-in-suspend;
381					regulator-suspend-microvolt = <3000000>;
382				};
383			};
384
385			vcc3v3_s3: vcc_lan: SWITCH_REG1 {
386				regulator-name = "vcc3v3_s3";
387				regulator-always-on;
388				regulator-boot-on;
389				regulator-state-mem {
390					regulator-off-in-suspend;
391				};
392			};
393
394			vcc3v3_s0: SWITCH_REG2 {
395				regulator-name = "vcc3v3_s0";
396				regulator-always-on;
397				regulator-boot-on;
398				regulator-state-mem {
399					regulator-off-in-suspend;
400				};
401			};
402		};
403	};
404
405	vdd_cpu_b: regulator@40 {
406		compatible = "silergy,syr827";
407		reg = <0x40>;
408		fcs,suspend-voltage-selector = <1>;
409		regulator-name = "vdd_cpu_b";
410		regulator-min-microvolt = <712500>;
411		regulator-max-microvolt = <1500000>;
412		regulator-ramp-delay = <1000>;
413		regulator-always-on;
414		regulator-boot-on;
415		vin-supply = <&vcc_sys>;
416
417		regulator-state-mem {
418			regulator-off-in-suspend;
419		};
420	};
421
422	vdd_gpu: regulator@41 {
423		compatible = "silergy,syr828";
424		reg = <0x41>;
425		fcs,suspend-voltage-selector = <1>;
426		regulator-name = "vdd_gpu";
427		regulator-min-microvolt = <712500>;
428		regulator-max-microvolt = <1500000>;
429		regulator-ramp-delay = <1000>;
430		regulator-always-on;
431		regulator-boot-on;
432		vin-supply = <&vcc_sys>;
433
434		regulator-state-mem {
435			regulator-off-in-suspend;
436		};
437	};
438};
439
440&i2c3 {
441	i2c-scl-rising-time-ns = <450>;
442	i2c-scl-falling-time-ns = <15>;
443	status = "okay";
444};
445
446&i2s2 {
447	status = "okay";
448};
449
450&io_domains {
451	status = "okay";
452
453	bt656-supply = <&vcc_3v0>;
454	audio-supply = <&vcca1v8_codec>;
455	sdmmc-supply = <&vcc_sdio>;
456	gpio1830-supply = <&vcc_3v0>;
457};
458
459&pmu_io_domains {
460	pmu1830-supply = <&vcc_3v0>;
461	status = "okay";
462};
463
464&pinctrl {
465	buttons {
466		pwr_btn: pwr-btn {
467			rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>;
468		};
469	};
470
471	fan {
472		motor_pwr: motor-pwr {
473			rockchip,pins =
474				<1 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>;
475		};
476	};
477
478	pmic {
479		pmic_int_l: pmic-int-l {
480			rockchip,pins =
481				<1 RK_PC5 RK_FUNC_GPIO &pcfg_pull_up>;
482		};
483
484		vsel1_gpio: vsel1-gpio {
485			rockchip,pins = <1 RK_PC1 RK_FUNC_GPIO &pcfg_pull_down>;
486		};
487
488		vsel2_gpio: vsel2-gpio {
489			rockchip,pins = <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_down>;
490		};
491	};
492
493	sd {
494		sdmmc0_pwr_h: sdmmc0-pwr-h {
495			rockchip,pins =
496				<0 RK_PA1 RK_FUNC_GPIO &pcfg_pull_none>;
497		};
498	};
499
500	usb2 {
501		vcc5v0_host_en: vcc5v0-host-en {
502			rockchip,pins =
503				<4 RK_PD1 RK_FUNC_GPIO &pcfg_pull_none>;
504		};
505		vcc5v0_typec0_en: vcc5v0-typec0-en {
506			rockchip,pins =
507				<2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>;
508		};
509	};
510};
511
512&pwm0 {
513	status = "okay";
514};
515
516&pwm2 {
517	status = "okay";
518};
519
520&saradc {
521	vref-supply = <&vcca1v8_s3>;
522	status = "okay";
523};
524
525&sdhci {
526	bus-width = <8>;
527	mmc-hs400-1_8v;
528	mmc-hs400-enhanced-strobe;
529	non-removable;
530	status = "okay";
531};
532
533&sdmmc {
534	broken-cd;
535	bus-width = <4>;
536	cap-mmc-highspeed;
537	cap-sd-highspeed;
538	clock-frequency = <150000000>;
539	disable-wp;
540	max-frequency = <150000000>;
541	pinctrl-names = "default";
542	pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>;
543	vmmc-supply = <&vcc3v0_sd>;
544	vqmmc-supply = <&vcc_sdio>;
545	status = "okay";
546};
547
548&tcphy0 {
549	status = "okay";
550};
551
552&tcphy1 {
553	status = "okay";
554};
555
556&tsadc {
557	/* tshut mode 0:CRU 1:GPIO */
558	rockchip,hw-tshut-mode = <1>;
559	/* tshut polarity 0:LOW 1:HIGH */
560	rockchip,hw-tshut-polarity = <1>;
561	status = "okay";
562};
563
564&u2phy0 {
565	status = "okay";
566
567	u2phy0_otg: otg-port {
568		status = "okay";
569	};
570
571	u2phy0_host: host-port {
572		phy-supply = <&vcc5v0_typec0>;
573		status = "okay";
574	};
575};
576
577&u2phy1 {
578	status = "okay";
579
580	u2phy1_otg: otg-port {
581		status = "okay";
582	};
583
584	u2phy1_host: host-port {
585		phy-supply = <&vcc5v0_host>;
586		status = "okay";
587	};
588};
589
590&uart0 {
591	pinctrl-names = "default";
592	pinctrl-0 = <&uart0_xfer &uart0_cts>;
593	status = "okay";
594};
595
596&uart2 {
597	status = "okay";
598};
599
600&usb_host0_ehci {
601	status = "okay";
602};
603
604&usb_host0_ohci {
605	status = "okay";
606};
607
608&usb_host1_ehci {
609	status = "okay";
610};
611
612&usb_host1_ohci {
613	status = "okay";
614};
615
616&usbdrd3_0 {
617	status = "okay";
618};
619
620&usbdrd_dwc3_0 {
621	status = "okay";
622	dr_mode = "host";
623};
624
625&usbdrd3_1 {
626	status = "okay";
627};
628
629&usbdrd_dwc3_1 {
630	status = "okay";
631	dr_mode = "host";
632};
633
634&vopb {
635	status = "okay";
636};
637
638&vopb_mmu {
639	status = "okay";
640};
641
642&vopl {
643	status = "okay";
644};
645
646&vopl_mmu {
647	status = "okay";
648};
649