blob: ec0a323f6f33990f23f91535a51a119d2f928f05 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 04882a33afbee2fd86cdb244a0faf0748f163b31 Mon Sep 17 00:00:00 2001
developera46f6132024-03-26 14:09:54 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Mon, 4 Mar 2024 11:29:06 +0800
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 1048/1052] wifi: mt76: mt7915: add background radar hw cap
developera46f6132024-03-26 14:09:54 +08005 check
6
7Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
8---
9 mt7915/debugfs.c | 5 +++++
10 mt7915/eeprom.h | 30 ++++++++++++++++++++++++++++++
11 mt7915/init.c | 7 ++++---
12 3 files changed, 39 insertions(+), 3 deletions(-)
13
14diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
developer05f3b2b2024-08-19 19:17:34 +080015index f031b54c..3fd1654c 100644
developera46f6132024-03-26 14:09:54 +080016--- a/mt7915/debugfs.c
17+++ b/mt7915/debugfs.c
18@@ -459,6 +459,11 @@ mt7915_rdd_monitor(struct seq_file *s, void *data)
19
20 mutex_lock(&dev->mt76.mutex);
21
22+ if (!mt7915_get_background_radar_cap(dev)) {
23+ seq_puts(s, "no background radar capability\n");
24+ goto out;
25+ }
26+
27 if (!cfg80211_chandef_valid(chandef)) {
28 ret = -EINVAL;
29 goto out;
30diff --git a/mt7915/eeprom.h b/mt7915/eeprom.h
developer05f3b2b2024-08-19 19:17:34 +080031index 70fca0b3..adeee104 100644
developera46f6132024-03-26 14:09:54 +080032--- a/mt7915/eeprom.h
33+++ b/mt7915/eeprom.h
34@@ -55,6 +55,7 @@ enum mt7915_eeprom_field {
35 #define MT_EE_CAL_DPD_SIZE_V2_7981 (102 * MT_EE_CAL_UNIT) /* no 6g dpd data */
36
37 #define MT_EE_WIFI_CONF0_TX_PATH GENMASK(2, 0)
38+#define MT_EE_WIFI_CONF0_RX_PATH GENMASK(5, 3)
39 #define MT_EE_WIFI_CONF0_BAND_SEL GENMASK(7, 6)
40 #define MT_EE_WIFI_CONF1_BAND_SEL GENMASK(7, 6)
41 #define MT_EE_WIFI_CONF_STREAM_NUM GENMASK(7, 5)
42@@ -206,6 +207,35 @@ mt7915_get_cal_dpd_size(struct mt7915_dev *dev)
43 return MT_EE_CAL_DPD_SIZE_V2;
44 }
45
46+static inline bool
47+mt7915_get_background_radar_cap(struct mt7915_dev *dev)
48+{
49+ u8 buf[MT7915_EEPROM_BLOCK_SIZE];
50+ int val, band_sel, tx_path, rx_path, offs = MT_EE_WIFI_CONF + 1;
51+
52+ switch (mt76_chip(&dev->mt76)) {
53+ case 0x7915:
54+ return 1;
55+ case 0x7906:
56+ if (!mt7915_mcu_get_eeprom(dev, offs, buf)) {
57+ val = buf[offs % MT7915_EEPROM_BLOCK_SIZE];
58+ band_sel = FIELD_GET(MT_EE_WIFI_CONF0_BAND_SEL, val);
59+ rx_path = FIELD_GET(MT_EE_WIFI_CONF0_RX_PATH, val);
60+ tx_path = FIELD_GET(MT_EE_WIFI_CONF0_TX_PATH, val);
61+
62+ return (band_sel == MT_EE_V2_BAND_SEL_5GHZ &&
63+ tx_path == rx_path && rx_path == 2);
64+ }
65+ break;
66+ case 0x7981:
67+ case 0x7986:
68+ default:
69+ break;
70+ }
71+
72+ return 0;
73+}
74+
75 extern const u8 mt7915_sku_group_len[MAX_SKU_RATE_GROUP_NUM];
76
77 #endif
78diff --git a/mt7915/init.c b/mt7915/init.c
developer05f3b2b2024-08-19 19:17:34 +080079index e8a6fcda..03c86ae0 100644
developera46f6132024-03-26 14:09:54 +080080--- a/mt7915/init.c
81+++ b/mt7915/init.c
developer05f3b2b2024-08-19 19:17:34 +080082@@ -405,9 +405,10 @@ mt7915_init_wiphy(struct mt7915_phy *phy)
developera46f6132024-03-26 14:09:54 +080083 if (!is_mt7915(&dev->mt76))
84 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_STA_TX_PWR);
85
86- if (!mdev->dev->of_node ||
87- !of_property_read_bool(mdev->dev->of_node,
88- "mediatek,disable-radar-background"))
89+ if (mt7915_get_background_radar_cap(phy->dev) &&
90+ (!mdev->dev->of_node ||
91+ !of_property_read_bool(mdev->dev->of_node,
92+ "mediatek,disable-radar-background")))
93 wiphy_ext_feature_set(wiphy,
94 NL80211_EXT_FEATURE_RADAR_BACKGROUND);
95
96--
972.18.0
98