1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Author: Frank Wunderlich <frank-w@public-files.de>
4 *
5 */
6
7/dts-v1/;
8#include <dt-bindings/gpio/gpio.h>
9#include <dt-bindings/leds/common.h>
10#include <dt-bindings/pinctrl/rockchip.h>
11#include "rk3568.dtsi"
12
13/ {
14	model = "Bananapi-R2 Pro (RK3568) DDR4 Board";
15	compatible = "rockchip,rk3568-bpi-r2pro", "rockchip,rk3568";
16
17	aliases {
18		ethernet0 = &gmac0;
19		ethernet1 = &gmac1;
20		mmc0 = &sdmmc0;
21		mmc1 = &sdhci;
22	};
23
24	chosen: chosen {
25		stdout-path = "serial2:1500000n8";
26	};
27
28	leds {
29		compatible = "gpio-leds";
30		pinctrl-names = "default";
31		pinctrl-0 = <&blue_led_pin &green_led_pin>;
32
33		blue_led: led-0 {
34			color = <LED_COLOR_ID_BLUE>;
35			default-state = "off";
36			function = LED_FUNCTION_STATUS;
37			gpios = <&gpio0 RK_PD6 GPIO_ACTIVE_HIGH>;
38		};
39
40		green_led: led-1 {
41			color = <LED_COLOR_ID_GREEN>;
42			default-state = "on";
43			function = LED_FUNCTION_POWER;
44			gpios = <&gpio0 RK_PD5 GPIO_ACTIVE_HIGH>;
45		};
46	};
47
48	dc_12v: dc-12v {
49		compatible = "regulator-fixed";
50		regulator-name = "dc_12v";
51		regulator-always-on;
52		regulator-boot-on;
53		regulator-min-microvolt = <12000000>;
54		regulator-max-microvolt = <12000000>;
55	};
56
57	vcc3v3_sys: vcc3v3-sys {
58		compatible = "regulator-fixed";
59		regulator-name = "vcc3v3_sys";
60		regulator-always-on;
61		regulator-boot-on;
62		regulator-min-microvolt = <3300000>;
63		regulator-max-microvolt = <3300000>;
64		vin-supply = <&dc_12v>;
65	};
66
67	vcc5v0_sys: vcc5v0-sys {
68		compatible = "regulator-fixed";
69		regulator-name = "vcc5v0_sys";
70		regulator-always-on;
71		regulator-boot-on;
72		regulator-min-microvolt = <5000000>;
73		regulator-max-microvolt = <5000000>;
74		vin-supply = <&dc_12v>;
75	};
76
77	vcc5v0_usb: vcc5v0_usb {
78		compatible = "regulator-fixed";
79		regulator-name = "vcc5v0_usb";
80		regulator-always-on;
81		regulator-boot-on;
82		regulator-min-microvolt = <5000000>;
83		regulator-max-microvolt = <5000000>;
84		vin-supply = <&dc_12v>;
85	};
86
87	vcc5v0_usb_host: vcc5v0-usb-host {
88		compatible = "regulator-fixed";
89		enable-active-high;
90		gpio = <&gpio0 RK_PA6 GPIO_ACTIVE_HIGH>;
91		pinctrl-names = "default";
92		pinctrl-0 = <&vcc5v0_usb_host_en>;
93		regulator-name = "vcc5v0_usb_host";
94		regulator-min-microvolt = <5000000>;
95		regulator-max-microvolt = <5000000>;
96		vin-supply = <&vcc5v0_usb>;
97	};
98
99	vcc5v0_usb_otg: vcc5v0-usb-otg {
100		compatible = "regulator-fixed";
101		enable-active-high;
102		gpio = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>;
103		pinctrl-names = "default";
104		pinctrl-0 = <&vcc5v0_usb_otg_en>;
105		regulator-name = "vcc5v0_usb_otg";
106		regulator-min-microvolt = <5000000>;
107		regulator-max-microvolt = <5000000>;
108		vin-supply = <&vcc5v0_usb>;
109	};
110};
111
112&combphy0 {
113	/* used for USB3 */
114	status = "okay";
115};
116
117&combphy1 {
118	/* used for USB3 */
119	status = "okay";
120};
121
122&combphy2 {
123	/* used for SATA */
124	status = "okay";
125};
126
127&gmac0 {
128	assigned-clocks = <&cru SCLK_GMAC0_RX_TX>, <&cru SCLK_GMAC0>;
129	assigned-clock-parents = <&cru SCLK_GMAC0_RGMII_SPEED>, <&cru CLK_MAC0_2TOP>;
130	clock_in_out = "input";
131	phy-mode = "rgmii";
132	pinctrl-names = "default";
133	pinctrl-0 = <&gmac0_miim
134		     &gmac0_tx_bus2
135		     &gmac0_rx_bus2
136		     &gmac0_rgmii_clk
137		     &gmac0_rgmii_bus>;
138	snps,reset-gpio = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
139	snps,reset-active-low;
140	/* Reset time is 20ms, 100ms for rtl8211f */
141	snps,reset-delays-us = <0 20000 100000>;
142	tx_delay = <0x4f>;
143	rx_delay = <0x0f>;
144	status = "okay";
145
146	fixed-link {
147		speed = <1000>;
148		full-duplex;
149		pause;
150	};
151};
152
153&gmac1 {
154	assigned-clocks = <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1>;
155	assigned-clock-parents = <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru CLK_MAC1_2TOP>;
156	clock_in_out = "output";
157	phy-handle = <&rgmii_phy1>;
158	phy-mode = "rgmii";
159	pinctrl-names = "default";
160	pinctrl-0 = <&gmac1m1_miim
161		     &gmac1m1_tx_bus2
162		     &gmac1m1_rx_bus2
163		     &gmac1m1_rgmii_clk
164		     &gmac1m1_rgmii_bus>;
165
166	snps,reset-gpio = <&gpio3 RK_PB0 GPIO_ACTIVE_LOW>;
167	snps,reset-active-low;
168	/* Reset time is 20ms, 100ms for rtl8211f */
169	snps,reset-delays-us = <0 20000 100000>;
170
171	tx_delay = <0x3c>;
172	rx_delay = <0x2f>;
173
174	status = "okay";
175};
176
177&i2c0 {
178	status = "okay";
179
180	rk809: pmic@20 {
181		compatible = "rockchip,rk809";
182		reg = <0x20>;
183		interrupt-parent = <&gpio0>;
184		interrupts = <RK_PA3 IRQ_TYPE_LEVEL_LOW>;
185		#clock-cells = <1>;
186		pinctrl-names = "default";
187		pinctrl-0 = <&pmic_int>;
188		rockchip,system-power-controller;
189		vcc1-supply = <&vcc3v3_sys>;
190		vcc2-supply = <&vcc3v3_sys>;
191		vcc3-supply = <&vcc3v3_sys>;
192		vcc4-supply = <&vcc3v3_sys>;
193		vcc5-supply = <&vcc3v3_sys>;
194		vcc6-supply = <&vcc3v3_sys>;
195		vcc7-supply = <&vcc3v3_sys>;
196		vcc8-supply = <&vcc3v3_sys>;
197		vcc9-supply = <&vcc3v3_sys>;
198		wakeup-source;
199
200		regulators {
201			vdd_logic: DCDC_REG1 {
202				regulator-name = "vdd_logic";
203				regulator-always-on;
204				regulator-boot-on;
205				regulator-init-microvolt = <900000>;
206				regulator-initial-mode = <0x2>;
207				regulator-min-microvolt = <500000>;
208				regulator-max-microvolt = <1350000>;
209				regulator-ramp-delay = <6001>;
210
211				regulator-state-mem {
212					regulator-off-in-suspend;
213				};
214			};
215
216			vdd_gpu: DCDC_REG2 {
217				regulator-name = "vdd_gpu";
218				regulator-init-microvolt = <900000>;
219				regulator-initial-mode = <0x2>;
220				regulator-min-microvolt = <500000>;
221				regulator-max-microvolt = <1350000>;
222				regulator-ramp-delay = <6001>;
223
224				regulator-state-mem {
225					regulator-off-in-suspend;
226				};
227			};
228
229			vcc_ddr: DCDC_REG3 {
230				regulator-name = "vcc_ddr";
231				regulator-always-on;
232				regulator-boot-on;
233				regulator-initial-mode = <0x2>;
234
235				regulator-state-mem {
236					regulator-on-in-suspend;
237				};
238			};
239
240			vdd_npu: DCDC_REG4 {
241				regulator-name = "vdd_npu";
242				regulator-init-microvolt = <900000>;
243				regulator-initial-mode = <0x2>;
244				regulator-min-microvolt = <500000>;
245				regulator-max-microvolt = <1350000>;
246				regulator-ramp-delay = <6001>;
247
248				regulator-state-mem {
249					regulator-off-in-suspend;
250				};
251			};
252
253			vcc_1v8: DCDC_REG5 {
254				regulator-name = "vcc_1v8";
255				regulator-always-on;
256				regulator-boot-on;
257				regulator-min-microvolt = <1800000>;
258				regulator-max-microvolt = <1800000>;
259
260				regulator-state-mem {
261					regulator-off-in-suspend;
262				};
263			};
264
265			vdda0v9_image: LDO_REG1 {
266				regulator-name = "vdda0v9_image";
267				regulator-min-microvolt = <900000>;
268				regulator-max-microvolt = <900000>;
269
270				regulator-state-mem {
271					regulator-off-in-suspend;
272				};
273			};
274
275			vdda_0v9: LDO_REG2 {
276				regulator-name = "vdda_0v9";
277				regulator-always-on;
278				regulator-boot-on;
279				regulator-min-microvolt = <900000>;
280				regulator-max-microvolt = <900000>;
281
282				regulator-state-mem {
283					regulator-off-in-suspend;
284				};
285			};
286
287			vdda0v9_pmu: LDO_REG3 {
288				regulator-name = "vdda0v9_pmu";
289				regulator-always-on;
290				regulator-boot-on;
291				regulator-min-microvolt = <900000>;
292				regulator-max-microvolt = <900000>;
293
294				regulator-state-mem {
295					regulator-on-in-suspend;
296					regulator-suspend-microvolt = <900000>;
297				};
298			};
299
300			vccio_acodec: LDO_REG4 {
301				regulator-name = "vccio_acodec";
302				regulator-always-on;
303				regulator-boot-on;
304				regulator-min-microvolt = <3300000>;
305				regulator-max-microvolt = <3300000>;
306
307				regulator-state-mem {
308					regulator-off-in-suspend;
309				};
310			};
311
312			vccio_sd: LDO_REG5 {
313				regulator-name = "vccio_sd";
314				regulator-min-microvolt = <1800000>;
315				regulator-max-microvolt = <3300000>;
316
317				regulator-state-mem {
318					regulator-off-in-suspend;
319				};
320			};
321
322			vcc3v3_pmu: LDO_REG6 {
323				regulator-name = "vcc3v3_pmu";
324				regulator-always-on;
325				regulator-boot-on;
326				regulator-min-microvolt = <3300000>;
327				regulator-max-microvolt = <3300000>;
328
329				regulator-state-mem {
330					regulator-on-in-suspend;
331					regulator-suspend-microvolt = <3300000>;
332				};
333			};
334
335			vcca_1v8: LDO_REG7 {
336				regulator-name = "vcca_1v8";
337				regulator-always-on;
338				regulator-boot-on;
339				regulator-min-microvolt = <1800000>;
340				regulator-max-microvolt = <1800000>;
341
342				regulator-state-mem {
343					regulator-off-in-suspend;
344				};
345			};
346
347			vcca1v8_pmu: LDO_REG8 {
348				regulator-name = "vcca1v8_pmu";
349				regulator-always-on;
350				regulator-boot-on;
351				regulator-min-microvolt = <1800000>;
352				regulator-max-microvolt = <1800000>;
353
354				regulator-state-mem {
355					regulator-on-in-suspend;
356					regulator-suspend-microvolt = <1800000>;
357				};
358			};
359
360			vcca1v8_image: LDO_REG9 {
361				regulator-name = "vcca1v8_image";
362				regulator-min-microvolt = <1800000>;
363				regulator-max-microvolt = <1800000>;
364
365				regulator-state-mem {
366					regulator-off-in-suspend;
367				};
368			};
369
370			vcc_3v3: SWITCH_REG1 {
371				regulator-name = "vcc_3v3";
372				regulator-always-on;
373				regulator-boot-on;
374
375				regulator-state-mem {
376					regulator-off-in-suspend;
377				};
378			};
379
380			vcc3v3_sd: SWITCH_REG2 {
381				regulator-name = "vcc3v3_sd";
382				regulator-always-on;
383
384				regulator-state-mem {
385					regulator-off-in-suspend;
386				};
387			};
388		};
389	};
390};
391
392&i2c5 {
393	/* pin 3 (SDA) + 4 (SCL) of header con2 */
394	status = "disabled";
395};
396
397&mdio0 {
398	#address-cells = <1>;
399	#size-cells = <0>;
400
401	switch@0 {
402		compatible = "mediatek,mt7531";
403		reg = <0>;
404
405		ports {
406			#address-cells = <1>;
407			#size-cells = <0>;
408
409			port@1 {
410				reg = <1>;
411				label = "lan0";
412			};
413
414			port@2 {
415				reg = <2>;
416				label = "lan1";
417			};
418
419			port@3 {
420				reg = <3>;
421				label = "lan2";
422			};
423
424			port@4 {
425				reg = <4>;
426				label = "lan3";
427			};
428
429			port@5 {
430				reg = <5>;
431				label = "cpu";
432				ethernet = <&gmac0>;
433				phy-mode = "rgmii";
434
435				fixed-link {
436					speed = <1000>;
437					full-duplex;
438					pause;
439				};
440			};
441		};
442	};
443};
444
445&mdio1 {
446	rgmii_phy1: ethernet-phy@0 {
447		compatible = "ethernet-phy-ieee802.3-c22";
448		reg = <0x0>;
449	};
450};
451
452&pinctrl {
453	leds {
454		blue_led_pin: blue-led-pin {
455			rockchip,pins = <0 RK_PD6 RK_FUNC_GPIO &pcfg_pull_none>;
456		};
457		green_led_pin: green-led-pin {
458			rockchip,pins = <0 RK_PD5 RK_FUNC_GPIO &pcfg_pull_none>;
459		};
460	};
461
462	pmic {
463		pmic_int: pmic_int {
464			rockchip,pins =
465				<0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>;
466		};
467	};
468
469	usb {
470		vcc5v0_usb_host_en: vcc5v0_usb_host_en {
471			rockchip,pins = <0 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>;
472		};
473
474		vcc5v0_usb_otg_en: vcc5v0_usb_otg_en {
475			rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_none>;
476		};
477	};
478};
479
480&pmu_io_domains {
481	pmuio1-supply = <&vcc3v3_pmu>;
482	pmuio2-supply = <&vcc3v3_pmu>;
483	vccio1-supply = <&vccio_acodec>;
484	vccio3-supply = <&vccio_sd>;
485	vccio4-supply = <&vcc_3v3>;
486	vccio5-supply = <&vcc_3v3>;
487	vccio6-supply = <&vcc_1v8>;
488	vccio7-supply = <&vcc_3v3>;
489	status = "okay";
490};
491
492&pwm8 {
493	/* fan 5v - gnd - pwm */
494	status = "okay";
495};
496
497&pwm10 {
498	/* pin 7 of header con2 */
499	status = "disabled";
500};
501
502&pwm11 {
503	/* pin 15 of header con2 */
504	status = "disabled";
505};
506
507&pwm12 {
508	/* pin 21 of header con2 */
509	/* shared with uart9 + spi3 */
510	pinctrl-0 = <&pwm12m1_pins>;
511	status = "disabled";
512};
513
514&pwm13 {
515	/* pin 24 of header con2 */
516	/* shared with uart9 */
517	pinctrl-0 = <&pwm13m1_pins>;
518	status = "disabled";
519};
520
521&pwm14 {
522	/* pin 23 of header con2 */
523	/* shared with spi3 */
524	pinctrl-0 = <&pwm14m1_pins>;
525	status = "disabled";
526};
527
528&pwm15 {
529	/* pin 19 of header con2 */
530	/* shared with spi3 */
531	pinctrl-0 = <&pwm15m1_pins>;
532	status = "disabled";
533};
534
535&saradc {
536	vref-supply = <&vcca_1v8>;
537	status = "okay";
538};
539
540&sata2 {
541	status = "okay";
542};
543
544&sdhci {
545	bus-width = <8>;
546	max-frequency = <200000000>;
547	non-removable;
548	pinctrl-names = "default";
549	pinctrl-0 = <&emmc_bus8 &emmc_clk &emmc_cmd &emmc_datastrobe>;
550	status = "okay";
551};
552
553&sdmmc0 {
554	bus-width = <4>;
555	cap-sd-highspeed;
556	cd-gpios = <&gpio0 RK_PA4 GPIO_ACTIVE_LOW>;
557	disable-wp;
558	pinctrl-names = "default";
559	pinctrl-0 = <&sdmmc0_bus4 &sdmmc0_clk &sdmmc0_cmd &sdmmc0_det>;
560	sd-uhs-sdr104;
561	vmmc-supply = <&vcc3v3_sd>;
562	vqmmc-supply = <&vccio_sd>;
563	status = "okay";
564};
565
566&spi3 {
567	/* pin 19 (MO) + 21 (MI) + 23 (CK) of header con2 */
568	/* shared with pwm12/14/15 and uart9 */
569	pinctrl-0 = <&spi3m1_pins>;
570	status = "disabled";
571};
572
573&tsadc {
574	status = "okay";
575};
576
577&uart0 {
578	/* pin 8 (TX) + 10 (RX) (RTS:16, CTS:18) of header con2 */
579	status = "disabled";
580};
581
582&uart2 {
583	/* debug-uart */
584	status = "okay";
585};
586
587&uart7 {
588	/* pin 11 (TX) + 13 (RX) of header con2 */
589	pinctrl-0 = <&uart7m1_xfer>;
590	status = "disabled";
591};
592
593&uart9 {
594	/* pin 21 (TX) + 24 (RX) of header con2 */
595	/* shared with pwm13 and pwm12/spi3 */
596	pinctrl-0 = <&uart9m1_xfer>;
597	status = "disabled";
598};
599
600&usb_host0_ehci {
601	status = "okay";
602};
603
604&usb_host0_ohci {
605	status = "okay";
606};
607
608&usb_host0_xhci {
609	extcon = <&usb2phy0>;
610	status = "okay";
611};
612
613&usb_host1_ehci {
614	status = "okay";
615};
616
617&usb_host1_ohci {
618	status = "okay";
619};
620
621&usb_host1_xhci {
622	status = "okay";
623};
624
625&usb2phy0 {
626	status = "okay";
627};
628
629&usb2phy0_host {
630	phy-supply = <&vcc5v0_usb_host>;
631	status = "okay";
632};
633
634&usb2phy0_otg {
635	phy-supply = <&vcc5v0_usb_otg>;
636	status = "okay";
637};
638