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		i2c10 = &i2c10;
13		mmc0 = &sdhci;
14	};
15
16	leds {
17		compatible = "gpio-leds";
18		pinctrl-names = "default";
19		pinctrl-0 = <&module_led_pin>;
20
21		module_led: led-0 {
22			label = "module_led";
23			gpios = <&gpio2 RK_PD1 GPIO_ACTIVE_HIGH>;
24			linux,default-trigger = "heartbeat";
25			panic-indicator;
26		};
27	};
28
29	extcon_usb3: extcon-usb3 {
30		compatible = "linux,extcon-usb-gpio";
31		id-gpios = <&gpio1 RK_PC2 GPIO_ACTIVE_HIGH>;
32		pinctrl-names = "default";
33		pinctrl-0 = <&usb3_id>;
34	};
35
36	clkin_gmac: external-gmac-clock {
37		compatible = "fixed-clock";
38		clock-frequency = <125000000>;
39		clock-output-names = "clkin_gmac";
40		#clock-cells = <0>;
41	};
42
43	vcc1v2_phy: regulator-vcc1v2-phy {
44		compatible = "regulator-fixed";
45		regulator-name = "vcc1v2_phy";
46		regulator-always-on;
47		regulator-boot-on;
48		regulator-min-microvolt = <1200000>;
49		regulator-max-microvolt = <1200000>;
50		vin-supply = <&vcc5v0_sys>;
51	};
52
53	vcc3v3_sys: regulator-vcc3v3-sys {
54		compatible = "regulator-fixed";
55		regulator-name = "vcc3v3_sys";
56		regulator-always-on;
57		regulator-boot-on;
58		regulator-min-microvolt = <3300000>;
59		regulator-max-microvolt = <3300000>;
60		vin-supply = <&vcc5v0_sys>;
61	};
62
63	vcc5v0_host: regulator-vcc5v0-host {
64		compatible = "regulator-fixed";
65		gpio = <&gpio4 RK_PA3 GPIO_ACTIVE_LOW>;
66		pinctrl-names = "default";
67		pinctrl-0 = <&vcc5v0_host_en>;
68		regulator-name = "vcc5v0_host";
69		regulator-always-on;
70		vin-supply = <&vcc5v0_sys>;
71	};
72
73	vcc5v0_sys: regulator-vcc5v0-sys {
74		compatible = "regulator-fixed";
75		regulator-name = "vcc5v0_sys";
76		regulator-always-on;
77		regulator-boot-on;
78		regulator-min-microvolt = <5000000>;
79		regulator-max-microvolt = <5000000>;
80	};
81
82	vcca_0v9: regulator-vcca-0v9 {
83		compatible = "regulator-fixed";
84		regulator-name = "vcca_0v9";
85		regulator-always-on;
86		regulator-boot-on;
87		regulator-min-microvolt = <900000>;
88		regulator-max-microvolt = <900000>;
89		vin-supply = <&vcc_1v8>;
90	};
91
92	vcca_1v8: regulator-vcca-1v8 {
93		compatible = "regulator-fixed";
94		regulator-name = "vcca_1v8";
95		regulator-always-on;
96		regulator-boot-on;
97		regulator-min-microvolt = <1800000>;
98		regulator-max-microvolt = <1800000>;
99		vin-supply = <&vcc3v3_sys>;
100	};
101
102	vdd_log: regulator-vdd-log {
103		compatible = "pwm-regulator";
104		pwms = <&pwm2 0 25000 1>;
105		pwm-supply = <&vcc5v0_sys>;
106		regulator-name = "vdd_log";
107		regulator-min-microvolt = <800000>;
108		regulator-max-microvolt = <1400000>;
109		regulator-always-on;
110		regulator-boot-on;
111	};
112};
113
114&cpu_b0 {
115	cpu-supply = <&vdd_cpu_b>;
116};
117
118&cpu_b1 {
119	cpu-supply = <&vdd_cpu_b>;
120};
121
122&cpu_l0 {
123	cpu-supply = <&vdd_cpu_l>;
124};
125
126&cpu_l1 {
127	cpu-supply = <&vdd_cpu_l>;
128};
129
130&cpu_l2 {
131	cpu-supply = <&vdd_cpu_l>;
132};
133
134&cpu_l3 {
135	cpu-supply = <&vdd_cpu_l>;
136};
137
138&emmc_phy {
139	status = "okay";
140	drive-impedance-ohm = <33>;
141};
142
143&gpio0 {
144	/*
145	 * The BIOS_DISABLE hog is a feedback pin for the actual status of the
146	 * signal. This usually represents the state of a switch on the baseboard.
147	 * The pin has a 10k pull-up resistor connected, so no pull-up setting is needed.
148	 */
149	bios-disable-hog {
150		gpios = <RK_PB0 GPIO_ACTIVE_HIGH>;
151		gpio-hog;
152		input;
153		line-name = "bios_disable";
154	};
155};
156
157&gpio3 {
158	/*
159	 * The Qseven BIOS_DISABLE signal on the RK3399-Q7 keeps the on-module
160	 * eMMC and SPI flash powered-down initially (in fact it keeps the
161	 * reset signal asserted). BIOS_DISABLE_OVERRIDE pin allows to override
162	 * that signal so that eMMC and SPI can be used regardless of the state
163	 * of the signal.
164	 */
165	bios-disable-override-hog {
166		gpios = <RK_PD5 GPIO_ACTIVE_LOW>;
167		gpio-hog;
168		line-name = "bios_disable_override";
169		output-high;
170	};
171};
172
173&gmac {
174	assigned-clocks = <&cru SCLK_RMII_SRC>;
175	assigned-clock-parents = <&clkin_gmac>;
176	clock_in_out = "input";
177	phy-supply = <&vcc1v2_phy>;
178	phy-mode = "rgmii";
179	pinctrl-names = "default";
180	pinctrl-0 = <&rgmii_pins>;
181	snps,reset-gpio = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;
182	snps,reset-active-low;
183	snps,reset-delays-us = <0 10000 50000>;
184	tx_delay = <0x10>;
185	rx_delay = <0x23>;
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		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&hdmi {
392	ddc-i2c-bus = <&i2c3>;
393};
394
395&i2c6 {
396	clock-frequency = <400000>;
397};
398
399&i2c7 {
400	status = "okay";
401	clock-frequency = <400000>;
402
403	fan: fan@18 {
404		compatible = "tsd,mule", "ti,amc6821";
405		reg = <0x18>;
406
407		i2c-mux {
408			compatible = "tsd,mule-i2c-mux";
409			#address-cells = <1>;
410			#size-cells = <0>;
411
412			i2c10: i2c@0 {
413				reg = <0x0>;
414				#address-cells = <1>;
415				#size-cells = <0>;
416
417				rtc_twi: rtc@6f {
418					compatible = "isil,isl1208";
419					reg = <0x6f>;
420				};
421			};
422		};
423	};
424};
425
426&i2c8 {
427	status = "okay";
428	clock-frequency = <400000>;
429
430	vdd_cpu_b: regulator@60 {
431		compatible = "fcs,fan53555";
432		reg = <0x60>;
433		vin-supply = <&vcc5v0_sys>;
434		regulator-name = "vdd_cpu_b";
435		regulator-min-microvolt = <600000>;
436		regulator-max-microvolt = <1230000>;
437		regulator-ramp-delay = <1000>;
438		fcs,suspend-voltage-selector = <1>;
439		regulator-always-on;
440		regulator-boot-on;
441	};
442};
443
444&i2s0 {
445	pinctrl-0 = <&i2s0_2ch_bus>;
446	pinctrl-1 = <&i2s0_2ch_bus_bclk_off>;
447	rockchip,playback-channels = <2>;
448	rockchip,capture-channels = <2>;
449};
450
451/*
452 * As Q7 does not specify neither a global nor a RX clock for I2S these
453 * signals are not used. Furthermore I2S0_LRCK_RX is used as GPIO.
454 * Therefore we have to redefine the i2s0_2ch_bus and i2s0_2ch_bus_bclk_off
455 * definitions to prevent conflicts.
456 */
457&i2s0_2ch_bus {
458	rockchip,pins =
459		<3 RK_PD0 1 &pcfg_pull_none>,
460		<3 RK_PD2 1 &pcfg_pull_none>,
461		<3 RK_PD3 1 &pcfg_pull_none>,
462		<3 RK_PD7 1 &pcfg_pull_none>;
463};
464
465&i2s0_2ch_bus_bclk_off {
466	rockchip,pins =
467		<3 RK_PD0 RK_FUNC_GPIO &pcfg_pull_none>,
468		<3 RK_PD2 1 &pcfg_pull_none>,
469		<3 RK_PD3 1 &pcfg_pull_none>,
470		<3 RK_PD7 1 &pcfg_pull_none>;
471};
472
473&io_domains {
474	status = "okay";
475	bt656-supply = <&vcc_1v8>;
476	audio-supply = <&vcc_1v8>;
477	sdmmc-supply = <&vcc_sd>;
478	gpio1830-supply = <&vcc_1v8>;
479};
480
481&pcie0 {
482	/* PCIe PHY supplies */
483	vpcie0v9-supply = <&vcca_0v9>;
484	vpcie1v8-supply = <&vcca_1v8>;
485};
486
487&pcie_clkreqn_cpm {
488	rockchip,pins =
489		<2 RK_PD2 RK_FUNC_GPIO &pcfg_pull_up>;
490};
491
492&pinctrl {
493	pinctrl-names = "default";
494	pinctrl-0 = <&q7_thermal_pin &bios_disable_override_hog_pin>;
495
496	gpios {
497		bios_disable_override_hog_pin: bios-disable-override-hog-pin {
498			rockchip,pins =
499				<3 RK_PD5 RK_FUNC_GPIO &pcfg_pull_down>;
500		};
501
502		q7_thermal_pin: q7-thermal-pin {
503			rockchip,pins =
504				<0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>;
505		};
506	};
507
508	i2c8 {
509		i2c8_xfer_a: i2c8-xfer {
510			rockchip,pins =
511			  <1 RK_PC4 1 &pcfg_pull_up>,
512			  <1 RK_PC5 1 &pcfg_pull_up>;
513		};
514	};
515
516	leds {
517		module_led_pin: module-led-pin {
518			rockchip,pins =
519			  <2 RK_PD1 RK_FUNC_GPIO &pcfg_pull_none>;
520		};
521	};
522
523	pmic {
524		pmic_int_l: pmic-int-l {
525			rockchip,pins =
526			  <1 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up>;
527		};
528	};
529
530	usb2 {
531		vcc5v0_host_en: vcc5v0-host-en {
532			rockchip,pins =
533			  <4 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>;
534		};
535	};
536
537	usb3 {
538		usb3_id: usb3-id {
539			rockchip,pins =
540			  <1 RK_PC2 RK_FUNC_GPIO &pcfg_pull_up>;
541		};
542	};
543};
544
545&pmu_io_domains {
546	status = "okay";
547	pmu1830-supply = <&vcc_1v8>;
548};
549
550&pwm2 {
551	status = "okay";
552};
553
554&sdhci {
555	/*
556	 * Signal integrity isn't great at 200MHz but 100MHz has proven stable
557	 * enough.
558	 */
559	max-frequency = <100000000>;
560
561	bus-width = <8>;
562	mmc-hs400-1_8v;
563	mmc-hs400-enhanced-strobe;
564	non-removable;
565	status = "okay";
566};
567
568&sdmmc {
569	vqmmc-supply = <&vcc_sd>;
570};
571
572&spi1 {
573	status = "okay";
574
575	norflash: flash@0 {
576		compatible = "jedec,spi-nor";
577		reg = <0>;
578		spi-max-frequency = <50000000>;
579	};
580};
581
582&tcphy1 {
583	status = "okay";
584};
585
586&tsadc {
587	rockchip,hw-tshut-mode = <1>;
588	rockchip,hw-tshut-polarity = <1>;
589	status = "okay";
590};
591
592&u2phy1 {
593	status = "okay";
594
595	u2phy1_otg: otg-port {
596		status = "okay";
597	};
598
599	u2phy1_host: host-port {
600		phy-supply = <&vcc5v0_host>;
601		status = "okay";
602	};
603};
604
605&usbdrd3_1 {
606	status = "okay";
607};
608
609&usbdrd_dwc3_1 {
610	status = "okay";
611	dr_mode = "host";
612};
613
614&usb_host1_ehci {
615	status = "okay";
616};
617
618&usb_host1_ohci {
619	status = "okay";
620};
621