developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 1 | From a94962822a9df3869525ec040e2698be0c39c1e6 Mon Sep 17 00:00:00 2001 |
| 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Wed, 5 Jul 2023 10:00:17 +0800 |
| 4 | Subject: [PATCH 1023/1024] wifi: mt76: mt7996: add eagle iFEM HWITS ZWDFS SW |
| 5 | workaround |
| 6 | |
| 7 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 8 | --- |
| 9 | mt7996/main.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++--- |
| 10 | mt7996/mcu.c | 6 ++++-- |
| 11 | mt7996/mt7996.h | 1 + |
| 12 | 3 files changed, 57 insertions(+), 5 deletions(-) |
| 13 | |
| 14 | diff --git a/mt7996/main.c b/mt7996/main.c |
| 15 | index bae25ceda..a00ebf9e6 100644 |
| 16 | --- a/mt7996/main.c |
| 17 | +++ b/mt7996/main.c |
| 18 | @@ -1410,6 +1410,51 @@ mt7996_twt_teardown_request(struct ieee80211_hw *hw, |
| 19 | mutex_unlock(&dev->mt76.mutex); |
| 20 | } |
| 21 | |
| 22 | +static void |
| 23 | +mt7996_background_radar_handle_7975_ifem(struct ieee80211_hw *hw, |
| 24 | + struct cfg80211_chan_def *user_chandef, |
| 25 | + struct cfg80211_chan_def *fw_chandef) |
| 26 | +{ |
| 27 | + struct mt7996_phy *phy = mt7996_hw_phy(hw); |
| 28 | + struct mt7996_dev *dev = phy->dev; |
| 29 | + struct cfg80211_chan_def *c = user_chandef; |
| 30 | + bool is_ifem_adie, expand = false; |
| 31 | + u32 origin_control; |
| 32 | + |
| 33 | + is_ifem_adie = is_mt7996(&dev->mt76) && |
| 34 | + !!(mt76_get_field(dev, MT_PAD_GPIO, MT_PAD_GPIO_ADIE_COMB) % 2); |
| 35 | + if (!user_chandef || !is_ifem_adie) |
| 36 | + goto out; |
| 37 | + |
| 38 | + if (user_chandef->width == NL80211_CHAN_WIDTH_160) { |
| 39 | + origin_control = user_chandef->chan->center_freq; |
| 40 | + if (dev->bg_nxt_freq) |
| 41 | + goto out; |
| 42 | + |
| 43 | + if (user_chandef->chan->flags & IEEE80211_CHAN_RADAR) |
| 44 | + dev->bg_nxt_freq = origin_control; |
| 45 | + else |
| 46 | + c = fw_chandef; |
| 47 | + |
| 48 | + c->chan = ieee80211_get_channel(hw->wiphy, origin_control + 80); |
| 49 | + } else { |
| 50 | + if (!dev->bg_nxt_freq) |
| 51 | + goto out; |
| 52 | + |
| 53 | + c->chan = ieee80211_get_channel(hw->wiphy, dev->bg_nxt_freq); |
| 54 | + dev->bg_nxt_freq = 0; |
| 55 | + expand = true; |
| 56 | + } |
| 57 | + c->width = NL80211_CHAN_WIDTH_80; |
| 58 | + c->center_freq1 = c->chan->center_freq + 30; |
| 59 | + |
| 60 | + if (c == user_chandef) |
| 61 | + cfg80211_background_radar_update_channel(hw->wiphy, c, expand); |
| 62 | + return; |
| 63 | +out: |
| 64 | + dev->bg_nxt_freq = 0; |
| 65 | +} |
| 66 | + |
| 67 | static int |
| 68 | mt7996_set_radar_background(struct ieee80211_hw *hw, |
| 69 | struct cfg80211_chan_def *chandef) |
| 70 | @@ -1418,6 +1463,7 @@ mt7996_set_radar_background(struct ieee80211_hw *hw, |
| 71 | struct mt7996_dev *dev = phy->dev; |
| 72 | int ret = -EINVAL; |
| 73 | bool running; |
| 74 | + struct cfg80211_chan_def ifem_chandef = {}; |
| 75 | |
| 76 | mutex_lock(&dev->mt76.mutex); |
| 77 | |
| 78 | @@ -1430,13 +1476,14 @@ mt7996_set_radar_background(struct ieee80211_hw *hw, |
| 79 | goto out; |
| 80 | } |
| 81 | |
| 82 | + mt7996_background_radar_handle_7975_ifem(hw, chandef, &ifem_chandef); |
| 83 | + |
| 84 | /* rdd2 already configured on a radar channel */ |
| 85 | running = dev->rdd2_phy && |
| 86 | cfg80211_chandef_valid(&dev->rdd2_chandef) && |
| 87 | !!(dev->rdd2_chandef.chan->flags & IEEE80211_CHAN_RADAR); |
| 88 | |
| 89 | - if (!chandef || running || |
| 90 | - !(chandef->chan->flags & IEEE80211_CHAN_RADAR)) { |
| 91 | + if (!chandef || running) { |
| 92 | ret = mt7996_mcu_rdd_background_enable(phy, NULL); |
| 93 | if (ret) |
| 94 | goto out; |
| 95 | @@ -1445,7 +1492,9 @@ mt7996_set_radar_background(struct ieee80211_hw *hw, |
| 96 | goto update_phy; |
| 97 | } |
| 98 | |
| 99 | - ret = mt7996_mcu_rdd_background_enable(phy, chandef); |
| 100 | + ret = mt7996_mcu_rdd_background_enable(phy, |
| 101 | + ifem_chandef.chan ? |
| 102 | + &ifem_chandef : chandef); |
| 103 | if (ret) |
| 104 | goto out; |
| 105 | |
| 106 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
| 107 | index 76788907a..f9387ea56 100644 |
| 108 | --- a/mt7996/mcu.c |
| 109 | +++ b/mt7996/mcu.c |
| 110 | @@ -350,12 +350,14 @@ mt7996_mcu_rx_radar_detected(struct mt7996_dev *dev, struct sk_buff *skb) |
| 111 | if (!mphy) |
| 112 | return; |
| 113 | |
| 114 | - if (r->band_idx == MT_RX_SEL2) |
| 115 | + if (r->band_idx == MT_RX_SEL2) { |
| 116 | + dev->bg_nxt_freq = 0; |
| 117 | cfg80211_background_radar_event(mphy->hw->wiphy, |
| 118 | &dev->rdd2_chandef, |
| 119 | GFP_ATOMIC); |
| 120 | - else |
| 121 | + } else { |
| 122 | ieee80211_radar_detected(mphy->hw); |
| 123 | + } |
| 124 | dev->hw_pattern++; |
| 125 | } |
| 126 | |
| 127 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
| 128 | index feb82e440..6447b2c90 100644 |
| 129 | --- a/mt7996/mt7996.h |
| 130 | +++ b/mt7996/mt7996.h |
| 131 | @@ -340,6 +340,7 @@ struct mt7996_dev { |
| 132 | bool testmode_enable; |
| 133 | bool bin_file_mode; |
| 134 | u8 eeprom_mode; |
| 135 | + u32 bg_nxt_freq; |
| 136 | |
| 137 | bool ibf; |
| 138 | u8 fw_debug_wm; |
| 139 | -- |
| 140 | 2.39.2 |
| 141 | |