blob: 39612b05c3c5b7718adec67d3dfe5df4cc1da14e [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 90dfcdd20e564dc3b82342141dfd6917899b7b66 Mon Sep 17 00:00:00 2001
developer1a173672023-12-21 14:49:33 +08002From: "Henry.Yen" <henry.yen@mediatek.com>
3Date: Mon, 11 Dec 2023 16:01:55 +0800
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 1039/1052] wifi: mt76: mt7915 add mt7981 efuse variants
developer753619c2024-02-22 13:42:45 +08005 support
developer1a173672023-12-21 14:49:33 +08006
7---
8 mt7915/eeprom.c | 22 ++++++++++++++++++++++
9 mt7915/mt7915.h | 7 ++++++-
10 2 files changed, 28 insertions(+), 1 deletion(-)
11
12diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c
developer05f3b2b2024-08-19 19:17:34 +080013index 6133c200..df5e396c 100644
developer1a173672023-12-21 14:49:33 +080014--- a/mt7915/eeprom.c
15+++ b/mt7915/eeprom.c
developera46f6132024-03-26 14:09:54 +080016@@ -193,6 +193,21 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev)
developer1a173672023-12-21 14:49:33 +080017 return mt7915_check_eeprom(dev);
18 }
19
20+static int mt7915_eeprom_parse_efuse_hw_cap(struct mt7915_dev *dev)
21+{
22+#define WTBL_SIZE_GROUP GENMASK(1, 0)
23+ u32 buf;
24+ int ret;
25+
26+ ret = mt76_get_of_data_from_nvmem(&dev->mt76, &buf, "variant", 4);
27+ if (ret)
28+ return ret;
29+
30+ dev->limited_wtbl_size = buf & WTBL_SIZE_GROUP;
31+
32+ return 0;
33+}
34+
35 static void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy)
36 {
37 struct mt7915_dev *dev = phy->dev;
developera46f6132024-03-26 14:09:54 +080038@@ -243,6 +258,13 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
developer1a173672023-12-21 14:49:33 +080039 u8 path, nss, nss_max = 4, *eeprom = dev->mt76.eeprom.data;
40 struct mt76_phy *mphy = phy->mt76;
41 u8 band = phy->mt76->band_idx;
42+ int ret;
43+
44+ if (is_mt7981(&dev->mt76)) {
45+ ret = mt7915_eeprom_parse_efuse_hw_cap(dev);
46+ if (ret)
47+ dev->limited_wtbl_size = true;
48+ }
49
50 mt7915_eeprom_parse_band_config(phy);
51
52diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer05f3b2b2024-08-19 19:17:34 +080053index 183d59da..c8f9ed52 100644
developer1a173672023-12-21 14:49:33 +080054--- a/mt7915/mt7915.h
55+++ b/mt7915/mt7915.h
developer05f3b2b2024-08-19 19:17:34 +080056@@ -424,6 +424,7 @@ struct mt7915_dev {
developer1a173672023-12-21 14:49:33 +080057
58 u32 hw_pattern;
59
60+ bool limited_wtbl_size;
61 bool dbdc_support;
62 bool flash_mode;
63 bool bin_file_mode;
developer05f3b2b2024-08-19 19:17:34 +080064@@ -698,7 +699,11 @@ void mt7915_tm_rf_test_event(struct mt7915_dev *dev, struct sk_buff *skb);
developer1a173672023-12-21 14:49:33 +080065
66 static inline u16 mt7915_wtbl_size(struct mt7915_dev *dev)
67 {
68- return is_mt7915(&dev->mt76) ? MT7915_WTBL_SIZE : MT7916_WTBL_SIZE;
69+ if (is_mt7915(&dev->mt76) ||
70+ (is_mt7981(&dev->mt76) && dev->limited_wtbl_size))
71+ return MT7915_WTBL_SIZE;
72+
73+ return MT7916_WTBL_SIZE;
74 }
75
76 static inline u16 mt7915_eeprom_size(struct mt7915_dev *dev)
77--
782.18.0
79