blob: ec0a323f6f33990f23f91535a51a119d2f928f05 [file] [log] [blame]
From 04882a33afbee2fd86cdb244a0faf0748f163b31 Mon Sep 17 00:00:00 2001
From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Date: Mon, 4 Mar 2024 11:29:06 +0800
Subject: [PATCH 1048/1052] wifi: mt76: mt7915: add background radar hw cap
check
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
---
mt7915/debugfs.c | 5 +++++
mt7915/eeprom.h | 30 ++++++++++++++++++++++++++++++
mt7915/init.c | 7 ++++---
3 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
index f031b54c..3fd1654c 100644
--- a/mt7915/debugfs.c
+++ b/mt7915/debugfs.c
@@ -459,6 +459,11 @@ mt7915_rdd_monitor(struct seq_file *s, void *data)
mutex_lock(&dev->mt76.mutex);
+ if (!mt7915_get_background_radar_cap(dev)) {
+ seq_puts(s, "no background radar capability\n");
+ goto out;
+ }
+
if (!cfg80211_chandef_valid(chandef)) {
ret = -EINVAL;
goto out;
diff --git a/mt7915/eeprom.h b/mt7915/eeprom.h
index 70fca0b3..adeee104 100644
--- a/mt7915/eeprom.h
+++ b/mt7915/eeprom.h
@@ -55,6 +55,7 @@ enum mt7915_eeprom_field {
#define MT_EE_CAL_DPD_SIZE_V2_7981 (102 * MT_EE_CAL_UNIT) /* no 6g dpd data */
#define MT_EE_WIFI_CONF0_TX_PATH GENMASK(2, 0)
+#define MT_EE_WIFI_CONF0_RX_PATH GENMASK(5, 3)
#define MT_EE_WIFI_CONF0_BAND_SEL GENMASK(7, 6)
#define MT_EE_WIFI_CONF1_BAND_SEL GENMASK(7, 6)
#define MT_EE_WIFI_CONF_STREAM_NUM GENMASK(7, 5)
@@ -206,6 +207,35 @@ mt7915_get_cal_dpd_size(struct mt7915_dev *dev)
return MT_EE_CAL_DPD_SIZE_V2;
}
+static inline bool
+mt7915_get_background_radar_cap(struct mt7915_dev *dev)
+{
+ u8 buf[MT7915_EEPROM_BLOCK_SIZE];
+ int val, band_sel, tx_path, rx_path, offs = MT_EE_WIFI_CONF + 1;
+
+ switch (mt76_chip(&dev->mt76)) {
+ case 0x7915:
+ return 1;
+ case 0x7906:
+ if (!mt7915_mcu_get_eeprom(dev, offs, buf)) {
+ val = buf[offs % MT7915_EEPROM_BLOCK_SIZE];
+ band_sel = FIELD_GET(MT_EE_WIFI_CONF0_BAND_SEL, val);
+ rx_path = FIELD_GET(MT_EE_WIFI_CONF0_RX_PATH, val);
+ tx_path = FIELD_GET(MT_EE_WIFI_CONF0_TX_PATH, val);
+
+ return (band_sel == MT_EE_V2_BAND_SEL_5GHZ &&
+ tx_path == rx_path && rx_path == 2);
+ }
+ break;
+ case 0x7981:
+ case 0x7986:
+ default:
+ break;
+ }
+
+ return 0;
+}
+
extern const u8 mt7915_sku_group_len[MAX_SKU_RATE_GROUP_NUM];
#endif
diff --git a/mt7915/init.c b/mt7915/init.c
index e8a6fcda..03c86ae0 100644
--- a/mt7915/init.c
+++ b/mt7915/init.c
@@ -405,9 +405,10 @@ mt7915_init_wiphy(struct mt7915_phy *phy)
if (!is_mt7915(&dev->mt76))
wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_STA_TX_PWR);
- if (!mdev->dev->of_node ||
- !of_property_read_bool(mdev->dev->of_node,
- "mediatek,disable-radar-background"))
+ if (mt7915_get_background_radar_cap(phy->dev) &&
+ (!mdev->dev->of_node ||
+ !of_property_read_bool(mdev->dev->of_node,
+ "mediatek,disable-radar-background")))
wiphy_ext_feature_set(wiphy,
NL80211_EXT_FEATURE_RADAR_BACKGROUND);
--
2.18.0