From 7a2dd8b3e4c1c9f988c6b6ba681f394e29bd8c73 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Fri, 17 Jun 2016 11:20:08 +0200
Subject: [PATCH] Revert "ar71xx: backport fixes for better CPE210/510 support"

This reverts commit ffd1f0b3a5b2950d8c626a2de26fb1dc8e384408.
---
 ...=> 0090-ar71xx-add-GL-AR150-support.patch} |  16 +-
 ...10-enable-LNA-for-CPE210-220-510-520.patch |  35 ----
 ...le-into-2-profiles-cpe210-and-cpe510.patch | 169 ----------------
 ...ix-version-detection-for-Make-4.2.1.patch} |   0
 ...10-use-second-wifi-calibration-table.patch |  24 ---
 ...j-for-parallel-builds-with-Make-4.2.patch} |   0
 ...oader.c-Add-support-for-Archer-C2600.patch | 188 ------------------
 ...ke-fix-parallel-build-with-Make-4.2.patch} |   0
 ...IPv6-builtin-if-selected-saves-30KB.patch} |   0
 ...der-split-CPE210-from-CPE510-profile.patch | 102 ----------
 ...ages-with-multiple-PROVIDES-entries.patch} |   0
 ...od-crypto-core-and-kmod-crypto-arc4.patch} |   0
 targets/ar71xx-generic/profiles.mk            |  13 +-
 13 files changed, 14 insertions(+), 533 deletions(-)
 rename patches/openwrt/{0095-ar71xx-add-GL-AR150-support.patch => 0090-ar71xx-add-GL-AR150-support.patch} (97%)
 delete mode 100644 patches/openwrt/0090-ar71xx-cpe510-enable-LNA-for-CPE210-220-510-520.patch
 delete mode 100644 patches/openwrt/0091-ar71xx-cpe510-split-profile-into-2-profiles-cpe210-and-cpe510.patch
 rename patches/openwrt/{0096-scripts-feeds-fix-version-detection-for-Make-4.2.1.patch => 0091-scripts-feeds-fix-version-detection-for-Make-4.2.1.patch} (100%)
 delete mode 100644 patches/openwrt/0092-ar71xx-cpe510-use-second-wifi-calibration-table.patch
 rename patches/openwrt/{0097-build-don-t-add-j-for-parallel-builds-with-Make-4.2.patch => 0092-build-don-t-add-j-for-parallel-builds-with-Make-4.2.patch} (100%)
 delete mode 100644 patches/openwrt/0093-fw-utils-tplink-safeloader.c-Add-support-for-Archer-C2600.patch
 rename patches/openwrt/{0098-tools-cmake-fix-parallel-build-with-Make-4.2.patch => 0093-tools-cmake-fix-parallel-build-with-Make-4.2.patch} (100%)
 rename patches/openwrt/{0099-linux-make-IPv6-builtin-if-selected-saves-30KB.patch => 0094-linux-make-IPv6-builtin-if-selected-saves-30KB.patch} (100%)
 delete mode 100644 patches/openwrt/0094-tools-tplink-safeloader-split-CPE210-from-CPE510-profile.patch
 rename patches/openwrt/{0100-package-ipkg.mk-fix-Provides-for-packages-with-multiple-PROVIDES-entries.patch => 0095-package-ipkg.mk-fix-Provides-for-packages-with-multiple-PROVIDES-entries.patch} (100%)
 rename patches/openwrt/{0101-kernel-remove-packaging-of-kmod-crypto-core-and-kmod-crypto-arc4.patch => 0096-kernel-remove-packaging-of-kmod-crypto-core-and-kmod-crypto-arc4.patch} (100%)

diff --git a/patches/openwrt/0095-ar71xx-add-GL-AR150-support.patch b/patches/openwrt/0090-ar71xx-add-GL-AR150-support.patch
similarity index 97%
rename from patches/openwrt/0095-ar71xx-add-GL-AR150-support.patch
rename to patches/openwrt/0090-ar71xx-add-GL-AR150-support.patch
index ca4b803ac..d8787a521 100644
--- a/patches/openwrt/0095-ar71xx-add-GL-AR150-support.patch
+++ b/patches/openwrt/0090-ar71xx-add-GL-AR150-support.patch
@@ -9,10 +9,10 @@ https://raw.githubusercontent.com/domino-team/OpenWrt-patches/master/AR150%2C%20
 (and fixed indentation in target/linux/ar71xx/base-files/lib/ar71xx.sh)
 
 diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-index 129f6b7..e29c1b5 100644
+index ae17853..dc8b8d6 100644
 --- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
 +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-@@ -182,6 +182,10 @@ dlan-pro-1200-ac)
+@@ -181,6 +181,10 @@ dlan-pro-1200-ac)
  	ucidef_set_led_trigger_gpio "plcr" "dLAN" "devolo:error:dlan" "16" "0"
  	;;
  
