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