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