1 // SPDX-License-Identifier: GPL-2.0-only
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>
8 #include <linux/etherdevice.h>
11 int mt76x0_set_channel(struct mt76_phy
*mphy
)
13 struct mt76x02_dev
*dev
= container_of(mphy
->dev
, struct mt76x02_dev
, mt76
);
15 mt76x02_pre_tbtt_enable(dev
, false);
16 if (mt76_is_mmio(&dev
->mt76
))
17 tasklet_disable(&dev
->dfs_pd
.dfs_tasklet
);
19 mt76x0_phy_set_channel(dev
, &mphy
->chandef
);
21 mt76x02_mac_cc_reset(dev
);
22 mt76x02_edcca_init(dev
);
24 if (mt76_is_mmio(&dev
->mt76
)) {
25 mt76x02_dfs_init_params(dev
);
26 tasklet_enable(&dev
->dfs_pd
.dfs_tasklet
);
28 mt76x02_pre_tbtt_enable(dev
, true);
32 EXPORT_SYMBOL_GPL(mt76x0_set_channel
);
34 int mt76x0_set_sar_specs(struct ieee80211_hw
*hw
,
35 const struct cfg80211_sar_specs
*sar
)
37 int err
= -EINVAL
, power
= hw
->conf
.power_level
* 2;
38 struct mt76x02_dev
*dev
= hw
->priv
;
39 struct mt76_phy
*mphy
= &dev
->mphy
;
41 mutex_lock(&dev
->mt76
.mutex
);
42 if (!cfg80211_chandef_valid(&mphy
->chandef
))
45 err
= mt76_init_sar_power(hw
, sar
);
49 dev
->txpower_conf
= mt76_get_sar_power(mphy
, mphy
->chandef
.chan
,
51 if (test_bit(MT76_STATE_RUNNING
, &mphy
->state
))
52 mt76x0_phy_set_txpower(dev
);
54 mutex_unlock(&dev
->mt76
.mutex
);
58 EXPORT_SYMBOL_GPL(mt76x0_set_sar_specs
);
60 int mt76x0_config(struct ieee80211_hw
*hw
, u32 changed
)
62 struct mt76x02_dev
*dev
= hw
->priv
;
64 if (changed
& IEEE80211_CONF_CHANGE_CHANNEL
)
65 mt76_update_channel(&dev
->mphy
);
67 mutex_lock(&dev
->mt76
.mutex
);
69 if (changed
& IEEE80211_CONF_CHANGE_POWER
) {
70 struct mt76_phy
*mphy
= &dev
->mphy
;
72 dev
->txpower_conf
= hw
->conf
.power_level
* 2;
73 dev
->txpower_conf
= mt76_get_sar_power(mphy
,
76 if (test_bit(MT76_STATE_RUNNING
, &mphy
->state
))
77 mt76x0_phy_set_txpower(dev
);
80 if (changed
& IEEE80211_CONF_CHANGE_MONITOR
) {
81 if (!(hw
->conf
.flags
& IEEE80211_CONF_MONITOR
))
82 dev
->mt76
.rxfilter
|= MT_RX_FILTR_CFG_PROMISC
;
84 dev
->mt76
.rxfilter
&= ~MT_RX_FILTR_CFG_PROMISC
;
86 mt76_wr(dev
, MT_RX_FILTR_CFG
, dev
->mt76
.rxfilter
);
89 mutex_unlock(&dev
->mt76
.mutex
);
93 EXPORT_SYMBOL_GPL(mt76x0_config
);