[rdk-b][common][bsp][Refactor and sync kernel/wifi from Openwrt]
[Description]
Refactor and sync kernel/wifi from Openwrt
[Release-log]
N/A
diff --git a/recipes-wifi/atenl/files/src/atenl.h b/recipes-wifi/atenl/files/src/atenl.h
index 75ee474..13f7b95 100644
--- a/recipes-wifi/atenl/files/src/atenl.h
+++ b/recipes-wifi/atenl/files/src/atenl.h
@@ -19,11 +19,11 @@
#define BRIDGE_NAME_OPENWRT "br-lan"
#define BRIDGE_NAME_RDKB "brlan0"
-#define ETH_P_RACFG 0x2880
+#define ETH_P_RACFG 0x2880
#define RACFG_PKT_MAX_SIZE 1600
-#define RACFG_HLEN 12
-#define RACFG_MAGIC_NO 0x18142880
-#define PRE_CAL_INFO 16
+#define RACFG_HLEN 12
+#define RACFG_MAGIC_NO 0x18142880
+#define PRE_CAL_INFO 16
#define DPD_INFO_CH_SHIFT 24
#define DPD_INFO_2G_SHIFT 16
#define DPD_INFO_5G_SHIFT 8
@@ -93,7 +93,7 @@
const char *mtd_part;
u32 mtd_offset;
- u8 is_main_phy;
+ u8 band_idx;
u8 *eeprom_data;
int eeprom_fd;
u16 eeprom_size;
@@ -275,8 +275,20 @@
MT_EE_BAND_SEL_5G_6G,
};
+/* for mt7996 */
+enum {
+ MT_EE_EAGLE_BAND_SEL_DEFAULT,
+ MT_EE_EAGLE_BAND_SEL_2GHZ,
+ MT_EE_EAGLE_BAND_SEL_5GHZ,
+ MT_EE_EAGLE_BAND_SEL_6GHZ,
+ MT_EE_EAGLE_BAND_SEL_5GHZ_6GHZ,
+};
+
#define MT_EE_WIFI_CONF 0x190
#define MT_EE_WIFI_CONF0_BAND_SEL GENMASK(7, 6)
+#define MT_EE_WIFI_EAGLE_CONF0_BAND_SEL GENMASK(2, 0)
+#define MT_EE_WIFI_EAGLE_CONF1_BAND_SEL GENMASK(5, 3)
+#define MT_EE_WIFI_EAGLE_CONF2_BAND_SEL GENMASK(2, 0)
enum {
MT7976_ONE_ADIE_DBDC = 0x7,
@@ -389,6 +401,11 @@
return an->chip_id == 0x7986;
}
+static inline bool is_mt7996(struct atenl *an)
+{
+ return an->chip_id == 0x7990;
+}
+
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/recipes-wifi/atenl/files/src/eeprom.c b/recipes-wifi/atenl/files/src/eeprom.c
index d18262e..b71708e 100644
--- a/recipes-wifi/atenl/files/src/eeprom.c
+++ b/recipes-wifi/atenl/files/src/eeprom.c
@@ -22,7 +22,7 @@
max_len = EEPROM_PART_SIZE;
} else {
atenl_dbg("%s: init eeprom with efuse mode\n", __func__);
- max_len = 0x1000;
+ max_len = 0x1e00;
}
snprintf(fname, sizeof(fname),
@@ -147,6 +147,8 @@
an->sub_chip_id = sub_id;
an->adie_id = is_7975 ? 0x7975 : 0x7976;
+ } else if (is_mt7996(an)) {
+ /* TODO: parse info if required */
}
}
@@ -164,6 +166,9 @@
an->eeprom_size = 4096;
an->eeprom_prek_offs = 0x19a;
break;
+ case 0x7990:
+ an->eeprom_size = 7680;
+ an->eeprom_prek_offs = 0x1a5;
default:
break;
}
@@ -172,6 +177,7 @@
static void
atenl_eeprom_init_band_cap(struct atenl *an)
{
+#define EAGLE_BAND_SEL(index) MT_EE_WIFI_EAGLE_CONF##index##_BAND_SEL
u8 *eeprom = an->eeprom_data;
if (is_mt7915(an)) {
@@ -228,6 +234,36 @@
break;
}
}
+ } else if (is_mt7996(an)) {
+ struct atenl_band *anb;
+ u8 val, band_sel;
+ u8 band_sel_mask[3] = {EAGLE_BAND_SEL(0), EAGLE_BAND_SEL(1),
+ EAGLE_BAND_SEL(2)};
+ int i;
+
+ for (i = 0; i < 3; 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;
+ }
+ }
}
}
@@ -247,6 +283,10 @@
} else if (is_mt7986(an)) {
an->anb[0].chainmask = 0xf;
an->anb[1].chainmask = 0xf;
+ } else if (is_mt7996(an)) {
+ an->anb[0].chainmask = 0xf;
+ an->anb[1].chainmask = 0xf;
+ an->anb[2].chainmask = 0xf;
}
}
@@ -261,8 +301,9 @@
atenl_nl_check_mtd(an);
flash_mode = an->mtd_part != NULL;
+ // Get the first main phy index for this chip
if (flash_mode)
- main_phy_idx = an->is_main_phy ? main_phy_idx : (main_phy_idx - 1);
+ main_phy_idx -= an->band_idx;
snprintf(buf, sizeof(buf), "/tmp/atenl-eeprom-phy%u", main_phy_idx);
eeprom_file = strdup(buf);
diff --git a/recipes-wifi/atenl/files/src/nl.c b/recipes-wifi/atenl/files/src/nl.c
index 7cbda0f..beada05 100644
--- a/recipes-wifi/atenl/files/src/nl.c
+++ b/recipes-wifi/atenl/files/src/nl.c
@@ -26,7 +26,7 @@
[MT76_TM_ATTR_STATE] = { .type = NLA_U8 },
[MT76_TM_ATTR_MTD_PART] = { .type = NLA_STRING },
[MT76_TM_ATTR_MTD_OFFSET] = { .type = NLA_U32 },
- [MT76_TM_ATTR_IS_MAIN_PHY] = { .type = NLA_U8 },
+ [MT76_TM_ATTR_BAND_IDX] = { .type = NLA_U8 },
[MT76_TM_ATTR_TX_COUNT] = { .type = NLA_U32 },
[MT76_TM_ATTR_TX_LENGTH] = { .type = NLA_U32 },
[MT76_TM_ATTR_TX_RATE_MODE] = { .type = NLA_U8 },
@@ -1180,7 +1180,7 @@
an->mtd_part = strdup(nla_get_string(tb[MT76_TM_ATTR_MTD_PART]));
an->mtd_offset = nla_get_u32(tb[MT76_TM_ATTR_MTD_OFFSET]);
- an->is_main_phy = nla_get_u32(tb[MT76_TM_ATTR_IS_MAIN_PHY]);
+ an->band_idx = nla_get_u32(tb[MT76_TM_ATTR_BAND_IDX]);
return NL_SKIP;
}
diff --git a/recipes-wifi/atenl/files/src/nl.h b/recipes-wifi/atenl/files/src/nl.h
index 1c774c9..b76abfe 100644
--- a/recipes-wifi/atenl/files/src/nl.h
+++ b/recipes-wifi/atenl/files/src/nl.h
@@ -14,7 +14,7 @@
*
* @MT76_TM_ATTR_MTD_PART: mtd partition used for eeprom data (string)
* @MT76_TM_ATTR_MTD_OFFSET: offset of eeprom data within the partition (u32)
- * @MT76_TM_ATTR_IS_MAIN_PHY: Is current phy index the main phy or the ext phy (u8)
+ * @MT76_TM_ATTR_BAND_IDX: band idx of the chip (u8)
*
* @MT76_TM_ATTR_TX_COUNT: configured number of frames to send when setting
* state to MT76_TM_STATE_TX_FRAMES (u32)
@@ -86,7 +86,7 @@
MT76_TM_ATTR_MTD_PART,
MT76_TM_ATTR_MTD_OFFSET,
- MT76_TM_ATTR_IS_MAIN_PHY,
+ MT76_TM_ATTR_BAND_IDX,
MT76_TM_ATTR_TX_COUNT,
MT76_TM_ATTR_TX_LENGTH,