blob: 9780db3c50f39f0653ff1fa2775d17042314606d [file] [log] [blame]
developer9bc8ec12022-11-18 16:01:14 +08001From ba976379e903eb0a26276037718d5679ae95051a Mon Sep 17 00:00:00 2001
developer29344f12022-10-17 12:01:44 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Thu, 13 Oct 2022 13:22:05 +0800
developerb81e95d2022-11-08 10:16:29 +08004Subject: [PATCH 1127/1128] mt76: mt7915: add E3 re-bonding for low yield rate
developer29344f12022-10-17 12:01:44 +08005 issue
6
7Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
8---
9 mt7915/eeprom.c | 27 ++++++++++++++++++++++++++-
10 mt7915/mcu.c | 13 ++++++++++---
11 mt7915/mt7915.h | 3 ++-
12 3 files changed, 38 insertions(+), 5 deletions(-)
13
14diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c
developer9bc8ec12022-11-18 16:01:14 +080015index 4d2d9ca..b3d2bbc 100644
developer29344f12022-10-17 12:01:44 +080016--- a/mt7915/eeprom.c
17+++ b/mt7915/eeprom.c
developer9bc8ec12022-11-18 16:01:14 +080018@@ -97,7 +97,7 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev)
developer29344f12022-10-17 12:01:44 +080019 MT7915_EEPROM_BLOCK_SIZE);
20 for (i = 0; i < block_num; i++)
21 mt7915_mcu_get_eeprom(dev,
22- i * MT7915_EEPROM_BLOCK_SIZE);
23+ i * MT7915_EEPROM_BLOCK_SIZE, NULL);
developer9bc8ec12022-11-18 16:01:14 +080024 dev->eeprom_mode = EFUSE_MODE;
developer29344f12022-10-17 12:01:44 +080025 }
26
developer9bc8ec12022-11-18 16:01:14 +080027@@ -198,6 +198,29 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
developer29344f12022-10-17 12:01:44 +080028 dev->chainshift = hweight8(dev->mphy.chainmask);
29 }
30
31+void mt7915_eeprom_rebonding(struct mt7915_dev *dev)
32+{
33+#define MT7976_ADIE_MASK BIT(1)
34+#define MT7986_ADIE1_EFFUSE_OFFSET 0x1000
35+#define MT7986_ADIE1_MT7976C_OFFSET 0x270
36+#define MT7986_ADIE1_E3_OFFSET 0x271
37+ u32 adie_offset, sku = mt7915_check_adie(dev, true);
38+ u8 read_buf, *eeprom = dev->mt76.eeprom.data;
39+
40+ if (!(sku & MT7976_ADIE_MASK))
41+ return;
42+
43+ adie_offset = (sku == MT7976_DUAL_ADIE) ? MT7986_ADIE1_EFFUSE_OFFSET : 0;
44+
45+ /* 7976 A-Die, To identify MT7976C */
46+ mt7915_mcu_get_eeprom(dev, MT7986_ADIE1_MT7976C_OFFSET + adie_offset, &read_buf);
47+ eeprom[MT7986_ADIE1_MT7976C_OFFSET] = read_buf;
48+
49+ /* E3 re-binding */
50+ mt7915_mcu_get_eeprom(dev, MT7986_ADIE1_E3_OFFSET + adie_offset, &read_buf);
51+ eeprom[MT7986_ADIE1_E3_OFFSET] = read_buf;
52+}
53+
54 int mt7915_eeprom_init(struct mt7915_dev *dev)
55 {
56 int ret;
developer9bc8ec12022-11-18 16:01:14 +080057@@ -229,6 +252,8 @@ int mt7915_eeprom_init(struct mt7915_dev *dev)
developer29344f12022-10-17 12:01:44 +080058 return ret;
59 }
60
61+ mt7915_eeprom_rebonding(dev);
62+
63 ret = mt7915_eeprom_load_precal(dev);
64 if (ret)
65 return ret;
66diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer9bc8ec12022-11-18 16:01:14 +080067index 39c8e2c..fad3559 100644
developer29344f12022-10-17 12:01:44 +080068--- a/mt7915/mcu.c
69+++ b/mt7915/mcu.c
developer2cbf2fb2022-11-16 12:20:48 +080070@@ -2779,7 +2779,7 @@ int mt7915_mcu_set_eeprom(struct mt7915_dev *dev, bool flash_mode)
developer29344f12022-10-17 12:01:44 +080071 &req, sizeof(req), true);
72 }
73
74-int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
75+int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf)
76 {
77 struct mt7915_mcu_eeprom_info req = {
78 .addr = cpu_to_le32(round_down(offset,
developer2cbf2fb2022-11-16 12:20:48 +080079@@ -2796,8 +2796,15 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
developer29344f12022-10-17 12:01:44 +080080 return ret;
81
82 res = (struct mt7915_mcu_eeprom_info *)skb->data;
83- buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
84- memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE);
85+
86+ if (read_buf) {
87+ u32 offs = offset % MT7915_EEPROM_BLOCK_SIZE;
88+ *read_buf = res->data[offs];
89+ } else {
90+ buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
91+ memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE);
92+ }
93+
94 dev_kfree_skb(skb);
95
96 return 0;
97diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer9bc8ec12022-11-18 16:01:14 +080098index 4cdcb63..dbd634a 100644
developer29344f12022-10-17 12:01:44 +080099--- a/mt7915/mt7915.h
100+++ b/mt7915/mt7915.h
developer9bc8ec12022-11-18 16:01:14 +0800101@@ -560,6 +560,7 @@ u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id);
developer29344f12022-10-17 12:01:44 +0800102
103 int mt7915_register_device(struct mt7915_dev *dev);
104 void mt7915_unregister_device(struct mt7915_dev *dev);
105+void mt7915_eeprom_rebonding(struct mt7915_dev *dev);
106 int mt7915_eeprom_init(struct mt7915_dev *dev);
107 void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
108 struct mt7915_phy *phy);
developer9bc8ec12022-11-18 16:01:14 +0800109@@ -613,7 +614,7 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev,
developer29344f12022-10-17 12:01:44 +0800110 struct ieee80211_sta *sta,
111 void *data, u32 field);
112 int mt7915_mcu_set_eeprom(struct mt7915_dev *dev, bool flash_mode);
113-int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset);
114+int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf);
115 int mt7915_mcu_get_eeprom_free_block(struct mt7915_dev *dev, u8 *block_num);
116 int mt7915_mcu_set_mac(struct mt7915_dev *dev, int band, bool enable,
117 bool hdr_trans);
118--
developerb81e95d2022-11-08 10:16:29 +08001192.18.0
developer29344f12022-10-17 12:01:44 +0800120