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