[PATCH v3 09/11] usb: dwc3: omap: add basic suspend/resume support
this patch implements basic suspend/resume functionality for the OMAP glue layer. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/dwc3-omap.c | 56 1 file changed, 56 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 3214236..422bfed 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -141,6 +141,8 @@ struct dwc3_omap { int irq; void __iomem*base; + u32 utmi_otg_status; + u32 dma_status:1; }; @@ -444,12 +446,66 @@ static const struct of_device_id of_dwc3_match[] = { }; MODULE_DEVICE_TABLE(of, of_dwc3_match); +#ifdef CONFIG_PM +static int dwc3_omap_prepare(struct device *dev) +{ + struct dwc3_omap*omap = dev_get_drvdata(dev); + + dwc3_omap_disable_irqs(omap); + + return 0; +} + +static void dwc3_omap_complete(struct device *dev) +{ + struct dwc3_omap*omap = dev_get_drvdata(dev); + + dwc3_omap_enable_irqs(omap); +} + +static int dwc3_omap_suspend(struct device *dev) +{ + struct dwc3_omap*omap = dev_get_drvdata(dev); + + omap-utmi_otg_status = dwc3_omap_readl(omap-base, + USBOTGSS_UTMI_OTG_STATUS); + + return 0; +} + +static int dwc3_omap_resume(struct device *dev) +{ + struct dwc3_omap*omap = dev_get_drvdata(dev); + + dwc3_omap_writel(omap-base, USBOTGSS_UTMI_OTG_STATUS, + omap-utmi_otg_status); + + pm_runtime_disable(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + + return 0; +} + +static const struct dev_pm_ops dwc3_omap_dev_pm_ops = { + .prepare= dwc3_omap_prepare, + .complete = dwc3_omap_complete, + + SET_SYSTEM_SLEEP_PM_OPS(dwc3_omap_suspend, dwc3_omap_resume) +}; + +#define DEV_PM_OPS (dwc3_omap_dev_pm_ops) +#else +#define DEV_PM_OPS NULL +#endif /* CONFIG_PM */ + static struct platform_driver dwc3_omap_driver = { .probe = dwc3_omap_probe, .remove = dwc3_omap_remove, .driver = { .name = omap-dwc3, .of_match_table = of_dwc3_match, + .pm = DEV_PM_OPS, }, }; -- 1.8.1.rc1.5.g7e0651a -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 09/11] usb: dwc3: omap: add basic suspend/resume support
Hi, On Monday 11 February 2013 03:22 PM, Felipe Balbi wrote: this patch implements basic suspend/resume functionality for the OMAP glue layer. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/dwc3-omap.c | 56 1 file changed, 56 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 3214236..422bfed 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -141,6 +141,8 @@ struct dwc3_omap { int irq; void __iomem*base; + u32 utmi_otg_status; + u32 dma_status:1; }; @@ -444,12 +446,66 @@ static const struct of_device_id of_dwc3_match[] = { }; MODULE_DEVICE_TABLE(of, of_dwc3_match); +#ifdef CONFIG_PM +static int dwc3_omap_prepare(struct device *dev) +{ + struct dwc3_omap*omap = dev_get_drvdata(dev); + + dwc3_omap_disable_irqs(omap); Any reason for disabling irqs in *prepare* instead of *suspend*? From whatever I could make out from *include/linux/pm.h*, prepare should be used to prevent new calls to the probe method from being made too oncece @prepare() has succeeded. Thanks Kishon -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 09/11] usb: dwc3: omap: add basic suspend/resume support
On Mon, Feb 11, 2013 at 04:32:10PM +0530, kishon wrote: Hi, On Monday 11 February 2013 03:22 PM, Felipe Balbi wrote: this patch implements basic suspend/resume functionality for the OMAP glue layer. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/dwc3-omap.c | 56 1 file changed, 56 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 3214236..422bfed 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -141,6 +141,8 @@ struct dwc3_omap { int irq; void __iomem*base; +u32 utmi_otg_status; + u32 dma_status:1; }; @@ -444,12 +446,66 @@ static const struct of_device_id of_dwc3_match[] = { }; MODULE_DEVICE_TABLE(of, of_dwc3_match); +#ifdef CONFIG_PM +static int dwc3_omap_prepare(struct device *dev) +{ +struct dwc3_omap*omap = dev_get_drvdata(dev); + +dwc3_omap_disable_irqs(omap); Any reason for disabling irqs in *prepare* instead of *suspend*? From whatever I could make out from *include/linux/pm.h*, prepare should be used to prevent new calls to the probe method from being made too oncece @prepare() has succeeded. well, it helps at least with the possibility of us ever implementing e.g. freeze and suspend differently. Because -prepare() will always run, we mask the IRQs early enough and don't need to sprinkle disable_irqs() in many places. -- balbi signature.asc Description: Digital signature