d1: add new target
[openwrt/staging/mans0n.git] / target / linux / d1 / patches-6.1 / 0029-riscv-dts-allwinner-Add-Allwinner-D1-Nezha-devicetre.patch
1 From 5da27190c54b7a51062786eb01246f6f4cf2ba98 Mon Sep 17 00:00:00 2001
2 From: Samuel Holland <samuel@sholland.org>
3 Date: Tue, 28 Jun 2022 23:31:16 -0500
4 Subject: [PATCH 029/117] riscv: dts: allwinner: Add Allwinner D1 Nezha
5 devicetree
6
7 "D1 Nezha" is Allwinner's first-party development board for the D1 SoC.
8 It was shipped with 512M, 1G, or 2G of DDR3. It supports onboard audio,
9 HDMI, gigabit Ethernet, WiFi and Bluetooth, USB 2.0 host and OTG ports,
10 plus low-speed I/O from the SoC and a GPIO expander chip.
11
12 Most other D1 boards copied the Nezha's power tree, with the 1.8V rail
13 powered by the SoCs internal LDOA, analog domains powered by ALDO, and
14 the rest of the board powered by always-on fixed regulators. Some (but
15 not all) boards also copied the PWM CPU regulator. To avoid duplication,
16 factor out the out the regulator references that are common across all
17 known boards.
18
19 Reviewed-by: Heiko Stuebner <heiko@sntech.de>
20 Tested-by: Conor Dooley <conor.dooley@microchip.com>
21 Tested-by: Heiko Stuebner <heiko@sntech.de>
22 Signed-off-by: Samuel Holland <samuel@sholland.org>
23 ---
24 arch/riscv/boot/dts/allwinner/Makefile | 1 +
25 .../sun20i-d1-common-regulators.dtsi | 51 ++++++
26 .../boot/dts/allwinner/sun20i-d1-nezha.dts | 171 ++++++++++++++++++
27 3 files changed, 223 insertions(+)
28 create mode 100644 arch/riscv/boot/dts/allwinner/sun20i-d1-common-regulators.dtsi
29 create mode 100644 arch/riscv/boot/dts/allwinner/sun20i-d1-nezha.dts
30
31 --- a/arch/riscv/boot/dts/allwinner/Makefile
32 +++ b/arch/riscv/boot/dts/allwinner/Makefile
33 @@ -1 +1,2 @@
34 # SPDX-License-Identifier: GPL-2.0
35 +dtb-$(CONFIG_ARCH_SUNXI) += sun20i-d1-nezha.dtb
36 --- /dev/null
37 +++ b/arch/riscv/boot/dts/allwinner/sun20i-d1-common-regulators.dtsi
38 @@ -0,0 +1,51 @@
39 +// SPDX-License-Identifier: (GPL-2.0+ or MIT)
40 +// Copyright (C) 2021-2022 Samuel Holland <samuel@sholland.org>
41 +
42 +/ {
43 + reg_vcc: vcc {
44 + compatible = "regulator-fixed";
45 + regulator-name = "vcc";
46 + regulator-min-microvolt = <5000000>;
47 + regulator-max-microvolt = <5000000>;
48 + };
49 +
50 + reg_vcc_3v3: vcc-3v3 {
51 + compatible = "regulator-fixed";
52 + regulator-name = "vcc-3v3";
53 + regulator-min-microvolt = <3300000>;
54 + regulator-max-microvolt = <3300000>;
55 + vin-supply = <&reg_vcc>;
56 + };
57 +};
58 +
59 +&lradc {
60 + vref-supply = <&reg_aldo>;
61 +};
62 +
63 +&pio {
64 + vcc-pb-supply = <&reg_vcc_3v3>;
65 + vcc-pc-supply = <&reg_vcc_3v3>;
66 + vcc-pd-supply = <&reg_vcc_3v3>;
67 + vcc-pe-supply = <&reg_vcc_3v3>;
68 + vcc-pf-supply = <&reg_vcc_3v3>;
69 + vcc-pg-supply = <&reg_vcc_3v3>;
70 +};
71 +
72 +&reg_aldo {
73 + regulator-min-microvolt = <1800000>;
74 + regulator-max-microvolt = <1800000>;
75 + vdd33-supply = <&reg_vcc_3v3>;
76 +};
77 +
78 +&reg_hpldo {
79 + regulator-min-microvolt = <1800000>;
80 + regulator-max-microvolt = <1800000>;
81 + hpldoin-supply = <&reg_vcc_3v3>;
82 +};
83 +
84 +&reg_ldoa {
85 + regulator-always-on;
86 + regulator-min-microvolt = <1800000>;
87 + regulator-max-microvolt = <1800000>;
88 + ldo-in-supply = <&reg_vcc_3v3>;
89 +};
90 --- /dev/null
91 +++ b/arch/riscv/boot/dts/allwinner/sun20i-d1-nezha.dts
92 @@ -0,0 +1,171 @@
93 +// SPDX-License-Identifier: (GPL-2.0+ or MIT)
94 +// Copyright (C) 2021-2022 Samuel Holland <samuel@sholland.org>
95 +
96 +/dts-v1/;
97 +
98 +#include <dt-bindings/gpio/gpio.h>
99 +#include <dt-bindings/input/input.h>
100 +
101 +#include "sun20i-d1.dtsi"
102 +#include "sun20i-d1-common-regulators.dtsi"
103 +
104 +/ {
105 + model = "Allwinner D1 Nezha";
106 + compatible = "allwinner,d1-nezha", "allwinner,sun20i-d1";
107 +
108 + aliases {
109 + ethernet0 = &emac;
110 + ethernet1 = &xr829;
111 + mmc0 = &mmc0;
112 + serial0 = &uart0;
113 + };
114 +
115 + chosen {
116 + stdout-path = "serial0:115200n8";
117 + };
118 +
119 + reg_usbvbus: usbvbus {
120 + compatible = "regulator-fixed";
121 + regulator-name = "usbvbus";
122 + regulator-min-microvolt = <5000000>;
123 + regulator-max-microvolt = <5000000>;
124 + gpio = <&pio 3 19 GPIO_ACTIVE_HIGH>; /* PD19 */
125 + enable-active-high;
126 + vin-supply = <&reg_vcc>;
127 + };
128 +
129 + /*
130 + * This regulator is PWM-controlled, but the PWM controller is not
131 + * yet supported, so fix the regulator to its default voltage.
132 + */
133 + reg_vdd_cpu: vdd-cpu {
134 + compatible = "regulator-fixed";
135 + regulator-name = "vdd-cpu";
136 + regulator-min-microvolt = <1100000>;
137 + regulator-max-microvolt = <1100000>;
138 + vin-supply = <&reg_vcc>;
139 + };
140 +
141 + wifi_pwrseq: wifi-pwrseq {
142 + compatible = "mmc-pwrseq-simple";
143 + reset-gpios = <&pio 6 12 GPIO_ACTIVE_LOW>; /* PG12 */
144 + };
145 +};
146 +
147 +&cpu0 {
148 + cpu-supply = <&reg_vdd_cpu>;
149 +};
150 +
151 +&ehci0 {
152 + status = "okay";
153 +};
154 +
155 +&ehci1 {
156 + status = "okay";
157 +};
158 +
159 +&emac {
160 + pinctrl-0 = <&rgmii_pe_pins>;
161 + pinctrl-names = "default";
162 + phy-handle = <&ext_rgmii_phy>;
163 + phy-mode = "rgmii-id";
164 + phy-supply = <&reg_vcc_3v3>;
165 + status = "okay";
166 +};
167 +
168 +&i2c2 {
169 + pinctrl-0 = <&i2c2_pb0_pins>;
170 + pinctrl-names = "default";
171 + status = "okay";
172 +
173 + pcf8574a: gpio@38 {
174 + compatible = "nxp,pcf8574a";
175 + reg = <0x38>;
176 + interrupt-parent = <&pio>;
177 + interrupts = <1 2 IRQ_TYPE_LEVEL_LOW>; /* PB2 */
178 + interrupt-controller;
179 + gpio-controller;
180 + #gpio-cells = <2>;
181 + #interrupt-cells = <2>;
182 + };
183 +};
184 +
185 +&lradc {
186 + status = "okay";
187 +
188 + button-160 {
189 + label = "OK";
190 + linux,code = <KEY_OK>;
191 + channel = <0>;
192 + voltage = <160000>;
193 + };
194 +};
195 +
196 +&mdio {
197 + ext_rgmii_phy: ethernet-phy@1 {
198 + compatible = "ethernet-phy-ieee802.3-c22";
199 + reg = <1>;
200 + };
201 +};
202 +
203 +&mmc0 {
204 + bus-width = <4>;
205 + cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
206 + disable-wp;
207 + vmmc-supply = <&reg_vcc_3v3>;
208 + vqmmc-supply = <&reg_vcc_3v3>;
209 + pinctrl-0 = <&mmc0_pins>;
210 + pinctrl-names = "default";
211 + status = "okay";
212 +};
213 +
214 +&mmc1 {
215 + bus-width = <4>;
216 + mmc-pwrseq = <&wifi_pwrseq>;
217 + non-removable;
218 + vmmc-supply = <&reg_vcc_3v3>;
219 + vqmmc-supply = <&reg_vcc_3v3>;
220 + pinctrl-0 = <&mmc1_pins>;
221 + pinctrl-names = "default";
222 + status = "okay";
223 +
224 + xr829: wifi@1 {
225 + reg = <1>;
226 + };
227 +};
228 +
229 +&ohci0 {
230 + status = "okay";
231 +};
232 +
233 +&ohci1 {
234 + status = "okay";
235 +};
236 +
237 +&uart0 {
238 + pinctrl-0 = <&uart0_pb8_pins>;
239 + pinctrl-names = "default";
240 + status = "okay";
241 +};
242 +
243 +&uart1 {
244 + uart-has-rtscts;
245 + pinctrl-0 = <&uart1_pg6_pins>, <&uart1_pg8_rts_cts_pins>;
246 + pinctrl-names = "default";
247 + status = "okay";
248 +
249 + /* XR829 bluetooth is connected here */
250 +};
251 +
252 +&usb_otg {
253 + dr_mode = "otg";
254 + status = "okay";
255 +};
256 +
257 +&usbphy {
258 + usb0_id_det-gpios = <&pio 3 21 GPIO_ACTIVE_HIGH>; /* PD21 */
259 + usb0_vbus_det-gpios = <&pio 3 20 GPIO_ACTIVE_HIGH>; /* PD20 */
260 + usb0_vbus-supply = <&reg_usbvbus>;
261 + usb1_vbus-supply = <&reg_vcc>;
262 + status = "okay";
263 +};