diff options
author | Felipe Balbi <balbi@ti.com> | 2013-02-11 04:12:02 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-03-18 05:17:02 -0400 |
commit | f3e117f4437af5a2d1b72ae0fa1890dbf9bca72f (patch) | |
tree | 6801b75966f972b90448e8c80aa457b08760e69f | |
parent | 1d9a00eeca1deeebf001047aa5e5e9d00e5588cf (diff) |
usb: dwc3: omap: add basic suspend/resume support
this patch implements basic suspend/resume
functionality for the OMAP glue layer.
Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/dwc3/dwc3-omap.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index ed178c0fc426..35b9673b84df 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -121,6 +121,8 @@ struct dwc3_omap { | |||
121 | int irq; | 121 | int irq; |
122 | void __iomem *base; | 122 | void __iomem *base; |
123 | 123 | ||
124 | u32 utmi_otg_status; | ||
125 | |||
124 | u32 dma_status:1; | 126 | u32 dma_status:1; |
125 | }; | 127 | }; |
126 | 128 | ||
@@ -402,12 +404,66 @@ static const struct of_device_id of_dwc3_match[] = { | |||
402 | }; | 404 | }; |
403 | MODULE_DEVICE_TABLE(of, of_dwc3_match); | 405 | MODULE_DEVICE_TABLE(of, of_dwc3_match); |
404 | 406 | ||
407 | #ifdef CONFIG_PM | ||
408 | static int dwc3_omap_prepare(struct device *dev) | ||
409 | { | ||
410 | struct dwc3_omap *omap = dev_get_drvdata(dev); | ||
411 | |||
412 | dwc3_omap_disable_irqs(omap); | ||
413 | |||
414 | return 0; | ||
415 | } | ||
416 | |||
417 | static void dwc3_omap_complete(struct device *dev) | ||
418 | { | ||
419 | struct dwc3_omap *omap = dev_get_drvdata(dev); | ||
420 | |||
421 | dwc3_omap_enable_irqs(omap); | ||
422 | } | ||
423 | |||
424 | static int dwc3_omap_suspend(struct device *dev) | ||
425 | { | ||
426 | struct dwc3_omap *omap = dev_get_drvdata(dev); | ||
427 | |||
428 | omap->utmi_otg_status = dwc3_omap_readl(omap->base, | ||
429 | USBOTGSS_UTMI_OTG_STATUS); | ||
430 | |||
431 | return 0; | ||
432 | } | ||
433 | |||
434 | static int dwc3_omap_resume(struct device *dev) | ||
435 | { | ||
436 | struct dwc3_omap *omap = dev_get_drvdata(dev); | ||
437 | |||
438 | dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS, | ||
439 | omap->utmi_otg_status); | ||
440 | |||
441 | pm_runtime_disable(dev); | ||
442 | pm_runtime_set_active(dev); | ||
443 | pm_runtime_enable(dev); | ||
444 | |||
445 | return 0; | ||
446 | } | ||
447 | |||
448 | static const struct dev_pm_ops dwc3_omap_dev_pm_ops = { | ||
449 | .prepare = dwc3_omap_prepare, | ||
450 | .complete = dwc3_omap_complete, | ||
451 | |||
452 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_omap_suspend, dwc3_omap_resume) | ||
453 | }; | ||
454 | |||
455 | #define DEV_PM_OPS (&dwc3_omap_dev_pm_ops) | ||
456 | #else | ||
457 | #define DEV_PM_OPS NULL | ||
458 | #endif /* CONFIG_PM */ | ||
459 | |||
405 | static struct platform_driver dwc3_omap_driver = { | 460 | static struct platform_driver dwc3_omap_driver = { |
406 | .probe = dwc3_omap_probe, | 461 | .probe = dwc3_omap_probe, |
407 | .remove = dwc3_omap_remove, | 462 | .remove = dwc3_omap_remove, |
408 | .driver = { | 463 | .driver = { |
409 | .name = "omap-dwc3", | 464 | .name = "omap-dwc3", |
410 | .of_match_table = of_dwc3_match, | 465 | .of_match_table = of_dwc3_match, |
466 | .pm = DEV_PM_OPS, | ||
411 | }, | 467 | }, |
412 | }; | 468 | }; |
413 | 469 | ||