Commit e54b8702 authored by Allan Wang's avatar Allan Wang Committed by Felix Fietkau
Browse files

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: default avatarAllan Wang <allan.wang@mediatek.com>
Link: https://patch.msgid.link/20250507053131.4173691-1-allan.wang@mediatek.com


Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 56e38675
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1306,6 +1306,7 @@ enum {
	MCU_UNI_CMD_PER_STA_INFO = 0x6d,
	MCU_UNI_CMD_ALL_STA_INFO = 0x6e,
	MCU_UNI_CMD_ASSERT_DUMP = 0x6f,
	MCU_UNI_CMD_RADIO_STATUS = 0x80,
	MCU_UNI_CMD_SDO = 0x88,
};

+16 −0
Original line number Diff line number Diff line
@@ -334,6 +334,9 @@ int __mt7925_start(struct mt792x_phy *phy)
	ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
				     MT792x_WATCHDOG_TIME);

	if (phy->chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN)
		wiphy_rfkill_start_polling(mphy->hw->wiphy);

	return 0;
}
EXPORT_SYMBOL_GPL(__mt7925_start);
@@ -2205,6 +2208,18 @@ static void mt7925_unassign_vif_chanctx(struct ieee80211_hw *hw,
	mutex_unlock(&dev->mt76.mutex);
}

static void mt7925_rfkill_poll(struct ieee80211_hw *hw)
{
	struct mt792x_phy *phy = mt792x_hw_phy(hw);
	int ret;

	mt792x_mutex_acquire(phy->dev);
	ret = mt7925_mcu_wf_rf_pin_ctrl(phy);
	mt792x_mutex_release(phy->dev);

	wiphy_rfkill_set_hw_state(hw->wiphy, ret == 0);
}

const struct ieee80211_ops mt7925_ops = {
	.tx = mt792x_tx,
	.start = mt7925_start,
@@ -2267,6 +2282,7 @@ const struct ieee80211_ops mt7925_ops = {
	.link_info_changed = mt7925_link_info_changed,
	.change_vif_links = mt7925_change_vif_links,
	.change_sta_links = mt7925_change_sta_links,
	.rfkill_poll = mt7925_rfkill_poll,
};
EXPORT_SYMBOL_GPL(mt7925_ops);

+37 −0
Original line number Diff line number Diff line
@@ -3682,6 +3682,43 @@ int mt7925_mcu_set_rate_txpower(struct mt76_phy *phy)
	return 0;
}

int mt7925_mcu_wf_rf_pin_ctrl(struct mt792x_phy *phy)
{
#define UNI_CMD_RADIO_STATUS_GET	0
	struct mt792x_dev *dev = phy->dev;
	struct sk_buff *skb;
	int ret;
	struct {
		__le16 tag;
		__le16 len;
		u8 rsv[4];
	} __packed req = {
		.tag = UNI_CMD_RADIO_STATUS_GET,
		.len = cpu_to_le16(sizeof(req)),
	};
	struct mt7925_radio_status_event {
		__le16 tag;
		__le16 len;

		u8 data;
		u8 rsv[3];
	} __packed *status;

	ret = mt76_mcu_send_and_get_msg(&dev->mt76,
					MCU_UNI_CMD(RADIO_STATUS),
					&req, sizeof(req), true, &skb);
	if (ret)
		return ret;

	skb_pull(skb, sizeof(struct tlv));
	status = (struct mt7925_radio_status_event *)skb->data;
	ret = status->data;

	dev_kfree_skb(skb);

	return ret;
}

int mt7925_mcu_set_rxfilter(struct mt792x_dev *dev, u32 fif,
			    u8 bit_op, u32 bit_map)
{
+1 −0
Original line number Diff line number Diff line
@@ -365,6 +365,7 @@ int mt7925_mcu_wtbl_update_hdr_trans(struct mt792x_dev *dev,
				     struct ieee80211_vif *vif,
				     struct ieee80211_sta *sta,
				     int link_id);
int mt7925_mcu_wf_rf_pin_ctrl(struct mt792x_phy *phy);

int mt7925_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
			void *data, int len);
+4 −0
Original line number Diff line number Diff line
@@ -31,6 +31,10 @@ static void mt7925e_unregister_device(struct mt792x_dev *dev)
{
	int i;
	struct mt76_connac_pm *pm = &dev->pm;
	struct ieee80211_hw *hw = mt76_hw(dev);

	if (dev->phy.chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN)
		wiphy_rfkill_stop_polling(hw->wiphy);

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