@@ -226,6 +226,25 @@ static u32 mt7921_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val)
return dev->bus_ops->rmw(mdev, addr, mask, val);
}
+static int mt7921e_reboot_notifier(struct notifier_block *nb,
+ unsigned long code, void *unused)
+{
+ struct mt76_dev *mdev = container_of(nb, struct mt76_dev,
+ reboot_nb);
+ struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
+ struct mt76_connac_pm *pm = &dev->pm;
+
+ cancel_delayed_work_sync(&pm->ps_work);
+ cancel_work_sync(&pm->wake_work);
+
+ /* chip cleanup before reboot */
+ mt7921_mcu_drv_pmctrl(dev);
+ mt7921_dma_cleanup(dev);
+ mt7921_wfsys_reset(dev);
+
+ return NOTIFY_DONE;
+}
+
static int mt7921_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
@@ -357,6 +376,8 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
if (ret)
goto err_free_irq;
+ mdev->reboot_nb.notifier_call = mt7921e_reboot_notifier;
+
ret = mt7921_register_device(dev);
if (ret)
goto err_free_irq;