diff options
author | Tony Lindgren <tony@atomide.com> | 2010-09-23 20:29:36 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2010-09-23 20:29:36 -0400 |
commit | 39cdd14570e3c32728d407cb38de17e80cf16104 (patch) | |
tree | 7e0f3473e186d84aa8110f39075381e07fead5d2 /arch/arm | |
parent | 172c11351576cf5daa8f1b02a265bf84de8bbed1 (diff) | |
parent | e933ec7c4ebd7e7daaad67b22e5f4a9a0ab102ea (diff) |
Merge branch 'pm-runtime' of ssh://master.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm into omap-for-linus
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-omap1/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap1/pm_bus.c | 98 | ||||
-rw-r--r-- | arch/arm/mach-omap2/Makefile | 10 | ||||
-rw-r--r-- | arch/arm/mach-omap2/pm_bus.c | 85 |
4 files changed, 191 insertions, 4 deletions
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile index facfaeb1ae5c..9a304d854e33 100644 --- a/arch/arm/mach-omap1/Makefile +++ b/arch/arm/mach-omap1/Makefile | |||
@@ -12,7 +12,7 @@ obj-$(CONFIG_OMAP_MPU_TIMER) += time.o | |||
12 | obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o | 12 | obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o |
13 | 13 | ||
14 | # Power Management | 14 | # Power Management |
15 | obj-$(CONFIG_PM) += pm.o sleep.o | 15 | obj-$(CONFIG_PM) += pm.o sleep.o pm_bus.o |
16 | 16 | ||
17 | # DSP | 17 | # DSP |
18 | obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o | 18 | obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o |
diff --git a/arch/arm/mach-omap1/pm_bus.c b/arch/arm/mach-omap1/pm_bus.c new file mode 100644 index 000000000000..8b66392be745 --- /dev/null +++ b/arch/arm/mach-omap1/pm_bus.c | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
2 | * Runtime PM support code for OMAP1 | ||
3 | * | ||
4 | * Author: Kevin Hilman, Deep Root Systems, LLC | ||
5 | * | ||
6 | * Copyright (C) 2010 Texas Instruments, Inc. | ||
7 | * | ||
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. | ||
11 | */ | ||
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> | ||
20 | |||
21 | #include <plat/omap_device.h> | ||
22 | #include <plat/omap-pm.h> | ||
23 | |||
24 | #ifdef CONFIG_PM_RUNTIME | ||
25 | static int omap1_pm_runtime_suspend(struct device *dev) | ||
26 | { | ||
27 | struct clk *iclk, *fclk; | ||
28 | int ret = 0; | ||
29 | |||
30 | dev_dbg(dev, "%s\n", __func__); | ||
31 | |||
32 | ret = pm_generic_runtime_suspend(dev); | ||
33 | |||
34 | fclk = clk_get(dev, "fck"); | ||
35 | if (!IS_ERR(fclk)) { | ||
36 | clk_disable(fclk); | ||
37 | clk_put(fclk); | ||
38 | } | ||
39 | |||
40 | iclk = clk_get(dev, "ick"); | ||
41 | if (!IS_ERR(iclk)) { | ||
42 | clk_disable(iclk); | ||
43 | clk_put(iclk); | ||
44 | } | ||
45 | |||
46 | return 0; | ||
47 | }; | ||
48 | |||
49 | static int omap1_pm_runtime_resume(struct device *dev) | ||
50 | { | ||
51 | int ret = 0; | ||
52 | struct clk *iclk, *fclk; | ||
53 | |||
54 | dev_dbg(dev, "%s\n", __func__); | ||
55 | |||
56 | iclk = clk_get(dev, "ick"); | ||
57 | if (!IS_ERR(iclk)) { | ||
58 | clk_enable(iclk); | ||
59 | clk_put(iclk); | ||
60 | } | ||
61 | |||
62 | fclk = clk_get(dev, "fck"); | ||
63 | if (!IS_ERR(fclk)) { | ||
64 | clk_enable(fclk); | ||
65 | clk_put(fclk); | ||
66 | } | ||
67 | |||
68 | return pm_generic_runtime_resume(dev); | ||
69 | }; | ||
70 | |||
71 | static int __init omap1_pm_runtime_init(void) | ||
72 | { | ||
73 | const struct dev_pm_ops *pm; | ||
74 | struct dev_pm_ops *omap_pm; | ||
75 | |||
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; | ||
81 | } | ||
82 | |||
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; | ||
88 | } | ||
89 | |||
90 | omap_pm->runtime_suspend = omap1_pm_runtime_suspend; | ||
91 | omap_pm->runtime_resume = omap1_pm_runtime_resume; | ||
92 | |||
93 | platform_bus_set_pm_ops(omap_pm); | ||
94 | |||
95 | return 0; | ||
96 | } | ||
97 | core_initcall(omap1_pm_runtime_init); | ||
98 | #endif /* CONFIG_PM_RUNTIME */ | ||
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index 826cb0980054..e599ae2a5de4 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile | |||
@@ -49,14 +49,18 @@ obj-$(CONFIG_ARCH_OMAP2) += sdrc2xxx.o | |||
49 | # Power Management | 49 | # Power Management |
50 | ifeq ($(CONFIG_PM),y) | 50 | ifeq ($(CONFIG_PM),y) |
51 | obj-$(CONFIG_ARCH_OMAP2) += pm24xx.o | 51 | obj-$(CONFIG_ARCH_OMAP2) += pm24xx.o |
52 | obj-$(CONFIG_ARCH_OMAP2) += sleep24xx.o | 52 | obj-$(CONFIG_ARCH_OMAP2) += sleep24xx.o pm_bus.o |
53 | obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o cpuidle34xx.o | 53 | obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o cpuidle34xx.o pm_bus.o |
54 | obj-$(CONFIG_ARCH_OMAP4) += pm44xx.o | 54 | obj-$(CONFIG_ARCH_OMAP4) += pm44xx.o pm_bus.o |
55 | obj-$(CONFIG_PM_DEBUG) += pm-debug.o | 55 | obj-$(CONFIG_PM_DEBUG) += pm-debug.o |
56 | 56 | ||
57 | AFLAGS_sleep24xx.o :=-Wa,-march=armv6 | 57 | AFLAGS_sleep24xx.o :=-Wa,-march=armv6 |
58 | AFLAGS_sleep34xx.o :=-Wa,-march=armv7-a | 58 | AFLAGS_sleep34xx.o :=-Wa,-march=armv7-a |
59 | 59 | ||
60 | ifeq ($(CONFIG_PM_VERBOSE),y) | ||
61 | CFLAGS_pm_bus.o += -DDEBUG | ||
62 | endif | ||
63 | |||
60 | endif | 64 | endif |
61 | 65 | ||
62 | # PRCM | 66 | # PRCM |
diff --git a/arch/arm/mach-omap2/pm_bus.c b/arch/arm/mach-omap2/pm_bus.c new file mode 100644 index 000000000000..784989f8f2f5 --- /dev/null +++ b/arch/arm/mach-omap2/pm_bus.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * Runtime PM support code for OMAP | ||
3 | * | ||
4 | * Author: Kevin Hilman, Deep Root Systems, LLC | ||
5 | * | ||
6 | * Copyright (C) 2010 Texas Instruments, Inc. | ||
7 | * | ||
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. | ||
11 | */ | ||
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 | |||
19 | #include <plat/omap_device.h> | ||
20 | #include <plat/omap-pm.h> | ||
21 | |||
22 | #ifdef CONFIG_PM_RUNTIME | ||
23 | int omap_pm_runtime_suspend(struct device *dev) | ||
24 | { | ||
25 | struct platform_device *pdev = to_platform_device(dev); | ||
26 | int r, ret = 0; | ||
27 | |||
28 | dev_dbg(dev, "%s\n", __func__); | ||
29 | |||
30 | ret = pm_generic_runtime_suspend(dev); | ||
31 | |||
32 | if (!ret && dev->parent == &omap_device_parent) { | ||
33 | r = omap_device_idle(pdev); | ||
34 | WARN_ON(r); | ||
35 | } | ||
36 | |||
37 | return ret; | ||
38 | }; | ||
39 | |||
40 | int omap_pm_runtime_resume(struct device *dev) | ||
41 | { | ||
42 | struct platform_device *pdev = to_platform_device(dev); | ||
43 | int r; | ||
44 | |||
45 | dev_dbg(dev, "%s\n", __func__); | ||
46 | |||
47 | if (dev->parent == &omap_device_parent) { | ||
48 | r = omap_device_enable(pdev); | ||
49 | WARN_ON(r); | ||
50 | } | ||
51 | |||
52 | return pm_generic_runtime_resume(dev); | ||
53 | }; | ||
54 | #else | ||
55 | #define omap_pm_runtime_suspend NULL | ||
56 | #define omap_pm_runtime_resume NULL | ||
57 | #endif /* CONFIG_PM_RUNTIME */ | ||
58 | |||
59 | static int __init omap_pm_runtime_init(void) | ||
60 | { | ||
61 | const struct dev_pm_ops *pm; | ||
62 | struct dev_pm_ops *omap_pm; | ||
63 | |||
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; | ||
69 | } | ||
70 | |||
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; | ||
76 | } | ||
77 | |||
78 | omap_pm->runtime_suspend = omap_pm_runtime_suspend; | ||
79 | omap_pm->runtime_resume = omap_pm_runtime_resume; | ||
80 | |||
81 | platform_bus_set_pm_ops(omap_pm); | ||
82 | |||
83 | return 0; | ||
84 | } | ||
85 | core_initcall(omap_pm_runtime_init); | ||