[][MAC80211][WiFi7][app][Add Kite support in atenl]

[Description]
Add Kite support in atenl

[Release-log]
N/A

Change-Id: I2906371e32a5af826763f84db23a6c1edd3766cb
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8113443
diff --git a/feed/atenl/files/iwpriv.sh b/feed/atenl/files/iwpriv.sh
index 4fe407a..a29c765 100755
--- a/feed/atenl/files/iwpriv.sh
+++ b/feed/atenl/files/iwpriv.sh
@@ -1411,7 +1411,7 @@
 elif [ "${cmd_type}" = "dump" ]; then
     do_cmd "mt76-vendor $*"
 elif [ "${cmd_type}" = "switch" ]; then
-    eeprom_mode_file=sys/kernel/debug/ieee80211/phy0/mt76/eeprom_mode
+    eeprom_mode_file=/sys/kernel/debug/ieee80211/phy0/mt76/eeprom_mode
     eeprom_mode=$(cat ${eeprom_mode_file} | grep "mode" | sed -n 2p | cut -d " " -f 4)
     eeprom_testmode_offset="1af"
     testmode_enable="0"
diff --git a/feed/atenl/src/atenl.h b/feed/atenl/src/atenl.h
index 3641532..60feaf4 100644
--- a/feed/atenl/src/atenl.h
+++ b/feed/atenl/src/atenl.h
@@ -410,6 +410,16 @@
 	return an->chip_id == 0x7990;
 }
 
+static inline bool is_mt7992(struct atenl *an)
+{
+	return an->chip_id == 0x7992;
+}
+
+static inline bool is_connac3(struct atenl *an)
+{
+	return is_mt7996(an) || is_mt7992(an);
+}
+
 int atenl_eth_init(struct atenl *an);
 int atenl_eth_recv(struct atenl *an, struct atenl_data *data);
 int atenl_eth_send(struct atenl *an, struct atenl_data *data);
diff --git a/feed/atenl/src/eeprom.c b/feed/atenl/src/eeprom.c
index d40c806..10720d0 100644
--- a/feed/atenl/src/eeprom.c
+++ b/feed/atenl/src/eeprom.c
@@ -149,6 +149,8 @@
 		an->adie_id = is_7975 ? 0x7975 : 0x7976;
 	} else if (is_mt7996(an)) {
 		/* TODO: parse info if required */
+	} else if (is_mt7992(an)) {
+		/* TODO: parse info if required */
 	}
 }
 
@@ -167,6 +169,7 @@
 		an->eeprom_prek_offs = 0x19a;
 		break;
 	case 0x7990:
+	case 0x7992:
 		an->eeprom_size = 7680;
 		an->eeprom_prek_offs = 0x1a5;
 	default:
@@ -264,29 +267,70 @@
 				break;
 			}
 		}
+	} else if (is_mt7992(an)) {
+		struct atenl_band *anb;
+		u8 val, band_sel;
+		u8 band_sel_mask[2] = {EAGLE_BAND_SEL(0), EAGLE_BAND_SEL(1)};
+		int i;
+
+		for (i = 0; i < 2; i++) {
+			val = eeprom[MT_EE_WIFI_CONF + i];
+			band_sel = FIELD_GET(band_sel_mask[i], val);
+			anb = &an->anb[i];
+
+			anb->valid = true;
+			switch (band_sel) {
+			case MT_EE_EAGLE_BAND_SEL_2GHZ:
+				anb->cap = BAND_TYPE_2G;
+				break;
+			case MT_EE_EAGLE_BAND_SEL_5GHZ:
+				anb->cap = BAND_TYPE_5G;
+				break;
+			case MT_EE_EAGLE_BAND_SEL_6GHZ:
+				anb->cap = BAND_TYPE_6G;
+				break;
+			case MT_EE_EAGLE_BAND_SEL_5GHZ_6GHZ:
+				anb->cap = BAND_TYPE_5G_6G;
+				break;
+			default:
+				break;
+			}
+		}
 	}
 }
 
 static void
 atenl_eeprom_init_antenna_cap(struct atenl *an)
 {
-	if (is_mt7915(an)) {
+	switch (an->chip_id) {
+	case 0x7915:
 		if (an->anb[0].cap == BAND_TYPE_2G_5G)
 			an->anb[0].chainmask = 0xf;
 		else {
 			an->anb[0].chainmask = 0x3;
 			an->anb[1].chainmask = 0xc;
 		}
-	} else if (is_mt7916(an)) {
+		break;
+	case 0x7906:
+	case 0x7916:
 		an->anb[0].chainmask = 0x3;
 		an->anb[1].chainmask = 0x3;
-	} else if (is_mt7986(an)) {
+		break;
+	case 0x7986:
 		an->anb[0].chainmask = 0xf;
 		an->anb[1].chainmask = 0xf;
-	} else if (is_mt7996(an)) {
+		break;
+	case 0x7990:
 		an->anb[0].chainmask = 0xf;
 		an->anb[1].chainmask = 0xf;
 		an->anb[2].chainmask = 0xf;
+		break;
+	case 0x7992:
+		an->anb[0].chainmask = 0xf;
+		an->anb[1].chainmask = 0xf;
+		break;
+	default:
+		break;
 	}
 }
 
@@ -502,10 +546,10 @@
 
 			if (!strncmp(s, "flash", 5)) {
 				atenl_eeprom_write_mtd(an);
-            } else if (!strncmp(s, "to efuse", 8)) {
-                atenl_eeprom_sync_to_driver(an);
-                atenl_nl_write_efuse_all(an);
-            }
+			} else if (!strncmp(s, "to efuse", 8)) {
+				atenl_eeprom_sync_to_driver(an);
+				atenl_nl_write_efuse_all(an);
+			}
 		} else if (!strncmp(s, "read", 4)) {
 			u32 offset;
 
diff --git a/feed/atenl/src/nl.c b/feed/atenl/src/nl.c
index 56c68f1..6850fc8 100644
--- a/feed/atenl/src/nl.c
+++ b/feed/atenl/src/nl.c
@@ -309,7 +309,7 @@
 			atenl_set_attr_antenna(an, msg, tx_antenna);
 		}
 
