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