mcu.c (dfc7743de1ebb5ff5c2ed323eaff1994da11abd9) mcu.c (8910a4e5ba342ad661acb6f99fa14e0dd809465e)
1// SPDX-License-Identifier: ISC
2/* Copyright (C) 2020 MediaTek Inc. */
3
4#include <linux/firmware.h>
5#include <linux/fs.h>
6#include "mt7921.h"
7#include "mt7921_trace.h"
8#include "mcu.h"

--- 208 unchanged lines hidden (view full) ---

217 }
218 default:
219 skb_pull(skb, sizeof(struct mt7921_mcu_rxd));
220 break;
221 }
222
223 return ret;
224}
1// SPDX-License-Identifier: ISC
2/* Copyright (C) 2020 MediaTek Inc. */
3
4#include <linux/firmware.h>
5#include <linux/fs.h>
6#include "mt7921.h"
7#include "mt7921_trace.h"
8#include "mcu.h"

--- 208 unchanged lines hidden (view full) ---

217 }
218 default:
219 skb_pull(skb, sizeof(struct mt7921_mcu_rxd));
220 break;
221 }
222
223 return ret;
224}
225EXPORT_SYMBOL_GPL(mt7921_mcu_parse_response);
225
226int mt7921_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
227 int cmd, int *wait_seq)
228{
229 struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
230 int txd_len, mcu_cmd = cmd & MCU_CMD_MASK;
231 enum mt76_mcuq_id txq = MT_MCUQ_WM;
232 struct mt7921_uni_txd *uni_txd;

--- 81 unchanged lines hidden (view full) ---

314 mcu_txd->set_query != MCU_Q_QUERY);
315
316exit:
317 if (wait_seq)
318 *wait_seq = seq;
319
320 return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[txq], skb, 0);
321}
226
227int mt7921_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
228 int cmd, int *wait_seq)
229{
230 struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
231 int txd_len, mcu_cmd = cmd & MCU_CMD_MASK;
232 enum mt76_mcuq_id txq = MT_MCUQ_WM;
233 struct mt7921_uni_txd *uni_txd;

--- 81 unchanged lines hidden (view full) ---

315 mcu_txd->set_query != MCU_Q_QUERY);
316
317exit:
318 if (wait_seq)
319 *wait_seq = seq;
320
321 return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[txq], skb, 0);
322}
323EXPORT_SYMBOL_GPL(mt7921_mcu_send_message);
322
323static void
324mt7921_mcu_scan_event(struct mt7921_dev *dev, struct sk_buff *skb)
325{
326 struct mt76_phy *mphy = &dev->mt76.phy;
327 struct mt7921_phy *phy = (struct mt7921_phy *)mphy->priv;
328
329 spin_lock_bh(&dev->mt76.lock);

--- 265 unchanged lines hidden (view full) ---

595 u8 rsv[3];
596 } req = {
597 .power_mode = 1,
598 };
599
600 return mt76_mcu_send_msg(dev, MCU_CMD_NIC_POWER_CTRL, &req,
601 sizeof(req), false);
602}
324
325static void
326mt7921_mcu_scan_event(struct mt7921_dev *dev, struct sk_buff *skb)
327{
328 struct mt76_phy *mphy = &dev->mt76.phy;
329 struct mt7921_phy *phy = (struct mt7921_phy *)mphy->priv;
330
331 spin_lock_bh(&dev->mt76.lock);

--- 265 unchanged lines hidden (view full) ---

597 u8 rsv[3];
598 } req = {
599 .power_mode = 1,
600 };
601
602 return mt76_mcu_send_msg(dev, MCU_CMD_NIC_POWER_CTRL, &req,
603 sizeof(req), false);
604}
605EXPORT_SYMBOL_GPL(mt7921_mcu_restart);
603
604static u32 mt7921_get_data_mode(struct mt7921_dev *dev, u32 info)
605{
606 u32 mode = DL_MODE_NEED_RSP;
607
608 if (info == PATCH_SEC_NOT_SUPPORT)
609 return mode;
610

--- 287 unchanged lines hidden (view full) ---

898 if (err)
899 return err;
900
901 set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state);
902 mt7921_mcu_fw_log_2_host(dev, 1);
903
904 return mt76_connac_mcu_get_nic_capability(&dev->mphy);
905}
606
607static u32 mt7921_get_data_mode(struct mt7921_dev *dev, u32 info)
608{
609 u32 mode = DL_MODE_NEED_RSP;
610
611 if (info == PATCH_SEC_NOT_SUPPORT)
612 return mode;
613

--- 287 unchanged lines hidden (view full) ---

901 if (err)
902 return err;
903
904 set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state);
905 mt7921_mcu_fw_log_2_host(dev, 1);
906
907 return mt76_connac_mcu_get_nic_capability(&dev->mphy);
908}
909EXPORT_SYMBOL_GPL(mt7921_run_firmware);
906
907void mt7921_mcu_exit(struct mt7921_dev *dev)
908{
909 skb_queue_purge(&dev->mt76.mcu.res_q);
910}
910
911void mt7921_mcu_exit(struct mt7921_dev *dev)
912{
913 skb_queue_purge(&dev->mt76.mcu.res_q);
914}
915EXPORT_SYMBOL_GPL(mt7921_mcu_exit);
911
912int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif)
913{
914#define WMM_AIFS_SET BIT(0)
915#define WMM_CW_MIN_SET BIT(1)
916#define WMM_CW_MAX_SET BIT(2)
917#define WMM_TXOP_SET BIT(3)
918#define WMM_PARAM_SET GENMASK(3, 0)

--- 158 unchanged lines hidden (view full) ---

1077 } __packed req = {
1078 .buffer_mode = EE_MODE_EFUSE,
1079 .format = EE_FORMAT_WHOLE,
1080 };
1081
1082 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_BUFFER_MODE,
1083 &req, sizeof(req), true);
1084}
916
917int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif)
918{
919#define WMM_AIFS_SET BIT(0)
920#define WMM_CW_MIN_SET BIT(1)
921#define WMM_CW_MAX_SET BIT(2)
922#define WMM_TXOP_SET BIT(3)
923#define WMM_PARAM_SET GENMASK(3, 0)

--- 158 unchanged lines hidden (view full) ---

1082 } __packed req = {
1083 .buffer_mode = EE_MODE_EFUSE,
1084 .format = EE_FORMAT_WHOLE,
1085 };
1086
1087 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_BUFFER_MODE,
1088 &req, sizeof(req), true);
1089}
1090EXPORT_SYMBOL_GPL(mt7921_mcu_set_eeprom);
1085
1086int mt7921_mcu_get_eeprom(struct mt7921_dev *dev, u32 offset)
1087{
1088 struct mt7921_mcu_eeprom_info req = {
1089 .addr = cpu_to_le32(round_down(offset, 16)),
1090 };
1091 struct mt7921_mcu_eeprom_info *res;
1092 struct sk_buff *skb;

--- 166 unchanged lines hidden (view full) ---

1259out:
1260 mutex_unlock(&pm->mutex);
1261
1262 if (err)
1263 mt7921_reset(&dev->mt76);
1264
1265 return err;
1266}
1091
1092int mt7921_mcu_get_eeprom(struct mt7921_dev *dev, u32 offset)
1093{
1094 struct mt7921_mcu_eeprom_info req = {
1095 .addr = cpu_to_le32(round_down(offset, 16)),
1096 };
1097 struct mt7921_mcu_eeprom_info *res;
1098 struct sk_buff *skb;

--- 166 unchanged lines hidden (view full) ---

1265out:
1266 mutex_unlock(&pm->mutex);
1267
1268 if (err)
1269 mt7921_reset(&dev->mt76);
1270
1271 return err;
1272}
1273EXPORT_SYMBOL_GPL(mt7921_mcu_drv_pmctrl);
1267
1268int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev)
1269{
1270 struct mt76_phy *mphy = &dev->mt76.phy;
1271 struct mt76_connac_pm *pm = &dev->pm;
1272 int err = 0;
1273
1274 mutex_lock(&pm->mutex);

--- 5 unchanged lines hidden (view full) ---

1280out:
1281 mutex_unlock(&pm->mutex);
1282
1283 if (err)
1284 mt7921_reset(&dev->mt76);
1285
1286 return err;
1287}
1274
1275int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev)
1276{
1277 struct mt76_phy *mphy = &dev->mt76.phy;
1278 struct mt76_connac_pm *pm = &dev->pm;
1279 int err = 0;
1280
1281 mutex_lock(&pm->mutex);

--- 5 unchanged lines hidden (view full) ---

1287out:
1288 mutex_unlock(&pm->mutex);
1289
1290 if (err)
1291 mt7921_reset(&dev->mt76);
1292
1293 return err;
1294}
1295EXPORT_SYMBOL_GPL(mt7921_mcu_fw_pmctrl);
1288
1289int mt7921_mcu_set_beacon_filter(struct mt7921_dev *dev,
1290 struct ieee80211_vif *vif,
1291 bool enable)
1292{
1293 struct ieee80211_hw *hw = mt76_hw(dev);
1294 int err;
1295

--- 45 unchanged lines hidden ---
1296
1297int mt7921_mcu_set_beacon_filter(struct mt7921_dev *dev,
1298 struct ieee80211_vif *vif,
1299 bool enable)
1300{
1301 struct ieee80211_hw *hw = mt76_hw(dev);
1302 int err;
1303

--- 45 unchanged lines hidden ---