1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (C) 2021 Chukun Pan <amadeus@jmu.edu.cn>
4 *
5 * Based on sun50i-h5-nanopi-neo-plus2.dts, which is:
6 *   Copyright (C) 2017 Antony Antony <antony@phenome.org>
7 *   Copyright (C) 2016 ARM Ltd.
8 */
9
10/dts-v1/;
11#include "sun50i-h5.dtsi"
12#include "sun50i-h5-cpu-opp.dtsi"
13
14#include <dt-bindings/gpio/gpio.h>
15#include <dt-bindings/input/input.h>
16#include <dt-bindings/leds/common.h>
17
18/ {
19	model = "FriendlyARM NanoPi R1S H5";
20	compatible = "friendlyarm,nanopi-r1s-h5", "allwinner,sun50i-h5";
21
22	aliases {
23		ethernet0 = &emac;
24		ethernet1 = &rtl8189etv;
25		serial0 = &uart0;
26	};
27
28	chosen {
29		stdout-path = "serial0:115200n8";
30	};
31
32	leds {
33		compatible = "gpio-leds";
34
35		led-0 {
36			function = LED_FUNCTION_LAN;
37			color = <LED_COLOR_ID_GREEN>;
38			gpios = <&pio 0 9 GPIO_ACTIVE_HIGH>;
39		};
40
41		led-1 {
42			function = LED_FUNCTION_STATUS;
43			color = <LED_COLOR_ID_RED>;
44			gpios = <&pio 0 10 GPIO_ACTIVE_HIGH>;
45			linux,default-trigger = "heartbeat";
46		};
47
48		led-2 {
49			function = LED_FUNCTION_WAN;
50			color = <LED_COLOR_ID_GREEN>;
51			gpios = <&pio 6 11 GPIO_ACTIVE_HIGH>;
52		};
53	};
54
55	gpio-keys {
56		compatible = "gpio-keys";
57
58		key-reset {
59			label = "reset";
60			linux,code = <KEY_RESTART>;
61			gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
62		};
63	};
64
65	reg_gmac_3v3: gmac-3v3 {
66		compatible = "regulator-fixed";
67		regulator-name = "gmac-3v3";
68		regulator-min-microvolt = <3300000>;
69		regulator-max-microvolt = <3300000>;
70		startup-delay-us = <100000>;
71		enable-active-high;
72		gpio = <&pio 3 6 GPIO_ACTIVE_HIGH>;
73	};
74
75	reg_vcc3v3: vcc3v3 {
76		compatible = "regulator-fixed";
77		regulator-name = "vcc3v3";
78		regulator-min-microvolt = <3300000>;
79		regulator-max-microvolt = <3300000>;
80	};
81
82	reg_usb0_vbus: usb0-vbus {
83		compatible = "regulator-fixed";
84		regulator-name = "usb0-vbus";
85		regulator-min-microvolt = <5000000>;
86		regulator-max-microvolt = <5000000>;
87		enable-active-high;
88		gpio = <&r_pio 0 2 GPIO_ACTIVE_HIGH>; /* PL2 */
89		status = "okay";
90	};
91
92	vdd_cpux: gpio-regulator {
93		compatible = "regulator-gpio";
94		regulator-name = "vdd-cpux";
95		regulator-type = "voltage";
96		regulator-boot-on;
97		regulator-always-on;
98		regulator-min-microvolt = <1100000>;
99		regulator-max-microvolt = <1300000>;
100		regulator-ramp-delay = <50>; /* 4ms */
101		gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>;
102		gpios-states = <0x1>;
103		states = <1100000 0x0>, <1300000 0x1>;
104	};
105
106	wifi_pwrseq: wifi_pwrseq {
107		compatible = "mmc-pwrseq-simple";
108		reset-gpios = <&r_pio 0 7 GPIO_ACTIVE_LOW>; /* PL7 */
109		post-power-on-delay-ms = <200>;
110	};
111};
112
113&cpu0 {
114	cpu-supply = <&vdd_cpux>;
115};
116
117&ehci1 {
118	status = "okay";
119};
120
121&ehci2 {
122	status = "okay";
123};
124
125&emac {
126	pinctrl-names = "default";
127	pinctrl-0 = <&emac_rgmii_pins>;
128	phy-supply = <&reg_gmac_3v3>;
129	phy-handle = <&ext_rgmii_phy>;
130	phy-mode = "rgmii-id";
131	status = "okay";
132};
133
134&external_mdio {
135	ext_rgmii_phy: ethernet-phy@7 {
136		compatible = "ethernet-phy-ieee802.3-c22";
137		reg = <7>;
138	};
139};
140
141&i2c0 {
142	status = "okay";
143
144	eeprom@51 {
145		compatible = "microchip,24c02", "atmel,24c02";
146		reg = <0x51>;
147		pagesize = <16>;
148		read-only;
149		#address-cells = <1>;
150		#size-cells = <1>;
151
152		eth_mac1: mac-address@fa {
153			reg = <0xfa 0x06>;
154		};
155	};
156};
157
158&mmc0 {
159	vmmc-supply = <&reg_vcc3v3>;
160	bus-width = <4>;
161	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
162	status = "okay";
163};
164
165&mmc1 {
166	vmmc-supply = <&reg_vcc3v3>;
167	vqmmc-supply = <&reg_vcc3v3>;
168	mmc-pwrseq = <&wifi_pwrseq>;
169	bus-width = <4>;
170	non-removable;
171	status = "okay";
172
173	rtl8189etv: sdio_wifi@1 {
174		reg = <1>;
175	};
176};
177
178&ohci1 {
179	status = "okay";
180};
181
182&ohci2 {
183	status = "okay";
184};
185
186&uart0 {
187	pinctrl-names = "default";
188	pinctrl-0 = <&uart0_pa_pins>;
189	status = "okay";
190};
191
192&usb_otg {
193	dr_mode = "peripheral";
194	status = "okay";
195};
196
197&usbphy {
198	/* USB Type-A port's VBUS is always on */
199	usb0_id_det-gpios = <&pio 6 12 GPIO_ACTIVE_HIGH>; /* PG12 */
200	usb0_vbus-supply = <&reg_usb0_vbus>;
201	status = "okay";
202};
203