1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (C) 2023 Arm Ltd.
4 */
5
6/dts-v1/;
7
8#include "sun50i-h616.dtsi"
9#include "sun50i-h616-cpu-opp.dtsi"
10
11#include <dt-bindings/gpio/gpio.h>
12#include <dt-bindings/interrupt-controller/arm-gic.h>
13#include <dt-bindings/leds/common.h>
14
15/ {
16	model = "OrangePi Zero 2W";
17	compatible = "xunlong,orangepi-zero2w", "allwinner,sun50i-h618";
18
19	aliases {
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_STATUS;
32			color = <LED_COLOR_ID_GREEN>;
33			gpios = <&pio 2 13 GPIO_ACTIVE_HIGH>; /* PC13 */
34		};
35	};
36
37	reg_vcc5v: vcc5v {
38		/* board wide 5V supply directly from the USB-C socket */
39		compatible = "regulator-fixed";
40		regulator-name = "vcc-5v";
41		regulator-min-microvolt = <5000000>;
42		regulator-max-microvolt = <5000000>;
43		regulator-always-on;
44	};
45
46	reg_vcc3v3: vcc3v3 {
47		/* SY8089 DC/DC converter */
48		compatible = "regulator-fixed";
49		regulator-name = "vcc-3v3";
50		regulator-min-microvolt = <3300000>;
51		regulator-max-microvolt = <3300000>;
52		vin-supply = <&reg_vcc5v>;
53		regulator-always-on;
54	};
55};
56
57&cpu0 {
58	cpu-supply = <&reg_dcdc2>;
59};
60
61&ehci1 {
62	status = "okay";
63};
64
65/* USB 2 & 3 are on the FPC connector (or the exansion board) */
66
67&mmc0 {
68	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;	/* PF6 */
69	bus-width = <4>;
70	vmmc-supply = <&reg_vcc3v3>;
71	status = "okay";
72};
73
74&ohci1 {
75	status = "okay";
76};
77
78&pio {
79	vcc-pc-supply = <&reg_dldo1>;
80	vcc-pf-supply = <&reg_dldo1>;	/* internally via VCC-IO */
81	vcc-pg-supply = <&reg_aldo1>;
82	vcc-ph-supply = <&reg_dldo1>;	/* internally via VCC-IO */
83	vcc-pi-supply = <&reg_dldo1>;
84};
85
86&r_i2c {
87	status = "okay";
88
89	axp313: pmic@36 {
90		compatible = "x-powers,axp313a";
91		reg = <0x36>;
92		#interrupt-cells = <1>;
93		interrupt-controller;
94		interrupt-parent = <&pio>;
95		interrupts = <2 9 IRQ_TYPE_LEVEL_LOW>;	/* PC9 */
96
97		vin1-supply = <&reg_vcc5v>;
98		vin2-supply = <&reg_vcc5v>;
99		vin3-supply = <&reg_vcc5v>;
100
101		regulators {
102			/* Supplies VCC-PLL and DRAM */
103			reg_aldo1: aldo1 {
104				regulator-always-on;
105				regulator-min-microvolt = <1800000>;
106				regulator-max-microvolt = <1800000>;
107				regulator-name = "vcc1v8";
108			};
109
110			/* Supplies VCC-IO, so needs to be always on. */
111			reg_dldo1: dldo1 {
112				regulator-always-on;
113				regulator-min-microvolt = <3300000>;
114				regulator-max-microvolt = <3300000>;
115				regulator-name = "vcc3v3";
116			};
117
118			reg_dcdc1: dcdc1 {
119				regulator-always-on;
120				regulator-min-microvolt = <810000>;
121				regulator-max-microvolt = <990000>;
122				regulator-name = "vdd-gpu-sys";
123			};
124
125			reg_dcdc2: dcdc2 {
126				regulator-always-on;
127				regulator-min-microvolt = <810000>;
128				regulator-max-microvolt = <1100000>;
129				regulator-name = "vdd-cpu";
130			};
131
132			reg_dcdc3: dcdc3 {
133				regulator-always-on;
134				regulator-min-microvolt = <1100000>;
135				regulator-max-microvolt = <1100000>;
136				regulator-name = "vdd-dram";
137			};
138		};
139	};
140};
141
142&spi0  {
143	status = "okay";
144	pinctrl-names = "default";
145	pinctrl-0 = <&spi0_pins>, <&spi0_cs0_pin>;
146
147	flash@0 {
148		#address-cells = <1>;
149		#size-cells = <1>;
150		compatible = "jedec,spi-nor";
151		reg = <0>;
152		spi-max-frequency = <40000000>;
153	};
154};
155
156&uart0 {
157	pinctrl-names = "default";
158	pinctrl-0 = <&uart0_ph_pins>;
159	status = "okay";
160};
161
162&usbotg {
163	/*
164	 * PHY0 pins are connected to a USB-C socket, but a role switch
165	 * is not implemented: both CC pins are pulled to GND.
166	 * The VBUS pins power the device, so a fixed peripheral mode
167	 * is the best choice.
168	 * The board can be powered via GPIOs, in this case port0 *can*
169	 * act as a host (with a cable/adapter ignoring CC), as VBUS is
170	 * then provided by the GPIOs. Any user of this setup would
171	 * need to adjust the DT accordingly: dr_mode set to "host",
172	 * enabling OHCI0 and EHCI0.
173	 */
174	dr_mode = "peripheral";
175	status = "okay";
176};
177
178&usbphy {
179	usb1_vbus-supply = <&reg_vcc5v>;
180	status = "okay";
181};
182