From 43a7177563683a1e7d192138f65073d687ed068b Mon Sep 17 00:00:00 2001
From: Patrick Yavitz <pyavitz@armbian.com>
Date: Tue, 7 Jan 2025 06:39:30 -0500
Subject: Add BananaPi BPI-M4-Zero overlays

Signed-off-by: Patrick Yavitz <pyavitz@armbian.com>
---
 .../arm64/boot/dts/allwinner/overlay/Makefile | 13 ++++++
 ...sun50i-h616-bananapi-m4-pg-15-16-i2c4.dtso | 13 ++++++
 ...sun50i-h616-bananapi-m4-pg-17-18-i2c3.dtso | 13 ++++++
 .../sun50i-h616-bananapi-m4-pg-6-7-uart1.dtso | 13 ++++++
 ...h616-bananapi-m4-pg-8-9-rts-cts-uart1.dtso | 16 +++++++
 .../sun50i-h616-bananapi-m4-ph-2-3-uart5.dtso | 13 ++++++
 ...un50i-h616-bananapi-m4-pi-13-14-uart4.dtso | 13 ++++++
 ...16-bananapi-m4-pi-15-16-rts-cts-uart4.dtso | 16 +++++++
 .../sun50i-h616-bananapi-m4-pi-5-6-i2c0.dtso  | 13 ++++++
 .../sun50i-h616-bananapi-m4-pi-7-8-i2c1.dtso  | 13 ++++++
 .../sun50i-h616-bananapi-m4-sdio-wifi-bt.dtso | 44 +++++++++++++++++++
 ...-h616-bananapi-m4-spi1-cs0-cs1-spidev.dtso | 32 ++++++++++++++
 ...n50i-h616-bananapi-m4-spi1-cs0-spidev.dtso | 24 ++++++++++
 ...n50i-h616-bananapi-m4-spi1-cs1-spidev.dtso | 13 ++++++
 14 files changed, 249 insertions(+)
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-15-16-i2c4.dtso
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-17-18-i2c3.dtso
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-6-7-uart1.dtso
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-8-9-rts-cts-uart1.dtso
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-ph-2-3-uart5.dtso
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-13-14-uart4.dtso
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-15-16-rts-cts-uart4.dtso
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-5-6-i2c0.dtso
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-7-8-i2c1.dtso
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-sdio-wifi-bt.dtso
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-spi1-cs0-cs1-spidev.dtso
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-spi1-cs0-spidev.dtso
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-spi1-cs1-spidev.dtso

diff --git a/arch/arm64/boot/dts/allwinner/overlay/Makefile b/arch/arm64/boot/dts/allwinner/overlay/Makefile
index ccb89b5bf495..3e87d21c9d14 100644
--- a/arch/arm64/boot/dts/allwinner/overlay/Makefile
+++ b/arch/arm64/boot/dts/allwinner/overlay/Makefile
@@ -49,6 +49,19 @@ dtb-$(CONFIG_ARCH_SUNXI) += \
 	sun50i-h6-uart2.dtbo \
 	sun50i-h6-uart3.dtbo \
 	sun50i-h6-w1-gpio.dtbo \
