From: Jiebing Li <jiebing.li@xxxxxxxxx> This patch adds runtime pm framework for langwell_udc controller driver. The actul implementation on runtime_suspend/resume will be added in another patch. Signed-off-by: Jiebing Li <jiebing.li@xxxxxxxxx> Signed-off-by: Hao Wu <hao.wu@xxxxxxxxx> --- drivers/usb/gadget/langwell_udc.c | 52 +++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-) diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c index 2c56faf..8f17d16 100644 --- a/drivers/usb/gadget/langwell_udc.c +++ b/drivers/usb/gadget/langwell_udc.c @@ -2761,6 +2761,9 @@ static void handle_bus_suspend(struct langwell_udc *dev) { dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); + if (dev->usb_state == USB_STATE_SUSPENDED) + return; + dev->resume_state = dev->usb_state; dev->usb_state = USB_STATE_SUSPENDED; @@ -2777,6 +2780,8 @@ static void handle_bus_suspend(struct langwell_udc *dev) } } + pm_runtime_put(&dev->pdev->dev); + /* enter PHY low power suspend */ langwell_phy_low_power(dev, 1); @@ -2807,6 +2812,8 @@ static void handle_bus_resume(struct langwell_udc *dev) } } + pm_runtime_get(&dev->pdev->dev); + dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); } @@ -3449,6 +3456,42 @@ static int langwell_udc_resume(struct pci_dev *pdev) } +#ifdef CONFIG_PM_RUNTIME +/* device controller runtime suspend */ +static int langwell_udc_runtime_suspend(struct device *device) +{ + struct langwell_udc *dev = the_controller; + + dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); + + /* TODO: queue flush and SRAM release */ + + dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); + return 0; +} + + +/* device controller runtime resume */ +static int langwell_udc_runtime_resume(struct device *device) +{ + struct langwell_udc *dev = the_controller; + + dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); + + /* TODO: queue re-enable and SRAM resume */ + + dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); + return 0; +} + +#else + +#define langwell_udc_runtime_suspend NULL +#define langwell_udc_runtime_resume NULL + +#endif + + /* pci driver shutdown */ static void langwell_udc_shutdown(struct pci_dev *pdev) { @@ -3488,7 +3531,16 @@ static const struct pci_device_id pci_ids[] = { { MODULE_DEVICE_TABLE(pci, pci_ids); +static const struct dev_pm_ops langwell_udc_pm_ops = { + .runtime_suspend = langwell_udc_runtime_suspend, + .runtime_resume = langwell_udc_runtime_resume, +}; + + static struct pci_driver langwell_pci_driver = { + .driver = { + .pm = &langwell_udc_pm_ops, + }, .name = (char *) driver_name, .id_table = pci_ids, -- 1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html