USB: Free bandwidth when usb_disable_device is called.
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-omap2 / pm_bus.c
blob5acd2ab298b107786bb57433f608f487884377b6
1 /*
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>
14 #include <linux/io.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);
26 int r, ret = 0;
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);
34 WARN_ON(r);
37 return ret;
40 static int omap_pm_runtime_resume(struct device *dev)
42 struct platform_device *pdev = to_platform_device(dev);
43 int r;
45 dev_dbg(dev, "%s\n", __func__);
47 if (dev->parent == &omap_device_parent) {
48 r = omap_device_enable(pdev);
49 WARN_ON(r);
52 return pm_generic_runtime_resume(dev);
54 #else
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();
65 if (!pm) {
66 pr_err("%s: unable to get dev_pm_ops from platform_bus\n",
67 __func__);
68 return -ENODEV;
71 omap_pm = kmemdup(pm, sizeof(struct dev_pm_ops), GFP_KERNEL);
72 if (!omap_pm) {
73 pr_err("%s: unable to alloc memory for new dev_pm_ops\n",
74 __func__);
75 return -ENOMEM;
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);
83 return 0;
85 core_initcall(omap_pm_runtime_init);