From a9bad790ae9a9e9befbe8e8938b6baca84ee5138 Mon Sep 17 00:00:00 2001
From: Marek Belisko <marek.belisko@open-nandra.com>
Date: Tue, 24 Oct 2023 10:40:52 +0200
Subject: [PATCH] dts: orangepi-zero: Add wifi support

Upstream-Status: Pending

Signed-off-by: Marek Belisko <marek.belisko@open-nandra.com>
---
 .../allwinner/sun8i-h2-plus-orangepi-zero.dts | 46 +++++++++++++++----
 1 file changed, 37 insertions(+), 9 deletions(-)

diff --git a/arch/arm/boot/dts/allwinner/sun8i-h2-plus-orangepi-zero.dts b/arch/arm/boot/dts/allwinner/sun8i-h2-plus-orangepi-zero.dts
index 3706216ff..ca94e313f 100644
--- a/arch/arm/boot/dts/allwinner/sun8i-h2-plus-orangepi-zero.dts
+++ b/arch/arm/boot/dts/allwinner/sun8i-h2-plus-orangepi-zero.dts
@@ -80,13 +80,15 @@ status_led {
 		};
 	};
 
-	reg_vcc_wifi: reg_vcc_wifi {
+	vdd_wifi: vdd_wifi {
 		compatible = "regulator-fixed";
-		regulator-min-microvolt = <3300000>;
-		regulator-max-microvolt = <3300000>;
-		regulator-name = "vcc-wifi";
-		enable-active-high;
+		regulator-name = "wifi";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
 		gpio = <&pio 0 20 GPIO_ACTIVE_HIGH>;
+		startup-delay-us = <70000>;
+		enable-active-high;
+
 	};
 
 	reg_vdd_cpux: vdd-cpux-regulator {
@@ -105,10 +107,12 @@ reg_vdd_cpux: vdd-cpux-regulator {
 		states = <1100000 0>, <1300000 1>;
 	};
 
-	wifi_pwrseq: wifi_pwrseq {
+	pwrseq_wifi: pwrseq_wifi {
 		compatible = "mmc-pwrseq-simple";
+		pinctrl-names = "default";
+		pinctrl-0 = <&wifi_rst>;
 		reset-gpios = <&r_pio 0 7 GPIO_ACTIVE_LOW>;
-		post-power-on-delay-ms = <200>;
+		post-power-on-delay-ms = <50>;
 	};
 };
 
@@ -139,9 +143,11 @@ &mmc0 {
 };
 
 &mmc1 {
-	vmmc-supply = <&reg_vcc_wifi>;
-	mmc-pwrseq = <&wifi_pwrseq>;
+	vmmc-supply = <&reg_vcc3v3>;
+	vqmmc-supply = <&vdd_wifi>;
+	mmc-pwrseq = <&pwrseq_wifi>;
 	bus-width = <4>;
+	max-frequency = <16000000>;
 	non-removable;
 	status = "okay";
 
@@ -151,6 +157,13 @@ &mmc1 {
 	 */
 	xr819: sdio_wifi@1 {
 		reg = <1>;
+		compatible = "xradio,xr819";
+		pinctrl-names = "default";
+		pinctrl-0 = <&wifi_wake>;
+		interrupt-parent = <&pio>;
+		interrupts = <6 10 IRQ_TYPE_EDGE_RISING>;
+		interrupt-names = "host-wake";
+		local-mac-address = [dc 44 6d c0 ff ee];
 	};
 };
 
@@ -207,3 +220,18 @@ &usbphy {
 	status = "okay";
 	usb0_id_det-gpios = <&pio 6 12 GPIO_ACTIVE_HIGH>; /* PG12 */
 };
+
+&pio {
+	wifi_wake: wifi_wake {
+		pins = "PG10";
+		function = "gpio_in";
+    };
+};
+
+&r_pio {
+	wifi_rst: wifi_rst {
+		pins = "PL7";
+		function = "gpio_out";
+    };
+};
+
-- 
2.25.1