@@ -24,10 +24,10 @@ index 129f6b7..e29c1b5 100644
  	ucidef_set_led_netdev "lan" "LAN" "gl-connect:green:lan" "eth1"
  	ucidef_set_led_wlan "wlan" "WLAN" "gl-connect:red:wlan" "phy0tpt"
 diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-index 1d0142f..3895394 100755
+index 4066506..89a2184 100755
 --- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
 +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-@@ -382,6 +382,7 @@ dir-505-a1)
+@@ -381,6 +381,7 @@ dir-505-a1)
  alfa-ap96 |\
  alfa-nx |\
  ap83 |\
@@ -36,10 +36,10 @@ index 1d0142f..3895394 100755
  jwap003 |\
  pb42 |\
 diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index 4000b5b..2cb884b 100755
+index fbf76c8..db908f9 100755
 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
 +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -504,6 +504,9 @@ ar71xx_board_detect() {
+@@ -500,6 +500,9 @@ ar71xx_board_detect() {
  		name="gl-inet"
  		gl_inet_board_detect
  		;;
@@ -50,7 +50,7 @@ index 4000b5b..2cb884b 100755
  		name="epg5000"
  		;;
 diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-index eded91e..5bd4c2b 100755
+index 4a4c476..aeb4577 100755
 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
 +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
 @@ -215,6 +215,7 @@ platform_check_image() {
@@ -261,7 +261,7 @@ index 0000000..a6ad661
 +
 +$(eval $(call Profile,GL-AR150))
 diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index 57f38a5..3ce1809 100644
+index 06dbb77..a35ded9 100644
 --- a/target/linux/ar71xx/image/Makefile
 +++ b/target/linux/ar71xx/image/Makefile
 @@ -144,6 +144,14 @@ define Device/weio
diff --git a/patches/openwrt/0090-ar71xx-cpe510-enable-LNA-for-CPE210-220-510-520.patch b/patches/openwrt/0090-ar71xx-cpe510-enable-LNA-for-CPE210-220-510-520.patch
deleted file mode 100644
index c5c278bcf..000000000
--- a/patches/openwrt/0090-ar71xx-cpe510-enable-LNA-for-CPE210-220-510-520.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 9 Jun 2016 04:39:08 +0200
-Subject: ar71xx/cpe510: enable LNA for CPE210/220/510/520
-
-The LNA improves the rx path. Within a simple test setup
-it improved the signal from -60dbm to -40dbm.
-
-Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
-
-Backport of LEDE 94e23bf7409d6cc4c9efb55ed32aba8e5a497966
-
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-index 8bf5c0f..5cb052a 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-@@ -30,6 +30,9 @@
- #define CPE510_GPIO_LED_L3	15
- #define CPE510_GPIO_LED_L4	16
- 
-+#define CPE510_GPIO_EXTERNAL_LNA0	18
-+#define CPE510_GPIO_EXTERNAL_LNA1	19
-+
- #define CPE510_GPIO_BTN_RESET	4
- 
- #define CPE510_KEYS_POLL_INTERVAL	20 /* msecs */
-@@ -93,6 +96,9 @@ static void __init cpe510_setup(void)
- 					ARRAY_SIZE(cpe510_gpio_keys),
- 					cpe510_gpio_keys);
- 
-+	ath79_wmac_set_ext_lna_gpio(0, CPE510_GPIO_EXTERNAL_LNA0);
-+	ath79_wmac_set_ext_lna_gpio(1, CPE510_GPIO_EXTERNAL_LNA1);
-+
- 	ath79_register_m25p80(NULL);
- 
- 	ath79_register_mdio(1, 0);
diff --git a/patches/openwrt/0091-ar71xx-cpe510-split-profile-into-2-profiles-cpe210-and-cpe510.patch b/patches/openwrt/0091-ar71xx-cpe510-split-profile-into-2-profiles-cpe210-and-cpe510.patch
deleted file mode 100644
index 98f4c2731..000000000
--- a/patches/openwrt/0091-ar71xx-cpe510-split-profile-into-2-profiles-cpe210-and-cpe510.patch
+++ /dev/null
@@ -1,169 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 9 Jun 2016 04:55:37 +0200
-Subject: ar71xx/cpe510: split profile into 2 profiles cpe210 and cpe510
-
-Split profile into 2GHz and 5GHz. The 5GHz devices are
-quite "special". The 2 GHz works perfect.
-
-Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
-
-Backport of LEDE c5ff273d85f69981e5b126eeaed3dee5b4061fb4
-
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches b/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches
-index b41f275..0f7a415 100644
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches
-@@ -15,6 +15,7 @@ nanostation-m)
- nanostation-m-xw)
- 	ucidef_set_gpio_switch "poe_passthrough" "PoE Passthrough" "2"
- 	;;
-+cpe210|\
- cpe510)
- 	ucidef_set_gpio_switch "poe_passthrough" "PoE Passthrough" "20"
- 	;;
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-index ae17853..129f6b7 100644
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-@@ -78,6 +78,7 @@ carambola2)
- 	ucidef_set_led_wlan "wlan" "WLAN" "carambola2:green:wlan" "phy0tpt"
- 	;;
- 
-+cpe210|\
- cpe510)
- 	ucidef_set_led_switch "lan0" "LAN0" "tp-link:green:lan0" "switch0" "0x20"
- 	ucidef_set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x10"
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-index 4066506..1d0142f 100755
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-@@ -71,6 +71,7 @@ bsb)
- 	ucidef_set_interface_wlan
- 	;;
- 
-+cpe210|\
- cpe510)
- 	ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
- 	ucidef_add_switch "switch0" "1" "1"
-diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index fbf76c8..4000b5b 100755
---- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
-+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -438,7 +438,11 @@ ar71xx_board_detect() {
- 	*CAP4200AG)
- 		name="cap4200ag"
- 		;;
--	*"CPE210/220/510/520")
-+	*"CPE210/220")
-+		name="cpe210"
-+		tplink_pharos_board_detect
-+		;;
-+	*"CPE510/520")
- 		name="cpe510"
- 		tplink_pharos_board_detect
- 		;;
-diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-index 4a4c476..eded91e 100755
---- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-@@ -263,6 +263,7 @@ platform_check_image() {
- 		return 0
- 		;;
- 
-+	cpe210|\
- 	cpe510)
- 		tplink_pharos_check_image "$1" && return 0
- 		return 1
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-index 5cb052a..74daf43 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-@@ -78,12 +78,8 @@ static struct gpio_keys_button cpe510_gpio_keys[] __initdata = {
- 	}
- };
- 
--
--static void __init cpe510_setup(void)
-+static void __init cpe_setup(u8 *mac)
- {
--	u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
--	u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
--
- 	/* Disable JTAG, enabling GPIOs 0-3 */
- 	/* Configure OBS4 line, for GPIO 4*/
- 	ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
-@@ -105,9 +101,31 @@ static void __init cpe510_setup(void)
- 	ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
- 	ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
- 	ath79_register_eth(1);
-+}
-+
-+
-+static void __init cpe210_setup(void)
-+{
-+	u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
-+	u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
-+
-+	cpe_setup(mac);
- 
- 	ath79_register_wmac(ee, mac);
- }
- 
--MIPS_MACHINE(ATH79_MACH_CPE510, "CPE510", "TP-LINK CPE210/220/510/520",
-+static void __init cpe510_setup(void)
-+{
-+	u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
-+	u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
-+
-+	cpe_setup(mac);
-+
-+	ath79_register_wmac(ee, mac);
-+}
-+
-+MIPS_MACHINE(ATH79_MACH_CPE210, "CPE210", "TP-LINK CPE210/220",
-+	     cpe210_setup);
-+
-+MIPS_MACHINE(ATH79_MACH_CPE510, "CPE510", "TP-LINK CPE510/520",
- 	     cpe510_setup);
-diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index 06dbb77..272abe0 100644
---- a/target/linux/ar71xx/image/Makefile
-+++ b/target/linux/ar71xx/image/Makefile
-@@ -2094,7 +2094,8 @@ $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR1043V2,tl-wr1043nd-v2,TL-WR10
- $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR1043V3,tl-wr1043nd-v3,TL-WR1043ND-v2,ttyS0,115200,0x10430003,1,8M))
- $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR2543,tl-wr2543-v1,TL-WR2543N,ttyS0,115200,0x25430001,1,8Mlzma,-v 3.13.99))
- 
--$(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE510,cpe210-220-510-520,CPE510,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
-+$(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE210_220,cpe210-220,CPE210,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
-+$(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE510_520,cpe510-520,CPE510,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
- 
- $(eval $(call SingleProfile,UAPPRO,64k,UAPPRO,ubnt-uap-pro,UAP-PRO,ttyS0,115200,BZ,BZ,ar934x))
- $(eval $(call SingleProfile,UAPPRO,64k,UBNTUNIFIOUTDOORPLUS,ubnt-unifi-outdoor-plus,UBNT-UOP,ttyS0,115200,BZ,BZ,ar7240))
-@@ -2158,6 +2159,7 @@ $(eval $(call MultiProfile,TLWR842,TLWR842V1))
- $(eval $(call MultiProfile,TLWR941,TLWR941NV2 TLWR941NV3 TLWR941NV4))
- $(eval $(call MultiProfile,TLWR1043,TLWR1043V1 TLWR1043V2 TLWR1043V3))
- $(eval $(call MultiProfile,TLWDR4300,TLWDR3500V1 TLWDR3600V1 TLWDR4300V1 TLWDR4300V1IL TLWDR4310V1 MW4530RV1))
-+$(eval $(call MultiProfile,CPE510,CPE210_220 CPE510_520))
- $(eval $(call MultiProfile,TUBE2H,TUBE2H8M TUBE2H16M))
- $(eval $(call MultiProfile,UBNT,UBNTAIRROUTER UBNTRS UBNTRSPRO UBNTLSSR71 UBNTBULLETM UBNTROCKETM UBNTROCKETMXW UBNTNANOM UBNTNANOMXW UBNTLOCOXW UBNTUNIFI UBNTUNIFIOUTDOOR UBNTUNIFIOUTDOORPLUS UAPPRO UBNTAIRGW))
- $(eval $(call MultiProfile,WNR612V2,REALWNR612V2 N150R))
-diff --git a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-index dbd3fca..b2f5366 100644
---- a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-+++ b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-@@ -1,6 +1,6 @@
- --- a/arch/mips/ath79/machtypes.h
- +++ b/arch/mips/ath79/machtypes.h
--@@ -16,22 +16,201 @@
-+@@ -16,22 +16,202 @@
-  
-  enum ath79_mach_type {
-  	ATH79_MACH_GENERIC = 0,
-@@ -26,6 +26,7 @@
- +	ATH79_MACH_BHU_BXU2000N2_A1,	/* BHU BXU2000n-2 A1 */
- +	ATH79_MACH_CAP4200AG,		/* Senao CAP4200AG */
- +	ATH79_MACH_CARAMBOLA2,		/* 8devices Carambola2 */
-++	ATH79_MACH_CPE210,		/* TP-LINK CPE210 */
- +	ATH79_MACH_CPE510,		/* TP-LINK CPE510 */
-  	ATH79_MACH_DB120,		/* Atheros DB120 reference board */
-  	ATH79_MACH_PB44,		/* Atheros PB44 reference board */
diff --git a/patches/openwrt/0096-scripts-feeds-fix-version-detection-for-Make-4.2.1.patch b/patches/openwrt/0091-scripts-feeds-fix-version-detection-for-Make-4.2.1.patch
similarity index 100%
rename from patches/openwrt/0096-scripts-feeds-fix-version-detection-for-Make-4.2.1.patch
rename to patches/openwrt/0091-scripts-feeds-fix-version-detection-for-Make-4.2.1.patch
diff --git a/patches/openwrt/0092-ar71xx-cpe510-use-second-wifi-calibration-table.patch b/patches/openwrt/0092-ar71xx-cpe510-use-second-wifi-calibration-table.patch
deleted file mode 100644
index 7a5cd5d4a..000000000
--- a/patches/openwrt/0092-ar71xx-cpe510-use-second-wifi-calibration-table.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 9 Jun 2016 04:57:24 +0200
-Subject: ar71xx/cpe510: use second wifi calibration table
-
-The cpe510 has two calibration tables. The first calibration
-table requires to modify ath9k driver to work (patched tx gain table).
-
-Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
-
-Backport of LEDE bf27ac019c137e7baf90ca6ef0e40945ae871797
-
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-index 74daf43..875589d 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-@@ -117,7 +117,7 @@ static void __init cpe210_setup(void)
- static void __init cpe510_setup(void)
- {
- 	u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
--	u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
-+	u8 *ee = (u8 *) KSEG1ADDR(0x1fff5000);
- 
- 	cpe_setup(mac);
- 
diff --git a/patches/openwrt/0097-build-don-t-add-j-for-parallel-builds-with-Make-4.2.patch b/patches/openwrt/0092-build-don-t-add-j-for-parallel-builds-with-Make-4.2.patch
similarity index 100%
rename from patches/openwrt/0097-build-don-t-add-j-for-parallel-builds-with-Make-4.2.patch
rename to patches/openwrt/0092-build-don-t-add-j-for-parallel-builds-with-Make-4.2.patch
diff --git a/patches/openwrt/0093-fw-utils-tplink-safeloader.c-Add-support-for-Archer-C2600.patch b/patches/openwrt/0093-fw-utils-tplink-safeloader.c-Add-support-for-Archer-C2600.patch
deleted file mode 100644
index 0c33a4d39..000000000
--- a/patches/openwrt/0093-fw-utils-tplink-safeloader.c-Add-support-for-Archer-C2600.patch
+++ /dev/null
@@ -1,188 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 9 Jun 2016 05:02:18 +0200
-Subject: fw-utils/tplink-safeloader.c: Add support for Archer C2600
-
-Signed-off-by: Ash Benz <ash.benz@bk.ru>
-
-Backport of LEDE 955c341d3bec0eb4971a03924e99156367255d7b
-
-diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c
-index 77a894b..2e204aa 100644
---- a/tools/firmware-utils/src/tplink-safeloader.c
-+++ b/tools/firmware-utils/src/tplink-safeloader.c
-@@ -105,6 +105,8 @@ static const uint8_t md5_salt[16] = {
- /** Vendor information for CPE210/220/510/520 */
- static const char cpe510_vendor[] = "CPE510(TP-LINK|UN|N300-5):1.0\r\n";
- 
-+/** Vendor information for C2600 */
-+static const char c2600_vendor[] = "";
- 
- /**
-     The flash partition table for CPE210/220/510/520;
-@@ -128,6 +130,39 @@ static const struct flash_partition_entry cpe510_partitions[] = {
- };
- 
- /**
-+    The flash partition table for C2600;
-+    it is the same as the one used by the stock images.
-+*/
-+static const struct flash_partition_entry c2600_partitions[] = {
-+        {"SBL1", 0x00000, 0x20000},
-+        {"MIBIB", 0x20000, 0x20000},
-+        {"SBL2", 0x40000, 0x20000},
-+        {"SBL3", 0x60000, 0x30000},
-+        {"DDRCONFIG", 0x90000, 0x10000},
-+        {"SSD", 0xa0000, 0x10000},
-+        {"TZ", 0xb0000, 0x30000},
-+        {"RPM", 0xe0000, 0x20000},
-+        {"fs-uboot", 0x100000, 0x70000},
-+        {"uboot-env", 0x170000, 0x40000},
-+        {"radio", 0x1b0000, 0x40000},
-+        {"os-image", 0x1f0000, 0x200000},
-+        {"file-system", 0x3f0000, 0x1b00000},
-+        {"default-mac", 0x1ef0000, 0x00200},
-+        {"pin", 0x1ef0200, 0x00200},
-+        {"product-info", 0x1ef0400, 0x0fc00},
-+        {"partition-table", 0x1f00000, 0x10000},
-+        {"soft-version", 0x1f10000, 0x10000},
-+        {"support-list", 0x1f20000, 0x10000},
-+        {"profile", 0x1f30000, 0x10000},
-+        {"default-config", 0x1f40000, 0x10000},
-+        {"user-config", 0x1f50000, 0x40000},
-+        {"qos-db", 0x1f90000, 0x40000},
-+        {"usb-config", 0x1fd0000, 0x10000},
-+        {"log", 0x1fe0000, 0x20000},
-+	{NULL, 0, 0}
-+};
-+
-+/**
-    The support list for CPE210/220/510/520
- */
- static const char cpe510_support_list[] =
-@@ -141,6 +176,13 @@ static const char cpe510_support_list[] =
- 	"CPE220(TP-LINK|UN|N300-2):1.0\r\n"
- 	"CPE220(TP-LINK|UN|N300-2):1.1\r\n";
- 
-+/**
-+   The support list for C2600
-+*/
-+static const char c2600_support_list[] =
-+	"SupportList:\r\n"
-+	"{product_name:Archer C2600,product_ver:1.0.0,special_id:00000000}\r\n";
-+
- #define error(_ret, _errno, _str, ...)				\
- 	do {							\
- 		fprintf(stderr, _str ": %s\n", ## __VA_ARGS__,	\
-@@ -240,14 +282,14 @@ static struct image_partition_entry make_soft_version(uint32_t rev) {
- }
- 
- /** Generates the support-list partition */
--static struct image_partition_entry make_support_list(const char *support_list) {
-+static struct image_partition_entry make_support_list(const char *support_list, bool trailzero) {
- 	size_t len = strlen(support_list);
- 	struct image_partition_entry entry = alloc_image_partition("support-list", len + 9);
- 
- 	put32(entry.data, len);
- 	memset(entry.data+4, 0, 4);
- 	memcpy(entry.data+8, support_list, len);
--	entry.data[len+8] = '\xff';
-+	entry.data[len+8] = trailzero ? '\x00' : '\xff';
- 
- 	return entry;
- }
-@@ -436,6 +478,37 @@ static void * generate_sysupgrade_image(const struct flash_partition_entry *flas
- 	return image;
- }
- 
-+static void * generate_sysupgrade_image_c2600(const struct flash_partition_entry *flash_parts, const struct image_partition_entry *image_parts, size_t *len) {
-+	const struct flash_partition_entry *flash_os_image = &flash_parts[11];
-+	const struct flash_partition_entry *flash_file_system = &flash_parts[12];
-+
-+	const struct image_partition_entry *image_os_image = &image_parts[3];
-+	const struct image_partition_entry *image_file_system = &image_parts[4];
-+
-+	assert(strcmp(flash_os_image->name, "os-image") == 0);
-+	assert(strcmp(flash_file_system->name, "file-system") == 0);
-+
-+	assert(strcmp(image_os_image->name, "os-image") == 0);
-+	assert(strcmp(image_file_system->name, "file-system") == 0);
-+
-+	if (image_os_image->size > flash_os_image->size)
-+		error(1, 0, "kernel image too big (more than %u bytes)", (unsigned)flash_os_image->size);
-+	if (image_file_system->size > flash_file_system->size)
-+		error(1, 0, "rootfs image too big (more than %u bytes)", (unsigned)flash_file_system->size);
-+
-+	*len = flash_file_system->base - flash_os_image->base + image_file_system->size;
-+
-+	uint8_t *image = malloc(*len);
-+	if (!image)
-+		error(1, errno, "malloc");
-+
-+	memset(image, 0xff, *len);
-+
-+	memcpy(image, image_os_image->data, image_os_image->size);
-+	memcpy(image + flash_file_system->base - flash_os_image->base, image_file_system->data, image_file_system->size);
-+
-+	return image;
-+}
- 
- /** Generates an image for CPE210/220/510/520 and writes it to a file */
- static void do_cpe510(const char *output, const char *kernel_image, const char *rootfs_image, uint32_t rev, bool add_jffs2_eof, bool sysupgrade) {
-@@ -443,7 +516,7 @@ static void do_cpe510(const char *output, const char *kernel_image, const char *
- 
- 	parts[0] = make_partition_table(cpe510_partitions);
- 	parts[1] = make_soft_version(rev);
--	parts[2] = make_support_list(cpe510_support_list);
-+	parts[2] = make_support_list(cpe510_support_list,false);
- 	parts[3] = read_file("os-image", kernel_image, false);
- 	parts[4] = read_file("file-system", rootfs_image, add_jffs2_eof);
- 
-@@ -470,6 +543,39 @@ static void do_cpe510(const char *output, const char *kernel_image, const char *
- 		free_image_partition(parts[i]);
- }
- 
-+/** Generates an image for C2600 and writes it to a file */
-+static void do_c2600(const char *output, const char *kernel_image, const char *rootfs_image, uint32_t rev, bool add_jffs2_eof, bool sysupgrade) {
-+	struct image_partition_entry parts[6] = {};
-+
-+	parts[0] = make_partition_table(c2600_partitions);
-+	parts[1] = make_soft_version(rev);
-+	parts[2] = make_support_list(c2600_support_list,true);
-+	parts[3] = read_file("os-image", kernel_image, false);
-+	parts[4] = read_file("file-system", rootfs_image, add_jffs2_eof);
-+
-+	size_t len;
-+	void *image;
-+	if (sysupgrade)
-+		image = generate_sysupgrade_image_c2600(c2600_partitions, parts, &len);
-+	else
-+		image = generate_factory_image(c2600_vendor, parts, &len);
-+
-+	FILE *file = fopen(output, "wb");
-+	if (!file)
-+		error(1, errno, "unable to open output file");
-+
-+	if (fwrite(image, len, 1, file) != 1)
-+		error(1, 0, "unable to write output file");
-+
-+	fclose(file);
-+
-+	free(image);
-+
-+	size_t i;
-+	for (i = 0; parts[i].name; i++)
-+		free_image_partition(parts[i]);
-+}
-+
- 
- /** Usage output */
- static void usage(const char *argv0) {
-@@ -552,6 +658,8 @@ int main(int argc, char *argv[]) {
- 
- 	if (strcmp(board, "CPE510") == 0)
- 		do_cpe510(output, kernel_image, rootfs_image, rev, add_jffs2_eof, sysupgrade);
-+	else if (strcmp(board, "C2600") == 0)
-+		do_c2600(output, kernel_image, rootfs_image, rev, add_jffs2_eof, sysupgrade);
- 	else
- 		error(1, 0, "unsupported board %s", board);
- 
diff --git a/patches/openwrt/0098-tools-cmake-fix-parallel-build-with-Make-4.2.patch b/patches/openwrt/0093-tools-cmake-fix-parallel-build-with-Make-4.2.patch
similarity index 100%
rename from patches/openwrt/0098-tools-cmake-fix-parallel-build-with-Make-4.2.patch
rename to patches/openwrt/0093-tools-cmake-fix-parallel-build-with-Make-4.2.patch
diff --git a/patches/openwrt/0099-linux-make-IPv6-builtin-if-selected-saves-30KB.patch b/patches/openwrt/0094-linux-make-IPv6-builtin-if-selected-saves-30KB.patch
similarity index 100%
rename from patches/openwrt/0099-linux-make-IPv6-builtin-if-selected-saves-30KB.patch
rename to patches/openwrt/0094-linux-make-IPv6-builtin-if-selected-saves-30KB.patch
diff --git a/patches/openwrt/0094-tools-tplink-safeloader-split-CPE210-from-CPE510-profile.patch b/patches/openwrt/0094-tools-tplink-safeloader-split-CPE210-from-CPE510-profile.patch
deleted file mode 100644
index a6c131287..000000000
--- a/patches/openwrt/0094-tools-tplink-safeloader-split-CPE210-from-CPE510-profile.patch
+++ /dev/null
@@ -1,102 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 9 Jun 2016 05:03:35 +0200
-Subject: tools/tplink-safeloader: split CPE210 from CPE510 profile
-
-The CPE210 was still described for the OEM upgrade as compatible,
-even the wireless configuration isn't compatible anymore between
-both series (2ghz and 5ghz).
-Update the CPE210 image profile to use the new profile.
-
-Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
-
-Backport of LEDE 824147960569f2c1cd22140c9074c62c3df911a5
-
-diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index 272abe0..57f38a5 100644
---- a/target/linux/ar71xx/image/Makefile
-+++ b/target/linux/ar71xx/image/Makefile
-@@ -2094,7 +2094,7 @@ $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR1043V2,tl-wr1043nd-v2,TL-WR10
- $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR1043V3,tl-wr1043nd-v3,TL-WR1043ND-v2,ttyS0,115200,0x10430003,1,8M))
- $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR2543,tl-wr2543-v1,TL-WR2543N,ttyS0,115200,0x25430001,1,8Mlzma,-v 3.13.99))
- 
--$(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE210_220,cpe210-220,CPE210,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
-+$(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE210_220,cpe210-220,CPE210,ttyS0,115200,$$(cpe510_mtdlayout),CPE210))
- $(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE510_520,cpe510-520,CPE510,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
- 
- $(eval $(call SingleProfile,UAPPRO,64k,UAPPRO,ubnt-uap-pro,UAP-PRO,ttyS0,115200,BZ,BZ,ar934x))
-diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c
-index 2e204aa..4938f74 100644
---- a/tools/firmware-utils/src/tplink-safeloader.c
-+++ b/tools/firmware-utils/src/tplink-safeloader.c
-@@ -163,6 +163,15 @@ static const struct flash_partition_entry c2600_partitions[] = {
- };
- 
- /**
-+   The support list for CPE210/220
-+*/
-+static const char cpe210_support_list[] =
-+	"SupportList:\r\n"
-+	"CPE210(TP-LINK|UN|N300-2):1.0\r\n"
-+	"CPE210(TP-LINK|UN|N300-2):1.1\r\n"
-+	"CPE220(TP-LINK|UN|N300-2):1.0\r\n"
-+	"CPE220(TP-LINK|UN|N300-2):1.1\r\n";
-+/**
-    The support list for CPE210/220/510/520
- */
- static const char cpe510_support_list[] =
-@@ -170,11 +179,7 @@ static const char cpe510_support_list[] =
- 	"CPE510(TP-LINK|UN|N300-5):1.0\r\n"
- 	"CPE510(TP-LINK|UN|N300-5):1.1\r\n"
- 	"CPE520(TP-LINK|UN|N300-5):1.0\r\n"
--	"CPE520(TP-LINK|UN|N300-5):1.1\r\n"
--	"CPE210(TP-LINK|UN|N300-2):1.0\r\n"
--	"CPE210(TP-LINK|UN|N300-2):1.1\r\n"
--	"CPE220(TP-LINK|UN|N300-2):1.0\r\n"
--	"CPE220(TP-LINK|UN|N300-2):1.1\r\n";
-+	"CPE520(TP-LINK|UN|N300-5):1.1\r\n";
- 
- /**
-    The support list for C2600
-@@ -511,12 +516,18 @@ static void * generate_sysupgrade_image_c2600(const struct flash_partition_entry
- }
- 
- /** Generates an image for CPE210/220/510/520 and writes it to a file */
--static void do_cpe510(const char *output, const char *kernel_image, const char *rootfs_image, uint32_t rev, bool add_jffs2_eof, bool sysupgrade) {
-+static void do_cpe(const char *output,
-+		const char *kernel_image,
-+		const char *rootfs_image,
-+		uint32_t rev,
-+		bool add_jffs2_eof,
-+		bool sysupgrade,
-+		const char *support_list) {
- 	struct image_partition_entry parts[6] = {};
- 
- 	parts[0] = make_partition_table(cpe510_partitions);
- 	parts[1] = make_soft_version(rev);
--	parts[2] = make_support_list(cpe510_support_list,false);
-+	parts[2] = make_support_list(support_list, false);
- 	parts[3] = read_file("os-image", kernel_image, false);
- 	parts[4] = read_file("file-system", rootfs_image, add_jffs2_eof);
- 
-@@ -549,7 +560,7 @@ static void do_c2600(const char *output, const char *kernel_image, const char *r
- 
- 	parts[0] = make_partition_table(c2600_partitions);
- 	parts[1] = make_soft_version(rev);
--	parts[2] = make_support_list(c2600_support_list,true);
-+	parts[2] = make_support_list(c2600_support_list, true);
- 	parts[3] = read_file("os-image", kernel_image, false);
- 	parts[4] = read_file("file-system", rootfs_image, add_jffs2_eof);
- 
-@@ -656,8 +667,10 @@ int main(int argc, char *argv[]) {
- 	if (!output)
- 		error(1, 0, "no output filename has been specified");
- 
--	if (strcmp(board, "CPE510") == 0)
--		do_cpe510(output, kernel_image, rootfs_image, rev, add_jffs2_eof, sysupgrade);
-+	if (strcmp(board, "CPE210") == 0)
-+		do_cpe(output, kernel_image, rootfs_image, rev, add_jffs2_eof, sysupgrade, cpe210_support_list);
-+	else if (strcmp(board, "CPE510") == 0)
-+		do_cpe(output, kernel_image, rootfs_image, rev, add_jffs2_eof, sysupgrade, cpe510_support_list);
- 	else if (strcmp(board, "C2600") == 0)
- 		do_c2600(output, kernel_image, rootfs_image, rev, add_jffs2_eof, sysupgrade);
- 	else
diff --git a/patches/openwrt/0100-package-ipkg.mk-fix-Provides-for-packages-with-multiple-PROVIDES-entries.patch b/patches/openwrt/0095-package-ipkg.mk-fix-Provides-for-packages-with-multiple-PROVIDES-entries.patch
similarity index 100%
rename from patches/openwrt/0100-package-ipkg.mk-fix-Provides-for-packages-with-multiple-PROVIDES-entries.patch
rename to patches/openwrt/0095-package-ipkg.mk-fix-Provides-for-packages-with-multiple-PROVIDES-entries.patch
diff --git a/patches/openwrt/0101-kernel-remove-packaging-of-kmod-crypto-core-and-kmod-crypto-arc4.patch b/patches/openwrt/0096-kernel-remove-packaging-of-kmod-crypto-core-and-kmod-crypto-arc4.patch
similarity index 100%
rename from patches/openwrt/0101-kernel-remove-packaging-of-kmod-crypto-core-and-kmod-crypto-arc4.patch
rename to patches/openwrt/0096-kernel-remove-packaging-of-kmod-crypto-core-and-kmod-crypto-arc4.patch
diff --git a/targets/ar71xx-generic/profiles.mk b/targets/ar71xx-generic/profiles.mk
index 587ea6d6f..9d78c9497 100644
--- a/targets/ar71xx-generic/profiles.mk
+++ b/targets/ar71xx-generic/profiles.mk
@@ -4,15 +4,14 @@
 
 # CPE210/220/510/520
 $(eval $(call GluonProfile,CPE510,rssileds))
+$(eval $(call GluonModel,CPE510,cpe210-220-510-520,tp-link-cpe510-v1.0))
 
-$(eval $(call GluonModel,CPE510,cpe210-220,tp-link-cpe210-v1.0))
-$(eval $(call GluonModelAlias,CPE510,tp-link-cpe210-v1.0,tp-link-cpe210-v1.1))
-$(eval $(call GluonModelAlias,CPE510,tp-link-cpe210-v1.0,tp-link-cpe220-v1.0))
-$(eval $(call GluonModelAlias,CPE510,tp-link-cpe210-v1.0,tp-link-cpe220-v1.1))
-
-$(eval $(call GluonModel,CPE510,cpe510-520,tp-link-cpe510-v1.0))
-$(eval $(call GluonModelAlias,CPE510,tp-link-cpe510-v1.0,tp-link-cpe510-v1.1))
+$(eval $(call GluonModelAlias,CPE510,tp-link-cpe510-v1.0,tp-link-cpe210-v1.0))
+$(eval $(call GluonModelAlias,CPE510,tp-link-cpe510-v1.0,tp-link-cpe220-v1.0))
 $(eval $(call GluonModelAlias,CPE510,tp-link-cpe510-v1.0,tp-link-cpe520-v1.0))
+$(eval $(call GluonModelAlias,CPE510,tp-link-cpe510-v1.0,tp-link-cpe210-v1.1))
+$(eval $(call GluonModelAlias,CPE510,tp-link-cpe510-v1.0,tp-link-cpe220-v1.1))
+$(eval $(call GluonModelAlias,CPE510,tp-link-cpe510-v1.0,tp-link-cpe510-v1.1))
 $(eval $(call GluonModelAlias,CPE510,tp-link-cpe510-v1.0,tp-link-cpe520-v1.1))
 
 # TL-WA701N/ND v1, v2
-- 
GitLab