blob: 39612b05c3c5b7718adec67d3dfe5df4cc1da14e [file] [log] [blame]
From 90dfcdd20e564dc3b82342141dfd6917899b7b66 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/1052] 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 6133c200..df5e396c 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 183d59da..c8f9ed52 100644
--- a/mt7915/mt7915.h
+++ b/mt7915/mt7915.h
@@ -424,6 +424,7 @@ struct mt7915_dev {
u32 hw_pattern;
+ bool limited_wtbl_size;
bool dbdc_support;
bool flash_mode;
bool bin_file_mode;
@@ -698,7 +699,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