diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-05-17 17:23:46 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-05-17 17:23:46 -0400 |
commit | 290c748725c170ed9a02522959ae67f528eefe98 (patch) | |
tree | a920190b75c7e054af24d850e79cc54f5cf53263 /arch/arm | |
parent | 2d2a9163bd4f3ba301f8138c32e4790edc30156c (diff) | |
parent | 72874daa5e9064c4e8d689e6a04b1e96f687f872 (diff) |
Merge branch 'power-domains' into for-linus
* power-domains:
PM: Fix build issue in clock_ops.c for CONFIG_PM_RUNTIME unset
PM: Revert "driver core: platform_bus: allow runtime override of dev_pm_ops"
OMAP1 / PM: Use generic clock manipulation routines for runtime PM
PM / Runtime: Generic clock manipulation rountines for runtime PM (v6)
PM / Runtime: Add subsystem data field to struct dev_pm_info
OMAP2+ / PM: move runtime PM implementation to use device power domains
PM / Platform: Use generic runtime PM callbacks directly
shmobile: Use power domains for platform runtime PM
PM: Export platform bus type's default PM callbacks
PM: Make power domain callbacks take precedence over subsystem ones
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-omap1/pm_bus.c | 69 | ||||
-rw-r--r-- | arch/arm/mach-omap2/Makefile | 6 | ||||
-rw-r--r-- | arch/arm/mach-omap2/pm_bus.c | 85 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/pm_runtime.c | 145 | ||||
-rw-r--r-- | arch/arm/plat-omap/omap_device.c | 23 |
5 files changed, 65 insertions, 263 deletions
diff --git a/arch/arm/mach-omap1/pm_bus.c b/arch/arm/mach-omap1/pm_bus.c index 6588c22b8a64..fe31d933f0ed 100644 --- a/arch/arm/mach-omap1/pm_bus.c +++ b/arch/arm/mach-omap1/pm_bus.c | |||
@@ -24,75 +24,50 @@ | |||
24 | #ifdef CONFIG_PM_RUNTIME | 24 | #ifdef CONFIG_PM_RUNTIME |
25 | static int omap1_pm_runtime_suspend(struct device *dev) | 25 | static int omap1_pm_runtime_suspend(struct device *dev) |
26 | { | 26 | { |
27 | struct clk *iclk, *fclk; | 27 | int ret; |
28 | int ret = 0; | ||
29 | 28 | ||
30 | dev_dbg(dev, "%s\n", __func__); | 29 | dev_dbg(dev, "%s\n", __func__); |
31 | 30 | ||
32 | ret = pm_generic_runtime_suspend(dev); | 31 | ret = pm_generic_runtime_suspend(dev); |
32 | if (ret) | ||
33 | return ret; | ||
33 | 34 | ||
34 | fclk = clk_get(dev, "fck"); | 35 | ret = pm_runtime_clk_suspend(dev); |
35 | if (!IS_ERR(fclk)) { | 36 | if (ret) { |
36 | clk_disable(fclk); | 37 | pm_generic_runtime_resume(dev); |
37 | clk_put(fclk); | 38 | return ret; |
38 | } | ||
39 | |||
40 | iclk = clk_get(dev, "ick"); | ||
41 | if (!IS_ERR(iclk)) { | ||
42 | clk_disable(iclk); | ||
43 | clk_put(iclk); | ||
44 | } | 39 | } |
45 | 40 | ||
46 | return 0; | 41 | return 0; |
47 | }; | 42 | } |
48 | 43 | ||
49 | static int omap1_pm_runtime_resume(struct device *dev) | 44 | static int omap1_pm_runtime_resume(struct device *dev) |
50 | { | 45 | { |
51 | struct clk *iclk, *fclk; | ||
52 | |||
53 | dev_dbg(dev, "%s\n", __func__); | 46 | dev_dbg(dev, "%s\n", __func__); |
54 | 47 | ||
55 | iclk = clk_get(dev, "ick"); | 48 | pm_runtime_clk_resume(dev); |
56 | if (!IS_ERR(iclk)) { | 49 | return pm_generic_runtime_resume(dev); |
57 | clk_enable(iclk); | 50 | } |
58 | clk_put(iclk); | ||
59 | } | ||
60 | 51 | ||
61 | fclk = clk_get(dev, "fck"); | 52 | static struct dev_power_domain default_power_domain = { |
62 | if (!IS_ERR(fclk)) { | 53 | .ops = { |
63 | clk_enable(fclk); | 54 | .runtime_suspend = omap1_pm_runtime_suspend, |
64 | clk_put(fclk); | 55 | .runtime_resume = omap1_pm_runtime_resume, |
65 | } | 56 | USE_PLATFORM_PM_SLEEP_OPS |
57 | }, | ||
58 | }; | ||
66 | 59 | ||
67 | return pm_generic_runtime_resume(dev); | 60 | static struct pm_clk_notifier_block platform_bus_notifier = { |
61 | .pwr_domain = &default_power_domain, | ||
62 | .con_ids = { "ick", "fck", NULL, }, | ||
68 | }; | 63 | }; |
69 | 64 | ||
70 | static int __init omap1_pm_runtime_init(void) | 65 | static int __init omap1_pm_runtime_init(void) |
71 | { | 66 | { |
72 | const struct dev_pm_ops *pm; | ||
73 | struct dev_pm_ops *omap_pm; | ||
74 | |||
75 | if (!cpu_class_is_omap1()) | 67 | if (!cpu_class_is_omap1()) |
76 | return -ENODEV; | 68 | return -ENODEV; |
77 | 69 | ||
78 | pm = platform_bus_get_pm_ops(); | 70 | pm_runtime_clk_add_notifier(&platform_bus_type, &platform_bus_notifier); |
79 | if (!pm) { | ||
80 | pr_err("%s: unable to get dev_pm_ops from platform_bus\n", | ||
81 | __func__); | ||
82 | return -ENODEV; | ||
83 | } | ||
84 | |||
85 | omap_pm = kmemdup(pm, sizeof(struct dev_pm_ops), GFP_KERNEL); | ||
86 | if (!omap_pm) { | ||
87 | pr_err("%s: unable to alloc memory for new dev_pm_ops\n", | ||
88 | __func__); | ||
89 | return -ENOMEM; | ||
90 | } | ||
91 | |||
92 | omap_pm->runtime_suspend = omap1_pm_runtime_suspend; | ||
93 | omap_pm->runtime_resume = omap1_pm_runtime_resume; | ||
94 | |||
95 | platform_bus_set_pm_ops(omap_pm); | ||
96 | 71 | ||
97 | return 0; | 72 | return 0; |
98 | } | 73 | } |
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index 512b15204450..66dfbccacd25 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile | |||
@@ -59,10 +59,10 @@ endif | |||
59 | # Power Management | 59 | # Power Management |
60 | ifeq ($(CONFIG_PM),y) | 60 | ifeq ($(CONFIG_PM),y) |
61 | obj-$(CONFIG_ARCH_OMAP2) += pm24xx.o | 61 | obj-$(CONFIG_ARCH_OMAP2) += pm24xx.o |
62 | obj-$(CONFIG_ARCH_OMAP2) += sleep24xx.o pm_bus.o | 62 | obj-$(CONFIG_ARCH_OMAP2) += sleep24xx.o |
63 | obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o \ | 63 | obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o \ |
64 | cpuidle34xx.o pm_bus.o | 64 | cpuidle34xx.o |
65 | obj-$(CONFIG_ARCH_OMAP4) += pm44xx.o pm_bus.o | 65 | obj-$(CONFIG_ARCH_OMAP4) += pm44xx.o |
66 | obj-$(CONFIG_PM_DEBUG) += pm-debug.o | 66 | obj-$(CONFIG_PM_DEBUG) += pm-debug.o |
67 | obj-$(CONFIG_OMAP_SMARTREFLEX) += sr_device.o smartreflex.o | 67 | obj-$(CONFIG_OMAP_SMARTREFLEX) += sr_device.o smartreflex.o |
68 | obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS3) += smartreflex-class3.o | 68 | obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS3) += smartreflex-class3.o |
diff --git a/arch/arm/mach-omap2/pm_bus.c b/arch/arm/mach-omap2/pm_bus.c deleted file mode 100644 index 5acd2ab298b1..000000000000 --- a/arch/arm/mach-omap2/pm_bus.c +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
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 | static 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 | static 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); | ||
diff --git a/arch/arm/mach-shmobile/pm_runtime.c b/arch/arm/mach-shmobile/pm_runtime.c index 94912d3944d3..2d1b67a59e4a 100644 --- a/arch/arm/mach-shmobile/pm_runtime.c +++ b/arch/arm/mach-shmobile/pm_runtime.c | |||
@@ -18,152 +18,41 @@ | |||
18 | #include <linux/clk.h> | 18 | #include <linux/clk.h> |
19 | #include <linux/sh_clk.h> | 19 | #include <linux/sh_clk.h> |
20 | #include <linux/bitmap.h> | 20 | #include <linux/bitmap.h> |
21 | #include <linux/slab.h> | ||
21 | 22 | ||
22 | #ifdef CONFIG_PM_RUNTIME | 23 | #ifdef CONFIG_PM_RUNTIME |
23 | #define BIT_ONCE 0 | ||
24 | #define BIT_ACTIVE 1 | ||
25 | #define BIT_CLK_ENABLED 2 | ||
26 | 24 | ||
27 | struct pm_runtime_data { | 25 | static int default_platform_runtime_idle(struct device *dev) |
28 | unsigned long flags; | ||
29 | struct clk *clk; | ||
30 | }; | ||
31 | |||
32 | static void __devres_release(struct device *dev, void *res) | ||
33 | { | ||
34 | struct pm_runtime_data *prd = res; | ||
35 | |||
36 | dev_dbg(dev, "__devres_release()\n"); | ||
37 | |||
38 | if (test_bit(BIT_CLK_ENABLED, &prd->flags)) | ||
39 | clk_disable(prd->clk); | ||
40 | |||
41 | if (test_bit(BIT_ACTIVE, &prd->flags)) | ||
42 | clk_put(prd->clk); | ||
43 | } | ||
44 | |||
45 | static struct pm_runtime_data *__to_prd(struct device *dev) | ||
46 | { | ||
47 | return devres_find(dev, __devres_release, NULL, NULL); | ||
48 | } | ||
49 | |||
50 | static void platform_pm_runtime_init(struct device *dev, | ||
51 | struct pm_runtime_data *prd) | ||
52 | { | ||
53 | if (prd && !test_and_set_bit(BIT_ONCE, &prd->flags)) { | ||
54 | prd->clk = clk_get(dev, NULL); | ||
55 | if (!IS_ERR(prd->clk)) { | ||
56 | set_bit(BIT_ACTIVE, &prd->flags); | ||
57 | dev_info(dev, "clocks managed by runtime pm\n"); | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | |||
62 | static void platform_pm_runtime_bug(struct device *dev, | ||
63 | struct pm_runtime_data *prd) | ||
64 | { | ||
65 | if (prd && !test_and_set_bit(BIT_ONCE, &prd->flags)) | ||
66 | dev_err(dev, "runtime pm suspend before resume\n"); | ||
67 | } | ||
68 | |||
69 | int platform_pm_runtime_suspend(struct device *dev) | ||
70 | { | ||
71 | struct pm_runtime_data *prd = __to_prd(dev); | ||
72 | |||
73 | dev_dbg(dev, "platform_pm_runtime_suspend()\n"); | ||
74 | |||
75 | platform_pm_runtime_bug(dev, prd); | ||
76 | |||
77 | if (prd && test_bit(BIT_ACTIVE, &prd->flags)) { | ||
78 | clk_disable(prd->clk); | ||
79 | clear_bit(BIT_CLK_ENABLED, &prd->flags); | ||
80 | } | ||
81 | |||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | int platform_pm_runtime_resume(struct device *dev) | ||
86 | { | ||
87 | struct pm_runtime_data *prd = __to_prd(dev); | ||
88 | |||
89 | dev_dbg(dev, "platform_pm_runtime_resume()\n"); | ||
90 | |||
91 | platform_pm_runtime_init(dev, prd); | ||
92 | |||
93 | if (prd && test_bit(BIT_ACTIVE, &prd->flags)) { | ||
94 | clk_enable(prd->clk); | ||
95 | set_bit(BIT_CLK_ENABLED, &prd->flags); | ||
96 | } | ||
97 | |||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | int platform_pm_runtime_idle(struct device *dev) | ||
102 | { | 26 | { |
103 | /* suspend synchronously to disable clocks immediately */ | 27 | /* suspend synchronously to disable clocks immediately */ |
104 | return pm_runtime_suspend(dev); | 28 | return pm_runtime_suspend(dev); |
105 | } | 29 | } |
106 | 30 | ||
107 | static int platform_bus_notify(struct notifier_block *nb, | 31 | static struct dev_power_domain default_power_domain = { |
108 | unsigned long action, void *data) | 32 | .ops = { |
109 | { | 33 | .runtime_suspend = pm_runtime_clk_suspend, |
110 | struct device *dev = data; | 34 | .runtime_resume = pm_runtime_clk_resume, |
111 | struct pm_runtime_data *prd; | 35 | .runtime_idle = default_platform_runtime_idle, |
112 | 36 | USE_PLATFORM_PM_SLEEP_OPS | |
113 | dev_dbg(dev, "platform_bus_notify() %ld !\n", action); | 37 | }, |
114 | 38 | }; | |
115 | if (action == BUS_NOTIFY_BIND_DRIVER) { | ||
116 | prd = devres_alloc(__devres_release, sizeof(*prd), GFP_KERNEL); | ||
117 | if (prd) | ||
118 | devres_add(dev, prd); | ||
119 | else | ||
120 | dev_err(dev, "unable to alloc memory for runtime pm\n"); | ||
121 | } | ||
122 | |||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | #else /* CONFIG_PM_RUNTIME */ | ||
127 | |||
128 | static int platform_bus_notify(struct notifier_block *nb, | ||
129 | unsigned long action, void *data) | ||
130 | { | ||
131 | struct device *dev = data; | ||
132 | struct clk *clk; | ||
133 | 39 | ||
134 | dev_dbg(dev, "platform_bus_notify() %ld !\n", action); | 40 | #define DEFAULT_PWR_DOMAIN_PTR (&default_power_domain) |
135 | 41 | ||
136 | switch (action) { | 42 | #else |
137 | case BUS_NOTIFY_BIND_DRIVER: | ||
138 | clk = clk_get(dev, NULL); | ||
139 | if (!IS_ERR(clk)) { | ||
140 | clk_enable(clk); | ||
141 | clk_put(clk); | ||
142 | dev_info(dev, "runtime pm disabled, clock forced on\n"); | ||
143 | } | ||
144 | break; | ||
145 | case BUS_NOTIFY_UNBOUND_DRIVER: | ||
146 | clk = clk_get(dev, NULL); | ||
147 | if (!IS_ERR(clk)) { | ||
148 | clk_disable(clk); | ||
149 | clk_put(clk); | ||
150 | dev_info(dev, "runtime pm disabled, clock forced off\n"); | ||
151 | } | ||
152 | break; | ||
153 | } | ||
154 | 43 | ||
155 | return 0; | 44 | #define DEFAULT_PWR_DOMAIN_PTR NULL |
156 | } | ||
157 | 45 | ||
158 | #endif /* CONFIG_PM_RUNTIME */ | 46 | #endif /* CONFIG_PM_RUNTIME */ |
159 | 47 | ||
160 | static struct notifier_block platform_bus_notifier = { | 48 | static struct pm_clk_notifier_block platform_bus_notifier = { |
161 | .notifier_call = platform_bus_notify | 49 | .pwr_domain = DEFAULT_PWR_DOMAIN_PTR, |
50 | .con_ids = { NULL, }, | ||
162 | }; | 51 | }; |
163 | 52 | ||
164 | static int __init sh_pm_runtime_init(void) | 53 | static int __init sh_pm_runtime_init(void) |
165 | { | 54 | { |
166 | bus_register_notifier(&platform_bus_type, &platform_bus_notifier); | 55 | pm_runtime_clk_add_notifier(&platform_bus_type, &platform_bus_notifier); |
167 | return 0; | 56 | return 0; |
168 | } | 57 | } |
169 | core_initcall(sh_pm_runtime_init); | 58 | core_initcall(sh_pm_runtime_init); |
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index 9bbda9acb73b..a37b8eb65b76 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c | |||
@@ -536,6 +536,28 @@ int omap_early_device_register(struct omap_device *od) | |||
536 | return 0; | 536 | return 0; |
537 | } | 537 | } |
538 | 538 | ||
539 | static int _od_runtime_suspend(struct device *dev) | ||
540 | { | ||
541 | struct platform_device *pdev = to_platform_device(dev); | ||
542 | |||
543 | return omap_device_idle(pdev); | ||
544 | } | ||
545 | |||
546 | static int _od_runtime_resume(struct device *dev) | ||
547 | { | ||
548 | struct platform_device *pdev = to_platform_device(dev); | ||
549 | |||
550 | return omap_device_enable(pdev); | ||
551 | } | ||
552 | |||
553 | static struct dev_power_domain omap_device_power_domain = { | ||
554 | .ops = { | ||
555 | .runtime_suspend = _od_runtime_suspend, | ||
556 | .runtime_resume = _od_runtime_resume, | ||
557 | USE_PLATFORM_PM_SLEEP_OPS | ||
558 | } | ||
559 | }; | ||
560 | |||
539 | /** | 561 | /** |
540 | * omap_device_register - register an omap_device with one omap_hwmod | 562 | * omap_device_register - register an omap_device with one omap_hwmod |
541 | * @od: struct omap_device * to register | 563 | * @od: struct omap_device * to register |
@@ -549,6 +571,7 @@ int omap_device_register(struct omap_device *od) | |||
549 | pr_debug("omap_device: %s: registering\n", od->pdev.name); | 571 | pr_debug("omap_device: %s: registering\n", od->pdev.name); |
550 | 572 | ||
551 | od->pdev.dev.parent = &omap_device_parent; | 573 | od->pdev.dev.parent = &omap_device_parent; |
574 | od->pdev.dev.pwr_domain = &omap_device_power_domain; | ||
552 | return platform_device_register(&od->pdev); | 575 | return platform_device_register(&od->pdev); |
553 | } | 576 | } |
554 | 577 | ||