blob: 60261c6c426bfa4cf808d6ffe55ffad1824b1b37 [file] [log] [blame]
From a3c96bd2d17ffd8777dd7c3afe429daa3aada222 Mon Sep 17 00:00:00 2001
From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Date: Thu, 30 Mar 2023 15:12:37 +0800
Subject: [PATCH 1023/1034] wifi: mt76: mt7915: add E3 re-bonding for low yield
rate issue
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
---
mt7915/eeprom.c | 28 ++++++++++++++++++++++++++++
mt7915/mt7915.h | 1 +
2 files changed, 29 insertions(+)
diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c
index fd08d42a..3b44a9d7 100644
--- a/mt7915/eeprom.c
+++ b/mt7915/eeprom.c
@@ -244,6 +244,32 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
dev->chainshift = hweight8(dev->mphy.chainmask);
}
+void mt7915_eeprom_rebonding(struct mt7915_dev *dev)
+{
+#define MT7976_ADIE_MASK BIT(1)
+#define MT7986_ADIE1_EFFUSE_OFFSET 0x1000
+#define MT7986_ADIE1_MT7976C_OFFSET 0x270
+#define MT7986_ADIE1_E3_OFFSET 0x271
+ 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;
+
+ adie_offset = (sku == MT7976_DUAL_ADIE) ? MT7986_ADIE1_EFFUSE_OFFSET : 0;
+
+ /* 7976 A-Die, To identify MT7976C */
+ 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 */
+ 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;
@@ -280,6 +306,8 @@ int mt7915_eeprom_init(struct mt7915_dev *dev)
return ret;
}
+ mt7915_eeprom_rebonding(dev);
+
ret = mt7915_eeprom_load_precal(dev);
if (ret)
return ret;
diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
index b5f76a32..851caa99 100644
--- a/mt7915/mt7915.h
+++ b/mt7915/mt7915.h
@@ -503,6 +503,7 @@ u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id);
int mt7915_register_device(struct mt7915_dev *dev);
void mt7915_unregister_device(struct mt7915_dev *dev);
+void mt7915_eeprom_rebonding(struct mt7915_dev *dev);
int mt7915_eeprom_init(struct mt7915_dev *dev);
void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
struct mt7915_phy *phy);
--
2.39.2