wifi: mt76: mt7921: 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/20241209070922.28106-1-allan.wang@mediatek.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Allan Wang
2024-12-09 15:09:22 +08:00
committed by Felix Fietkau
parent 8aa2f59260
commit 5190594bce
7 changed files with 55 additions and 0 deletions

View File

@@ -1043,6 +1043,7 @@ enum {
MCU_EXT_EVENT_CSA_NOTIFY = 0x4f,
MCU_EXT_EVENT_WA_TX_STAT = 0x74,
MCU_EXT_EVENT_BCC_NOTIFY = 0x75,
MCU_EXT_EVENT_WF_RF_PIN_CTRL = 0x9a,
MCU_EXT_EVENT_MURU_CTRL = 0x9f,
};
@@ -1251,6 +1252,7 @@ enum {
MCU_EXT_CMD_GROUP_PRE_CAL_INFO = 0xab,
MCU_EXT_CMD_DPD_PRE_CAL_INFO = 0xac,
MCU_EXT_CMD_PHY_STAT_INFO = 0xad,
MCU_EXT_CMD_WF_RF_PIN_CTRL = 0xbd,
};
enum {

View File

@@ -252,6 +252,11 @@ int __mt7921_start(struct mt792x_phy *phy)
return err;
}
if (phy->chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN) {
mt7921_mcu_wf_rf_pin_ctrl(phy, WF_RF_PIN_INIT);
wiphy_rfkill_start_polling(mphy->hw->wiphy);
}
return 0;
}
EXPORT_SYMBOL_GPL(__mt7921_start);
@@ -1492,6 +1497,18 @@ static void mt7921_channel_switch_rx_beacon(struct ieee80211_hw *hw,
}
}
static void mt7921_rfkill_poll(struct ieee80211_hw *hw)
{
struct mt792x_phy *phy = mt792x_hw_phy(hw);
int ret = 0;
mt792x_mutex_acquire(phy->dev);
ret = mt7921_mcu_wf_rf_pin_ctrl(phy, WF_RF_PIN_POLL);
mt792x_mutex_release(phy->dev);
wiphy_rfkill_set_hw_state(hw->wiphy, ret ? false : true);
}
const struct ieee80211_ops mt7921_ops = {
.tx = mt792x_tx,
.start = mt7921_start,
@@ -1542,6 +1559,7 @@ const struct ieee80211_ops mt7921_ops = {
#endif /* CONFIG_PM */
.flush = mt792x_flush,
.set_sar_specs = mt7921_set_sar_specs,
.rfkill_poll = mt7921_rfkill_poll,
.remain_on_channel = mt7921_remain_on_channel,
.cancel_remain_on_channel = mt7921_cancel_remain_on_channel,
.add_chanctx = mt7921_add_chanctx,

View File

@@ -61,6 +61,12 @@ int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd,
skb_pull(skb, sizeof(*rxd));
event = (struct mt76_connac_mcu_reg_event *)skb->data;
ret = (int)le32_to_cpu(event->val);
} else if (cmd == MCU_EXT_CMD(WF_RF_PIN_CTRL)) {
struct mt7921_wf_rf_pin_ctrl_event *event;
skb_pull(skb, sizeof(*rxd));
event = (struct mt7921_wf_rf_pin_ctrl_event *)skb->data;
ret = (int)event->result;
} else {
skb_pull(skb, sizeof(struct mt76_connac2_mcu_rxd));
}
@@ -1427,6 +1433,21 @@ int mt7921_mcu_get_temperature(struct mt792x_phy *phy)
sizeof(req), true);
}
int mt7921_mcu_wf_rf_pin_ctrl(struct mt792x_phy *phy, u8 action)
{
struct mt792x_dev *dev = phy->dev;
struct {
u8 action;
u8 value;
} req = {
.action = action,
.value = 0,
};
return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(WF_RF_PIN_CTRL), &req,
sizeof(req), action ? true : false);
}
int mt7921_mcu_set_rxfilter(struct mt792x_dev *dev, u32 fif,
u8 bit_op, u32 bit_map)
{

View File

@@ -74,6 +74,11 @@ struct mt7921_txpwr_event {
struct mt7921_txpwr txpwr;
} __packed;
struct mt7921_wf_rf_pin_ctrl_event {
u8 result;
u8 value;
} __packed;
enum {
TM_SWITCH_MODE,
TM_SET_AT_CMD,

View File

@@ -31,6 +31,9 @@
#define EXT_CMD_RADIO_ON_LED 0x2
#define EXT_CMD_RADIO_OFF_LED 0x3
#define WF_RF_PIN_INIT 0x0
#define WF_RF_PIN_POLL 0x1
enum {
UNI_ROC_ACQUIRE,
UNI_ROC_ABORT,
@@ -202,6 +205,7 @@ void mt7921_mcu_rx_event(struct mt792x_dev *dev, struct sk_buff *skb);
int mt7921_mcu_set_rxfilter(struct mt792x_dev *dev, u32 fif,
u8 bit_op, u32 bit_map);
int mt7921_mcu_radio_led_ctrl(struct mt792x_dev *dev, u8 value);
int mt7921_mcu_wf_rf_pin_ctrl(struct mt792x_phy *phy, u8 action);
static inline u32
mt7921_reg_map_l1(struct mt792x_dev *dev, u32 addr)

View File

@@ -42,6 +42,10 @@ static void mt7921e_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);

View File

@@ -28,6 +28,7 @@
#define MT792x_CHIP_CAP_CLC_EVT_EN BIT(0)
#define MT792x_CHIP_CAP_RSSI_NOTIFY_EVT_EN BIT(1)
#define MT792x_CHIP_CAP_MLO_EVT_EN BIT(2)
#define MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN BIT(3)
/* NOTE: used to map mt76_rates. idx may change if firmware expands table */
#define MT792x_BASIC_RATES_TBL 11