blob: 7238522628c50e4e9f1401ba8ea53a927219231f [file] [log] [blame]
From 2d4f946641ceeac9fa1bd7d23124e590bec8233d 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 1044/1048] 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 96b1ea3..79d6fe9 100644
--- a/mt7915/eeprom.c
+++ b/mt7915/eeprom.c
@@ -179,6 +179,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;
@@ -229,6 +244,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 f3d9ee5..45e04af 100644
--- a/mt7915/mt7915.h
+++ b/mt7915/mt7915.h
@@ -399,6 +399,7 @@ struct mt7915_dev {
u32 hw_pattern;
+ bool limited_wtbl_size;
bool dbdc_support;
bool flash_mode;
bool bin_file_mode;
@@ -667,7 +668,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