diff options
author | Paul Walmsley <paul@pwsan.com> | 2011-09-14 18:01:21 -0400 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2011-09-14 19:20:44 -0400 |
commit | 129c65ee66a97fbf663f2f5fce26aacdc7348736 (patch) | |
tree | 50c732a7a31d8443212d95a428515952c839592f /arch/arm/mach-omap2/powerdomain.c | |
parent | a5ffef6af127721a813d70f87cd8cc348ea9d6ab (diff) |
OMAP: powerdomain: split pwrdm_init() into two functions
In preparation for OMAP_CHIP() removal, split pwrdm_init() into three
functions. This allows some of them to be called multiple times: for
example, pwrdm_register_pwrdms() can be called once to register
powerdomains that are common to a group of SoCs, and once to register
powerdomains that are specific to a single SoC.
The appropriate order to call these functions - which is enforced
by the code - is:
1. pwrdm_register_platform_funcs()
2. pwrdm_register_pwrdms() (can be called multiple times)
3. pwrdm_complete_init()
Convert the OMAP2, 3, and 4 powerdomain init code to use these new
functions.
While here, improve documentation, and increase CodingStyle
conformance by shortening some local variable names.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm/mach-omap2/powerdomain.c')
-rw-r--r-- | arch/arm/mach-omap2/powerdomain.c | 84 |
1 files changed, 62 insertions, 22 deletions
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c index ef71fdd40fc4..3483537b7939 100644 --- a/arch/arm/mach-omap2/powerdomain.c +++ b/arch/arm/mach-omap2/powerdomain.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * OMAP powerdomain control | 2 | * OMAP powerdomain control |
3 | * | 3 | * |
4 | * Copyright (C) 2007-2008 Texas Instruments, Inc. | 4 | * Copyright (C) 2007-2008, 2011 Texas Instruments, Inc. |
5 | * Copyright (C) 2007-2011 Nokia Corporation | 5 | * Copyright (C) 2007-2011 Nokia Corporation |
6 | * | 6 | * |
7 | * Written by Paul Walmsley | 7 | * Written by Paul Walmsley |
@@ -194,36 +194,76 @@ static int _pwrdm_post_transition_cb(struct powerdomain *pwrdm, void *unused) | |||
194 | /* Public functions */ | 194 | /* Public functions */ |
195 | 195 | ||
196 | /** | 196 | /** |
197 | * pwrdm_init - set up the powerdomain layer | 197 | * pwrdm_register_platform_funcs - register powerdomain implementation fns |
198 | * @pwrdms: array of struct powerdomain pointers to register | 198 | * @po: func pointers for arch specific implementations |
199 | * @custom_funcs: func pointers for arch specific implementations | ||
200 | * | 199 | * |
201 | * Loop through the array of powerdomains @pwrdms, registering all | 200 | * Register the list of function pointers used to implement the |
202 | * that are available on the current CPU. Also, program all | 201 | * powerdomain functions on different OMAP SoCs. Should be called |
203 | * powerdomain target state as ON; this is to prevent domains from | 202 | * before any other pwrdm_register*() function. Returns -EINVAL if |
204 | * hitting low power states (if bootloader has target states set to | 203 | * @po is null, -EEXIST if platform functions have already been |
205 | * something other than ON) and potentially even losing context while | 204 | * registered, or 0 upon success. |
206 | * PM is not fully initialized. The PM late init code can then program | ||
207 | * the desired target state for all the power domains. No return | ||
208 | * value. | ||
209 | */ | 205 | */ |
210 | void pwrdm_init(struct powerdomain **pwrdms, struct pwrdm_ops *custom_funcs) | 206 | int pwrdm_register_platform_funcs(struct pwrdm_ops *po) |
207 | { | ||
208 | if (!po) | ||
209 | return -EINVAL; | ||
210 | |||
211 | if (arch_pwrdm) | ||
212 | return -EEXIST; | ||
213 | |||
214 | arch_pwrdm = po; | ||
215 | |||
216 | return 0; | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * pwrdm_register_pwrdms - register SoC powerdomains | ||
221 | * @ps: pointer to an array of struct powerdomain to register | ||
222 | * | ||
223 | * Register the powerdomains available on a particular OMAP SoC. Must | ||
224 | * be called after pwrdm_register_platform_funcs(). May be called | ||
225 | * multiple times. Returns -EACCES if called before | ||
226 | * pwrdm_register_platform_funcs(); -EINVAL if the argument @ps is | ||
227 | * null; or 0 upon success. | ||
228 | */ | ||
229 | int pwrdm_register_pwrdms(struct powerdomain **ps) | ||
211 | { | 230 | { |
212 | struct powerdomain **p = NULL; | 231 | struct powerdomain **p = NULL; |
213 | struct powerdomain *temp_p; | ||
214 | 232 | ||
215 | if (!custom_funcs) | 233 | if (!arch_pwrdm) |
216 | WARN(1, "powerdomain: No custom pwrdm functions registered\n"); | 234 | return -EEXIST; |
217 | else | ||
218 | arch_pwrdm = custom_funcs; | ||
219 | 235 | ||
220 | if (pwrdms) { | 236 | if (!ps) |
221 | for (p = pwrdms; *p; p++) | 237 | return -EINVAL; |
222 | _pwrdm_register(*p); | 238 | |
223 | } | 239 | for (p = ps; *p; p++) |
240 | _pwrdm_register(*p); | ||
241 | |||
242 | return 0; | ||
243 | } | ||
244 | |||
245 | /** | ||
246 | * pwrdm_complete_init - set up the powerdomain layer | ||
247 | * | ||
248 | * Do whatever is necessary to initialize registered powerdomains and | ||
249 | * powerdomain code. Currently, this programs the next power state | ||
250 | * for each powerdomain to ON. This prevents powerdomains from | ||
251 | * unexpectedly losing context or entering high wakeup latency modes | ||
252 | * with non-power-management-enabled kernels. Must be called after | ||
253 | * pwrdm_register_pwrdms(). Returns -EACCES if called before | ||
254 | * pwrdm_register_pwrdms(), or 0 upon success. | ||
255 | */ | ||
256 | int pwrdm_complete_init(void) | ||
257 | { | ||
258 | struct powerdomain *temp_p; | ||
259 | |||
260 | if (list_empty(&pwrdm_list)) | ||
261 | return -EACCES; | ||
224 | 262 | ||
225 | list_for_each_entry(temp_p, &pwrdm_list, node) | 263 | list_for_each_entry(temp_p, &pwrdm_list, node) |
226 | pwrdm_set_next_pwrst(temp_p, PWRDM_POWER_ON); | 264 | pwrdm_set_next_pwrst(temp_p, PWRDM_POWER_ON); |
265 | |||
266 | return 0; | ||
227 | } | 267 | } |
228 | 268 | ||
229 | /** | 269 | /** |