blob: 264131d135f92a77e16755df183b4d2b51680a00 [file] [log] [blame]
developerae9afc02023-04-06 18:07:42 +08001From 6256e5a3577ddf726a30774b2366e7ccf098031a Mon Sep 17 00:00:00 2001
developer6a1998b2022-12-08 18:09:45 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
developerae9afc02023-04-06 18:07:42 +08003Date: Thu, 30 Mar 2023 15:12:37 +0800
developer78848c62023-04-06 13:44:00 +08004Subject: [PATCH 1025/1031] wifi: mt76: mt7915: add E3 re-bonding for low yield
5 rate issue
developer6a1998b2022-12-08 18:09:45 +08006
7Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
8---
developerae9afc02023-04-06 18:07:42 +08009 mt7915/eeprom.c | 28 ++++++++++++++++++++++++++++
10 mt7915/mt7915.h | 1 +
11 2 files changed, 29 insertions(+)
developer6a1998b2022-12-08 18:09:45 +080012
13diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c
developerae9afc02023-04-06 18:07:42 +080014index 612be3f..c6d8ca1 100644
developer6a1998b2022-12-08 18:09:45 +080015--- a/mt7915/eeprom.c
16+++ b/mt7915/eeprom.c
developerae9afc02023-04-06 18:07:42 +080017@@ -239,6 +239,32 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
developer6a1998b2022-12-08 18:09:45 +080018 dev->chainshift = hweight8(dev->mphy.chainmask);
19 }
20
21+void mt7915_eeprom_rebonding(struct mt7915_dev *dev)
22+{
23+#define MT7976_ADIE_MASK BIT(1)
24+#define MT7986_ADIE1_EFFUSE_OFFSET 0x1000
25+#define MT7986_ADIE1_MT7976C_OFFSET 0x270
26+#define MT7986_ADIE1_E3_OFFSET 0x271
developerae9afc02023-04-06 18:07:42 +080027+ u32 adie_offset, offset, sku = mt7915_check_adie(dev, true);
28+ u8 read_buf[MT7915_EEPROM_BLOCK_SIZE], *eeprom = dev->mt76.eeprom.data;
29+
developer6a1998b2022-12-08 18:09:45 +080030+
31+ if (!(sku & MT7976_ADIE_MASK))
32+ return;
33+
34+ adie_offset = (sku == MT7976_DUAL_ADIE) ? MT7986_ADIE1_EFFUSE_OFFSET : 0;
35+
36+ /* 7976 A-Die, To identify MT7976C */
developerae9afc02023-04-06 18:07:42 +080037+ offset = MT7986_ADIE1_MT7976C_OFFSET + adie_offset;
38+ mt7915_mcu_get_eeprom(dev, offset, read_buf);
39+ eeprom[MT7986_ADIE1_MT7976C_OFFSET] = read_buf[offset % MT7915_EEPROM_BLOCK_SIZE];
developer6a1998b2022-12-08 18:09:45 +080040+
41+ /* E3 re-binding */
developerae9afc02023-04-06 18:07:42 +080042+ offset = MT7986_ADIE1_E3_OFFSET + adie_offset;
43+ mt7915_mcu_get_eeprom(dev, offset, read_buf);
44+ eeprom[MT7986_ADIE1_E3_OFFSET] = read_buf[offset % MT7915_EEPROM_BLOCK_SIZE];
developer6a1998b2022-12-08 18:09:45 +080045+}
46+
47 int mt7915_eeprom_init(struct mt7915_dev *dev)
48 {
49 int ret;
developerae9afc02023-04-06 18:07:42 +080050@@ -275,6 +301,8 @@ int mt7915_eeprom_init(struct mt7915_dev *dev)
developer6a1998b2022-12-08 18:09:45 +080051 return ret;
52 }
53
54+ mt7915_eeprom_rebonding(dev);
55+
56 ret = mt7915_eeprom_load_precal(dev);
57 if (ret)
58 return ret;
developer6a1998b2022-12-08 18:09:45 +080059diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developerae9afc02023-04-06 18:07:42 +080060index 73bc030..5999134 100644
developer6a1998b2022-12-08 18:09:45 +080061--- a/mt7915/mt7915.h
62+++ b/mt7915/mt7915.h
developerb8853042023-02-17 11:50:45 +080063@@ -558,6 +558,7 @@ u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id);
developer6a1998b2022-12-08 18:09:45 +080064
65 int mt7915_register_device(struct mt7915_dev *dev);
66 void mt7915_unregister_device(struct mt7915_dev *dev);
67+void mt7915_eeprom_rebonding(struct mt7915_dev *dev);
68 int mt7915_eeprom_init(struct mt7915_dev *dev);
69 void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
70 struct mt7915_phy *phy);
developer6a1998b2022-12-08 18:09:45 +080071--
developerae9afc02023-04-06 18:07:42 +0800722.18.0
developer6a1998b2022-12-08 18:09:45 +080073