x86/speculation: Fix redundant MDS mitigation message
[linux-2.6-block.git] / drivers / net / wireless / mediatek / mt76 / mt76x0 / main.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
4  * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
5  * Copyright (C) 2018 Stanislaw Gruszka <stf_xl@wp.pl>
6  */
7
8 #include <linux/etherdevice.h>
9 #include "mt76x0.h"
10
11 static void
12 mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef)
13 {
14         cancel_delayed_work_sync(&dev->cal_work);
15         mt76x02_pre_tbtt_enable(dev, false);
16         if (mt76_is_mmio(dev))
17                 tasklet_disable(&dev->dfs_pd.dfs_tasklet);
18
19         mt76_set_channel(&dev->mt76);
20         mt76x0_phy_set_channel(dev, chandef);
21
22         /* channel cycle counters read-and-clear */
23         mt76_rr(dev, MT_CH_IDLE);
24         mt76_rr(dev, MT_CH_BUSY);
25
26         mt76x02_edcca_init(dev);
27
28         if (mt76_is_mmio(dev)) {
29                 mt76x02_dfs_init_params(dev);
30                 tasklet_enable(&dev->dfs_pd.dfs_tasklet);
31         }
32         mt76x02_pre_tbtt_enable(dev, true);
33
34         mt76_txq_schedule_all(&dev->mt76);
35 }
36
37 int mt76x0_config(struct ieee80211_hw *hw, u32 changed)
38 {
39         struct mt76x02_dev *dev = hw->priv;
40
41         mutex_lock(&dev->mt76.mutex);
42
43         if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
44                 ieee80211_stop_queues(hw);
45                 mt76x0_set_channel(dev, &hw->conf.chandef);
46                 ieee80211_wake_queues(hw);
47         }
48
49         if (changed & IEEE80211_CONF_CHANGE_POWER) {
50                 dev->mt76.txpower_conf = hw->conf.power_level * 2;
51
52                 if (test_bit(MT76_STATE_RUNNING, &dev->mt76.state))
53                         mt76x0_phy_set_txpower(dev);
54         }
55
56         if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
57                 if (!(hw->conf.flags & IEEE80211_CONF_MONITOR))
58                         dev->mt76.rxfilter |= MT_RX_FILTR_CFG_PROMISC;
59                 else
60                         dev->mt76.rxfilter &= ~MT_RX_FILTR_CFG_PROMISC;
61
62                 mt76_wr(dev, MT_RX_FILTR_CFG, dev->mt76.rxfilter);
63         }
64
65         mutex_unlock(&dev->mt76.mutex);
66
67         return 0;
68 }
69 EXPORT_SYMBOL_GPL(mt76x0_config);