ARM: 6672/1: LPAE: use phys_addr_t instead of unsigned long in mapping functions
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-omap1 / pm_bus.c
blob8b66392be745f5ef7fb3dae31daf99f0895a3960
1 /*
2 * Runtime PM support code for OMAP1
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>
18 #include <linux/clk.h>
19 #include <linux/err.h>
21 #include <plat/omap_device.h>
22 #include <plat/omap-pm.h>
24 #ifdef CONFIG_PM_RUNTIME
25 static int omap1_pm_runtime_suspend(struct device *dev)
27 struct clk *iclk, *fclk;
28 int ret = 0;
30 dev_dbg(dev, "%s\n", __func__);
32 ret = pm_generic_runtime_suspend(dev);
34 fclk = clk_get(dev, "fck");
35 if (!IS_ERR(fclk)) {
36 clk_disable(fclk);
37 clk_put(fclk);
40 iclk = clk_get(dev, "ick");
41 if (!IS_ERR(iclk)) {
42 clk_disable(iclk);
43 clk_put(iclk);
46 return 0;
49 static int omap1_pm_runtime_resume(struct device *dev)
51 int ret = 0;
52 struct clk *iclk, *fclk;
54 dev_dbg(dev, "%s\n", __func__);
56 iclk = clk_get(dev, "ick");
57 if (!IS_ERR(iclk)) {
58 clk_enable(iclk);
59 clk_put(iclk);
62 fclk = clk_get(dev, "fck");
63 if (!IS_ERR(fclk)) {
64 clk_enable(fclk);
65 clk_put(fclk);
68 return pm_generic_runtime_resume(dev);
71 static int __init omap1_pm_runtime_init(void)
73 const struct dev_pm_ops *pm;
74 struct dev_pm_ops *omap_pm;
76 pm = platform_bus_get_pm_ops();
77 if (!pm) {
78 pr_err("%s: unable to get dev_pm_ops from platform_bus\n",
79 __func__);
80 return -ENODEV;
83 omap_pm = kmemdup(pm, sizeof(struct dev_pm_ops), GFP_KERNEL);
84 if (!omap_pm) {
85 pr_err("%s: unable to alloc memory for new dev_pm_ops\n",
86 __func__);
87 return -ENOMEM;
90 omap_pm->runtime_suspend = omap1_pm_runtime_suspend;
91 omap_pm->runtime_resume = omap1_pm_runtime_resume;
93 platform_bus_set_pm_ops(omap_pm);
95 return 0;
97 core_initcall(omap1_pm_runtime_init);
98 #endif /* CONFIG_PM_RUNTIME */