Skip to content

Commit e54b870

Browse files
Allan Wangnbd168
authored andcommitted
wifi: mt76: mt7925: add rfkill_poll for hardware rfkill
Add mac80211 rfkill_poll ops to monitor hardware rfkill state and state change will be updated. Signed-off-by: Allan Wang <allan.wang@mediatek.com> Link: https://patch.msgid.link/20250507053131.4173691-1-allan.wang@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
1 parent 56e3867 commit e54b870

5 files changed

Lines changed: 59 additions & 0 deletions

File tree

drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,7 @@ enum {
13061306
MCU_UNI_CMD_PER_STA_INFO = 0x6d,
13071307
MCU_UNI_CMD_ALL_STA_INFO = 0x6e,
13081308
MCU_UNI_CMD_ASSERT_DUMP = 0x6f,
1309+
MCU_UNI_CMD_RADIO_STATUS = 0x80,
13091310
MCU_UNI_CMD_SDO = 0x88,
13101311
};
13111312

drivers/net/wireless/mediatek/mt76/mt7925/main.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ int __mt7925_start(struct mt792x_phy *phy)
334334
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
335335
MT792x_WATCHDOG_TIME);
336336

337+
if (phy->chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN)
338+
wiphy_rfkill_start_polling(mphy->hw->wiphy);
339+
337340
return 0;
338341
}
339342
EXPORT_SYMBOL_GPL(__mt7925_start);
@@ -2205,6 +2208,18 @@ static void mt7925_unassign_vif_chanctx(struct ieee80211_hw *hw,
22052208
mutex_unlock(&dev->mt76.mutex);
22062209
}
22072210

2211+
static void mt7925_rfkill_poll(struct ieee80211_hw *hw)
2212+
{
2213+
struct mt792x_phy *phy = mt792x_hw_phy(hw);
2214+
int ret;
2215+
2216+
mt792x_mutex_acquire(phy->dev);
2217+
ret = mt7925_mcu_wf_rf_pin_ctrl(phy);
2218+
mt792x_mutex_release(phy->dev);
2219+
2220+
wiphy_rfkill_set_hw_state(hw->wiphy, ret == 0);
2221+
}
2222+
22082223
const struct ieee80211_ops mt7925_ops = {
22092224
.tx = mt792x_tx,
22102225
.start = mt7925_start,
@@ -2267,6 +2282,7 @@ const struct ieee80211_ops mt7925_ops = {
22672282
.link_info_changed = mt7925_link_info_changed,
22682283
.change_vif_links = mt7925_change_vif_links,
22692284
.change_sta_links = mt7925_change_sta_links,
2285+
.rfkill_poll = mt7925_rfkill_poll,
22702286
};
22712287
EXPORT_SYMBOL_GPL(mt7925_ops);
22722288

drivers/net/wireless/mediatek/mt76/mt7925/mcu.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,6 +3682,43 @@ int mt7925_mcu_set_rate_txpower(struct mt76_phy *phy)
36823682
return 0;
36833683
}
36843684

3685+
int mt7925_mcu_wf_rf_pin_ctrl(struct mt792x_phy *phy)
3686+
{
3687+
#define UNI_CMD_RADIO_STATUS_GET 0
3688+
struct mt792x_dev *dev = phy->dev;
3689+
struct sk_buff *skb;
3690+
int ret;
3691+
struct {
3692+
__le16 tag;
3693+
__le16 len;
3694+
u8 rsv[4];
3695+
} __packed req = {
3696+
.tag = UNI_CMD_RADIO_STATUS_GET,
3697+
.len = cpu_to_le16(sizeof(req)),
3698+
};
3699+
struct mt7925_radio_status_event {
3700+
__le16 tag;
3701+
__le16 len;
3702+
3703+
u8 data;
3704+
u8 rsv[3];
3705+
} __packed *status;
3706+
3707+
ret = mt76_mcu_send_and_get_msg(&dev->mt76,
3708+
MCU_UNI_CMD(RADIO_STATUS),
3709+
&req, sizeof(req), true, &skb);
3710+
if (ret)
3711+
return ret;
3712+
3713+
skb_pull(skb, sizeof(struct tlv));
3714+
status = (struct mt7925_radio_status_event *)skb->data;
3715+
ret = status->data;
3716+
3717+
dev_kfree_skb(skb);
3718+
3719+
return ret;
3720+
}
3721+
36853722
int mt7925_mcu_set_rxfilter(struct mt792x_dev *dev, u32 fif,
36863723
u8 bit_op, u32 bit_map)
36873724
{

drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ int mt7925_mcu_wtbl_update_hdr_trans(struct mt792x_dev *dev,
365365
struct ieee80211_vif *vif,
366366
struct ieee80211_sta *sta,
367367
int link_id);
368+
int mt7925_mcu_wf_rf_pin_ctrl(struct mt792x_phy *phy);
368369

369370
int mt7925_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
370371
void *data, int len);

drivers/net/wireless/mediatek/mt76/mt7925/pci.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ static void mt7925e_unregister_device(struct mt792x_dev *dev)
3131
{
3232
int i;
3333
struct mt76_connac_pm *pm = &dev->pm;
34+
struct ieee80211_hw *hw = mt76_hw(dev);
35+
36+
if (dev->phy.chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN)
37+
wiphy_rfkill_stop_polling(hw->wiphy);
3438

3539
cancel_work_sync(&dev->init_work);
3640
mt76_unregister_device(&dev->mt76);

0 commit comments

Comments
 (0)