1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
4 */
5
6#include <dt-bindings/pwm/pwm.h>
7#include "rk3399.dtsi"
8
9/ {
10	aliases {
11		ethernet0 = &gmac;
12		mmc0 = &sdhci;
13	};
14
15	leds {
16		compatible = "gpio-leds";
17		pinctrl-names = "default";
18		pinctrl-0 = <&module_led_pin>;
19
20		module_led: led-0 {
21			label = "module_led";
22			gpios = <&gpio2 RK_PD1 GPIO_ACTIVE_HIGH>;
23			linux,default-trigger = "heartbeat";
24			panic-indicator;
25		};
26	};
27
28	extcon_usb3: extcon-usb3 {
29		compatible = "linux,extcon-usb-gpio";
30		id-gpios = <&gpio1 RK_PC2 GPIO_ACTIVE_HIGH>;
31		pinctrl-names = "default";
32		pinctrl-0 = <&usb3_id>;
33	};
34
35	clkin_gmac: external-gmac-clock {
36		compatible = "fixed-clock";
37		clock-frequency = <125000000>;
38		clock-output-names = "clkin_gmac";
39		#clock-cells = <0>;
40	};
41
42	vcc1v2_phy: vcc1v2-phy {
43		compatible = "regulator-fixed";
44		regulator-name = "vcc1v2_phy";
45		regulator-always-on;
46		regulator-boot-on;
47		regulator-min-microvolt = <1200000>;
48		regulator-max-microvolt = <1200000>;
49		vin-supply = <&vcc5v0_sys>;
50	};
51
52	vcc3v3_sys: vcc3v3-sys {
53		compatible = "regulator-fixed";
54		regulator-name = "vcc3v3_sys";
55		regulator-always-on;
56		regulator-boot-on;
57		regulator-min-microvolt = <3300000>;
58		regulator-max-microvolt = <3300000>;
59		vin-supply = <&vcc5v0_sys>;
60	};
61
62	vcc5v0_host: vcc5v0-host-regulator {
63		compatible = "regulator-fixed";
64		gpio = <&gpio4 RK_PA3 GPIO_ACTIVE_LOW>;
65		pinctrl-names = "default";
66		pinctrl-0 = <&vcc5v0_host_en>;
67		regulator-name = "vcc5v0_host";
68		regulator-always-on;
69		vin-supply = <&vcc5v0_sys>;
70	};
71
72	vcc5v0_sys: vcc5v0-sys {
73		compatible = "regulator-fixed";
74		regulator-name = "vcc5v0_sys";
75		regulator-always-on;
76		regulator-boot-on;
77		regulator-min-microvolt = <5000000>;
78		regulator-max-microvolt = <5000000>;
79	};
80
81	vcca_0v9: vcca-0v9-regulator {
82		compatible = "regulator-fixed";
83		regulator-name = "vcca_0v9";
84		regulator-always-on;
85		regulator-boot-on;
86		regulator-min-microvolt = <900000>;
87		regulator-max-microvolt = <900000>;
88		vin-supply = <&vcc_1v8>;
89	};
90
91	vcca_1v8: vcca-1v8-regulator {
92		compatible = "regulator-fixed";
93		regulator-name = "vcca_1v8";
94		regulator-always-on;
95		regulator-boot-on;
96		regulator-min-microvolt = <1800000>;
97		regulator-max-microvolt = <1800000>;
98		vin-supply = <&vcc3v3_sys>;
99	};
100
101	vdd_log: vdd-log {
102		compatible = "pwm-regulator";
103		pwms = <&pwm2 0 25000 1>;
104		pwm-supply = <&vcc5v0_sys>;
105		regulator-name = "vdd_log";
106		regulator-min-microvolt = <800000>;
107		regulator-max-microvolt = <1400000>;
108		regulator-always-on;
109		regulator-boot-on;
110	};
111};
112
113&cpu_b0 {
114	cpu-supply = <&vdd_cpu_b>;
115};
116
117&cpu_b1 {
118	cpu-supply = <&vdd_cpu_b>;
119};
120
121&cpu_l0 {
122	cpu-supply = <&vdd_cpu_l>;
123};
124
125&cpu_l1 {
126	cpu-supply = <&vdd_cpu_l>;
127};
128
129&cpu_l2 {
130	cpu-supply = <&vdd_cpu_l>;
131};
132
133&cpu_l3 {
134	cpu-supply = <&vdd_cpu_l>;
135};
136
137&emmc_phy {
138	status = "okay";
139	drive-impedance-ohm = <33>;
140};
141
142&gpio0 {
143	/*
144	 * The BIOS_DISABLE hog is a feedback pin for the actual status of the
145	 * signal. This usually represents the state of a switch on the baseboard.
146	 * The pin has a 10k pull-up resistor connected, so no pull-up setting is needed.
147	 */
148	bios-disable-hog {
149		gpios = <RK_PB0 GPIO_ACTIVE_HIGH>;
150		gpio-hog;
151		input;
152		line-name = "bios_disable";
153	};
154};
155
156&gpio3 {
157	/*
158	 * The Qseven BIOS_DISABLE signal on the RK3399-Q7 keeps the on-module
159	 * eMMC and SPI flash powered-down initially (in fact it keeps the
160	 * reset signal asserted). BIOS_DISABLE_OVERRIDE pin allows to override
161	 * that signal so that eMMC and SPI can be used regardless of the state
162	 * of the signal.
163	 */
164	bios-disable-override-hog {
165		gpios = <RK_PD5 GPIO_ACTIVE_LOW>;
166		gpio-hog;
167		line-name = "bios_disable_override";
168		output-high;
169	};
170};
171
172&gmac {
173	assigned-clocks = <&cru SCLK_RMII_SRC>;
174	assigned-clock-parents = <&clkin_gmac>;
175	clock_in_out = "input";
176	phy-supply = <&vcc1v2_phy>;
177	phy-mode = "rgmii";
178	pinctrl-names = "default";
179	pinctrl-0 = <&rgmii_pins>;
180	snps,reset-gpio = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;
181	snps,reset-active-low;
182	snps,reset-delays-us = <0 10000 50000>;
183	tx_delay = <0x10>;
184	rx_delay = <0x10>;
185	status = "okay";
186};
187
188&gpu {
189	mali-supply = <&vdd_gpu>;
190	status = "okay";
191};
192
193&i2c0 {
194	status = "okay";
195	i2c-scl-rising-time-ns = <168>;
196	i2c-scl-falling-time-ns = <4>;
197	clock-frequency = <400000>;
198
199	rk808: pmic@1b {
200		compatible = "rockchip,rk808";
201		reg = <0x1b>;
202		interrupt-parent = <&gpio1>;
203		interrupts = <22 IRQ_TYPE_LEVEL_LOW>;
204		#clock-cells = <1>;
205		clock-output-names = "xin32k", "rk808-clkout2";
206		pinctrl-names = "default";
207		pinctrl-0 = <&pmic_int_l>;
208		rockchip,system-power-controller;
209		wakeup-source;
210
211		vcc1-supply = <&vcc5v0_sys>;
212		vcc2-supply = <&vcc5v0_sys>;
213		vcc3-supply = <&vcc5v0_sys>;
214		vcc4-supply = <&vcc5v0_sys>;
215		vcc6-supply = <&vcc5v0_sys>;
216		vcc7-supply = <&vcc5v0_sys>;
217		vcc8-supply = <&vcc3v3_sys>;
218		vcc9-supply = <&vcc5v0_sys>;
219		vcc10-supply = <&vcc5v0_sys>;
220		vcc11-supply = <&vcc5v0_sys>;
221		vcc12-supply = <&vcc3v3_sys>;
222		vddio-supply = <&vcc1v8_pmu>;
223
224		regulators {
225			vdd_center: DCDC_REG1 {
226				regulator-name = "vdd_center";
227				regulator-min-microvolt = <750000>;
228				regulator-max-microvolt = <1350000>;
229				regulator-ramp-delay = <6001>;
230				regulator-always-on;
231				regulator-boot-on;
232				regulator-state-mem {
233					regulator-off-in-suspend;
234				};
235			};
236
237			vdd_cpu_l: DCDC_REG2 {
238				regulator-name = "vdd_cpu_l";
239				regulator-min-microvolt = <750000>;
240				regulator-max-microvolt = <1350000>;
241				regulator-ramp-delay = <6001>;
242				regulator-always-on;
243				regulator-boot-on;
244				regulator-state-mem {
245					regulator-off-in-suspend;
246				};
247			};
248
249			vcc_ddr: DCDC_REG3 {
250				regulator-name = "vcc_ddr";
251				regulator-always-on;
252				regulator-boot-on;
253				regulator-state-mem {
254					regulator-on-in-suspend;
255				};
256			};
257
258			vcc_1v8: DCDC_REG4 {
259				regulator-name = "vcc_1v8";
260				regulator-min-microvolt = <1800000>;
261				regulator-max-microvolt = <1800000>;
262				regulator-always-on;
263				regulator-boot-on;
264				regulator-state-mem {
265					regulator-on-in-suspend;
266					regulator-suspend-microvolt = <1800000>;
267				};
268			};
269
270			vcc_ldo1: LDO_REG1 {
271				regulator-name = "vcc_ldo1";
272				regulator-min-microvolt = <1800000>;
273				regulator-max-microvolt = <1800000>;
274				regulator-boot-on;
275				regulator-state-mem {
276					regulator-off-in-suspend;
277				};
278			};
279
280			vcc1v8_hdmi: LDO_REG2 {
281				regulator-name = "vcc1v8_hdmi";
282				regulator-min-microvolt = <1800000>;
283				regulator-max-microvolt = <1800000>;
284				regulator-always-on;
285				regulator-boot-on;
286				regulator-state-mem {
287					regulator-off-in-suspend;
288				};
289			};
290
291			vcc1v8_pmu: LDO_REG3 {
292				regulator-name = "vcc1v8_pmu";
293				regulator-min-microvolt = <1800000>;
294				regulator-max-microvolt = <1800000>;
295				regulator-always-on;
296				regulator-boot-on;
297				regulator-state-mem {
298					regulator-on-in-suspend;
299					regulator-suspend-microvolt = <1800000>;
300				};
301			};
302
303			vcc_sd: LDO_REG4 {
304				regulator-name = "vcc_sd";
305				regulator-min-microvolt = <1800000>;
306				regulator-max-microvolt = <3000000>;
307				regulator-always-on;
308				regulator-boot-on;
309				regulator-state-mem {
310					regulator-on-in-suspend;
311					regulator-suspend-microvolt = <3000000>;
312				};
313			};
314
315			vcc_ldo5: LDO_REG5 {
316				regulator-name = "vcc_ldo5";
317				regulator-min-microvolt = <3000000>;
318				regulator-max-microvolt = <3000000>;
319				regulator-boot-on;
320				regulator-state-mem {
321					regulator-off-in-suspend;
322				};
323			};
324
325			vcc_ldo6: LDO_REG6 {
326				regulator-name = "vcc_ldo6";
327				regulator-min-microvolt = <1500000>;
328				regulator-max-microvolt = <1500000>;
329				regulator-boot-on;
330				regulator-state-mem {
331					regulator-off-in-suspend;
332				};
333			};
334
335			vcc0v9_hdmi: LDO_REG7 {
336				regulator-name = "vcc0v9_hdmi";
337				regulator-min-microvolt = <900000>;
338				regulator-max-microvolt = <900000>;
339				regulator-always-on;
340				regulator-boot-on;
341				regulator-state-mem {
342					regulator-off-in-suspend;
343				};
344			};
345
346			vcc_efuse: LDO_REG8 {
347				regulator-name = "vcc_efuse";
348				regulator-min-microvolt = <1800000>;
349				regulator-max-microvolt = <1800000>;
350				regulator-always-on;
351				regulator-boot-on;
352				regulator-state-mem {
353					regulator-off-in-suspend;
354				};
355			};
356
357			vcc3v3_s3: SWITCH_REG1 {
358				regulator-name = "vcc3v3_s3";
359				regulator-always-on;
360				regulator-boot-on;
361				regulator-state-mem {
362					regulator-off-in-suspend;
363				};
364			};
365
366			vcc3v3_s0: SWITCH_REG2 {
367				regulator-name = "vcc3v3_s0";
368				regulator-always-on;
369				regulator-boot-on;
370				regulator-state-mem {
371					regulator-off-in-suspend;
372				};
373			};
374		};
375	};
376
377	vdd_gpu: regulator@60 {
378		compatible = "fcs,fan53555";
379		reg = <0x60>;
380		fcs,suspend-voltage-selector = <1>;
381		regulator-name = "vdd_gpu";
382		regulator-min-microvolt = <600000>;
383		regulator-max-microvolt = <1230000>;
384		regulator-ramp-delay = <1000>;
385		regulator-always-on;
386		regulator-boot-on;
387		vin-supply = <&vcc5v0_sys>;
388	};
389};
390
391&i2c7 {
392	status = "okay";
393	clock-frequency = <400000>;
394
395	fan: fan@18 {
396		compatible = "ti,amc6821";
397		reg = <0x18>;
398		#cooling-cells = <2>;
399	};
400
401	rtc_twi: rtc@6f {
402		compatible = "isil,isl1208";
403		reg = <0x6f>;
404	};
405};
406
407&i2c8 {
408	status = "okay";
409	clock-frequency = <400000>;
410
411	vdd_cpu_b: regulator@60 {
412		compatible = "fcs,fan53555";
413		reg = <0x60>;
414		vin-supply = <&vcc5v0_sys>;
415		regulator-name = "vdd_cpu_b";
416		regulator-min-microvolt = <600000>;
417		regulator-max-microvolt = <1230000>;
418		regulator-ramp-delay = <1000>;
419		fcs,suspend-voltage-selector = <1>;
420		regulator-always-on;
421		regulator-boot-on;
422	};
423};
424
425&i2s0 {
426	pinctrl-0 = <&i2s0_2ch_bus>;
427	pinctrl-1 = <&i2s0_2ch_bus_bclk_off>;
428	rockchip,playback-channels = <2>;
429	rockchip,capture-channels = <2>;
430	status = "okay";
431};
432
433/*
434 * As Q7 does not specify neither a global nor a RX clock for I2S these
435 * signals are not used. Furthermore I2S0_LRCK_RX is used as GPIO.
436 * Therefore we have to redefine the i2s0_2ch_bus and i2s0_2ch_bus_bclk_off
437 * definitions to prevent conflicts.
438 */
439&i2s0_2ch_bus {
440	rockchip,pins =
441		<3 RK_PD0 1 &pcfg_pull_none>,
442		<3 RK_PD2 1 &pcfg_pull_none>,
443		<3 RK_PD3 1 &pcfg_pull_none>,
444		<3 RK_PD7 1 &pcfg_pull_none>;
445};
446
447&i2s0_2ch_bus_bclk_off {
448	rockchip,pins =
449		<3 RK_PD0 RK_FUNC_GPIO &pcfg_pull_none>,
450		<3 RK_PD2 1 &pcfg_pull_none>,
451		<3 RK_PD3 1 &pcfg_pull_none>,
452		<3 RK_PD7 1 &pcfg_pull_none>;
453};
454
455&io_domains {
456	status = "okay";
457	bt656-supply = <&vcc_1v8>;
458	audio-supply = <&vcc_1v8>;
459	sdmmc-supply = <&vcc_sd>;
460	gpio1830-supply = <&vcc_1v8>;
461};
462
463&pcie0 {
464	/* PCIe PHY supplies */
465	vpcie0v9-supply = <&vcca_0v9>;
466	vpcie1v8-supply = <&vcca_1v8>;
467};
468
469&pcie_clkreqn_cpm {
470	rockchip,pins =
471		<2 RK_PD2 RK_FUNC_GPIO &pcfg_pull_up>;
472};
473
474&pinctrl {
475	pinctrl-names = "default";
476	pinctrl-0 = <&q7_thermal_pin &bios_disable_override_hog_pin>;
477
478	gpios {
479		bios_disable_override_hog_pin: bios-disable-override-hog-pin {
480			rockchip,pins =
481				<3 RK_PD5 RK_FUNC_GPIO &pcfg_pull_down>;
482		};
483
484		q7_thermal_pin: q7-thermal-pin {
485			rockchip,pins =
486				<0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>;
487		};
488	};
489
490	i2c8 {
491		i2c8_xfer_a: i2c8-xfer {
492			rockchip,pins =
493			  <1 RK_PC4 1 &pcfg_pull_up>,
494			  <1 RK_PC5 1 &pcfg_pull_up>;
495		};
496	};
497
498	leds {
499		module_led_pin: module-led-pin {
500			rockchip,pins =
501			  <2 RK_PD1 RK_FUNC_GPIO &pcfg_pull_none>;
502		};
503	};
504
505	pmic {
506		pmic_int_l: pmic-int-l {
507			rockchip,pins =
508			  <1 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up>;
509		};
510	};
511
512	usb2 {
513		vcc5v0_host_en: vcc5v0-host-en {
514			rockchip,pins =
515			  <4 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>;
516		};
517	};
518
519	usb3 {
520		usb3_id: usb3-id {
521			rockchip,pins =
522			  <1 RK_PC2 RK_FUNC_GPIO &pcfg_pull_up>;
523		};
524	};
525};
526
527&pmu_io_domains {
528	status = "okay";
529	pmu1830-supply = <&vcc_1v8>;
530};
531
532&pwm2 {
533	status = "okay";
534};
535
536&sdhci {
537	/*
538	 * Signal integrity isn't great at 200MHz but 100MHz has proven stable
539	 * enough.
540	 */
541	max-frequency = <100000000>;
542
543	bus-width = <8>;
544	mmc-hs400-1_8v;
545	mmc-hs400-enhanced-strobe;
546	non-removable;
547	status = "okay";
548};
549
550&sdmmc {
551	vqmmc-supply = <&vcc_sd>;
552};
553
554&spi1 {
555	status = "okay";
556
557	norflash: flash@0 {
558		compatible = "jedec,spi-nor";
559		reg = <0>;
560		spi-max-frequency = <50000000>;
561	};
562};
563
564&tcphy1 {
565	status = "okay";
566};
567
568&tsadc {
569	rockchip,hw-tshut-mode = <1>;
570	rockchip,hw-tshut-polarity = <1>;
571	status = "okay";
572};
573
574&u2phy1 {
575	status = "okay";
576
577	u2phy1_otg: otg-port {
578		status = "okay";
579	};
580
581	u2phy1_host: host-port {
582		phy-supply = <&vcc5v0_host>;
583		status = "okay";
584	};
585};
586
587&usbdrd3_1 {
588	status = "okay";
589};
590
591&usbdrd_dwc3_1 {
592	status = "okay";
593	dr_mode = "host";
594};
595
596&usb_host1_ehci {
597	status = "okay";
598};
599
600&usb_host1_ohci {
601	status = "okay";
602};
603