blob: b1594a10db1a9a743a57775393be3d45f9cb572e [file] [log] [blame]
From 45752d6719ee863fe80d2821f9ff6176e6a2497d Mon Sep 17 00:00:00 2001
From: "Henry.Yen" <henry.yen@mediatek.com>
Date: Mon, 11 Dec 2023 16:01:55 +0800
Subject: [PATCH 1040/1053] wifi: mt76: mt7915 add mt7981 efuse variants
support
---
mt7915/eeprom.c | 22 ++++++++++++++++++++++
mt7915/mt7915.h | 7 ++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c
index 6133c20..df5e396 100644
--- a/mt7915/eeprom.c
+++ b/mt7915/eeprom.c
@@ -193,6 +193,21 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev)
return mt7915_check_eeprom(dev);
}
+static int mt7915_eeprom_parse_efuse_hw_cap(struct mt7915_dev *dev)
+{
+#define WTBL_SIZE_GROUP GENMASK(1, 0)
+ u32 buf;
+ int ret;
+
+ ret = mt76_get_of_data_from_nvmem(&dev->mt76, &buf, "variant", 4);
+ if (ret)
+ return ret;
+
+ dev->limited_wtbl_size = buf & WTBL_SIZE_GROUP;
+
+ return 0;
+}
+
static void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy)
{
struct mt7915_dev *dev = phy->dev;
@@ -243,6 +258,13 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
u8 path, nss, nss_max = 4, *eeprom = dev->mt76.eeprom.data;
struct mt76_phy *mphy = phy->mt76;
u8 band = phy->mt76->band_idx;
+ int ret;
+
+ if (is_mt7981(&dev->mt76)) {
+ ret = mt7915_eeprom_parse_efuse_hw_cap(dev);
+ if (ret)
+ dev->limited_wtbl_size = true;
+ }
mt7915_eeprom_parse_band_config(phy);
diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
index 1b43c54..c6150c8 100644
--- a/mt7915/mt7915.h
+++ b/mt7915/mt7915.h
@@ -407,6 +407,7 @@ struct mt7915_dev {
u32 hw_pattern;
+ bool limited_wtbl_size;
bool dbdc_support;
bool flash_mode;
bool bin_file_mode;
@@ -681,7 +682,11 @@ void mt7915_tm_rf_test_event(struct mt7915_dev *dev, struct sk_buff *skb);
static inline u16 mt7915_wtbl_size(struct mt7915_dev *dev)
{
- return is_mt7915(&dev->mt76) ? MT7915_WTBL_SIZE : MT7916_WTBL_SIZE;
+ if (is_mt7915(&dev->mt76) ||
+ (is_mt7981(&dev->mt76) && dev->limited_wtbl_size))
+ return MT7915_WTBL_SIZE;
+
+ return MT7916_WTBL_SIZE;
}
static inline u16 mt7915_eeprom_size(struct mt7915_dev *dev)
--
2.18.0