From 7a64e652abec6be66101c28110a984bc9aca53dd Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Fri, 22 Mar 2024 00:12:52 +0100
Subject: [PATCH 416/463] arm64: dts: rk3566-pinetab2: Add DT nodes for besdbg
 driver

This uses bes pwrseq for now, because it's easy to experiment with.

This adds ability to monitor interrupts in besdbg driver and to be
able to access BES2600 serial console over uart1.

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 .../dts/rockchip/rk3566-pinetab2-v2.0.dts     | 76 ++++++++++++++++++-
 .../boot/dts/rockchip/rk3566-pinetab2.dtsi    |  2 +-
 2 files changed, 76 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3566-pinetab2-v2.0.dts b/arch/arm64/boot/dts/rockchip/rk3566-pinetab2-v2.0.dts
index 9349541cbbd0f..f54afebdb982f 100644
--- a/arch/arm64/boot/dts/rockchip/rk3566-pinetab2-v2.0.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3566-pinetab2-v2.0.dts
@@ -7,6 +7,32 @@
 / {
 	model = "Pine64 PineTab2 v2.0";
 	compatible = "pine64,pinetab2-v2.0", "pine64,pinetab2", "rockchip,rk3566";
+
+	// todo, use this + simple pwrseq instead of custom pwrseq driver
+	wl_reg: wl-regulator {
+		compatible = "regulator-fixed";
+//		enable-active-high;
+//		gpio = <&gpio0 RK_PA0 GPIO_ACTIVE_HIGH>;
+//		pinctrl-names = "default";
+//		pinctrl-0 = <&wifi_pwren>;
+		regulator-name = "wl_reg";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		vin-supply = <&vcc_sys>;
+//		startup-delay-us = <100000>;
+//		off-on-delay-us = <100000>;
+	};
+
+	wl_pwrseq: wl-pwrseq {
+		compatible = "mmc-pwrseq-bes";
+		clocks = <&rk817 1>;
+		clock-names = "ext_clock";
+		pinctrl-names = "default";
+		pinctrl-0 = <&wifi_pwrkey &wifi_reset &wifi_pwren>;
+		pwrkey-gpios = <&gpio3 RK_PD3 GPIO_ACTIVE_HIGH>;
+		pwren-gpios = <&gpio0 RK_PA0 GPIO_ACTIVE_HIGH>;
+		reset-gpios = <&gpio3 RK_PD2 GPIO_ACTIVE_HIGH>;
+	};
 };
 
 &gpio_keys {
@@ -41,8 +67,56 @@ hall_int_l: hall-int-l {
 			rockchip,pins = <0 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>;
 		};
 	};
+
+	wifi {
+		wifi_pwrkey: wifi-pwrkey {
+			rockchip,pins = <3 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+
+		wifi_reset: wifi-reset {
+			rockchip,pins = <3 RK_PD2 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+
+		wifi_regon: wifi-regon {
+			rockchip,pins = <0 RK_PC0 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+
+		wifi_pwren: wifi-pwren {
+			rockchip,pins = <0 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+	};
 };
 
 &sdmmc1 {
-	vmmc-supply = <&vcc_sys>;
+	vmmc-supply = <&wl_reg>;
+	mmc-pwrseq = <&wl_pwrseq>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	bes2600: wifi@1 {
+		compatible = "bestechnic,bes2600";
+		reg = <1>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&host_wake_wl &wifi_wake_host_h &wifi_regon>;
+
+		interrupt-parent = <&gpio0>;
+		interrupts = <RK_PC4 IRQ_TYPE_EDGE_RISING>;
+
+		device-wakeup-gpios = <&gpio0 RK_PB7 GPIO_ACTIVE_HIGH>; // host_wake_wl
+		//host-wakeup-gpios = <&gpio0 RK_PC4 GPIO_ACTIVE_HIGH>; // wifi_wake_host_h
+		regon-gpios = <&gpio0 RK_PC0 GPIO_ACTIVE_HIGH>;
+	};
+};
+
+// for wifi chip comm
+&uart1 {
+	pinctrl-0 = <&uart1m0_xfer>;
+	pinctrl-names = "default";
+	status = "okay";
+};
+
+&uart1m0_xfer {
+	rockchip,pins =
+		<2 RK_PB3 2 &pcfg_pull_down>, // RX
+		<2 RK_PB4 RK_FUNC_GPIO &pcfg_pull_down>; // TX
 };
diff --git a/arch/arm64/boot/dts/rockchip/rk3566-pinetab2.dtsi b/arch/arm64/boot/dts/rockchip/rk3566-pinetab2.dtsi
index b5d5a17909466..8cf9386aed98b 100644
--- a/arch/arm64/boot/dts/rockchip/rk3566-pinetab2.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3566-pinetab2.dtsi
@@ -862,7 +862,7 @@ &sdmmc1 {
 	pinctrl-0 = <&sdmmc1_bus4
 		     &sdmmc1_cmd
 		     &sdmmc1_clk>;
-	sd-uhs-sdr104;
+	//sd-uhs-sdr104;
 	vqmmc-supply = <&vcca1v8_pmu>;
 	status = "okay";
 };
-- 
2.46.0

