Commit c2a43a6b authored by Hante Meuleman's avatar Hante Meuleman Committed by Kalle Valo

brcmfmac: Use new methods for pcie Power Management.

Currently the legacy methods suspend and resume are used for pcie
devices. This is not the preferable method and is also causing
issues with some setups when doing hibernate. Changing this to
use the new PM methods.
Reviewed-by: default avatarArend Van Spriel <arend@broadcom.com>
Reviewed-by: default avatarFranky (Zhenhui) Lin <frankyl@broadcom.com>
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: default avatarHante Meuleman <meuleman@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 37a869ec
...@@ -1388,10 +1388,6 @@ static void brcmf_pcie_wowl_config(struct device *dev, bool enabled) ...@@ -1388,10 +1388,6 @@ static void brcmf_pcie_wowl_config(struct device *dev, bool enabled)
brcmf_dbg(PCIE, "Configuring WOWL, enabled=%d\n", enabled); brcmf_dbg(PCIE, "Configuring WOWL, enabled=%d\n", enabled);
devinfo->wowl_enabled = enabled; devinfo->wowl_enabled = enabled;
if (enabled)
device_set_wakeup_enable(&devinfo->pdev->dev, true);
else
device_set_wakeup_enable(&devinfo->pdev->dev, false);
} }
...@@ -1961,15 +1957,14 @@ brcmf_pcie_remove(struct pci_dev *pdev) ...@@ -1961,15 +1957,14 @@ brcmf_pcie_remove(struct pci_dev *pdev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int brcmf_pcie_suspend(struct pci_dev *pdev, pm_message_t state) static int brcmf_pcie_pm_enter_D3(struct device *dev)
{ {
struct brcmf_pciedev_info *devinfo; struct brcmf_pciedev_info *devinfo;
struct brcmf_bus *bus; struct brcmf_bus *bus;
int err;
brcmf_dbg(PCIE, "Enter, state=%d, pdev=%p\n", state.event, pdev); brcmf_err("Enter\n");
bus = dev_get_drvdata(&pdev->dev); bus = dev_get_drvdata(dev);
devinfo = bus->bus_priv.pcie->devinfo; devinfo = bus->bus_priv.pcie->devinfo;
brcmf_bus_change_state(bus, BRCMF_BUS_DOWN); brcmf_bus_change_state(bus, BRCMF_BUS_DOWN);
...@@ -1984,62 +1979,45 @@ static int brcmf_pcie_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -1984,62 +1979,45 @@ static int brcmf_pcie_suspend(struct pci_dev *pdev, pm_message_t state)
brcmf_err("Timeout on response for entering D3 substate\n"); brcmf_err("Timeout on response for entering D3 substate\n");
return -EIO; return -EIO;
} }
brcmf_pcie_send_mb_data(devinfo, BRCMF_H2D_HOST_D0_INFORM_IN_USE);
err = pci_save_state(pdev); devinfo->state = BRCMFMAC_PCIE_STATE_DOWN;
if (err)
brcmf_err("pci_save_state failed, err=%d\n", err);
if ((err) || (!devinfo->wowl_enabled)) {
brcmf_chip_detach(devinfo->ci);
devinfo->ci = NULL;
brcmf_pcie_remove(pdev);
return 0;
}
return pci_prepare_to_sleep(pdev); return 0;
} }
static int brcmf_pcie_resume(struct pci_dev *pdev)
static int brcmf_pcie_pm_leave_D3(struct device *dev)
{ {
struct brcmf_pciedev_info *devinfo; struct brcmf_pciedev_info *devinfo;
struct brcmf_bus *bus; struct brcmf_bus *bus;
struct pci_dev *pdev;
int err; int err;
bus = dev_get_drvdata(&pdev->dev); brcmf_err("Enter\n");
brcmf_dbg(PCIE, "Enter, pdev=%p, bus=%p\n", pdev, bus);
err = pci_set_power_state(pdev, PCI_D0); bus = dev_get_drvdata(dev);
if (err) { devinfo = bus->bus_priv.pcie->devinfo;
brcmf_err("pci_set_power_state failed, err=%d\n", err); brcmf_dbg(PCIE, "Enter, dev=%p, bus=%p\n", dev, bus);
goto cleanup;
}
pci_restore_state(pdev);
pci_enable_wake(pdev, PCI_D3hot, false);
pci_enable_wake(pdev, PCI_D3cold, false);
/* Check if device is still up and running, if so we are ready */ /* Check if device is still up and running, if so we are ready */
if (bus) { if (brcmf_pcie_read_reg32(devinfo, BRCMF_PCIE_PCIE2REG_INTMASK) != 0) {
devinfo = bus->bus_priv.pcie->devinfo; brcmf_dbg(PCIE, "Try to wakeup device....\n");
if (brcmf_pcie_read_reg32(devinfo, if (brcmf_pcie_send_mb_data(devinfo, BRCMF_H2D_HOST_D0_INFORM))
BRCMF_PCIE_PCIE2REG_INTMASK) != 0) {
if (brcmf_pcie_send_mb_data(devinfo,
BRCMF_H2D_HOST_D0_INFORM))
goto cleanup; goto cleanup;
brcmf_dbg(PCIE, "Hot resume, continue....\n"); brcmf_dbg(PCIE, "Hot resume, continue....\n");
devinfo->state = BRCMFMAC_PCIE_STATE_UP;
brcmf_pcie_select_core(devinfo, BCMA_CORE_PCIE2); brcmf_pcie_select_core(devinfo, BCMA_CORE_PCIE2);
brcmf_bus_change_state(bus, BRCMF_BUS_UP); brcmf_bus_change_state(bus, BRCMF_BUS_UP);
brcmf_pcie_intr_enable(devinfo); brcmf_pcie_intr_enable(devinfo);
return 0; return 0;
} }
}
cleanup: cleanup:
if (bus) {
devinfo = bus->bus_priv.pcie->devinfo;
brcmf_chip_detach(devinfo->ci); brcmf_chip_detach(devinfo->ci);
devinfo->ci = NULL; devinfo->ci = NULL;
pdev = devinfo->pdev;
brcmf_pcie_remove(pdev); brcmf_pcie_remove(pdev);
}
err = brcmf_pcie_probe(pdev, NULL); err = brcmf_pcie_probe(pdev, NULL);
if (err) if (err)
brcmf_err("probe after resume failed, err=%d\n", err); brcmf_err("probe after resume failed, err=%d\n", err);
...@@ -2048,6 +2026,14 @@ static int brcmf_pcie_resume(struct pci_dev *pdev) ...@@ -2048,6 +2026,14 @@ static int brcmf_pcie_resume(struct pci_dev *pdev)
} }
static const struct dev_pm_ops brcmf_pciedrvr_pm = {
.suspend = brcmf_pcie_pm_enter_D3,
.resume = brcmf_pcie_pm_leave_D3,
.freeze = brcmf_pcie_pm_enter_D3,
.restore = brcmf_pcie_pm_leave_D3,
};
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
...@@ -2086,9 +2072,8 @@ static struct pci_driver brcmf_pciedrvr = { ...@@ -2086,9 +2072,8 @@ static struct pci_driver brcmf_pciedrvr = {
.probe = brcmf_pcie_probe, .probe = brcmf_pcie_probe,
.remove = brcmf_pcie_remove, .remove = brcmf_pcie_remove,
#ifdef CONFIG_PM #ifdef CONFIG_PM
.suspend = brcmf_pcie_suspend, .driver.pm = &brcmf_pciedrvr_pm,
.resume = brcmf_pcie_resume #endif
#endif /* CONFIG_PM */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment