From a0eb587ea9e4d905e1796c4f0d64fff9cd8a88f3 Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Thu, 14 Oct 2021 15:13:56 +0200
Subject: [PATCH] spwlanpoe

Signed-off-by: John Crispin <john@phrozen.org>
---
 package/boot/uboot-envtools/files/ipq40xx           |  1 +
 target/linux/ipq40xx/base-files/etc/board.d/01_leds |  1 +
 .../linux/ipq40xx/base-files/etc/board.d/02_network |  1 +
 .../etc/hotplug.d/firmware/11-ath10k-caldata        |  2 ++
 .../ipq40xx/base-files/lib/upgrade/platform.sh      |  3 ++-
 .../boot/dts/qcom-ipq4018-spw2ac1200-lan-poe.dts    |  6 ++++++
 target/linux/ipq40xx/image/generic.mk               | 13 +++++++++++++
 .../patches-5.4/901-arm-boot-add-dts-files.patch    |  3 ++-
 8 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-spw2ac1200-lan-poe.dts

diff --git a/package/boot/uboot-envtools/files/ipq40xx b/package/boot/uboot-envtools/files/ipq40xx
index fd7ad69eff..c51b40ab12 100644
--- a/package/boot/uboot-envtools/files/ipq40xx
+++ b/package/boot/uboot-envtools/files/ipq40xx
@@ -35,6 +35,7 @@ alfa-network,ap120c-ac |\
 devolo,magic-2-wifi-next |\
 edgecore,ecw5211 |\
 edgecore,spw2ac1200 |\
+edgecore,spw2ac1200-lan-poe |\
 glinet,gl-ap1300 |\
 glinet,gl-b1300 |\
 luma,wrtq-329acn |\
diff --git a/target/linux/ipq40xx/base-files/etc/board.d/01_leds b/target/linux/ipq40xx/base-files/etc/board.d/01_leds
index d944d72184..5476dd5df6 100755
--- a/target/linux/ipq40xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ipq40xx/base-files/etc/board.d/01_leds
@@ -72,6 +72,7 @@ qxwlan,e2600ac-c2)
 	;;
 edgecore,ecw5211 |\
 edgecore,spw2ac1200 |\
+edgecore,spw2ac1200-lan-poe |\
 cig,wf610d |\
 zyxel,nbg6617 |\
 zyxel,wre6606)
diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network b/target/linux/ipq40xx/base-files/etc/board.d/02_network
index e4b009bf93..f533c39179 100755
--- a/target/linux/ipq40xx/base-files/etc/board.d/02_network
+++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network
@@ -15,6 +15,7 @@ ipq40xx_setup_interfaces()
 	8dev,habanero-dvk|\
 	8dev,jalapeno|\
 	alfa-network,ap120c-ac|\
+	edgecore,spw2ac1200-lan-poe |\
 	engenius,emr3500|\
 	engenius,ens620ext|\
 	luma,wrtq-329acn|\
diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index 97dd1b4039..e36821a596 100644
--- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -105,6 +105,7 @@ case "$FIRMWARE" in
 	compex,wpj428 |\
 	edgecore,ecw5211 |\
 	edgecore,spw2ac1200 |\
+	edgecore,spw2ac1200-lan-poe |\
 	edgecore,oap100 |\
 	engenius,eap1300 |\
 	engenius,eap2200 |\
@@ -226,6 +227,7 @@ case "$FIRMWARE" in
 	compex,wpj428 |\
 	edgecore,ecw5211 |\
 	edgecore,spw2ac1200 |\
+	edgecore,spw2ac1200-lan-poe |\
 	edgecore,oap100 |\
 	engenius,eap1300 |\
 	engenius,eap2200 |\
diff --git a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh
index 806b3edb66..d44a57c62a 100644
--- a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh
@@ -90,7 +90,8 @@ platform_do_upgrade() {
 		fi
 		nand_do_upgrade "$1"
 		;;
-	edgecore,spw2ac1200)
+	edgecore,spw2ac1200|\
+	edgecore,spw2ac1200-lan-poe)
 		CI_UBIPART="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
 		nand_do_upgrade "$1"
 		;;
diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-spw2ac1200-lan-poe.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-spw2ac1200-lan-poe.dts
new file mode 100644
index 0000000000..1c2a2a8621
--- /dev/null
+++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-spw2ac1200-lan-poe.dts
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "qcom-ipq4018-spw2ac1200.dts"
+/ {
+	compatible = "edgecore,spw2ac1200-lan-poe";
+};
diff --git a/target/linux/ipq40xx/image/generic.mk b/target/linux/ipq40xx/image/generic.mk
index ae1e2e49cf..7e6118e61c 100644
--- a/target/linux/ipq40xx/image/generic.mk
+++ b/target/linux/ipq40xx/image/generic.mk
@@ -387,6 +387,19 @@ define Device/edgecore_spw2ac1200
 endef
 TARGET_DEVICES += edgecore_spw2ac1200
 
+define Device/edgecore_spw2ac1200-lan-poe
+	$(call Device/FitImage)
+	$(call Device/UbiFit)
+	DEVICE_VENDOR := Edgecore
+	DEVICE_MODEL := SPW2AC1200
+	SOC := qcom-ipq4018
+	BLOCKSIZE := 128k
+	PAGESIZE := 2048
+	DEVICE_DTS_CONFIG := config@ap.dk01.1-c2
+	DEVICE_PACKAGES := kmod-tpm-i2c-atmel kmod-usb-acm uboot-envtools kmod-usb-net kmod-usb-net-cdc-qmi uqmi
+endef
+TARGET_DEVICES += edgecore_spw2ac1200-lan-poe
+
 define Device/edgecore_oap100
 	$(call Device/FitImage)
 	$(call Device/UbiFit)
diff --git a/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch
index 826e17b0e9..c4ecf62313 100644
--- a/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch
+++ b/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch
@@ -10,7 +10,7 @@ Signed-off-by: John Crispin <john@phrozen.org>
 
 --- a/arch/arm/boot/dts/Makefile
 +++ b/arch/arm/boot/dts/Makefile
-@@ -837,11 +837,63 @@ dtb-$(CONFIG_ARCH_QCOM) += \
+@@ -837,11 +837,64 @@ dtb-$(CONFIG_ARCH_QCOM) += \
  	qcom-apq8074-dragonboard.dtb \
  	qcom-apq8084-ifc6540.dtb \
  	qcom-apq8084-mtp.dtb \
@@ -23,6 +23,7 @@ Signed-off-by: John Crispin <john@phrozen.org>
 +	qcom-ipq4018-eap1300.dtb \
 +	qcom-ipq4018-ecw5211.dtb \
 +	qcom-ipq4018-spw2ac1200.dtb \
++	qcom-ipq4018-spw2ac1200-lan-poe.dtb \
 +	qcom-ipq4018-emd1.dtb \
 +	qcom-ipq4018-emr3500.dtb \
 +	qcom-ipq4018-ens620ext.dtb \
-- 
2.25.1

