1 // SPDX-License-Identifier: ISC 2 /* Copyright (C) 2023 MediaTek Inc. */ 3 4 #include "mt7925.h" 5 #include "mcu.h" 6 7 static int 8 mt7925_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, 9 int cmd, int *seq) 10 { 11 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); 12 enum mt76_mcuq_id txq = MT_MCUQ_WM; 13 int ret; 14 15 ret = mt7925_mcu_fill_message(mdev, skb, cmd, seq); 16 if (ret) 17 return ret; 18 19 mdev->mcu.timeout = 3 * HZ; 20 21 if (cmd == MCU_CMD(FW_SCATTER)) 22 txq = MT_MCUQ_FWDL; 23 24 return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[txq], skb, 0); 25 } 26 27 int mt7925e_mcu_init(struct mt792x_dev *dev) 28 { 29 static const struct mt76_mcu_ops mt7925_mcu_ops = { 30 .headroom = sizeof(struct mt76_connac2_mcu_txd), 31 .mcu_skb_send_msg = mt7925_mcu_send_message, 32 .mcu_parse_response = mt7925_mcu_parse_response, 33 }; 34 int err; 35 36 dev->mt76.mcu_ops = &mt7925_mcu_ops; 37 38 err = mt792xe_mcu_fw_pmctrl(dev); 39 if (err) 40 return err; 41 42 err = __mt792xe_mcu_drv_pmctrl(dev); 43 if (err) 44 return err; 45 46 mt76_rmw_field(dev, MT_PCIE_MAC_PM, MT_PCIE_MAC_PM_L0S_DIS, 1); 47 48 err = mt7925_run_firmware(dev); 49 50 mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_FWDL], false); 51 52 return err; 53 } 54