From: Allen Chien Enable the firmware thermal protection for MT7920/MT7921/MT7922 by sending the DowngradeTxStreamTemp chip config command at init time. Signed-off-by: Allen Chien --- .../net/wireless/mediatek/mt76/mt7921/init.c | 6 +++++ .../net/wireless/mediatek/mt76/mt7921/mcu.c | 25 +++++++++++++++++++ .../wireless/mediatek/mt76/mt7921/mt7921.h | 1 + 3 files changed, 32 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c index 49be2fa4e3fa..4ebc7c414b95 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c @@ -161,6 +161,12 @@ static void mt7921_init_work(struct work_struct *work) return; } + ret = mt7921_mcu_set_thermal_protect(dev); + if (ret) { + dev_err(dev->mt76.dev, "thermal protection enable failed\n"); + return; + } + /* we support chip reset now */ dev->hw_init_done = true; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index a118a301564c..8948985c65fa 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -1474,6 +1474,31 @@ int mt7921_mcu_wf_rf_pin_ctrl(struct mt792x_phy *phy, u8 action) sizeof(req), action ? true : false); } +#define MT7921_THERMAL_PROT_LOW_TEMP 105 +#define MT7921_THERMAL_PROT_HIGH_TEMP 115 + +static int mt7921_mcu_chip_config(struct mt792x_dev *dev, const char *cmd) +{ + struct mt76_connac_config req = { + .resp_type = 0, + }; + + snprintf(req.data, sizeof(req.data), "%s", cmd); + + return mt76_mcu_send_msg(&dev->mt76, MCU_CE_CMD(CHIP_CONFIG), + &req, sizeof(req), false); +} + +int mt7921_mcu_set_thermal_protect(struct mt792x_dev *dev) +{ + char cmd[64]; + + snprintf(cmd, sizeof(cmd), "DowngradeTxStreamTemp %d %d", + MT7921_THERMAL_PROT_LOW_TEMP, MT7921_THERMAL_PROT_HIGH_TEMP); + + return mt7921_mcu_chip_config(dev, cmd); +} + int mt7921_mcu_set_rxfilter(struct mt792x_dev *dev, u32 fif, u8 bit_op, u32 bit_map) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index fb8654b7c5e7..e632a3dea521 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -324,6 +324,7 @@ int mt7921_mcu_set_sniffer(struct mt792x_dev *dev, struct ieee80211_vif *vif, int mt7921_mcu_config_sniffer(struct mt792x_vif *vif, struct ieee80211_chanctx_conf *ctx); int mt7921_mcu_get_temperature(struct mt792x_phy *phy); +int mt7921_mcu_set_thermal_protect(struct mt792x_dev *dev); int mt7921_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, enum mt76_txq_id qid, struct mt76_wcid *wcid, -- 2.45.2