1/*
2 * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
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 "rk3399.dtsi"
45#include "rk3399-opp.dtsi"
46
47/ {
48	leds {
49		compatible = "gpio-leds";
50		pinctrl-names = "default";
51		pinctrl-0 = <&led_pin_module>;
52
53		module-led {
54			label = "module_led";
55			gpios = <&gpio2 RK_PD1 GPIO_ACTIVE_HIGH>;
56			linux,default-trigger = "heartbeat";
57			panic-indicator;
58		};
59	};
60
61	/*
62	 * Overwrite the opp-table for CPUB as this board uses a different
63	 * regulator (FAN53555) that only allows 10mV steps and therefore
64	 * can't reach the operation point target voltages from rk3399-opp.dtsi
65	 */
66	/delete-node/ opp-table1;
67	cluster1_opp: opp-table1 {
68		compatible = "operating-points-v2";
69		opp-shared;
70
71		opp00 {
72			opp-hz = /bits/ 64 <408000000>;
73			opp-microvolt = <800000>;
74			clock-latency-ns = <40000>;
75		};
76		opp01 {
77			opp-hz = /bits/ 64 <600000000>;
78			opp-microvolt = <800000>;
79		};
80		opp02 {
81			opp-hz = /bits/ 64 <816000000>;
82			opp-microvolt = <830000>;
83			opp-suspend;
84		};
85		opp03 {
86			opp-hz = /bits/ 64 <1008000000>;
87			opp-microvolt = <880000>;
88		};
89		opp04 {
90			opp-hz = /bits/ 64 <1200000000>;
91			opp-microvolt = <950000>;
92		};
93		opp05 {
94			opp-hz = /bits/ 64 <1416000000>;
95			opp-microvolt = <1030000>;
96		};
97		opp06 {
98			opp-hz = /bits/ 64 <1608000000>;
99			opp-microvolt = <1100000>;
100		};
101		opp07 {
102			opp-hz = /bits/ 64 <1800000000>;
103			opp-microvolt = <1200000>;
104		};
105		opp08 {
106			opp-hz = /bits/ 64 <1992000000>;
107			opp-microvolt = <1230000>;
108			turbo-mode;
109		};
110	};
111
112	clkin_gmac: external-gmac-clock {
113		compatible = "fixed-clock";
114		clock-frequency = <125000000>;
115		clock-output-names = "clkin_gmac";
116		#clock-cells = <0>;
117	};
118
119	vcc1v2_phy: vcc1v2-phy {
120		compatible = "regulator-fixed";
121		regulator-name = "vcc1v2_phy";
122		regulator-always-on;
123		regulator-boot-on;
124		regulator-min-microvolt = <1200000>;
125		regulator-max-microvolt = <1200000>;
126		vin-supply = <&vcc5v0_sys>;
127	};
128
129	vcc3v3_sys: vcc3v3-sys {
130		compatible = "regulator-fixed";
131		regulator-name = "vcc3v3_sys";
132		regulator-always-on;
133		regulator-boot-on;
134		regulator-min-microvolt = <3300000>;
135		regulator-max-microvolt = <3300000>;
136		vin-supply = <&vcc5v0_sys>;
137	};
138
139	vcc5v0_host: vcc5v0-host-regulator {
140		compatible = "regulator-fixed";
141		gpio = <&gpio4 RK_PA3 GPIO_ACTIVE_HIGH>;
142		enable-active-low;
143		pinctrl-names = "default";
144		pinctrl-0 = <&vcc5v0_host_en>;
145		regulator-name = "vcc5v0_host";
146		regulator-always-on;
147		vin-supply = <&vcc5v0_sys>;
148	};
149
150	vcc5v0_sys: vcc5v0-sys {
151		compatible = "regulator-fixed";
152		regulator-name = "vcc5v0_sys";
153		regulator-always-on;
154		regulator-boot-on;
155		regulator-min-microvolt = <5000000>;
156		regulator-max-microvolt = <5000000>;
157	};
158
159	vdd_log: vdd-log {
160		compatible = "pwm-regulator";
161		pwms = <&pwm2 0 25000 0>;
162		regulator-name = "vdd_log";
163		regulator-min-microvolt = <800000>;
164		regulator-max-microvolt = <1400000>;
165		regulator-always-on;
166		regulator-boot-on;
167		status = "okay";
168	};
169};
170
171&cpu_b0 {
172	cpu-supply = <&vdd_cpu_b>;
173};
174
175&cpu_b1 {
176	cpu-supply = <&vdd_cpu_b>;
177};
178
179&cpu_l0 {
180	cpu-supply = <&vdd_cpu_l>;
181};
182
183&cpu_l1 {
184	cpu-supply = <&vdd_cpu_l>;
185};
186
187&cpu_l2 {
188	cpu-supply = <&vdd_cpu_l>;
189};
190
191&cpu_l3 {
192	cpu-supply = <&vdd_cpu_l>;
193};
194
195&emmc_phy {
196	status = "okay";
197};
198
199&gmac {
200	assigned-clocks = <&cru SCLK_RMII_SRC>;
201	assigned-clock-parents = <&clkin_gmac>;
202	clock_in_out = "input";
203	phy-supply = <&vcc1v2_phy>;
204	phy-mode = "rgmii";
205	pinctrl-names = "default";
206	pinctrl-0 = <&rgmii_pins>;
207	snps,reset-gpio = <&gpio3 RK_PC0 GPIO_ACTIVE_HIGH>;
208	snps,reset-active-low;
209	snps,reset-delays-us = <0 10000 50000>;
210	tx_delay = <0x10>;
211	rx_delay = <0x10>;
212	status = "okay";
213};
214
215&i2c0 {
216	status = "okay";
217	i2c-scl-rising-time-ns = <168>;
218	i2c-scl-falling-time-ns = <4>;
219	clock-frequency = <400000>;
220
221	rk808: pmic@1b {
222		compatible = "rockchip,rk808";
223		reg = <0x1b>;
224		interrupt-parent = <&gpio1>;
225		interrupts = <22 IRQ_TYPE_LEVEL_LOW>;
226		#clock-cells = <1>;
227		clock-output-names = "xin32k", "rk808-clkout2";
228		pinctrl-names = "default";
229		pinctrl-0 = <&pmic_int_l>;
230		rockchip,system-power-controller;
231		wakeup-source;
232
233		vcc1-supply = <&vcc5v0_sys>;
234		vcc2-supply = <&vcc5v0_sys>;
235		vcc3-supply = <&vcc5v0_sys>;
236		vcc4-supply = <&vcc5v0_sys>;
237		vcc6-supply = <&vcc5v0_sys>;
238		vcc7-supply = <&vcc5v0_sys>;
239		vcc8-supply = <&vcc3v3_sys>;
240		vcc9-supply = <&vcc5v0_sys>;
241		vcc10-supply = <&vcc5v0_sys>;
242		vcc11-supply = <&vcc5v0_sys>;
243		vcc12-supply = <&vcc3v3_sys>;
244		vddio-supply = <&vcc1v8_pmu>;
245
246		regulators {
247			vdd_center: DCDC_REG1 {
248				regulator-name = "vdd_center";
249				regulator-min-microvolt = <750000>;
250				regulator-max-microvolt = <1350000>;
251				regulator-ramp-delay = <6001>;
252				regulator-always-on;
253				regulator-boot-on;
254				regulator-state-mem {
255					regulator-off-in-suspend;
256				};
257			};
258
259			vdd_cpu_l: DCDC_REG2 {
260				regulator-name = "vdd_cpu_l";
261				regulator-min-microvolt = <750000>;
262				regulator-max-microvolt = <1350000>;
263				regulator-ramp-delay = <6001>;
264				regulator-always-on;
265				regulator-boot-on;
266				regulator-state-mem {
267					regulator-off-in-suspend;
268				};
269			};
270
271			vcc_ddr: DCDC_REG3 {
272				regulator-name = "vcc_ddr";
273				regulator-always-on;
274				regulator-boot-on;
275				regulator-state-mem {
276					regulator-on-in-suspend;
277				};
278			};
279
280			vcc_1v8: DCDC_REG4 {
281				regulator-name = "vcc_1v8";
282				regulator-min-microvolt = <1800000>;
283				regulator-max-microvolt = <1800000>;
284				regulator-always-on;
285				regulator-boot-on;
286				regulator-state-mem {
287					regulator-on-in-suspend;
288					regulator-suspend-microvolt = <1800000>;
289				};
290			};
291
292			vcc_ldo1: LDO_REG1 {
293				regulator-name = "vcc_ldo1";
294				regulator-min-microvolt = <1800000>;
295				regulator-max-microvolt = <1800000>;
296				regulator-boot-on;
297				regulator-state-mem {
298					regulator-off-in-suspend;
299				};
300			};
301
302			vcc1v8_hdmi: LDO_REG2 {
303				regulator-name = "vcc1v8_hdmi";
304				regulator-min-microvolt = <1800000>;
305				regulator-max-microvolt = <1800000>;
306				regulator-always-on;
307				regulator-boot-on;
308				regulator-state-mem {
309					regulator-off-in-suspend;
310				};
311			};
312
313			vcc1v8_pmu: LDO_REG3 {
314				regulator-name = "vcc1v8_pmu";
315				regulator-min-microvolt = <1800000>;
316				regulator-max-microvolt = <1800000>;
317				regulator-always-on;
318				regulator-boot-on;
319				regulator-state-mem {
320					regulator-on-in-suspend;
321					regulator-suspend-microvolt = <1800000>;
322				};
323			};
324
325			vcc_sd: LDO_REG4 {
326				regulator-name = "vcc_sd";
327				regulator-min-microvolt = <1800000>;
328				regulator-max-microvolt = <3300000>;
329				regulator-always-on;
330				regulator-boot-on;
331				regulator-state-mem {
332					regulator-on-in-suspend;
333					regulator-suspend-microvolt = <3300000>;
334				};
335			};
336
337			vcc_ldo5: LDO_REG5 {
338				regulator-name = "vcc_ldo5";
339				regulator-min-microvolt = <3000000>;
340				regulator-max-microvolt = <3000000>;
341				regulator-boot-on;
342				regulator-state-mem {
343					regulator-off-in-suspend;
344				};
345			};
346
347			vcc_ldo6: LDO_REG6 {
348				regulator-name = "vcc_ldo6";
349				regulator-min-microvolt = <1500000>;
350				regulator-max-microvolt = <1500000>;
351				regulator-boot-on;
352				regulator-state-mem {
353					regulator-off-in-suspend;
354				};
355			};
356
357			vcc0v9_hdmi: LDO_REG7 {
358				regulator-name = "vcc0v9_hdmi";
359				regulator-min-microvolt = <900000>;
360				regulator-max-microvolt = <900000>;
361				regulator-always-on;
362				regulator-boot-on;
363				regulator-state-mem {
364					regulator-off-in-suspend;
365				};
366			};
367
368			vcc_efuse: LDO_REG8 {
369				regulator-name = "vcc_efuse";
370				regulator-min-microvolt = <1800000>;
371				regulator-max-microvolt = <1800000>;
372				regulator-always-on;
373				regulator-boot-on;
374				regulator-state-mem {
375					regulator-off-in-suspend;
376				};
377			};
378
379			vcc3v3_s3: SWITCH_REG1 {
380				regulator-name = "vcc3v3_s3";
381				regulator-always-on;
382				regulator-boot-on;
383				regulator-state-mem {
384					regulator-off-in-suspend;
385				};
386			};
387
388			vcc3v3_s0: SWITCH_REG2 {
389				regulator-name = "vcc3v3_s0";
390				regulator-always-on;
391				regulator-boot-on;
392				regulator-state-mem {
393					regulator-off-in-suspend;
394				};
395			};
396		};
397	};
398
399	vdd_gpu: regulator@60 {
400		compatible = "fcs,fan53555";
401		reg = <0x60>;
402		fcs,suspend-voltage-selector = <1>;
403		regulator-name = "vdd_gpu";
404		regulator-min-microvolt = <600000>;
405		regulator-max-microvolt = <1230000>;
406		regulator-ramp-delay = <1000>;
407		regulator-always-on;
408		regulator-boot-on;
409		vin-supply = <&vcc5v0_sys>;
410	};
411};
412
413&i2c7 {
414	status = "okay";
415	clock-frequency = <400000>;
416
417	fan: fan@18 {
418		compatible = "ti,amc6821";
419		reg = <0x18>;
420		cooling-min-state = <0>;
421		cooling-max-state = <9>;
422		#cooling-cells = <2>;
423	};
424
425	rtc_twi: rtc@6f {
426		compatible = "isil,isl1208";
427		reg = <0x6f>;
428	};
429};
430
431&i2c8 {
432	status = "okay";
433	clock-frequency = <400000>;
434
435	vdd_cpu_b: regulator@60 {
436		compatible = "fcs,fan53555";
437		reg = <0x60>;
438		vin-supply = <&vcc5v0_sys>;
439		regulator-name = "vdd_cpu_b";
440		regulator-min-microvolt = <600000>;
441		regulator-max-microvolt = <1230000>;
442		regulator-ramp-delay = <1000>;
443		fcs,suspend-voltage-selector = <1>;
444		regulator-always-on;
445		regulator-boot-on;
446	};
447};
448
449&io_domains {
450	status = "okay";
451	bt656-supply = <&vcc_1v8>;
452	audio-supply = <&vcc_1v8>;
453	sdmmc-supply = <&vcc_sd>;
454	gpio1830-supply = <&vcc_1v8>;
455};
456
457&pmu_io_domains {
458	status = "okay";
459	pmu1830-supply = <&vcc_1v8>;
460};
461
462&pwm2 {
463	status = "okay";
464};
465
466&pinctrl {
467	i2c8 {
468		i2c8_xfer_a: i2c8-xfer {
469			rockchip,pins =
470			  <RK_GPIO1 RK_PC4 RK_FUNC_1 &pcfg_pull_up>,
471			  <RK_GPIO1 RK_PC5 RK_FUNC_1 &pcfg_pull_up>;
472		};
473	};
474
475	leds {
476		led_pin_module: led-module-gpio {
477			rockchip,pins =
478			  <RK_GPIO2 RK_PD1 RK_FUNC_GPIO &pcfg_pull_none>;
479		};
480	};
481
482	pmic {
483		pmic_int_l: pmic-int-l {
484			rockchip,pins =
485			  <RK_GPIO1 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up>;
486		};
487	};
488
489	usb2 {
490		vcc5v0_host_en: vcc5v0-host-en {
491			rockchip,pins =
492			  <RK_GPIO4 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>;
493		};
494	};
495};
496
497&sdhci {
498	bus-width = <8>;
499	mmc-hs400-1_8v;
500	mmc-hs400-enhanced-strobe;
501	non-removable;
502	status = "okay";
503};
504
505&sdmmc {
506	vqmmc = <&vcc_sd>;
507};
508
509&spi1 {
510	status = "okay";
511
512	norflash: flash@0 {
513		compatible = "jedec,spi-nor";
514		reg = <0>;
515		spi-max-frequency = <50000000>;
516	};
517};
518
519&u2phy1 {
520	status = "okay";
521
522	u2phy1_otg: otg-port {
523		status = "okay";
524	};
525
526	u2phy1_host: host-port {
527		phy-supply = <&vcc5v0_host>;
528		status = "okay";
529	};
530};
531
532&usbdrd3_1 {
533	status = "okay";
534};
535
536&usbdrd_dwc3_1 {
537	status = "okay";
538	dr_mode = "host";
539};
540
541&usb_host1_ehci {
542	status = "okay";
543};
544
545&usb_host1_ohci {
546	status = "okay";
547};
548