developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame] | 1 | From 3ad316d5a0d9caa9a07597ac59df0663daf3e319 Mon Sep 17 00:00:00 2001 |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Mon, 4 Mar 2024 11:29:06 +0800 |
developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1048/1051] wifi: mt76: mt7915: add background radar hw cap |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 5 | check |
| 6 | |
| 7 | Signed-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 | |
| 14 | diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 15 | index b2a4ff4..03daf44 100644 |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 16 | --- 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; |
| 30 | diff --git a/mt7915/eeprom.h b/mt7915/eeprom.h |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 31 | index 70fca0b..adeee10 100644 |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 32 | --- 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 |
| 78 | diff --git a/mt7915/init.c b/mt7915/init.c |
developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame] | 79 | index 9932266..dc1b34d 100644 |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 80 | --- a/mt7915/init.c |
| 81 | +++ b/mt7915/init.c |
| 82 | @@ -404,9 +404,10 @@ mt7915_init_wiphy(struct mt7915_phy *phy) |
| 83 | 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 | -- |
| 97 | 2.18.0 |
| 98 | |