[rdkb][common][bsp][Refactor and sync wifi from openwrt]
[Description]
8846f9b [MAC80211][mt76][Add eeprom comparison before writting efuse]
833aa75 [MAC80211][app][Add runtime testmode/normal mode switch cmd in iwpriv wrapper]
[Release-log]
Change-Id: I3e369b203c2464ea318a865f7c43aaebf7206c85
diff --git a/recipes-wifi/atenl/files/iwpriv.sh b/recipes-wifi/atenl/files/iwpriv.sh
index 6739392..a84c61e 100644
--- a/recipes-wifi/atenl/files/iwpriv.sh
+++ b/recipes-wifi/atenl/files/iwpriv.sh
@@ -887,27 +887,29 @@
local offchan_ch="$(echo $param | cut -d ':' -f1)"
local offchan_bw="$(echo $param | cut -d ':' -f2)"
- if [ "$offchan_bw" = "0" ]; then
- offchan_bw="20"
- elif [ "$offchan_bw" = "1" ]; then
- offchan_bw="40"
- elif [ "$offchan_bw" = "2" ]; then
- offchan_bw="80"
- fi
+ if [ "$offchan_bw" = "0" ]; then
+ offchan_bw="20"
+ elif [ "$offchan_bw" = "1" ]; then
+ offchan_bw="40"
+ elif [ "$offchan_bw" = "2" ]; then
+ offchan_bw="80"
+ elif [ "$offchan_bw" = "3" ]; then
+ offchan_bw="160"
+ fi
- do_cmd "mt76-test phy${phy_idx} set state=idle"
- do_cmd "mt76-test phy${phy_idx} set offchan_ch=${offchan_ch} offchan_bw=${offchan_bw}"
+ do_cmd "mt76-test phy${phy_idx} set state=idle"
+ do_cmd "mt76-test phy${phy_idx} set offchan_ch=${offchan_ch} offchan_bw=${offchan_bw}"
;;
"DfsRxHist")
local ipi_th="$(echo $param | cut -d ':' -f 1)"
local ipi_period="$(echo $param | cut -d ':' -f 2)"
- local ipi_antenna="$(echo $param | cut -d ':' -f 3)"
+ local ipi_antenna="$(echo $param | cut -d ':' -f 3)"
- if [ -z $ipi_antenna ]; then
- do_cmd "mt76-test phy${phy_idx} set ipi_threshold=${ipi_th} ipi_period=${ipi_period}"
- else
- do_cmd "mt76-test phy${phy_idx} set ipi_threshold=${ipi_th} ipi_period=${ipi_period} ipi_antenna_idx=${ipi_antenna}"
- fi
+ if [ -z $ipi_antenna ]; then
+ do_cmd "mt76-test phy${phy_idx} set ipi_threshold=${ipi_th} ipi_period=${ipi_period}"
+ else
+ do_cmd "mt76-test phy${phy_idx} set ipi_threshold=${ipi_th} ipi_period=${ipi_period} ipi_antenna_idx=${ipi_antenna}"
+ fi
;;
*)
esac
@@ -1365,6 +1367,44 @@
## dump command is only for vendor commands
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=$(cat ${eeprom_mode_file} | grep "mode" | sed -n 2p | cut -d " " -f 4)
+ eeprom_testmode_offset="1af"
+ testmode_enable="0"
+
+ if [ ${is_eagle} == "0" ]; then
+ return
+ fi
+
+ if [ "${cmd}" = "testmode" ]; then
+ testmode_enable="1"
+ fi
+
+ if [ "${eeprom_mode}" = "flash" ]; then
+ ## flash mode should set eeprom testmode offset bit
+ ## efuse/bin file/default bin mode rely on module param only
+ do_cmd "atenl -i ${interface} -c \"eeprom set 0x${eeprom_testmode_offset}=0x${testmode_enable}\""
+ ## If has no precal, it would not affect
+ do_cmd "atenl -i ${interface} -c \"eeprom precal sync\""
+ do_cmd "atenl -i ${interface} -c \"sync eeprom all\""
+ fi
+
+ do_cmd "rmmod mt7996e"
+ do_cmd "rmmod mt76-connac-lib"
+ do_cmd "rmmod mt76"
+ do_cmd "rmmod mac80211"
+ do_cmd "rmmod cfg80211"
+ do_cmd "rmmod compat"
+ do_cmd "insmod compat"
+ do_cmd "insmod cfg80211"
+ do_cmd "insmod mac80211"
+ do_cmd "insmod mt76"
+ do_cmd "insmod mt76-connac-lib"
+ do_cmd "insmod mt7996e testmode_enable=${testmode_enable}"
+ do_cmd "sleep 5"
+ do_cmd "killall hostapd"
+ do_cmd "killall netifd"
else
echo "Unknown command"
fi
diff --git a/recipes-wifi/linux-mt76/files/patches/1010-wifi-mt76-testmode-additional-supports.patch b/recipes-wifi/linux-mt76/files/patches/1010-wifi-mt76-testmode-additional-supports.patch
index b30867b..0d4d7de 100644
--- a/recipes-wifi/linux-mt76/files/patches/1010-wifi-mt76-testmode-additional-supports.patch
+++ b/recipes-wifi/linux-mt76/files/patches/1010-wifi-mt76-testmode-additional-supports.patch
@@ -1,4 +1,4 @@
-From 007557d45c5a57b9444d575344ba566d55d751c7 Mon Sep 17 00:00:00 2001
+From 219040e9aa5a584809fce08c86d6a6279cf7fe8a Mon Sep 17 00:00:00 2001
From: Shayne Chen <shayne.chen@mediatek.com>
Date: Thu, 21 Apr 2022 15:43:19 +0800
Subject: [PATCH 1010/1031] wifi: mt76: testmode: additional supports
@@ -11,24 +11,25 @@
mt76.h | 108 ++++-
mt76_connac_mcu.c | 4 +
mt76_connac_mcu.h | 2 +
+ mt7915/eeprom.c | 2 +-
mt7915/init.c | 2 +-
mt7915/mac.c | 39 +-
mt7915/main.c | 2 +-
- mt7915/mcu.c | 10 +-
+ mt7915/mcu.c | 19 +-
mt7915/mcu.h | 28 +-
mt7915/mmio.c | 2 +
- mt7915/mt7915.h | 14 +-
+ mt7915/mt7915.h | 16 +-
mt7915/regs.h | 3 +
- mt7915/testmode.c | 1177 ++++++++++++++++++++++++++++++++++++++++++---
+ mt7915/testmode.c | 1184 ++++++++++++++++++++++++++++++++++++++++++---
mt7915/testmode.h | 278 +++++++++++
testmode.c | 280 +++++++++--
testmode.h | 75 +++
tools/fields.c | 84 +++-
tx.c | 3 +-
- 19 files changed, 1975 insertions(+), 151 deletions(-)
+ 20 files changed, 1990 insertions(+), 156 deletions(-)
diff --git a/dma.c b/dma.c
-index 2fc70e23..f6d540b9 100644
+index df2ca73..fe65e0f 100644
--- a/dma.c
+++ b/dma.c
@@ -568,8 +568,7 @@ free:
@@ -42,10 +43,10 @@
#endif
diff --git a/mac80211.c b/mac80211.c
-index c3fa85d9..f6fa7887 100644
+index ad5d6f8..9107c0c 100644
--- a/mac80211.c
+++ b/mac80211.c
-@@ -55,6 +55,13 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
+@@ -56,6 +56,13 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
CHAN5G(60, 5300),
CHAN5G(64, 5320),
@@ -59,7 +60,7 @@
CHAN5G(100, 5500),
CHAN5G(104, 5520),
CHAN5G(108, 5540),
-@@ -75,6 +82,11 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
+@@ -76,6 +83,11 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
CHAN5G(165, 5825),
CHAN5G(169, 5845),
CHAN5G(173, 5865),
@@ -72,7 +73,7 @@
static const struct ieee80211_channel mt76_channels_6ghz[] = {
diff --git a/mt76.h b/mt76.h
-index 024c5ed2..f1fda51e 100644
+index ca66448..898726e 100644
--- a/mt76.h
+++ b/mt76.h
@@ -642,6 +642,21 @@ struct mt76_testmode_ops {
@@ -234,10 +235,10 @@
static inline void mt76_testmode_reset(struct mt76_phy *phy, bool disable)
{
diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c
-index 856b2897..56493774 100644
+index 2fefac6..b6c2ccf 100644
--- a/mt76_connac_mcu.c
+++ b/mt76_connac_mcu.c
-@@ -395,6 +395,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
+@@ -394,6 +394,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
switch (vif->type) {
case NL80211_IFTYPE_MESH_POINT:
case NL80211_IFTYPE_AP:
@@ -245,7 +246,7 @@
if (vif->p2p)
conn_type = CONNECTION_P2P_GC;
else
-@@ -576,6 +577,9 @@ void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev,
+@@ -575,6 +576,9 @@ void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev,
rx->rca2 = 1;
rx->rv = 1;
@@ -256,7 +257,7 @@
return;
diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
-index aa6d2dac..9641a080 100644
+index 8ba8ebf..4a63a24 100644
--- a/mt76_connac_mcu.h
+++ b/mt76_connac_mcu.h
@@ -996,6 +996,7 @@ enum {
@@ -275,8 +276,21 @@
MCU_EXT_CMD_CERT_CFG = 0xb7,
MCU_EXT_CMD_CSI_CTRL = 0xc2,
};
+diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c
+index a796289..f1b1471 100644
+--- a/mt7915/eeprom.c
++++ b/mt7915/eeprom.c
+@@ -126,7 +126,7 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev)
+ /* read eeprom data from efuse */
+ block_num = DIV_ROUND_UP(eeprom_size, eeprom_blk_size);
+ for (i = 0; i < block_num; i++) {
+- ret = mt7915_mcu_get_eeprom(dev, i * eeprom_blk_size);
++ ret = mt7915_mcu_get_eeprom(dev, i * eeprom_blk_size, NULL);
+ if (ret < 0)
+ return ret;
+ }
diff --git a/mt7915/init.c b/mt7915/init.c
-index 1177e4e7..f40d09c3 100644
+index 1177e4e..f40d09c 100644
--- a/mt7915/init.c
+++ b/mt7915/init.c
@@ -695,7 +695,7 @@ static void mt7915_init_work(struct work_struct *work)
@@ -289,7 +303,7 @@
mt7915_init_txpower(dev, &dev->mphy.sband_2g.sband);
mt7915_init_txpower(dev, &dev->mphy.sband_5g.sband);
diff --git a/mt7915/mac.c b/mt7915/mac.c
-index de2bdba5..1460a32b 100644
+index de2bdba..1460a32 100644
--- a/mt7915/mac.c
+++ b/mt7915/mac.c
@@ -627,16 +627,38 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi,
@@ -371,7 +385,7 @@
goto out;
diff --git a/mt7915/main.c b/mt7915/main.c
-index f63cea4a..05e7d51f 100644
+index 3a9f343..8789444 100644
--- a/mt7915/main.c
+++ b/mt7915/main.c
@@ -238,7 +238,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw,
@@ -384,10 +398,10 @@
mvif->mt76.wmm_idx += 2;
diff --git a/mt7915/mcu.c b/mt7915/mcu.c
-index b2118afa..05935509 100644
+index b0cdd4a..6f9acd8 100644
--- a/mt7915/mcu.c
+++ b/mt7915/mcu.c
-@@ -384,6 +384,11 @@ mt7915_mcu_rx_ext_event(struct mt7915_dev *dev, struct sk_buff *skb)
+@@ -383,6 +383,11 @@ mt7915_mcu_rx_ext_event(struct mt7915_dev *dev, struct sk_buff *skb)
case MCU_EXT_EVENT_BCC_NOTIFY:
mt7915_mcu_rx_bcc_notify(dev, skb);
break;
@@ -399,7 +413,7 @@
default:
break;
}
-@@ -415,6 +420,7 @@ void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb)
+@@ -414,6 +419,7 @@ void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb)
rxd->ext_eid == MCU_EXT_EVENT_ASSERT_DUMP ||
rxd->ext_eid == MCU_EXT_EVENT_PS_SYNC ||
rxd->ext_eid == MCU_EXT_EVENT_BCC_NOTIFY ||
@@ -407,7 +421,7 @@
!rxd->seq)
mt7915_mcu_rx_unsolicited_event(dev, skb);
else
-@@ -2861,14 +2867,14 @@ static int mt7915_mcu_set_eeprom_flash(struct mt7915_dev *dev)
+@@ -2860,21 +2866,21 @@ static int mt7915_mcu_set_eeprom_flash(struct mt7915_dev *dev)
return 0;
}
@@ -424,8 +438,38 @@
return mt7915_mcu_set_eeprom_flash(dev);
return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(EFUSE_BUFFER_MODE),
+ &req, sizeof(req), true);
+ }
+
+-int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
++int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf)
+ {
+ struct mt7915_mcu_eeprom_info req = {
+ .addr = cpu_to_le32(round_down(offset,
+@@ -2883,7 +2889,7 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
+ struct mt7915_mcu_eeprom_info *res;
+ struct sk_buff *skb;
+ int ret;
+- u8 *buf;
++ u8 *buf = read_buf;
+
+ ret = mt76_mcu_send_and_get_msg(&dev->mt76,
+ MCU_EXT_QUERY(EFUSE_ACCESS),
+@@ -2892,8 +2898,11 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
+ return ret;
+
+ res = (struct mt7915_mcu_eeprom_info *)skb->data;
+- buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
++
++ if (!buf)
++ buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
+ memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE);
++
+ dev_kfree_skb(skb);
+
+ return 0;
diff --git a/mt7915/mcu.h b/mt7915/mcu.h
-index 99d733b4..dd6a44d4 100644
+index 99d733b..dd6a44d 100644
--- a/mt7915/mcu.h
+++ b/mt7915/mcu.h
@@ -8,10 +8,15 @@
@@ -482,7 +526,7 @@
enum {
diff --git a/mt7915/mmio.c b/mt7915/mmio.c
-index 9451bf5d..22dcd18f 100644
+index dbafb5f..bb752a8 100644
--- a/mt7915/mmio.c
+++ b/mt7915/mmio.c
@@ -134,6 +134,7 @@ static const u32 mt7915_offs[] = {
@@ -502,7 +546,7 @@
[AGG_PCR0] = 0x040,
[AGG_ACR0] = 0x054,
diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index 055cbb5f..bc7314b7 100644
+index 055cbb5..416606a 100644
--- a/mt7915/mt7915.h
+++ b/mt7915/mt7915.h
@@ -323,6 +323,9 @@ struct mt7915_phy {
@@ -530,15 +574,17 @@
#ifdef MTK_DEBUG
u16 wlan_idx;
struct {
-@@ -594,7 +605,7 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev,
+@@ -594,8 +605,8 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
void *data, u32 field);
-int mt7915_mcu_set_eeprom(struct mt7915_dev *dev);
+-int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset);
+int mt7915_mcu_set_eeprom(struct mt7915_dev *dev, bool flash_mode);
- int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset);
++int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf);
int mt7915_mcu_get_eeprom_free_block(struct mt7915_dev *dev, u8 *block_num);
int mt7915_mcu_set_mac(struct mt7915_dev *dev, int band, bool enable,
+ bool hdr_trans);
@@ -632,6 +643,7 @@ int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 type, u8 ctrl);
int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level);
void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb);
@@ -548,7 +594,7 @@
static inline u16 mt7915_wtbl_size(struct mt7915_dev *dev)
{
diff --git a/mt7915/regs.h b/mt7915/regs.h
-index d6a05f13..e8768488 100644
+index d6a05f1..e876848 100644
--- a/mt7915/regs.h
+++ b/mt7915/regs.h
@@ -62,6 +62,7 @@ enum offs_rev {
@@ -569,7 +615,7 @@
(_n) * 4))
#define MT_AGG_PCR0(_band, _n) MT_WF_AGG(_band, (__OFFS(AGG_PCR0) + \
diff --git a/mt7915/testmode.c b/mt7915/testmode.c
-index 46939191..9317a8e0 100644
+index 4693919..1ed2ea8 100644
--- a/mt7915/testmode.c
+++ b/mt7915/testmode.c
@@ -9,6 +9,9 @@
@@ -1850,7 +1896,7 @@
void *rx, *rssi;
int i;
-@@ -852,11 +1822,68 @@ mt7915_tm_dump_stats(struct mt76_phy *mphy, struct sk_buff *msg)
+@@ -852,11 +1822,75 @@ mt7915_tm_dump_stats(struct mt76_phy *mphy, struct sk_buff *msg)
nla_nest_end(msg, rx);
@@ -1864,7 +1910,7 @@
+mt7915_tm_write_back_to_efuse(struct mt7915_dev *dev)
+{
+ struct mt7915_mcu_eeprom_info req = {};
-+ u8 *eeprom = dev->mt76.eeprom.data;
++ u8 read_buf[MT76_TM_EEPROM_BLOCK_SIZE], *eeprom = dev->mt76.eeprom.data;
+ int i, ret = -EINVAL;
+
+ /* prevent from damaging chip id in efuse */
@@ -1873,7 +1919,14 @@
+
+ for (i = 0; i < mt7915_eeprom_size(dev); i += MT76_TM_EEPROM_BLOCK_SIZE) {
+ req.addr = cpu_to_le32(i);
-+ memcpy(&req.data, eeprom + i, MT76_TM_EEPROM_BLOCK_SIZE);
++ memcpy(req.data, eeprom + i, MT76_TM_EEPROM_BLOCK_SIZE);
++
++ ret = mt7915_mcu_get_eeprom(dev, i, read_buf);
++ if (ret < 0)
++ return ret;
++
++ if (!memcmp(req.data, read_buf, MT76_TM_EEPROM_BLOCK_SIZE))
++ continue;
+
+ ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(EFUSE_ACCESS),
+ &req, sizeof(req), true);
@@ -1920,7 +1973,7 @@
+ .set_eeprom = mt7915_tm_set_eeprom,
};
diff --git a/mt7915/testmode.h b/mt7915/testmode.h
-index a1c54c89..01b08e9e 100644
+index a1c54c8..01b08e9 100644
--- a/mt7915/testmode.h
+++ b/mt7915/testmode.h
@@ -4,6 +4,8 @@
@@ -2235,7 +2288,7 @@
+
#endif
diff --git a/testmode.c b/testmode.c
-index 1d0d5d30..fd3b9b20 100644
+index 1d0d5d3..fd3b9b2 100644
--- a/testmode.c
+++ b/testmode.c
@@ -27,28 +27,16 @@ const struct nla_policy mt76_tm_policy[NUM_MT76_TM_ATTRS] = {
@@ -2706,7 +2759,7 @@
a = nla_nest_start(msg, MT76_TM_ATTR_TX_POWER);
if (!a)
diff --git a/testmode.h b/testmode.h
-index 89613266..57949f2b 100644
+index 8961326..57949f2 100644
--- a/testmode.h
+++ b/testmode.h
@@ -6,6 +6,8 @@
@@ -2811,7 +2864,7 @@
+
#endif
diff --git a/tools/fields.c b/tools/fields.c
-index e3f69089..7e564a3b 100644
+index e3f6908..7e564a3 100644
--- a/tools/fields.c
+++ b/tools/fields.c
@@ -10,6 +10,7 @@ static const char * const testmode_state[] = {
@@ -2952,7 +3005,7 @@
};
diff --git a/tx.c b/tx.c
-index 1f309d05..6d55566f 100644
+index 1f309d0..6d55566 100644
--- a/tx.c
+++ b/tx.c
@@ -250,8 +250,7 @@ void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff *
@@ -2966,5 +3019,5 @@
wake_up(&dev->tx_wait);
--
-2.39.0
+2.18.0
diff --git a/recipes-wifi/linux-mt76/files/patches/1025-wifi-mt76-mt7915-add-E3-re-bonding-for-low-yield-rat.patch b/recipes-wifi/linux-mt76/files/patches/1025-wifi-mt76-mt7915-add-E3-re-bonding-for-low-yield-rat.patch
index b980f2e..264131d 100644
--- a/recipes-wifi/linux-mt76/files/patches/1025-wifi-mt76-mt7915-add-E3-re-bonding-for-low-yield-rat.patch
+++ b/recipes-wifi/linux-mt76/files/patches/1025-wifi-mt76-mt7915-add-E3-re-bonding-for-low-yield-rat.patch
@@ -1,30 +1,20 @@
-From b072c7894a7a495178996224ba3c0d939faf77d2 Mon Sep 17 00:00:00 2001
+From 6256e5a3577ddf726a30774b2366e7ccf098031a Mon Sep 17 00:00:00 2001
From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
-Date: Thu, 13 Oct 2022 13:22:05 +0800
+Date: Thu, 30 Mar 2023 15:12:37 +0800
Subject: [PATCH 1025/1031] wifi: mt76: mt7915: add E3 re-bonding for low yield
rate issue
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
---
- mt7915/eeprom.c | 27 ++++++++++++++++++++++++++-
- mt7915/mcu.c | 13 ++++++++++---
- mt7915/mt7915.h | 3 ++-
- 3 files changed, 38 insertions(+), 5 deletions(-)
+ mt7915/eeprom.c | 28 ++++++++++++++++++++++++++++
+ mt7915/mt7915.h | 1 +
+ 2 files changed, 29 insertions(+)
diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c
-index 54803e8e..849275e1 100644
+index 612be3f..c6d8ca1 100644
--- a/mt7915/eeprom.c
+++ b/mt7915/eeprom.c
-@@ -132,7 +132,7 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev)
- /* read eeprom data from efuse */
- block_num = DIV_ROUND_UP(eeprom_size, eeprom_blk_size);
- for (i = 0; i < block_num; i++) {
-- ret = mt7915_mcu_get_eeprom(dev, i * eeprom_blk_size);
-+ ret = mt7915_mcu_get_eeprom(dev, i * eeprom_blk_size, NULL);
- if (ret < 0)
- return ret;
- }
-@@ -239,6 +239,29 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
+@@ -239,6 +239,32 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
dev->chainshift = hweight8(dev->mphy.chainmask);
}
@@ -34,8 +24,9 @@
+#define MT7986_ADIE1_EFFUSE_OFFSET 0x1000
+#define MT7986_ADIE1_MT7976C_OFFSET 0x270
+#define MT7986_ADIE1_E3_OFFSET 0x271
-+ u32 adie_offset, sku = mt7915_check_adie(dev, true);
-+ u8 read_buf, *eeprom = dev->mt76.eeprom.data;
++ u32 adie_offset, offset, sku = mt7915_check_adie(dev, true);
++ u8 read_buf[MT7915_EEPROM_BLOCK_SIZE], *eeprom = dev->mt76.eeprom.data;
++
+
+ if (!(sku & MT7976_ADIE_MASK))
+ return;
@@ -43,18 +34,20 @@
+ adie_offset = (sku == MT7976_DUAL_ADIE) ? MT7986_ADIE1_EFFUSE_OFFSET : 0;
+
+ /* 7976 A-Die, To identify MT7976C */
-+ mt7915_mcu_get_eeprom(dev, MT7986_ADIE1_MT7976C_OFFSET + adie_offset, &read_buf);
-+ eeprom[MT7986_ADIE1_MT7976C_OFFSET] = read_buf;
++ offset = MT7986_ADIE1_MT7976C_OFFSET + adie_offset;
++ mt7915_mcu_get_eeprom(dev, offset, read_buf);
++ eeprom[MT7986_ADIE1_MT7976C_OFFSET] = read_buf[offset % MT7915_EEPROM_BLOCK_SIZE];
+
+ /* E3 re-binding */
-+ mt7915_mcu_get_eeprom(dev, MT7986_ADIE1_E3_OFFSET + adie_offset, &read_buf);
-+ eeprom[MT7986_ADIE1_E3_OFFSET] = read_buf;
++ offset = MT7986_ADIE1_E3_OFFSET + adie_offset;
++ mt7915_mcu_get_eeprom(dev, offset, read_buf);
++ eeprom[MT7986_ADIE1_E3_OFFSET] = read_buf[offset % MT7915_EEPROM_BLOCK_SIZE];
+}
+
int mt7915_eeprom_init(struct mt7915_dev *dev)
{
int ret;
-@@ -275,6 +298,8 @@ int mt7915_eeprom_init(struct mt7915_dev *dev)
+@@ -275,6 +301,8 @@ int mt7915_eeprom_init(struct mt7915_dev *dev)
return ret;
}
@@ -63,39 +56,8 @@
ret = mt7915_eeprom_load_precal(dev);
if (ret)
return ret;
-diff --git a/mt7915/mcu.c b/mt7915/mcu.c
-index 1479afd5..eced0325 100644
---- a/mt7915/mcu.c
-+++ b/mt7915/mcu.c
-@@ -2899,7 +2899,7 @@ int mt7915_mcu_set_eeprom(struct mt7915_dev *dev, bool flash_mode)
- &req, sizeof(req), true);
- }
-
--int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
-+int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf)
- {
- struct mt7915_mcu_eeprom_info req = {
- .addr = cpu_to_le32(round_down(offset,
-@@ -2917,8 +2917,15 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
- return ret;
-
- res = (struct mt7915_mcu_eeprom_info *)skb->data;
-- buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
-- memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE);
-+
-+ if (read_buf) {
-+ u32 offs = offset % MT7915_EEPROM_BLOCK_SIZE;
-+ *read_buf = res->data[offs];
-+ } else {
-+ buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
-+ memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE);
-+ }
-+
- dev_kfree_skb(skb);
-
- return 0;
diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index 84bc906e..5999134d 100644
+index 73bc030..5999134 100644
--- a/mt7915/mt7915.h
+++ b/mt7915/mt7915.h
@@ -558,6 +558,7 @@ u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id);
@@ -106,15 +68,6 @@
int mt7915_eeprom_init(struct mt7915_dev *dev);
void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
struct mt7915_phy *phy);
-@@ -614,7 +615,7 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev,
- struct ieee80211_sta *sta,
- void *data, u32 field);
- int mt7915_mcu_set_eeprom(struct mt7915_dev *dev, bool flash_mode);
--int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset);
-+int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf);
- int mt7915_mcu_get_eeprom_free_block(struct mt7915_dev *dev, u8 *block_num);
- int mt7915_mcu_set_mac(struct mt7915_dev *dev, int band, bool enable,
- bool hdr_trans);
--
-2.39.0
+2.18.0