2 * Runtime PM support code for OMAP
4 * Author: Kevin Hilman, Deep Root Systems, LLC
6 * Copyright (C) 2010 Texas Instruments, Inc.
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
12 #include <linux/init.h>
13 #include <linux/kernel.h>
15 #include <linux/pm_runtime.h>
16 #include <linux/platform_device.h>
17 #include <linux/mutex.h>
19 #include <plat/omap_device.h>
20 #include <plat/omap-pm.h>
22 #ifdef CONFIG_PM_RUNTIME
23 static int omap_pm_runtime_suspend(struct device
*dev
)
25 struct platform_device
*pdev
= to_platform_device(dev
);
28 dev_dbg(dev
, "%s\n", __func__
);
30 ret
= pm_generic_runtime_suspend(dev
);
32 if (!ret
&& dev
->parent
== &omap_device_parent
) {
33 r
= omap_device_idle(pdev
);
40 static int omap_pm_runtime_resume(struct device
*dev
)
42 struct platform_device
*pdev
= to_platform_device(dev
);
45 dev_dbg(dev
, "%s\n", __func__
);
47 if (dev
->parent
== &omap_device_parent
) {
48 r
= omap_device_enable(pdev
);
52 return pm_generic_runtime_resume(dev
);
55 #define omap_pm_runtime_suspend NULL
56 #define omap_pm_runtime_resume NULL
57 #endif /* CONFIG_PM_RUNTIME */
59 static int __init
omap_pm_runtime_init(void)
61 const struct dev_pm_ops
*pm
;
62 struct dev_pm_ops
*omap_pm
;
64 pm
= platform_bus_get_pm_ops();
66 pr_err("%s: unable to get dev_pm_ops from platform_bus\n",
71 omap_pm
= kmemdup(pm
, sizeof(struct dev_pm_ops
), GFP_KERNEL
);
73 pr_err("%s: unable to alloc memory for new dev_pm_ops\n",
78 omap_pm
->runtime_suspend
= omap_pm_runtime_suspend
;
79 omap_pm
->runtime_resume
= omap_pm_runtime_resume
;
81 platform_bus_set_pm_ops(omap_pm
);
85 core_initcall(omap_pm_runtime_init
);