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