1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2020 David Bauer <mail@david-bauer.net>
4 */
5
6/dts-v1/;
7
8#include <dt-bindings/input/input.h>
9#include <dt-bindings/gpio/gpio.h>
10#include "rk3328.dtsi"
11
12/ {
13	model = "FriendlyElec NanoPi R2S";
14	compatible = "friendlyarm,nanopi-r2s", "rockchip,rk3328";
15
16	chosen {
17		stdout-path = "serial2:1500000n8";
18	};
19
20	gmac_clk: gmac-clock {
21		compatible = "fixed-clock";
22		clock-frequency = <125000000>;
23		clock-output-names = "gmac_clkin";
24		#clock-cells = <0>;
25	};
26
27	keys {
28		compatible = "gpio-keys";
29		pinctrl-0 = <&reset_button_pin>;
30		pinctrl-names = "default";
31
32		reset {
33			label = "reset";
34			gpios = <&gpio0 RK_PA0 GPIO_ACTIVE_LOW>;
35			linux,code = <KEY_RESTART>;
36			debounce-interval = <50>;
37		};
38	};
39
40	leds {
41		compatible = "gpio-leds";
42		pinctrl-0 = <&lan_led_pin>,  <&sys_led_pin>, <&wan_led_pin>;
43		pinctrl-names = "default";
44
45		lan_led: led-0 {
46			gpios = <&gpio2 RK_PB7 GPIO_ACTIVE_HIGH>;
47			label = "nanopi-r2s:green:lan";
48		};
49
50		sys_led: led-1 {
51			gpios = <&gpio0 RK_PA2 GPIO_ACTIVE_HIGH>;
52			label = "nanopi-r2s:red:sys";
53			default-state = "on";
54		};
55
56		wan_led: led-2 {
57			gpios = <&gpio2 RK_PC2 GPIO_ACTIVE_HIGH>;
58			label = "nanopi-r2s:green:wan";
59		};
60	};
61
62	vcc_io_sdio: sdmmcio-regulator {
63		compatible = "regulator-gpio";
64		enable-active-high;
65		gpios = <&gpio1 RK_PD4 GPIO_ACTIVE_HIGH>;
66		pinctrl-0 = <&sdio_vcc_pin>;
67		pinctrl-names = "default";
68		regulator-name = "vcc_io_sdio";
69		regulator-always-on;
70		regulator-min-microvolt = <1800000>;
71		regulator-max-microvolt = <3300000>;
72		regulator-settling-time-us = <5000>;
73		regulator-type = "voltage";
74		startup-delay-us = <2000>;
75		states = <1800000 0x1
76			  3300000 0x0>;
77		vin-supply = <&vcc_io_33>;
78	};
79
80	vcc_sd: sdmmc-regulator {
81		compatible = "regulator-fixed";
82		gpio = <&gpio0 RK_PD6 GPIO_ACTIVE_LOW>;
83		pinctrl-0 = <&sdmmc0m1_pin>;
84		pinctrl-names = "default";
85		regulator-name = "vcc_sd";
86		regulator-boot-on;
87		regulator-min-microvolt = <3300000>;
88		regulator-max-microvolt = <3300000>;
89		vin-supply = <&vcc_io_33>;
90	};
91
92	vdd_5v: vdd-5v {
93		compatible = "regulator-fixed";
94		regulator-name = "vdd_5v";
95		regulator-always-on;
96		regulator-boot-on;
97		regulator-min-microvolt = <5000000>;
98		regulator-max-microvolt = <5000000>;
99	};
100};
101
102&cpu0 {
103	cpu-supply = <&vdd_arm>;
104};
105
106&cpu1 {
107	cpu-supply = <&vdd_arm>;
108};
109
110&cpu2 {
111	cpu-supply = <&vdd_arm>;
112};
113
114&cpu3 {
115	cpu-supply = <&vdd_arm>;
116};
117
118&display_subsystem {
119	status = "disabled";
120};
121
122&gmac2io {
123	assigned-clocks = <&cru SCLK_MAC2IO>, <&cru SCLK_MAC2IO_EXT>;
124	assigned-clock-parents = <&gmac_clk>, <&gmac_clk>;
125	clock_in_out = "input";
126	phy-handle = <&rtl8211e>;
127	phy-mode = "rgmii";
128	phy-supply = <&vcc_io_33>;
129	pinctrl-0 = <&rgmiim1_pins>;
130	pinctrl-names = "default";
131	rx_delay = <0x18>;
132	snps,aal;
133	tx_delay = <0x24>;
134	status = "okay";
135
136	mdio {
137		compatible = "snps,dwmac-mdio";
138		#address-cells = <1>;
139		#size-cells = <0>;
140
141		rtl8211e: ethernet-phy@1 {
142			reg = <1>;
143			pinctrl-0 = <&eth_phy_reset_pin>;
144			pinctrl-names = "default";
145			reset-assert-us = <10000>;
146			reset-deassert-us = <50000>;
147			reset-gpios = <&gpio1 RK_PC2 GPIO_ACTIVE_LOW>;
148		};
149	};
150};
151
152&i2c1 {
153	status = "okay";
154
155	rk805: pmic@18 {
156		compatible = "rockchip,rk805";
157		reg = <0x18>;
158		interrupt-parent = <&gpio1>;
159		interrupts = <24 IRQ_TYPE_LEVEL_LOW>;
160		#clock-cells = <1>;
161		clock-output-names = "xin32k", "rk805-clkout2";
162		gpio-controller;
163		#gpio-cells = <2>;
164		pinctrl-0 = <&pmic_int_l>;
165		pinctrl-names = "default";
166		rockchip,system-power-controller;
167		wakeup-source;
168
169		vcc1-supply = <&vdd_5v>;
170		vcc2-supply = <&vdd_5v>;
171		vcc3-supply = <&vdd_5v>;
172		vcc4-supply = <&vdd_5v>;
173		vcc5-supply = <&vcc_io_33>;
174		vcc6-supply = <&vdd_5v>;
175
176		regulators {
177			vdd_log: DCDC_REG1 {
178				regulator-name = "vdd_log";
179				regulator-always-on;
180				regulator-boot-on;
181				regulator-min-microvolt = <712500>;
182				regulator-max-microvolt = <1450000>;
183				regulator-ramp-delay = <12500>;
184
185				regulator-state-mem {
186					regulator-on-in-suspend;
187					regulator-suspend-microvolt = <1000000>;
188				};
189			};
190
191			vdd_arm: DCDC_REG2 {
192				regulator-name = "vdd_arm";
193				regulator-always-on;
194				regulator-boot-on;
195				regulator-min-microvolt = <712500>;
196				regulator-max-microvolt = <1450000>;
197				regulator-ramp-delay = <12500>;
198
199				regulator-state-mem {
200					regulator-on-in-suspend;
201					regulator-suspend-microvolt = <950000>;
202				};
203			};
204
205			vcc_ddr: DCDC_REG3 {
206				regulator-name = "vcc_ddr";
207				regulator-always-on;
208				regulator-boot-on;
209
210				regulator-state-mem {
211					regulator-on-in-suspend;
212				};
213			};
214
215			vcc_io_33: DCDC_REG4 {
216				regulator-name = "vcc_io_33";
217				regulator-always-on;
218				regulator-boot-on;
219				regulator-min-microvolt = <3300000>;
220				regulator-max-microvolt = <3300000>;
221
222				regulator-state-mem {
223					regulator-on-in-suspend;
224					regulator-suspend-microvolt = <3300000>;
225				};
226			};
227
228			vcc_18: LDO_REG1 {
229				regulator-name = "vcc_18";
230				regulator-always-on;
231				regulator-boot-on;
232				regulator-min-microvolt = <1800000>;
233				regulator-max-microvolt = <1800000>;
234
235				regulator-state-mem {
236					regulator-on-in-suspend;
237					regulator-suspend-microvolt = <1800000>;
238				};
239			};
240
241			vcc18_emmc: LDO_REG2 {
242				regulator-name = "vcc18_emmc";
243				regulator-always-on;
244				regulator-boot-on;
245				regulator-min-microvolt = <1800000>;
246				regulator-max-microvolt = <1800000>;
247
248				regulator-state-mem {
249					regulator-on-in-suspend;
250					regulator-suspend-microvolt = <1800000>;
251				};
252			};
253
254			vdd_10: LDO_REG3 {
255				regulator-name = "vdd_10";
256				regulator-always-on;
257				regulator-boot-on;
258				regulator-min-microvolt = <1000000>;
259				regulator-max-microvolt = <1000000>;
260
261				regulator-state-mem {
262					regulator-on-in-suspend;
263					regulator-suspend-microvolt = <1000000>;
264				};
265			};
266		};
267	};
268};
269
270&io_domains {
271	pmuio-supply = <&vcc_io_33>;
272	vccio1-supply = <&vcc_io_33>;
273	vccio2-supply = <&vcc18_emmc>;
274	vccio3-supply = <&vcc_io_sdio>;
275	vccio4-supply = <&vcc_18>;
276	vccio5-supply = <&vcc_io_33>;
277	vccio6-supply = <&vcc_io_33>;
278	status = "okay";
279};
280
281&pinctrl {
282	button {
283		reset_button_pin: reset-button-pin {
284			rockchip,pins = <0 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>;
285		};
286	};
287
288	gmac2io {
289		eth_phy_reset_pin: eth-phy-reset-pin {
290			rockchip,pins = <1 RK_PC2 RK_FUNC_GPIO &pcfg_pull_down>;
291		};
292	};
293
294	leds {
295		lan_led_pin: lan-led-pin {
296			rockchip,pins = <2 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>;
297		};
298
299		sys_led_pin: sys-led-pin {
300			rockchip,pins = <0 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>;
301		};
302
303		wan_led_pin: wan-led-pin {
304			rockchip,pins = <2 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>;
305		};
306	};
307
308	pmic {
309		pmic_int_l: pmic-int-l {
310			rockchip,pins = <1 RK_PD0 RK_FUNC_GPIO &pcfg_pull_up>;
311		};
312	};
313
314	sd {
315		sdio_vcc_pin: sdio-vcc-pin {
316			rockchip,pins = <1 RK_PD4 RK_FUNC_GPIO &pcfg_pull_up>;
317		};
318	};
319};
320
321&pwm2 {
322	status = "okay";
323};
324
325&sdmmc {
326	bus-width = <4>;
327	cap-sd-highspeed;
328	disable-wp;
329	pinctrl-0 = <&sdmmc0_clk>, <&sdmmc0_cmd>, <&sdmmc0_dectn>, <&sdmmc0_bus4>;
330	pinctrl-names = "default";
331	sd-uhs-sdr12;
332	sd-uhs-sdr25;
333	sd-uhs-sdr50;
334	sd-uhs-sdr104;
335	vmmc-supply = <&vcc_sd>;
336	vqmmc-supply = <&vcc_io_sdio>;
337	status = "okay";
338};
339
340&tsadc {
341	rockchip,hw-tshut-mode = <0>;
342	rockchip,hw-tshut-polarity = <0>;
343	status = "okay";
344};
345
346&u2phy {
347	status = "okay";
348};
349
350&u2phy_host {
351	status = "okay";
352};
353
354&u2phy_otg {
355	status = "okay";
356};
357
358&uart2 {
359	status = "okay";
360};
361
362&usb20_otg {
363	status = "okay";
364	dr_mode = "host";
365};
366
367&usb_host0_ehci {
368	status = "okay";
369};
370
371&usb_host0_ohci {
372	status = "okay";
373};
374