blob: 9fbc58608436f902dae553fb8122c35e7fc64547 [file] [log] [blame]
developerbd9fa1e2023-10-16 11:04:00 +08001From b69722554a27e8c13612f62c9b9cf8651a30bd8f Mon Sep 17 00:00:00 2001
2From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Wed, 5 Jul 2023 10:00:17 +0800
4Subject: [PATCH 56/98] wifi: mt76: mt7996: add eagle iFEM HWITS ZWDFS SW
5 workaround
6
7Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
8---
9 mt7996/main.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++---
10 mt7996/mcu.c | 6 +++--
11 mt7996/mt7996.h | 1 +
12 3 files changed, 60 insertions(+), 5 deletions(-)
13
14diff --git a/mt7996/main.c b/mt7996/main.c
15index 35f8fee..d27275a 100644
16--- a/mt7996/main.c
17+++ b/mt7996/main.c
18@@ -1413,6 +1413,54 @@ 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+ if (is_mt7996(&dev->mt76))
34+ is_ifem_adie = !!(mt76_get_field(dev, MT_PAD_GPIO, MT_PAD_GPIO_ADIE_COMB) % 2);
35+ else
36+ is_ifem_adie = (mt76_get_field(dev, MT_PAD_GPIO, MT_PAD_GPIO_ADIE_COMB_7992) == 1);
37+
38+ if (!user_chandef || !is_ifem_adie)
39+ goto out;
40+
41+ if (user_chandef->width == NL80211_CHAN_WIDTH_160) {
42+ origin_control = user_chandef->chan->center_freq;
43+ if (dev->bg_nxt_freq)
44+ goto out;
45+
46+ if (user_chandef->chan->flags & IEEE80211_CHAN_RADAR)
47+ dev->bg_nxt_freq = origin_control;
48+ else
49+ c = fw_chandef;
50+
51+ c->chan = ieee80211_get_channel(hw->wiphy, origin_control + 80);
52+ } else {
53+ if (!dev->bg_nxt_freq)
54+ goto out;
55+
56+ c->chan = ieee80211_get_channel(hw->wiphy, dev->bg_nxt_freq);
57+ dev->bg_nxt_freq = 0;
58+ expand = true;
59+ }
60+ c->width = NL80211_CHAN_WIDTH_80;
61+ c->center_freq1 = c->chan->center_freq + 30;
62+
63+ if (c == user_chandef)
64+ cfg80211_background_radar_update_channel(hw->wiphy, c, expand);
65+ return;
66+out:
67+ dev->bg_nxt_freq = 0;
68+}
69+
70 static int
71 mt7996_set_radar_background(struct ieee80211_hw *hw,
72 struct cfg80211_chan_def *chandef)
73@@ -1421,6 +1469,7 @@ mt7996_set_radar_background(struct ieee80211_hw *hw,
74 struct mt7996_dev *dev = phy->dev;
75 int ret = -EINVAL;
76 bool running;
77+ struct cfg80211_chan_def ifem_chandef = {};
78
79 mutex_lock(&dev->mt76.mutex);
80
81@@ -1433,13 +1482,14 @@ mt7996_set_radar_background(struct ieee80211_hw *hw,
82 goto out;
83 }
84
85+ mt7996_background_radar_handle_7975_ifem(hw, chandef, &ifem_chandef);
86+
87 /* rdd2 already configured on a radar channel */
88 running = dev->rdd2_phy &&
89 cfg80211_chandef_valid(&dev->rdd2_chandef) &&
90 !!(dev->rdd2_chandef.chan->flags & IEEE80211_CHAN_RADAR);
91
92- if (!chandef || running ||
93- !(chandef->chan->flags & IEEE80211_CHAN_RADAR)) {
94+ if (!chandef || running) {
95 ret = mt7996_mcu_rdd_background_enable(phy, NULL);
96 if (ret)
97 goto out;
98@@ -1448,7 +1498,9 @@ mt7996_set_radar_background(struct ieee80211_hw *hw,
99 goto update_phy;
100 }
101
102- ret = mt7996_mcu_rdd_background_enable(phy, chandef);
103+ ret = mt7996_mcu_rdd_background_enable(phy,
104+ ifem_chandef.chan ?
105+ &ifem_chandef : chandef);
106 if (ret)
107 goto out;
108
109diff --git a/mt7996/mcu.c b/mt7996/mcu.c
110index 2dbec1e..a4f3ed9 100644
111--- a/mt7996/mcu.c
112+++ b/mt7996/mcu.c
113@@ -350,12 +350,14 @@ mt7996_mcu_rx_radar_detected(struct mt7996_dev *dev, struct sk_buff *skb)
114 if (!mphy)
115 return;
116
117- if (r->band_idx == MT_RX_SEL2)
118+ if (r->band_idx == MT_RX_SEL2) {
119+ dev->bg_nxt_freq = 0;
120 cfg80211_background_radar_event(mphy->hw->wiphy,
121 &dev->rdd2_chandef,
122 GFP_ATOMIC);
123- else
124+ } else {
125 ieee80211_radar_detected(mphy->hw);
126+ }
127 dev->hw_pattern++;
128 }
129
130diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
131index 1fac783..413fbf7 100644
132--- a/mt7996/mt7996.h
133+++ b/mt7996/mt7996.h
134@@ -392,6 +392,7 @@ struct mt7996_dev {
135 bool testmode_enable;
136 bool bin_file_mode;
137 u8 eeprom_mode;
138+ u32 bg_nxt_freq;
139
140 bool ibf;
141 u8 fw_debug_wm;
142--
1432.18.0
144