blob: 4bc7d88b574a2c1d5e2acaeb72bd346374fb54d7 [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From 0ed31af01bf9c0f5f040222fabee17af063f9eb8 Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Wed, 5 Jul 2023 10:00:17 +0800
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 022/223] mtk: mt76: mt7996: support eagle ZWDFS on iFEM
developer66e89bc2024-04-23 14:50:01 +08005
6Fix the case that control channel is not first chan during first
7interface setup.
8Refactor ifem adie logic (if/else to switch, use sku_type & fem_type)
9
developer66e89bc2024-04-23 14:50:01 +080010Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
11---
12 mt7996/main.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++---
13 mt7996/mcu.c | 6 +++--
14 mt7996/mt7996.h | 1 +
15 3 files changed, 67 insertions(+), 5 deletions(-)
16
17diff --git a/mt7996/main.c b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +080018index e65b5bd7..ad4cd5dd 100644
developer66e89bc2024-04-23 14:50:01 +080019--- a/mt7996/main.c
20+++ b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +080021@@ -1433,6 +1433,61 @@ mt7996_twt_teardown_request(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +080022 mutex_unlock(&dev->mt76.mutex);
23 }
24
25+static void
26+mt7996_background_radar_handle_7975_ifem(struct ieee80211_hw *hw,
27+ struct cfg80211_chan_def *user_chandef,
28+ struct cfg80211_chan_def *fw_chandef)
29+{
30+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
31+ struct cfg80211_chan_def *c = user_chandef;
32+ struct ieee80211_channel *first_chan;
33+ bool is_ifem_adie, expand = false;
34+
35+ switch (mt76_chip(&dev->mt76)) {
36+ case 0x7990:
37+ is_ifem_adie = dev->fem_type == MT7996_FEM_INT &&
38+ dev->chip_sku != MT7996_SKU_233;
39+ break;
40+ case 0x7992:
41+ is_ifem_adie = dev->chip_sku == MT7992_SKU_44 &&
42+ dev->fem_type != MT7996_FEM_EXT;
43+ break;
44+ default:
45+ return;
46+ }
47+
48+ if (!user_chandef || !is_ifem_adie)
49+ goto out;
50+
51+ if (user_chandef->width == NL80211_CHAN_WIDTH_160) {
52+ first_chan = ieee80211_get_channel(hw->wiphy, user_chandef->center_freq1 - 70);
53+ if (dev->bg_nxt_freq)
54+ goto out;
55+
56+ if (first_chan->flags & IEEE80211_CHAN_RADAR)
57+ dev->bg_nxt_freq = first_chan->center_freq;
58+ else
59+ c = fw_chandef;
60+
61+ c->chan = ieee80211_get_channel(hw->wiphy, first_chan->center_freq + 80);
62+ } else {
63+ if (!dev->bg_nxt_freq)
64+ goto out;
65+
66+ c->chan = ieee80211_get_channel(hw->wiphy, dev->bg_nxt_freq);
67+ dev->bg_nxt_freq = 0;
68+ expand = true;
69+ }
70+ c->width = NL80211_CHAN_WIDTH_80;
71+ c->center_freq1 = c->chan->center_freq + 30;
72+
73+ if (c == user_chandef)
74+ cfg80211_background_radar_update_channel(hw->wiphy, c, expand);
75+ return;
76+out:
77+ dev->bg_nxt_freq = 0;
78+}
79+
80 static int
81 mt7996_set_radar_background(struct ieee80211_hw *hw,
82 struct cfg80211_chan_def *chandef)
developerd0c89452024-10-11 16:53:27 +080083@@ -1441,6 +1496,7 @@ mt7996_set_radar_background(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +080084 struct mt7996_dev *dev = phy->dev;
85 int ret = -EINVAL;
86 bool running;
87+ struct cfg80211_chan_def ifem_chandef = {};
88
89 mutex_lock(&dev->mt76.mutex);
90
developerd0c89452024-10-11 16:53:27 +080091@@ -1453,13 +1509,14 @@ mt7996_set_radar_background(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +080092 goto out;
93 }
94
95+ mt7996_background_radar_handle_7975_ifem(hw, chandef, &ifem_chandef);
96+
97 /* rdd2 already configured on a radar channel */
98 running = dev->rdd2_phy &&
99 cfg80211_chandef_valid(&dev->rdd2_chandef) &&
100 !!(dev->rdd2_chandef.chan->flags & IEEE80211_CHAN_RADAR);
101
102- if (!chandef || running ||
103- !(chandef->chan->flags & IEEE80211_CHAN_RADAR)) {
104+ if (!chandef || running) {
105 ret = mt7996_mcu_rdd_background_enable(phy, NULL);
106 if (ret)
107 goto out;
developerd0c89452024-10-11 16:53:27 +0800108@@ -1468,7 +1525,9 @@ mt7996_set_radar_background(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800109 goto update_phy;
110 }
111
112- ret = mt7996_mcu_rdd_background_enable(phy, chandef);
113+ ret = mt7996_mcu_rdd_background_enable(phy,
114+ ifem_chandef.chan ?
115+ &ifem_chandef : chandef);
116 if (ret)
117 goto out;
118
119diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +0800120index 59a24478..7ef6bb1f 100644
developer66e89bc2024-04-23 14:50:01 +0800121--- a/mt7996/mcu.c
122+++ b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +0800123@@ -382,12 +382,14 @@ mt7996_mcu_rx_radar_detected(struct mt7996_dev *dev, struct sk_buff *skb)
developer66e89bc2024-04-23 14:50:01 +0800124 if (!mphy)
125 return;
126
127- if (r->band_idx == MT_RX_SEL2)
128+ if (r->band_idx == MT_RX_SEL2) {
129+ dev->bg_nxt_freq = 0;
130 cfg80211_background_radar_event(mphy->hw->wiphy,
131 &dev->rdd2_chandef,
132 GFP_ATOMIC);
133- else
134+ } else {
135 ieee80211_radar_detected(mphy->hw);
136+ }
137 dev->hw_pattern++;
138 }
139
140diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
developerd0c89452024-10-11 16:53:27 +0800141index 1fe681cf..2ec72496 100644
developer66e89bc2024-04-23 14:50:01 +0800142--- a/mt7996/mt7996.h
143+++ b/mt7996/mt7996.h
developerd0c89452024-10-11 16:53:27 +0800144@@ -407,6 +407,7 @@ struct mt7996_dev {
developer66e89bc2024-04-23 14:50:01 +0800145 bool testmode_enable;
146 bool bin_file_mode;
147 u8 eeprom_mode;
148+ u32 bg_nxt_freq;
149
150 bool ibf;
151 u8 fw_debug_wm;
152--
developerd0c89452024-10-11 16:53:27 +08001532.45.2
developer66e89bc2024-04-23 14:50:01 +0800154