[rdkb][common][bsp][Refactor and sync wifi from openwrt]

[Description]
1776d62e [MAC80211][WiFi6/7][app][Fix atenl sync eeprom all issue]
f27a8bc9 [MAC80211][WiFi6][misc][Add coredump support for MT7981]
8ae764db [mac80211][netifd][wifi7][Fix patch fail]
db2ba4ea [mac80211][netifd][wifi7][Fix patch fail]
1671230e [MAC80211][WiFi6][mt76][Fix dump PFMU tag kernel calltrace]
537408c4 [MAC80211][WiFi6][Rebase][Fix patch error]
9a4c64fa [mac80211][wifi6][mt76][Fix txpower sku issues]
8276145f [MAC80211][WiFi6][mt76][not send RTS before sending BSRP]
2c6e3189 [MAC80211][WiFi6][Rebase Patches][Fix patch error]
6b529b8c [[MAC80211][WiFi6][mt76][add per-bss counter for mt7915]
95df57b3 [MAC80211][WiFi6][app][Add atenl support for cheetah]
94705cb2 [MAC80211][WiFi6][mt76][Add support for cheetah]
4ff10eee [mac80211][wifi6][mt76][Add debugfs address map for Cheetah MT76]
85af3247 [MAC80211[WiFi6]][hostapd][Add extender behavior log]
04302ac4 [MAC80211[WiFi7]][hostapd][Add eht_bw320_offset configuration option]
88013859 [MAC80211][WiFi6/7][app][Fix atenl cannot support binfile mode precal issue]
c1cad928 [MAC80211][WiFi6][mt76][Fix binfile cannot sync precal data to atenl]
8fd441fb [MAC80211][WiFi6/7][misc][remove internal patch for ucode package]
4653100b [MAC80211][WiFi6][mt76][rename bf debug cmd to align connac3]
9edd5444 [MAC80211][WiFi6][mt76][Fixed null pointer dereference issue]

[Release-log]

Change-Id: Ia7013b21497826cdf4d9c6192d6812aff5f948ae
diff --git a/recipes-wifi/atenl/files/src/eeprom.c b/recipes-wifi/atenl/files/src/eeprom.c
index 10720d0..d112dc7 100644
--- a/recipes-wifi/atenl/files/src/eeprom.c
+++ b/recipes-wifi/atenl/files/src/eeprom.c
@@ -18,10 +18,10 @@
 
 	/* reserve space for pre-cal data in flash mode */
 	if (flash_mode) {
-		atenl_dbg("%s: init eeprom with flash mode\n", __func__);
+		atenl_dbg("%s: init eeprom with flash / binfile mode\n", __func__);
 		max_len = EEPROM_PART_SIZE;
 	} else {
-		atenl_dbg("%s: init eeprom with efuse mode\n", __func__);
+		atenl_dbg("%s: init eeprom with efuse / default bin mode\n", __func__);
 		max_len = 0x1e00;
 	}
 
@@ -117,7 +117,7 @@
 
 	if (is_mt7915(an)) {
 		an->adie_id = 0x7975;
-	} else if (is_mt7916(an)) {
+	} else if (is_mt7916(an) || is_mt7981(an)) {
 		an->adie_id = 0x7976;
 	} else if (is_mt7986(an)) {
 		bool is_7975 = false;
@@ -164,6 +164,7 @@
 		break;
 	case 0x7906:
 	case 0x7916:
+	case 0x7981:
 	case 0x7986:
 		an->eeprom_size = 4096;
 		an->eeprom_prek_offs = 0x19a;
@@ -209,7 +210,7 @@
 			anb->valid = true;
 			anb->cap = BAND_TYPE_5G;
 		}
-	} else if (is_mt7916(an) || is_mt7986(an)) {
+	} else if (is_mt7916(an) || is_mt7981(an) || is_mt7986(an)) {
 		struct atenl_band *anb;
 		u8 val, band_sel;
 		int i;
@@ -316,6 +317,10 @@
 		an->anb[0].chainmask = 0x3;
 		an->anb[1].chainmask = 0x3;
 		break;
+	case 0x7981:
+		an->anb[0].chainmask = 0x3;
+		an->anb[1].chainmask = 0x7;
+		break;
 	case 0x7986:
 		an->anb[0].chainmask = 0xf;
 		an->anb[1].chainmask = 0xf;
@@ -419,31 +424,27 @@
 
 int atenl_eeprom_write_mtd(struct atenl *an)
 {
-	bool flash_mode = an->mtd_part != NULL;
+#define TMP_FILE	"/tmp/tmp_eeprom.bin"
 	pid_t pid;
-	char offset[10];
+	u32 size = an->eeprom_size;
+	u32 *precal_info = an->eeprom_data + an->eeprom_size;
+	u32 precal_size = precal_info[0] + precal_info[1];
+	char cmd[100];
 
-	if (!flash_mode)
+	if (an->mtd_part == NULL || !(~an->mtd_offset))
 		return 0;
 
-	pid = fork();
-	if (pid < 0) {
-		perror("Fork");
-		return EXIT_FAILURE;
-	} else if (pid == 0) {
-		int ret;
-		char *part = strdup(an->mtd_part);
-		snprintf(offset, sizeof(offset), "%d", an->mtd_offset);
-		char *cmd[] = {"mtd", "-p", offset, "write", eeprom_file, part, NULL};
+	if (precal_size)
+		size += PRE_CAL_INFO + precal_size;
 
-		ret = execvp("mtd", cmd);
-		if (ret < 0) {
-			atenl_err("%s: exec error\n", __func__);
-			exit(0);
-		}
-	} else {
-		wait(&pid);
-	}
+	sprintf(cmd, "dd if=%s of=%s bs=1 count=%d", eeprom_file, TMP_FILE, size);
+	system(cmd);
+
+	sprintf(cmd, "mtd -p %d write %s %s", an->mtd_offset, TMP_FILE, an->mtd_part);
+	system(cmd);
+
+	sprintf(cmd, "rm %s", TMP_FILE);
+	system(cmd);
 
 	return 0;
 }
@@ -498,12 +499,9 @@
 
 void atenl_eeprom_cmd_handler(struct atenl *an, u8 phy_idx, char *cmd)
 {
-	bool flash_mode;
-
 	an->cmd_mode = true;
 
 	atenl_eeprom_init(an, phy_idx);
-	flash_mode = an->mtd_part != NULL;
 
 	if (!strncmp(cmd, "sync eeprom all", 15)) {
 		atenl_eeprom_write_mtd(an);
@@ -520,7 +518,11 @@
 			unlink(eeprom_file);
 		} else if (!strncmp(s, "file", 4)) {
 			atenl_info("%s\n", eeprom_file);
-			atenl_info("Flash mode: %d\n", flash_mode);
+			if (an->mtd_part != NULL)
+				atenl_info("%s mode\n",
+					   ~an->mtd_offset == 0 ? "Binfile" : "Flash");
+			else
+				atenl_info("Efuse / Default bin mode\n");
 		} else if (!strncmp(s, "set", 3)) {
 			u32 offset, val;