1// SPDX-License-Identifier: (GPL-2.0+ or MIT)
2/*
3 * Copyright (C) 2020 Arm Ltd.
4 */
5
6/dts-v1/;
7
8#include "sun50i-h616.dtsi"
9
10#include <dt-bindings/gpio/gpio.h>
11#include <dt-bindings/interrupt-controller/arm-gic.h>
12#include <dt-bindings/leds/common.h>
13
14/ {
15	model = "OrangePi Zero2";
16	compatible = "xunlong,orangepi-zero2", "allwinner,sun50i-h616";
17
18	aliases {
19		ethernet0 = &emac0;
20		serial0 = &uart0;
21	};
22
23	chosen {
24		stdout-path = "serial0:115200n8";
25	};
26
27	leds {
28		compatible = "gpio-leds";
29
30		led-0 {
31			function = LED_FUNCTION_POWER;
32			color = <LED_COLOR_ID_RED>;
33			gpios = <&pio 2 12 GPIO_ACTIVE_HIGH>; /* PC12 */
34			default-state = "on";
35		};
36
37		led-1 {
38			function = LED_FUNCTION_STATUS;
39			color = <LED_COLOR_ID_GREEN>;
40			gpios = <&pio 2 13 GPIO_ACTIVE_HIGH>; /* PC13 */
41		};
42	};
43
44	reg_vcc5v: vcc5v {
45		/* board wide 5V supply directly from the USB-C socket */
46		compatible = "regulator-fixed";
47		regulator-name = "vcc-5v";
48		regulator-min-microvolt = <5000000>;
49		regulator-max-microvolt = <5000000>;
50		regulator-always-on;
51	};
52
53	reg_usb1_vbus: regulator-usb1-vbus {
54		compatible = "regulator-fixed";
55		regulator-name = "usb1-vbus";
56		regulator-min-microvolt = <5000000>;
57		regulator-max-microvolt = <5000000>;
58		vin-supply = <&reg_vcc5v>;
59		enable-active-high;
60		gpio = <&pio 2 16 GPIO_ACTIVE_HIGH>; /* PC16 */
61	};
62};
63
64&ehci1 {
65	status = "okay";
66};
67
68/* USB 2 & 3 are on headers only. */
69
70&emac0 {
71	pinctrl-names = "default";
72	pinctrl-0 = <&ext_rgmii_pins>;
73	phy-mode = "rgmii";
74	phy-handle = <&ext_rgmii_phy>;
75	phy-supply = <&reg_dcdce>;
76	allwinner,rx-delay-ps = <3100>;
77	allwinner,tx-delay-ps = <700>;
78	status = "okay";
79};
80
81&mdio0 {
82	ext_rgmii_phy: ethernet-phy@1 {
83		compatible = "ethernet-phy-ieee802.3-c22";
84		reg = <1>;
85	};
86};
87
88&mmc0 {
89	vmmc-supply = <&reg_dcdce>;
90	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;	/* PF6 */
91	bus-width = <4>;
92	status = "okay";
93};
94
95&ohci1 {
96	status = "okay";
97};
98
99&r_rsb {
100	status = "okay";
101
102	axp305: pmic@745 {
103		compatible = "x-powers,axp305", "x-powers,axp805",
104			     "x-powers,axp806";
105		interrupt-controller;
106		#interrupt-cells = <1>;
107		reg = <0x745>;
108
109		x-powers,self-working-mode;
110		vina-supply = <&reg_vcc5v>;
111		vinb-supply = <&reg_vcc5v>;
112		vinc-supply = <&reg_vcc5v>;
113		vind-supply = <&reg_vcc5v>;
114		vine-supply = <&reg_vcc5v>;
115		aldoin-supply = <&reg_vcc5v>;
116		bldoin-supply = <&reg_vcc5v>;
117		cldoin-supply = <&reg_vcc5v>;
118
119		regulators {
120			reg_aldo1: aldo1 {
121				regulator-always-on;
122				regulator-min-microvolt = <3300000>;
123				regulator-max-microvolt = <3300000>;
124				regulator-name = "vcc-sys";
125			};
126
127			reg_aldo2: aldo2 {	/* 3.3V on headers */
128				regulator-always-on;
129				regulator-min-microvolt = <3300000>;
130				regulator-max-microvolt = <3300000>;
131				regulator-name = "vcc3v3-ext";
132			};
133
134			reg_aldo3: aldo3 {	/* 3.3V on headers */
135				regulator-always-on;
136				regulator-min-microvolt = <3300000>;
137				regulator-max-microvolt = <3300000>;
138				regulator-name = "vcc3v3-ext2";
139			};
140
141			reg_bldo1: bldo1 {
142				regulator-always-on;
143				regulator-min-microvolt = <1800000>;
144				regulator-max-microvolt = <1800000>;
145				regulator-name = "vcc1v8";
146			};
147
148			bldo2 {
149				/* unused */
150			};
151
152			bldo3 {
153				/* unused */
154			};
155
156			bldo4 {
157				/* unused */
158			};
159
160			cldo1 {
161				/* reserved */
162			};
163
164			cldo2 {
165				/* unused */
166			};
167
168			cldo3 {
169				/* unused */
170			};
171
172			reg_dcdca: dcdca {
173				regulator-always-on;
174				regulator-min-microvolt = <810000>;
175				regulator-max-microvolt = <1100000>;
176				regulator-name = "vdd-cpu";
177			};
178
179			reg_dcdcc: dcdcc {
180				regulator-always-on;
181				regulator-min-microvolt = <810000>;
182				regulator-max-microvolt = <990000>;
183				regulator-name = "vdd-gpu-sys";
184			};
185
186			reg_dcdcd: dcdcd {
187				regulator-always-on;
188				regulator-min-microvolt = <1500000>;
189				regulator-max-microvolt = <1500000>;
190				regulator-name = "vdd-dram";
191			};
192
193			reg_dcdce: dcdce {
194				regulator-always-on;
195				regulator-min-microvolt = <3300000>;
196				regulator-max-microvolt = <3300000>;
197				regulator-name = "vcc-eth-mmc";
198			};
199
200			sw {
201				/* unused */
202			};
203		};
204	};
205};
206
207&pio {
208	vcc-pc-supply = <&reg_aldo1>;
209	vcc-pf-supply = <&reg_aldo1>;
210	vcc-pg-supply = <&reg_bldo1>;
211	vcc-ph-supply = <&reg_aldo1>;
212	vcc-pi-supply = <&reg_aldo1>;
213};
214
215&spi0  {
216	status = "okay";
217	pinctrl-names = "default";
218	pinctrl-0 = <&spi0_pins>, <&spi0_cs0_pin>;
219
220	flash@0 {
221		#address-cells = <1>;
222		#size-cells = <1>;
223		compatible = "jedec,spi-nor";
224		reg = <0>;
225		spi-max-frequency = <40000000>;
226	};
227};
228
229&uart0 {
230	pinctrl-names = "default";
231	pinctrl-0 = <&uart0_ph_pins>;
232	status = "okay";
233};
234
235&usbotg {
236	/*
237	 * PHY0 pins are connected to a USB-C socket, but a role switch
238	 * is not implemented: both CC pins are pulled to GND.
239	 * The VBUS pins power the device, so a fixed peripheral mode
240	 * is the best choice.
241	 * The board can be powered via GPIOs, in this case port0 *can*
242	 * act as a host (with a cable/adapter ignoring CC), as VBUS is
243	 * then provided by the GPIOs. Any user of this setup would
244	 * need to adjust the DT accordingly: dr_mode set to "host",
245	 * enabling OHCI0 and EHCI0.
246	 */
247	dr_mode = "peripheral";
248	status = "okay";
249};
250
251&usbphy {
252	usb1_vbus-supply = <&reg_usb1_vbus>;
253	status = "okay";
254};
255