Merge branch 'next/devel2' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/linux...
[pandora-kernel.git] / arch / arm / plat-omap / omap_device.c
index be45147..b6b4097 100644 (file)
@@ -547,6 +547,7 @@ int omap_early_device_register(struct omap_device *od)
        return 0;
 }
 
+#ifdef CONFIG_PM_RUNTIME
 static int _od_runtime_suspend(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
@@ -573,13 +574,55 @@ static int _od_runtime_resume(struct device *dev)
 
        return pm_generic_runtime_resume(dev);
 }
+#endif
 
-static struct dev_power_domain omap_device_power_domain = {
+#ifdef CONFIG_SUSPEND
+static int _od_suspend_noirq(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct omap_device *od = to_omap_device(pdev);
+       int ret;
+
+       if (od->flags & OMAP_DEVICE_NO_IDLE_ON_SUSPEND)
+               return pm_generic_suspend_noirq(dev);
+
+       ret = pm_generic_suspend_noirq(dev);
+
+       if (!ret && !pm_runtime_status_suspended(dev)) {
+               if (pm_generic_runtime_suspend(dev) == 0) {
+                       omap_device_idle(pdev);
+                       od->flags |= OMAP_DEVICE_SUSPENDED;
+               }
+       }
+
+       return ret;
+}
+
+static int _od_resume_noirq(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct omap_device *od = to_omap_device(pdev);
+
+       if (od->flags & OMAP_DEVICE_NO_IDLE_ON_SUSPEND)
+               return pm_generic_resume_noirq(dev);
+
+       if ((od->flags & OMAP_DEVICE_SUSPENDED) &&
+           !pm_runtime_status_suspended(dev)) {
+               od->flags &= ~OMAP_DEVICE_SUSPENDED;
+               omap_device_enable(pdev);
+               pm_generic_runtime_resume(dev);
+       }
+
+       return pm_generic_resume_noirq(dev);
+}
+#endif
+
+static struct dev_pm_domain omap_device_pm_domain = {
        .ops = {
-               .runtime_suspend = _od_runtime_suspend,
-               .runtime_idle = _od_runtime_idle,
-               .runtime_resume = _od_runtime_resume,
+               SET_RUNTIME_PM_OPS(_od_runtime_suspend, _od_runtime_resume,
+                                  _od_runtime_idle)
                USE_PLATFORM_PM_SLEEP_OPS
+               SET_SYSTEM_SLEEP_PM_OPS(_od_suspend_noirq, _od_resume_noirq)
        }
 };
 
@@ -596,7 +639,7 @@ int omap_device_register(struct omap_device *od)
        pr_debug("omap_device: %s: registering\n", od->pdev.name);
 
        od->pdev.dev.parent = &omap_device_parent;
-       od->pdev.dev.pwr_domain = &omap_device_power_domain;
+       od->pdev.dev.pm_domain = &omap_device_pm_domain;
        return platform_device_register(&od->pdev);
 }