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