1/*
2 * Copyright (c) 2017 Fuzhou Rockchip Electronics Co., Ltd.
3 *
4 * This file is dual-licensed: you can use it either under the terms
5 * of the GPL or the X11 license, at your option. Note that this dual
6 * licensing only applies to this file, and not this project as a
7 * whole.
8 *
9 *  a) This file is free software; you can redistribute it and/or
10 *     modify it under the terms of the GNU General Public License as
11 *     published by the Free Software Foundation; either version 2 of the
12 *     License, or (at your option) any later version.
13 *
14 *     This file is distributed in the hope that it will be useful,
15 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *     GNU General Public License for more details.
18 *
19 * Or, alternatively,
20 *
21 *  b) Permission is hereby granted, free of charge, to any person
22 *     obtaining a copy of this software and associated documentation
23 *     files (the "Software"), to deal in the Software without
24 *     restriction, including without limitation the rights to use,
25 *     copy, modify, merge, publish, distribute, sublicense, and/or
26 *     sell copies of the Software, and to permit persons to whom the
27 *     Software is furnished to do so, subject to the following
28 *     conditions:
29 *
30 *     The above copyright notice and this permission notice shall be
31 *     included in all copies or substantial portions of the Software.
32 *
33 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
34 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
35 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
36 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
37 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
38 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
39 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
40 *     OTHER DEALINGS IN THE SOFTWARE.
41 */
42
43#include "dt-bindings/pwm/pwm.h"
44#include "dt-bindings/input/input.h"
45#include "rk3399.dtsi"
46#include "rk3399-opp.dtsi"
47
48/ {
49	compatible = "rockchip,rk3399-sapphire", "rockchip,rk3399";
50
51	backlight: backlight {
52		compatible = "pwm-backlight";
53		brightness-levels = <
54			  0   1   2   3   4   5   6   7
55			  8   9  10  11  12  13  14  15
56			 16  17  18  19  20  21  22  23
57			 24  25  26  27  28  29  30  31
58			 32  33  34  35  36  37  38  39
59			 40  41  42  43  44  45  46  47
60			 48  49  50  51  52  53  54  55
61			 56  57  58  59  60  61  62  63
62			 64  65  66  67  68  69  70  71
63			 72  73  74  75  76  77  78  79
64			 80  81  82  83  84  85  86  87
65			 88  89  90  91  92  93  94  95
66			 96  97  98  99 100 101 102 103
67			104 105 106 107 108 109 110 111
68			112 113 114 115 116 117 118 119
69			120 121 122 123 124 125 126 127
70			128 129 130 131 132 133 134 135
71			136 137 138 139 140 141 142 143
72			144 145 146 147 148 149 150 151
73			152 153 154 155 156 157 158 159
74			160 161 162 163 164 165 166 167
75			168 169 170 171 172 173 174 175
76			176 177 178 179 180 181 182 183
77			184 185 186 187 188 189 190 191
78			192 193 194 195 196 197 198 199
79			200 201 202 203 204 205 206 207
80			208 209 210 211 212 213 214 215
81			216 217 218 219 220 221 222 223
82			224 225 226 227 228 229 230 231
83			232 233 234 235 236 237 238 239
84			240 241 242 243 244 245 246 247
85			248 249 250 251 252 253 254 255>;
86		default-brightness-level = <200>;
87		pwms = <&pwm0 0 25000 0>;
88	};
89
90	clkin_gmac: external-gmac-clock {
91		compatible = "fixed-clock";
92		clock-frequency = <125000000>;
93		clock-output-names = "clkin_gmac";
94		#clock-cells = <0>;
95	};
96
97	dc_12v: dc-12v {
98		compatible = "regulator-fixed";
99		regulator-name = "dc_12v";
100		regulator-always-on;
101		regulator-boot-on;
102		regulator-min-microvolt = <12000000>;
103		regulator-max-microvolt = <12000000>;
104	};
105
106	keys: gpio-keys {
107		compatible = "gpio-keys";
108		autorepeat;
109
110		power {
111			debounce-interval = <100>;
112			gpios = <&gpio0 RK_PA5 GPIO_ACTIVE_LOW>;
113			label = "GPIO Power";
114			linux,code = <KEY_POWER>;
115			linux,input-type = <1>;
116			pinctrl-names = "default";
117			pinctrl-0 = <&pwr_btn>;
118			wakeup-source;
119		};
120	};
121
122	/* switched by pmic_sleep */
123	vcc1v8_s3: vcca1v8_s3: vcc1v8-s3 {
124		compatible = "regulator-fixed";
125		regulator-name = "vcc1v8_s3";
126		regulator-always-on;
127		regulator-boot-on;
128		regulator-min-microvolt = <1800000>;
129		regulator-max-microvolt = <1800000>;
130		vin-supply = <&vcc_1v8>;
131	};
132
133	vcc3v3_sys: vcc3v3-sys {
134		compatible = "regulator-fixed";
135		regulator-name = "vcc3v3_sys";
136		regulator-always-on;
137		regulator-boot-on;
138		regulator-min-microvolt = <3300000>;
139		regulator-max-microvolt = <3300000>;
140		vin-supply = <&vcc_sys>;
141	};
142
143	vcc_sys: vcc-sys {
144		compatible = "regulator-fixed";
145		regulator-name = "vcc_sys";
146		regulator-always-on;
147		regulator-boot-on;
148		regulator-min-microvolt = <5000000>;
149		regulator-max-microvolt = <5000000>;
150		vin-supply = <&dc_12v>;
151	};
152
153	vcc5v0_host: vcc5v0-host-regulator {
154		compatible = "regulator-fixed";
155		enable-active-high;
156		gpio = <&gpio1 RK_PD1 GPIO_ACTIVE_HIGH>;
157		pinctrl-names = "default";
158		pinctrl-0 = <&vcc5v0_host_en>;
159		regulator-name = "vcc5v0_host";
160		regulator-always-on;
161		vin-supply = <&vcc_sys>;
162	};
163
164	vdd_log: vdd-log {
165		compatible = "pwm-regulator";
166		pwms = <&pwm2 0 25000 1>;
167		regulator-name = "vdd_log";
168		regulator-always-on;
169		regulator-boot-on;
170		regulator-min-microvolt = <800000>;
171		regulator-max-microvolt = <1400000>;
172		vin-supply = <&vcc_sys>;
173	};
174};
175
176&cpu_l0 {
177	cpu-supply = <&vdd_cpu_l>;
178};
179
180&cpu_l1 {
181	cpu-supply = <&vdd_cpu_l>;
182};
183
184&cpu_l2 {
185	cpu-supply = <&vdd_cpu_l>;
186};
187
188&cpu_l3 {
189	cpu-supply = <&vdd_cpu_l>;
190};
191
192&cpu_b0 {
193	cpu-supply = <&vdd_cpu_b>;
194};
195
196&cpu_b1 {
197	cpu-supply = <&vdd_cpu_b>;
198};
199
200&emmc_phy {
201	status = "okay";
202};
203
204&gmac {
205	assigned-clocks = <&cru SCLK_RMII_SRC>;
206	assigned-clock-parents = <&clkin_gmac>;
207	clock_in_out = "input";
208	phy-supply = <&vcc_lan>;
209	phy-mode = "rgmii";
210	pinctrl-names = "default";
211	pinctrl-0 = <&rgmii_pins>;
212	snps,reset-gpio = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
213	snps,reset-active-low;
214	snps,reset-delays-us = <0 10000 50000>;
215	tx_delay = <0x28>;
216	rx_delay = <0x11>;
217	status = "okay";
218};
219
220&gpu {
221	mali-supply = <&vdd_gpu>;
222	status = "okay";
223};
224
225&hdmi {
226	ddc-i2c-bus = <&i2c3>;
227	status = "okay";
228};
229
230&i2c0 {
231	clock-frequency = <400000>;
232	i2c-scl-rising-time-ns = <168>;
233	i2c-scl-falling-time-ns = <4>;
234	status = "okay";
235
236	rk808: pmic@1b {
237		compatible = "rockchip,rk808";
238		reg = <0x1b>;
239		interrupt-parent = <&gpio1>;
240		interrupts = <21 IRQ_TYPE_LEVEL_LOW>;
241		#clock-cells = <1>;
242		clock-output-names = "xin32k", "rk808-clkout2";
243		pinctrl-names = "default";
244		pinctrl-0 = <&pmic_int_l &pmic_dvs2>;
245		rockchip,system-power-controller;
246		wakeup-source;
247
248		vcc1-supply = <&vcc_sys>;
249		vcc2-supply = <&vcc_sys>;
250		vcc3-supply = <&vcc_sys>;
251		vcc4-supply = <&vcc_sys>;
252		vcc6-supply = <&vcc_sys>;
253		vcc7-supply = <&vcc_sys>;
254		vcc8-supply = <&vcc3v3_sys>;
255		vcc9-supply = <&vcc_sys>;
256		vcc10-supply = <&vcc_sys>;
257		vcc11-supply = <&vcc_sys>;
258		vcc12-supply = <&vcc3v3_sys>;
259		vddio-supply = <&vcc1v8_pmu>;
260
261		regulators {
262			vdd_center: DCDC_REG1 {
263				regulator-name = "vdd_center";
264				regulator-always-on;
265				regulator-boot-on;
266				regulator-min-microvolt = <750000>;
267				regulator-max-microvolt = <1350000>;
268				regulator-ramp-delay = <6001>;
269				regulator-state-mem {
270					regulator-off-in-suspend;
271				};
272			};
273
274			vdd_cpu_l: DCDC_REG2 {
275				regulator-name = "vdd_cpu_l";
276				regulator-always-on;
277				regulator-boot-on;
278				regulator-min-microvolt = <750000>;
279				regulator-max-microvolt = <1350000>;
280				regulator-ramp-delay = <6001>;
281				regulator-state-mem {
282					regulator-off-in-suspend;
283				};
284			};
285
286			vcc_ddr: DCDC_REG3 {
287				regulator-name = "vcc_ddr";
288				regulator-always-on;
289				regulator-boot-on;
290				regulator-state-mem {
291					regulator-on-in-suspend;
292				};
293			};
294
295			vcc_1v8: DCDC_REG4 {
296				regulator-name = "vcc_1v8";
297				regulator-always-on;
298				regulator-boot-on;
299				regulator-min-microvolt = <1800000>;
300				regulator-max-microvolt = <1800000>;
301				regulator-state-mem {
302					regulator-on-in-suspend;
303					regulator-suspend-microvolt = <1800000>;
304				};
305			};
306
307			vcc1v8_dvp: LDO_REG1 {
308				regulator-name = "vcc1v8_dvp";
309				regulator-always-on;
310				regulator-boot-on;
311				regulator-min-microvolt = <1800000>;
312				regulator-max-microvolt = <1800000>;
313				regulator-state-mem {
314					regulator-off-in-suspend;
315				};
316			};
317
318			vcc3v0_tp: LDO_REG2 {
319				regulator-name = "vcc3v0_tp";
320				regulator-always-on;
321				regulator-boot-on;
322				regulator-min-microvolt = <3000000>;
323				regulator-max-microvolt = <3000000>;
324				regulator-state-mem {
325					regulator-off-in-suspend;
326				};
327			};
328
329			vcc1v8_pmu: LDO_REG3 {
330				regulator-name = "vcc1v8_pmu";
331				regulator-always-on;
332				regulator-boot-on;
333				regulator-min-microvolt = <1800000>;
334				regulator-max-microvolt = <1800000>;
335				regulator-state-mem {
336					regulator-on-in-suspend;
337					regulator-suspend-microvolt = <1800000>;
338				};
339			};
340
341			vcc_sdio: LDO_REG4 {
342				regulator-name = "vcc_sdio";
343				regulator-always-on;
344				regulator-boot-on;
345				regulator-min-microvolt = <1800000>;
346				regulator-max-microvolt = <3000000>;
347				regulator-state-mem {
348					regulator-on-in-suspend;
349					regulator-suspend-microvolt = <3000000>;
350				};
351			};
352
353			vcca3v0_codec: LDO_REG5 {
354				regulator-name = "vcca3v0_codec";
355				regulator-always-on;
356				regulator-boot-on;
357				regulator-min-microvolt = <3000000>;
358				regulator-max-microvolt = <3000000>;
359				regulator-state-mem {
360					regulator-off-in-suspend;
361				};
362			};
363
364			vcc_1v5: LDO_REG6 {
365				regulator-name = "vcc_1v5";
366				regulator-always-on;
367				regulator-boot-on;
368				regulator-min-microvolt = <1500000>;
369				regulator-max-microvolt = <1500000>;
370				regulator-state-mem {
371					regulator-on-in-suspend;
372					regulator-suspend-microvolt = <1500000>;
373				};
374			};
375
376			vcca1v8_codec: LDO_REG7 {
377				regulator-name = "vcca1v8_codec";
378				regulator-always-on;
379				regulator-boot-on;
380				regulator-min-microvolt = <1800000>;
381				regulator-max-microvolt = <1800000>;
382				regulator-state-mem {
383					regulator-off-in-suspend;
384				};
385			};
386
387			vcc_3v0: LDO_REG8 {
388				regulator-name = "vcc_3v0";
389				regulator-always-on;
390				regulator-boot-on;
391				regulator-min-microvolt = <3000000>;
392				regulator-max-microvolt = <3000000>;
393				regulator-state-mem {
394					regulator-on-in-suspend;
395					regulator-suspend-microvolt = <3000000>;
396				};
397			};
398
399			vcc3v3_s3: vcc_lan: SWITCH_REG1 {
400				regulator-name = "vcc3v3_s3";
401				regulator-always-on;
402				regulator-boot-on;
403				regulator-state-mem {
404					regulator-off-in-suspend;
405				};
406			};
407
408			vcc3v3_s0: SWITCH_REG2 {
409				regulator-name = "vcc3v3_s0";
410				regulator-always-on;
411				regulator-boot-on;
412				regulator-state-mem {
413					regulator-off-in-suspend;
414				};
415			};
416		};
417	};
418
419	vdd_cpu_b: regulator@40 {
420		compatible = "silergy,syr827";
421		reg = <0x40>;
422		fcs,suspend-voltage-selector = <1>;
423		regulator-name = "vdd_cpu_b";
424		regulator-min-microvolt = <712500>;
425		regulator-max-microvolt = <1500000>;
426		regulator-ramp-delay = <1000>;
427		regulator-always-on;
428		regulator-boot-on;
429		vin-supply = <&vcc_sys>;
430
431		regulator-state-mem {
432			regulator-off-in-suspend;
433		};
434	};
435
436	vdd_gpu: regulator@41 {
437		compatible = "silergy,syr828";
438		reg = <0x41>;
439		fcs,suspend-voltage-selector = <1>;
440		regulator-name = "vdd_gpu";
441		regulator-min-microvolt = <712500>;
442		regulator-max-microvolt = <1500000>;
443		regulator-ramp-delay = <1000>;
444		regulator-always-on;
445		regulator-boot-on;
446		vin-supply = <&vcc_sys>;
447
448		regulator-state-mem {
449			regulator-off-in-suspend;
450		};
451	};
452};
453
454&i2c3 {
455	i2c-scl-rising-time-ns = <450>;
456	i2c-scl-falling-time-ns = <15>;
457	status = "okay";
458};
459
460&i2s2 {
461	#sound-dai-cells = <0>;
462	status = "okay";
463};
464
465&io_domains {
466	status = "okay";
467
468	bt656-supply = <&vcc_3v0>;
469	audio-supply = <&vcca1v8_codec>;
470	sdmmc-supply = <&vcc_sdio>;
471	gpio1830-supply = <&vcc_3v0>;
472};
473
474&pmu_io_domains {
475	pmu1830-supply = <&vcc_3v0>;
476	status = "okay";
477};
478
479&pinctrl {
480	buttons {
481		pwr_btn: pwr-btn {
482			rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>;
483		};
484	};
485
486	pmic {
487		pmic_int_l: pmic-int-l {
488			rockchip,pins =
489				<1 RK_PC5 RK_FUNC_GPIO &pcfg_pull_up>;
490		};
491
492		pmic_dvs2: pmic-dvs2 {
493			rockchip,pins =
494				<1 RK_PC2 RK_FUNC_GPIO &pcfg_pull_down>;
495		};
496
497		vsel1_gpio: vsel1-gpio {
498			rockchip,pins = <1 RK_PC1 RK_FUNC_GPIO &pcfg_pull_down>;
499		};
500
501		vsel2_gpio: vsel2-gpio {
502			rockchip,pins = <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_down>;
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	};
512};
513
514&pwm0 {
515	status = "okay";
516};
517
518&pwm2 {
519	status = "okay";
520};
521
522&saradc {
523	vref-supply = <&vcca1v8_s3>;
524	status = "okay";
525};
526
527&sdhci {
528	bus-width = <8>;
529	mmc-hs400-1_8v;
530	mmc-hs400-enhanced-strobe;
531	non-removable;
532	status = "okay";
533};
534
535&sdmmc {
536	bus-width = <4>;
537	cap-mmc-highspeed;
538	cap-sd-highspeed;
539	clock-frequency = <150000000>;
540	disable-wp;
541	max-frequency = <150000000>;
542	pinctrl-names = "default";
543	pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>;
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_host>;
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 = "otg";
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