blob: 2260e5fe3230d873a1ca0b20fc97f4c80b629389 [file] [log] [blame]
From 51410d3e134142548c1432c0ea5c07635d8646a5 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 1039/1051] 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 3dc99f8..3170aca 100644
--- a/mt7915/mt7915.h
+++ b/mt7915/mt7915.h
@@ -409,6 +409,7 @@ struct mt7915_dev {
u32 hw_pattern;
+ bool limited_wtbl_size;
bool dbdc_support;
bool flash_mode;
bool bin_file_mode;
@@ -684,7 +685,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