+	sun50i-h616-bananapi-m4-pg-6-7-uart1.dtbo \
+	sun50i-h616-bananapi-m4-pg-8-9-rts-cts-uart1.dtbo \
+	sun50i-h616-bananapi-m4-pg-15-16-i2c4.dtbo \
+	sun50i-h616-bananapi-m4-pg-17-18-i2c3.dtbo \
+	sun50i-h616-bananapi-m4-ph-2-3-uart5.dtbo \
+	sun50i-h616-bananapi-m4-pi-13-14-uart4.dtbo \
+	sun50i-h616-bananapi-m4-pi-15-16-rts-cts-uart4.dtbo \
+	sun50i-h616-bananapi-m4-pi-5-6-i2c0.dtbo \
+	sun50i-h616-bananapi-m4-pi-7-8-i2c1.dtbo \
+	sun50i-h616-bananapi-m4-sdio-wifi-bt.dtbo \
+	sun50i-h616-bananapi-m4-spi1-cs0-cs1-spidev.dtbo \
+	sun50i-h616-bananapi-m4-spi1-cs0-spidev.dtbo \
+	sun50i-h616-bananapi-m4-spi1-cs1-spidev.dtbo \
 	sun50i-h616-gpu.dtbo \
 	sun50i-h616-i2c0-pi.dtbo \
 	sun50i-h616-i2c1-pi.dtbo \
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-15-16-i2c4.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-15-16-i2c4.dtso
new file mode 100644
index 000000000000..4e78aa8f1f27
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-15-16-i2c4.dtso
@@ -0,0 +1,13 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target = <&i2c4>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-17-18-i2c3.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-17-18-i2c3.dtso
new file mode 100644
index 000000000000..3419eee0b70b
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-17-18-i2c3.dtso
@@ -0,0 +1,13 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target = <&i2c3>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-6-7-uart1.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-6-7-uart1.dtso
new file mode 100644
index 000000000000..7001781f42d2
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-6-7-uart1.dtso
@@ -0,0 +1,13 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target = <&uart1>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-8-9-rts-cts-uart1.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-8-9-rts-cts-uart1.dtso
new file mode 100644
index 000000000000..1317a9b3b52f
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pg-8-9-rts-cts-uart1.dtso
@@ -0,0 +1,16 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target = <&uart1>;
+		__overlay__ {
+			status = "okay";
+			pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
+			pinctrl-names = "default";
+			uart-has-rtscts;
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-ph-2-3-uart5.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-ph-2-3-uart5.dtso
new file mode 100644
index 000000000000..aaa96e46d708
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-ph-2-3-uart5.dtso
@@ -0,0 +1,13 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target = <&uart5>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-13-14-uart4.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-13-14-uart4.dtso
new file mode 100644
index 000000000000..0373f7d25449
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-13-14-uart4.dtso
@@ -0,0 +1,13 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target = <&uart4>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-15-16-rts-cts-uart4.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-15-16-rts-cts-uart4.dtso
new file mode 100644
index 000000000000..ef9394c8519c
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-15-16-rts-cts-uart4.dtso
@@ -0,0 +1,16 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target = <&uart4>;
+		__overlay__ {
+			status = "okay";
+			pinctrl-0 = <&uart4_pi_pins>, <&uart4_pi_rts_cts_pins>;
+			pinctrl-names = "default";
+			uart-has-rtscts;
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-5-6-i2c0.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-5-6-i2c0.dtso
new file mode 100644
index 000000000000..60c75e4d61b5
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-5-6-i2c0.dtso
@@ -0,0 +1,13 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target = <&i2c0>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-7-8-i2c1.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-7-8-i2c1.dtso
new file mode 100644
index 000000000000..99c7e2b8c5f6
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-pi-7-8-i2c1.dtso
@@ -0,0 +1,13 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target = <&i2c1>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-sdio-wifi-bt.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-sdio-wifi-bt.dtso
new file mode 100644
index 000000000000..307f6e5e921c
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-sdio-wifi-bt.dtso
@@ -0,0 +1,44 @@
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target-path = "/";
+		__overlay__ {
+			model = "BananaPi BPI-M4-Zero v2";
+		};
+	};
+
+	/* SDIO WIFI */
+	fragment@1 {
+		target = <&mmc1>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+
+	/* BLUETOOTH */
+	fragment@2 {
+		target = <&uart1>;
+		__overlay__ {
+			status = "okay";
+			pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
+			pinctrl-names = "default";
+			uart-has-rtscts;
+
+			bluetooth {
+				compatible = "brcm,bcm43540-bt";
+				host-wakeup-gpios = <&pio 6 16 GPIO_ACTIVE_HIGH>;
+				device-wakeup-gpios = <&pio 6 17 GPIO_ACTIVE_HIGH>;
+				shutdown-gpios = <&pio 6 19 GPIO_ACTIVE_HIGH>;
+				max-speed = <1500000>;
+				vbat-supply = <&reg_vcc3v3>;
+				vddio-supply = <&reg_vcc1v8>;
+			};
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-spi1-cs0-cs1-spidev.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-spi1-cs0-cs1-spidev.dtso
new file mode 100644
index 000000000000..7fa3b94bcc8d
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-spi1-cs0-cs1-spidev.dtso
@@ -0,0 +1,32 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target = <&spi1>;
+		__overlay__ {
+			status = "okay";
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			pinctrl-names = "default";
+			pinctrl-0 = <&spi1_pins>, <&spi1_cs0_pin>, <&spi1_cs1_pin>;
+
+			spidev@0 {
+				compatible = "rohm,dh2228fv";
+				status = "okay";
+				reg = <0>;
+				spi-max-frequency = <50000000>;
+			};
+
+			spidev@1 {
+				compatible = "rohm,dh2228fv";
+				status = "okay";
+				reg = <1>;
+				spi-max-frequency = <50000000>;
+			};
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-spi1-cs0-spidev.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-spi1-cs0-spidev.dtso
new file mode 100644
index 000000000000..fef73f1afa52
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-spi1-cs0-spidev.dtso
@@ -0,0 +1,24 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target = <&spi1>;
+		__overlay__ {
+			status = "okay";
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+                        pinctrl-names = "default";
+                        pinctrl-0 = <&spi1_pins>, <&spi1_cs0_pin>;
+			spidev@0 {
+				compatible = "rohm,dh2228fv";
+				status = "okay";
+				reg = <0>;
+				spi-max-frequency = <1000000>;
+			};
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-spi1-cs1-spidev.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-spi1-cs1-spidev.dtso
new file mode 100644
index 000000000000..840357f2e9e0
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-bananapi-m4-spi1-cs1-spidev.dtso
@@ -0,0 +1,13 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "sinovoip,bpi-m4-zero", "allwinner,sun50i-h616", "allwinner,sun50i-h618";
+
+	fragment@0 {
+		target = <&spi1>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+};
-- 
2.35.3

