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