Adds suspend and resume callbacks to exynos dwc3 driver as part of
power management support.
This change does gating of dwc3 clock during suspend/resume cycles.

Signed-off-by: Abhilash Kesavan <a.kesa...@samsung.com>
Signed-off-by: Vikas C Sajjan <vikas.saj...@linaro.org>
CC: Doug Anderson <diand...@chromium.org>
---
 drivers/usb/dwc3/dwc3-exynos.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index ca65978..8623b70 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/pm_runtime.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/dwc3-exynos.h>
 #include <linux/dma-mapping.h>
@@ -200,11 +201,41 @@ static int __devexit dwc3_exynos_remove(struct 
platform_device *pdev)
        return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int dwc3_exynos_suspend(struct device *dev)
+{
+       struct dwc3_exynos *exynos = dev_get_drvdata(dev);
+
+       clk_disable(exynos->clk);
+
+       return 0;
+}
+
+static int dwc3_exynos_resume(struct device *dev)
+{
+       struct dwc3_exynos *exynos = dev_get_drvdata(dev);
+
+       clk_enable(exynos->clk);
+
+       /* runtime set active to reflect active state. */
+       pm_runtime_disable(dev);
+       pm_runtime_set_active(dev);
+       pm_runtime_enable(dev);
+
+       return 0;
+}
+#endif /* CONFIG_PM_SLEEP */
+
+static const struct dev_pm_ops dwc3_exynos_pm_ops = {
+       SET_SYSTEM_SLEEP_PM_OPS(dwc3_exynos_suspend, dwc3_exynos_resume)
+};
+
 static struct platform_driver dwc3_exynos_driver = {
        .probe          = dwc3_exynos_probe,
        .remove         = __devexit_p(dwc3_exynos_remove),
        .driver         = {
                .name   = "exynos-dwc3",
+               .pm     = &dwc3_exynos_pm_ops,
        },
 };
 
-- 
1.7.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to