From e9af9229098d92145d0b894b78878bbc6ac7c910 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Tue, 17 May 2016 10:15:02 +0300 Subject: [PATCH] usb: dwc3: pci: add Power Management dummy hooks Allow for dwc3-pci to reach D3 and enable pm_runtime by providing dummy PM hooks. Without them, PCI subsystem won't put device to D3. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/dwc3-pci.c | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 14196cd416b3..a7b6a1c8bc81 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -180,7 +181,11 @@ static int dwc3_pci_probe(struct pci_dev *pci, goto err; } + device_init_wakeup(dev, true); + device_set_run_wake(dev, true); pci_set_drvdata(pci, dwc3); + pm_runtime_put(dev); + return 0; err: platform_device_put(dwc3); @@ -189,6 +194,8 @@ err: static void dwc3_pci_remove(struct pci_dev *pci) { + device_init_wakeup(&pci->dev, false); + pm_runtime_get(&pci->dev); acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pci->dev)); platform_device_unregister(pci_get_drvdata(pci)); } @@ -219,11 +226,43 @@ static const struct pci_device_id dwc3_pci_id_table[] = { }; MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); +#ifdef CONFIG_PM +static int dwc3_pci_runtime_suspend(struct device *dev) +{ + if (device_run_wake(dev)) + return 0; + + return -EBUSY; +} + +static int dwc3_pci_pm_dummy(struct device *dev) +{ + /* + * There's nothing to do here. No, seriously. Everything is either taken + * care either by PCI subsystem or dwc3/core.c, so we have nothing + * missing here. + * + * So you'd think we didn't need this at all, but PCI subsystem will + * bail out if we don't have a valid callback :-s + */ + return 0; +} +#endif /* CONFIG_PM */ + +static struct dev_pm_ops dwc3_pci_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_pm_dummy, dwc3_pci_pm_dummy) + SET_RUNTIME_PM_OPS(dwc3_pci_runtime_suspend, dwc3_pci_pm_dummy, + NULL) +}; + static struct pci_driver dwc3_pci_driver = { .name = "dwc3-pci", .id_table = dwc3_pci_id_table, .probe = dwc3_pci_probe, .remove = dwc3_pci_remove, + .driver = { + .pm = &dwc3_pci_dev_pm_ops, + } }; MODULE_AUTHOR("Felipe Balbi "); -- 2.39.5