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