summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/mediatek/mt76/mt7921
diff options
context:
space:
mode:
authorMing Yen Hsieh <mingyen.hsieh@mediatek.com>2023-09-30 10:25:09 +0800
committerFelix Fietkau <nbd@nbd.name>2023-09-30 20:17:18 +0200
commit09382d8f8641bc12fffc41a93eb9b37be0e653c0 (patch)
treeacb9d8d97d1fd2f61504bceb73bfc42fc4abf6a7 /drivers/net/wireless/mediatek/mt76/mt7921
parent4fc8df50fd41c2762d893211487be0ecb24c6a05 (diff)
wifi: mt76: mt7921: update the channel usage when the regd domain changed
The 5.9/6GHz channel license of a certain platform device has been regulated in various countries. That may be difference with standard Liunx regulatory domain settings. In this case, when .reg_notifier() called for regulatory change, mt792x chipset should update the channel usage based on clc or dts configurations. Channel would be disabled by following cases. * clc report the particular UNII-x is disabled. * dts enabled and the channel is not configured. Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com> Co-developed-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/mt7921')
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt7921/init.c51
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt7921/mcu.c3
2 files changed, 54 insertions, 0 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
index 534c7bee5ef1..55baac70860b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
@@ -59,6 +59,55 @@ static int mt7921_thermal_init(struct mt792x_phy *phy)
}
static void
+mt7921_regd_channel_update(struct wiphy *wiphy, struct mt792x_dev *dev)
+{
+#define IS_UNII_INVALID(idx, sfreq, efreq) \
+ (!(dev->phy.clc_chan_conf & BIT(idx)) && (cfreq) >= (sfreq) && (cfreq) <= (efreq))
+ struct ieee80211_supported_band *sband;
+ struct mt76_dev *mdev = &dev->mt76;
+ struct device_node *np, *band_np;
+ struct ieee80211_channel *ch;
+ int i, cfreq;
+
+ np = mt76_find_power_limits_node(mdev);
+
+ sband = wiphy->bands[NL80211_BAND_5GHZ];
+ band_np = np ? of_get_child_by_name(np, "txpower-5g") : NULL;
+ for (i = 0; i < sband->n_channels; i++) {
+ ch = &sband->channels[i];
+ cfreq = ch->center_freq;
+
+ if (np && (!band_np || !mt76_find_channel_node(band_np, ch))) {
+ ch->flags |= IEEE80211_CHAN_DISABLED;
+ continue;
+ }
+
+ /* UNII-4 */
+ if (IS_UNII_INVALID(0, 5850, 5925))
+ ch->flags |= IEEE80211_CHAN_DISABLED;
+ }
+
+ sband = wiphy->bands[NL80211_BAND_6GHZ];
+ band_np = np ? of_get_child_by_name(np, "txpower-6g") : NULL;
+ for (i = 0; i < sband->n_channels; i++) {
+ ch = &sband->channels[i];
+ cfreq = ch->center_freq;
+
+ if (np && (!band_np || !mt76_find_channel_node(band_np, ch))) {
+ ch->flags |= IEEE80211_CHAN_DISABLED;
+ continue;
+ }
+
+ /* UNII-5/6/7/8 */
+ if (IS_UNII_INVALID(1, 5925, 6425) ||
+ IS_UNII_INVALID(2, 6425, 6525) ||
+ IS_UNII_INVALID(3, 6525, 6875) ||
+ IS_UNII_INVALID(4, 6875, 7125))
+ ch->flags |= IEEE80211_CHAN_DISABLED;
+ }
+}
+
+static void
mt7921_regd_notifier(struct wiphy *wiphy,
struct regulatory_request *request)
{
@@ -74,6 +123,8 @@ mt7921_regd_notifier(struct wiphy *wiphy,
mt76_connac_mcu_set_channel_domain(hw->priv);
mt7921_set_tx_sar_pwr(hw, NULL);
mt792x_mutex_release(dev);
+
+ mt7921_regd_channel_update(wiphy, dev);
}
int mt7921_mac_init(struct mt792x_dev *dev)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index 4f66e27aa43a..63f3d4a5c9aa 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -1247,6 +1247,7 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
u8 idx)
{
#define CLC_CAP_EVT_EN BIT(0)
+#define CLC_CAP_DTS_EN BIT(1)
struct sk_buff *skb, *ret_skb = NULL;
struct {
u8 ver;
@@ -1274,6 +1275,8 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
if (dev->phy.chip_cap & MT792x_CHIP_CAP_CLC_EVT_EN)
req.cap |= CLC_CAP_EVT_EN;
+ if (mt76_find_power_limits_node(&dev->mt76))
+ req.cap |= CLC_CAP_DTS_EN;
pos = clc->data;
for (i = 0; i < clc->nr_country; i++) {