-		if (!is_mt7996(an) && tx_rate_mode >= MT76_TM_TX_MODE_HE_SU) {
+		if (!is_connac3(an) && tx_rate_mode >= MT76_TM_TX_MODE_HE_SU) {
 			u8 ofs = sgi;
 			size_t i;
 
@@ -369,7 +369,7 @@
 		v = (u32 *)(hdr->data + 18);
 
 		atenl_set_attr_antenna(an, msg, ntohl(v[0]));
-		if (is_mt7996(an)) {
+		if (is_connac3(an)) {
 			nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_MODE,
 				   phy_type_to_attr(ntohl(v[2])));
 			nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_SGI, ntohl(v[3]));
@@ -903,7 +903,7 @@
 		 */
 		an->ibf_mcs = val[0];
 		nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_IDX, an->ibf_mcs);
-		if (!is_mt7996(an)) {
+		if (!is_connac3(an)) {
 			an->ibf_ant = tmp_ant;
 			nla_put_u8(msg, MT76_TM_ATTR_TX_ANTENNA, an->ibf_ant);
 		}
@@ -948,7 +948,7 @@
 		 * reset to 1 (mid gain) and 0 for wifi 7 and wifi 6, respectively
 		 */
 		if (action == TXBF_ACT_IBF_PHASE_CAL)
-			val[4] = is_mt7996(an) ? 1 : 0;
+			val[4] = is_connac3(an) ? 1 : 0;
 		for (i = 0; i < 5; i++)
 			nla_put_u16(msg, i, val[i]);
 		/* Used to distinguish between command mode and HQADLL mode */
@@ -1424,8 +1424,8 @@
 
 	offs = an->eeprom_prek_offs;
 	cal_indicator = an->eeprom_data[offs];
-	group_ind_mask = is_mt7996(an) ? GROUP_IND_MASK_7996 : GROUP_IND_MASK;
-	dpd_ind_mask = is_mt7996(an) ? DPD_IND_MASK_7996 : DPD_IND_MASK;
+	group_ind_mask = is_connac3(an) ? GROUP_IND_MASK_7996 : GROUP_IND_MASK;
+	dpd_ind_mask = is_connac3(an) ? DPD_IND_MASK_7996 : DPD_IND_MASK;
 
 	if (cal_indicator) {
 		precal_info = an->eeprom_data + an->eeprom_size;
@@ -1459,17 +1459,17 @@
 	case PREK_SYNC_DPD_6G:
 		size_ptr = &dpd_size;
 		base_idx = 0;
-		dpd_base_map = is_mt7996(an) ? GENMASK(2, 1) : 0;
+		dpd_base_map = is_connac3(an) ? GENMASK(2, 1) : 0;
 		goto start;
 	case PREK_SYNC_DPD_5G:
 		size_ptr = &dpd_size;
 		base_idx = 1;
-		dpd_base_map = is_mt7996(an) ? BIT(2) : BIT(0);
+		dpd_base_map = is_connac3(an) ? BIT(2) : BIT(0);
 		goto start;
 	case PREK_SYNC_DPD_2G:
 		size_ptr = &dpd_size;
 		base_idx = 2;
-		dpd_base_map = is_mt7996(an) ? 0 : GENMASK(1, 0);
+		dpd_base_map = is_connac3(an) ? 0 : GENMASK(1, 0);
 
 start:
 		if (unl_genl_init(&nl_priv.unl, "nl80211") < 0) {