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