blob: 620672135768f0b27c6863e2aaf89e4d45ec5441 [file] [log] [blame]
Paul Walmsleyad67ef62008-08-19 11:08:40 +03001/*
2 * OMAP powerdomain control
3 *
4 * Copyright (C) 2007-2008 Texas Instruments, Inc.
Paul Walmsley55ed9692010-01-26 20:12:59 -07005 * Copyright (C) 2007-2009 Nokia Corporation
Paul Walmsleyad67ef62008-08-19 11:08:40 +03006 *
7 * Written by Paul Walmsley
Abhijit Pagare3a759f02010-01-26 20:12:53 -07008 * Added OMAP4 specific support by Abhijit Pagare <abhijitpagare@ti.com>
Paul Walmsley4788da22010-05-18 20:24:05 -06009 * State counting code by Tero Kristo <tero.kristo@nokia.com>
Abhijit Pagare3a759f02010-01-26 20:12:53 -070010 *
Paul Walmsleyad67ef62008-08-19 11:08:40 +030011 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
Paul Walmsley33903eb2009-12-08 16:33:10 -070015#undef DEBUG
Paul Walmsleyad67ef62008-08-19 11:08:40 +030016
17#include <linux/kernel.h>
Paul Walmsleyad67ef62008-08-19 11:08:40 +030018#include <linux/types.h>
Paul Walmsleyad67ef62008-08-19 11:08:40 +030019#include <linux/list.h>
20#include <linux/errno.h>
Rajendra Nayak9b7fc902010-12-21 20:01:19 -070021#include <linux/string.h>
Paul Walmsleyad67ef62008-08-19 11:08:40 +030022
Tony Lindgrence491cf2009-10-20 09:40:47 -070023#include <plat/cpu.h>
24#include <plat/powerdomain.h>
25#include <plat/clockdomain.h>
Paul Walmsley55ed9692010-01-26 20:12:59 -070026#include <plat/prcm.h>
Paul Walmsleyad67ef62008-08-19 11:08:40 +030027
Peter 'p2' De Schrijver6199ab22008-10-15 18:13:49 +030028#include "pm.h"
29
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +030030enum {
31 PWRDM_STATE_NOW = 0,
32 PWRDM_STATE_PREV,
33};
34
Abhijit Pagare3a759f02010-01-26 20:12:53 -070035
Paul Walmsleyad67ef62008-08-19 11:08:40 +030036/* pwrdm_list contains all registered struct powerdomains */
37static LIST_HEAD(pwrdm_list);
38
Rajendra Nayak3b1e8b22010-12-21 20:01:18 -070039static struct pwrdm_ops *arch_pwrdm;
40
Paul Walmsleyad67ef62008-08-19 11:08:40 +030041/* Private functions */
42
Paul Walmsleyad67ef62008-08-19 11:08:40 +030043static struct powerdomain *_pwrdm_lookup(const char *name)
44{
45 struct powerdomain *pwrdm, *temp_pwrdm;
46
47 pwrdm = NULL;
48
49 list_for_each_entry(temp_pwrdm, &pwrdm_list, node) {
50 if (!strcmp(name, temp_pwrdm->name)) {
51 pwrdm = temp_pwrdm;
52 break;
53 }
54 }
55
56 return pwrdm;
57}
58
Paul Walmsleye909d62a82010-01-26 20:13:00 -070059/**
60 * _pwrdm_register - register a powerdomain
61 * @pwrdm: struct powerdomain * to register
62 *
63 * Adds a powerdomain to the internal powerdomain list. Returns
64 * -EINVAL if given a null pointer, -EEXIST if a powerdomain is
65 * already registered by the provided name, or 0 upon success.
66 */
67static int _pwrdm_register(struct powerdomain *pwrdm)
68{
69 int i;
70
71 if (!pwrdm)
72 return -EINVAL;
73
74 if (!omap_chip_is(pwrdm->omap_chip))
75 return -EINVAL;
76
77 if (_pwrdm_lookup(pwrdm->name))
78 return -EEXIST;
79
80 list_add(&pwrdm->node, &pwrdm_list);
81
82 /* Initialize the powerdomain's state counter */
Paul Walmsleycf57aa72010-01-26 20:13:01 -070083 for (i = 0; i < PWRDM_MAX_PWRSTS; i++)
Paul Walmsleye909d62a82010-01-26 20:13:00 -070084 pwrdm->state_counter[i] = 0;
85
Thara Gopinathcde08f82010-02-24 12:05:50 -070086 pwrdm->ret_logic_off_counter = 0;
87 for (i = 0; i < pwrdm->banks; i++)
88 pwrdm->ret_mem_off_counter[i] = 0;
89
Paul Walmsleye909d62a82010-01-26 20:13:00 -070090 pwrdm_wait_transition(pwrdm);
91 pwrdm->state = pwrdm_read_pwrst(pwrdm);
92 pwrdm->state_counter[pwrdm->state] = 1;
93
94 pr_debug("powerdomain: registered %s\n", pwrdm->name);
95
96 return 0;
97}
98
Thara Gopinathcde08f82010-02-24 12:05:50 -070099static void _update_logic_membank_counters(struct powerdomain *pwrdm)
100{
101 int i;
102 u8 prev_logic_pwrst, prev_mem_pwrst;
103
104 prev_logic_pwrst = pwrdm_read_prev_logic_pwrst(pwrdm);
105 if ((pwrdm->pwrsts_logic_ret == PWRSTS_OFF_RET) &&
106 (prev_logic_pwrst == PWRDM_POWER_OFF))
107 pwrdm->ret_logic_off_counter++;
108
109 for (i = 0; i < pwrdm->banks; i++) {
110 prev_mem_pwrst = pwrdm_read_prev_mem_pwrst(pwrdm, i);
111
112 if ((pwrdm->pwrsts_mem_ret[i] == PWRSTS_OFF_RET) &&
113 (prev_mem_pwrst == PWRDM_POWER_OFF))
114 pwrdm->ret_mem_off_counter[i]++;
115 }
116}
117
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300118static int _pwrdm_state_switch(struct powerdomain *pwrdm, int flag)
119{
120
121 int prev;
122 int state;
123
124 if (pwrdm == NULL)
125 return -EINVAL;
126
127 state = pwrdm_read_pwrst(pwrdm);
128
129 switch (flag) {
130 case PWRDM_STATE_NOW:
131 prev = pwrdm->state;
132 break;
133 case PWRDM_STATE_PREV:
134 prev = pwrdm_read_prev_pwrst(pwrdm);
135 if (pwrdm->state != prev)
136 pwrdm->state_counter[prev]++;
Thara Gopinathcde08f82010-02-24 12:05:50 -0700137 if (prev == PWRDM_POWER_RET)
138 _update_logic_membank_counters(pwrdm);
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300139 break;
140 default:
141 return -EINVAL;
142 }
143
144 if (state != prev)
145 pwrdm->state_counter[state]++;
146
Peter 'p2' De Schrijver6199ab22008-10-15 18:13:49 +0300147 pm_dbg_update_time(pwrdm, prev);
148
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300149 pwrdm->state = state;
150
151 return 0;
152}
153
Peter 'p2' De Schrijver6199ab22008-10-15 18:13:49 +0300154static int _pwrdm_pre_transition_cb(struct powerdomain *pwrdm, void *unused)
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300155{
156 pwrdm_clear_all_prev_pwrst(pwrdm);
157 _pwrdm_state_switch(pwrdm, PWRDM_STATE_NOW);
158 return 0;
159}
160
Peter 'p2' De Schrijver6199ab22008-10-15 18:13:49 +0300161static int _pwrdm_post_transition_cb(struct powerdomain *pwrdm, void *unused)
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300162{
163 _pwrdm_state_switch(pwrdm, PWRDM_STATE_PREV);
164 return 0;
165}
166
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300167/* Public functions */
168
169/**
170 * pwrdm_init - set up the powerdomain layer
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700171 * @pwrdm_list: array of struct powerdomain pointers to register
Rajendra Nayak3b1e8b22010-12-21 20:01:18 -0700172 * @custom_funcs: func pointers for arch specfic implementations
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300173 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700174 * Loop through the array of powerdomains @pwrdm_list, registering all
175 * that are available on the current CPU. If pwrdm_list is supplied
176 * and not null, all of the referenced powerdomains will be
177 * registered. No return value. XXX pwrdm_list is not really a
178 * "list"; it is an array. Rename appropriately.
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300179 */
Rajendra Nayak3b1e8b22010-12-21 20:01:18 -0700180void pwrdm_init(struct powerdomain **pwrdm_list, struct pwrdm_ops *custom_funcs)
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300181{
182 struct powerdomain **p = NULL;
183
Rajendra Nayak3b1e8b22010-12-21 20:01:18 -0700184 if (!custom_funcs)
185 WARN(1, "powerdomain: No custom pwrdm functions registered\n");
186 else
187 arch_pwrdm = custom_funcs;
188
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300189 if (pwrdm_list) {
Paul Walmsleye909d62a82010-01-26 20:13:00 -0700190 for (p = pwrdm_list; *p; p++)
191 _pwrdm_register(*p);
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300192 }
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300193}
194
195/**
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300196 * pwrdm_lookup - look up a powerdomain by name, return a pointer
197 * @name: name of powerdomain
198 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700199 * Find a registered powerdomain by its name @name. Returns a pointer
200 * to the struct powerdomain if found, or NULL otherwise.
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300201 */
202struct powerdomain *pwrdm_lookup(const char *name)
203{
204 struct powerdomain *pwrdm;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300205
206 if (!name)
207 return NULL;
208
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300209 pwrdm = _pwrdm_lookup(name);
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300210
211 return pwrdm;
212}
213
214/**
Paul Walmsleye909d62a82010-01-26 20:13:00 -0700215 * pwrdm_for_each - call function on each registered clockdomain
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300216 * @fn: callback function *
217 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700218 * Call the supplied function @fn for each registered powerdomain.
219 * The callback function @fn can return anything but 0 to bail out
220 * early from the iterator. Returns the last return value of the
221 * callback function, which should be 0 for success or anything else
222 * to indicate failure; or -EINVAL if the function pointer is null.
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300223 */
Paul Walmsleye909d62a82010-01-26 20:13:00 -0700224int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user),
225 void *user)
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300226{
227 struct powerdomain *temp_pwrdm;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300228 int ret = 0;
229
230 if (!fn)
231 return -EINVAL;
232
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300233 list_for_each_entry(temp_pwrdm, &pwrdm_list, node) {
Peter 'p2' De Schrijver6199ab22008-10-15 18:13:49 +0300234 ret = (*fn)(temp_pwrdm, user);
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300235 if (ret)
236 break;
237 }
Artem Bityutskiyee894b12009-10-01 10:01:55 +0300238
239 return ret;
240}
241
242/**
Paul Walmsley8420bb12008-08-19 11:08:44 +0300243 * pwrdm_add_clkdm - add a clockdomain to a powerdomain
244 * @pwrdm: struct powerdomain * to add the clockdomain to
245 * @clkdm: struct clockdomain * to associate with a powerdomain
246 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700247 * Associate the clockdomain @clkdm with a powerdomain @pwrdm. This
Paul Walmsley8420bb12008-08-19 11:08:44 +0300248 * enables the use of pwrdm_for_each_clkdm(). Returns -EINVAL if
249 * presented with invalid pointers; -ENOMEM if memory could not be allocated;
250 * or 0 upon success.
251 */
252int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm)
253{
Paul Walmsley8420bb12008-08-19 11:08:44 +0300254 int i;
255 int ret = -EINVAL;
256
257 if (!pwrdm || !clkdm)
258 return -EINVAL;
259
260 pr_debug("powerdomain: associating clockdomain %s with powerdomain "
261 "%s\n", clkdm->name, pwrdm->name);
262
Paul Walmsley8420bb12008-08-19 11:08:44 +0300263 for (i = 0; i < PWRDM_MAX_CLKDMS; i++) {
264 if (!pwrdm->pwrdm_clkdms[i])
265 break;
266#ifdef DEBUG
267 if (pwrdm->pwrdm_clkdms[i] == clkdm) {
268 ret = -EINVAL;
269 goto pac_exit;
270 }
271#endif
272 }
273
274 if (i == PWRDM_MAX_CLKDMS) {
275 pr_debug("powerdomain: increase PWRDM_MAX_CLKDMS for "
276 "pwrdm %s clkdm %s\n", pwrdm->name, clkdm->name);
277 WARN_ON(1);
278 ret = -ENOMEM;
279 goto pac_exit;
280 }
281
282 pwrdm->pwrdm_clkdms[i] = clkdm;
283
284 ret = 0;
285
286pac_exit:
Paul Walmsley8420bb12008-08-19 11:08:44 +0300287 return ret;
288}
289
290/**
291 * pwrdm_del_clkdm - remove a clockdomain from a powerdomain
292 * @pwrdm: struct powerdomain * to add the clockdomain to
293 * @clkdm: struct clockdomain * to associate with a powerdomain
294 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700295 * Dissociate the clockdomain @clkdm from the powerdomain
296 * @pwrdm. Returns -EINVAL if presented with invalid pointers; -ENOENT
297 * if @clkdm was not associated with the powerdomain, or 0 upon
298 * success.
Paul Walmsley8420bb12008-08-19 11:08:44 +0300299 */
300int pwrdm_del_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm)
301{
Paul Walmsley8420bb12008-08-19 11:08:44 +0300302 int ret = -EINVAL;
303 int i;
304
305 if (!pwrdm || !clkdm)
306 return -EINVAL;
307
308 pr_debug("powerdomain: dissociating clockdomain %s from powerdomain "
309 "%s\n", clkdm->name, pwrdm->name);
310
Paul Walmsley8420bb12008-08-19 11:08:44 +0300311 for (i = 0; i < PWRDM_MAX_CLKDMS; i++)
312 if (pwrdm->pwrdm_clkdms[i] == clkdm)
313 break;
314
315 if (i == PWRDM_MAX_CLKDMS) {
316 pr_debug("powerdomain: clkdm %s not associated with pwrdm "
317 "%s ?!\n", clkdm->name, pwrdm->name);
318 ret = -ENOENT;
319 goto pdc_exit;
320 }
321
322 pwrdm->pwrdm_clkdms[i] = NULL;
323
324 ret = 0;
325
326pdc_exit:
Paul Walmsley8420bb12008-08-19 11:08:44 +0300327 return ret;
328}
329
330/**
331 * pwrdm_for_each_clkdm - call function on each clkdm in a pwrdm
332 * @pwrdm: struct powerdomain * to iterate over
333 * @fn: callback function *
334 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700335 * Call the supplied function @fn for each clockdomain in the powerdomain
336 * @pwrdm. The callback function can return anything but 0 to bail
Paul Walmsleye909d62a82010-01-26 20:13:00 -0700337 * out early from the iterator. Returns -EINVAL if presented with
338 * invalid pointers; or passes along the last return value of the
339 * callback function, which should be 0 for success or anything else
340 * to indicate failure.
Paul Walmsley8420bb12008-08-19 11:08:44 +0300341 */
342int pwrdm_for_each_clkdm(struct powerdomain *pwrdm,
343 int (*fn)(struct powerdomain *pwrdm,
344 struct clockdomain *clkdm))
345{
Paul Walmsley8420bb12008-08-19 11:08:44 +0300346 int ret = 0;
347 int i;
348
349 if (!fn)
350 return -EINVAL;
351
Paul Walmsley8420bb12008-08-19 11:08:44 +0300352 for (i = 0; i < PWRDM_MAX_CLKDMS && !ret; i++)
353 ret = (*fn)(pwrdm, pwrdm->pwrdm_clkdms[i]);
354
Paul Walmsley8420bb12008-08-19 11:08:44 +0300355 return ret;
356}
357
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300358/**
359 * pwrdm_get_mem_bank_count - get number of memory banks in this powerdomain
360 * @pwrdm: struct powerdomain *
361 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700362 * Return the number of controllable memory banks in powerdomain @pwrdm,
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300363 * starting with 1. Returns -EINVAL if the powerdomain pointer is null.
364 */
365int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm)
366{
367 if (!pwrdm)
368 return -EINVAL;
369
370 return pwrdm->banks;
371}
372
373/**
374 * pwrdm_set_next_pwrst - set next powerdomain power state
375 * @pwrdm: struct powerdomain * to set
376 * @pwrst: one of the PWRDM_POWER_* macros
377 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700378 * Set the powerdomain @pwrdm's next power state to @pwrst. The powerdomain
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300379 * may not enter this state immediately if the preconditions for this state
380 * have not been satisfied. Returns -EINVAL if the powerdomain pointer is
381 * null or if the power state is invalid for the powerdomin, or returns 0
382 * upon success.
383 */
384int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst)
385{
Rajendra Nayakf327e072010-12-21 20:01:18 -0700386 int ret = -EINVAL;
387
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300388 if (!pwrdm)
389 return -EINVAL;
390
391 if (!(pwrdm->pwrsts & (1 << pwrst)))
392 return -EINVAL;
393
394 pr_debug("powerdomain: setting next powerstate for %s to %0x\n",
395 pwrdm->name, pwrst);
396
Rajendra Nayakf327e072010-12-21 20:01:18 -0700397 if (arch_pwrdm && arch_pwrdm->pwrdm_set_next_pwrst)
398 ret = arch_pwrdm->pwrdm_set_next_pwrst(pwrdm, pwrst);
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300399
Rajendra Nayakf327e072010-12-21 20:01:18 -0700400 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300401}
402
403/**
404 * pwrdm_read_next_pwrst - get next powerdomain power state
405 * @pwrdm: struct powerdomain * to get power state
406 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700407 * Return the powerdomain @pwrdm's next power state. Returns -EINVAL
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300408 * if the powerdomain pointer is null or returns the next power state
409 * upon success.
410 */
411int pwrdm_read_next_pwrst(struct powerdomain *pwrdm)
412{
Rajendra Nayakf327e072010-12-21 20:01:18 -0700413 int ret = -EINVAL;
414
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300415 if (!pwrdm)
416 return -EINVAL;
417
Rajendra Nayakf327e072010-12-21 20:01:18 -0700418 if (arch_pwrdm && arch_pwrdm->pwrdm_read_next_pwrst)
419 ret = arch_pwrdm->pwrdm_read_next_pwrst(pwrdm);
420
421 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300422}
423
424/**
425 * pwrdm_read_pwrst - get current powerdomain power state
426 * @pwrdm: struct powerdomain * to get power state
427 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700428 * Return the powerdomain @pwrdm's current power state. Returns -EINVAL
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300429 * if the powerdomain pointer is null or returns the current power state
430 * upon success.
431 */
432int pwrdm_read_pwrst(struct powerdomain *pwrdm)
433{
Rajendra Nayakf327e072010-12-21 20:01:18 -0700434 int ret = -EINVAL;
435
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300436 if (!pwrdm)
437 return -EINVAL;
438
Rajendra Nayakf327e072010-12-21 20:01:18 -0700439 if (arch_pwrdm && arch_pwrdm->pwrdm_read_pwrst)
440 ret = arch_pwrdm->pwrdm_read_pwrst(pwrdm);
441
442 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300443}
444
445/**
446 * pwrdm_read_prev_pwrst - get previous powerdomain power state
447 * @pwrdm: struct powerdomain * to get previous power state
448 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700449 * Return the powerdomain @pwrdm's previous power state. Returns -EINVAL
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300450 * if the powerdomain pointer is null or returns the previous power state
451 * upon success.
452 */
453int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm)
454{
Rajendra Nayakf327e072010-12-21 20:01:18 -0700455 int ret = -EINVAL;
456
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300457 if (!pwrdm)
458 return -EINVAL;
459
Rajendra Nayakf327e072010-12-21 20:01:18 -0700460 if (arch_pwrdm && arch_pwrdm->pwrdm_read_prev_pwrst)
461 ret = arch_pwrdm->pwrdm_read_prev_pwrst(pwrdm);
462
463 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300464}
465
466/**
467 * pwrdm_set_logic_retst - set powerdomain logic power state upon retention
468 * @pwrdm: struct powerdomain * to set
469 * @pwrst: one of the PWRDM_POWER_* macros
470 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700471 * Set the next power state @pwrst that the logic portion of the
472 * powerdomain @pwrdm will enter when the powerdomain enters retention.
473 * This will be either RETENTION or OFF, if supported. Returns
474 * -EINVAL if the powerdomain pointer is null or the target power
475 * state is not not supported, or returns 0 upon success.
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300476 */
477int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst)
478{
Rajendra Nayak12627572010-12-21 20:01:18 -0700479 int ret = -EINVAL;
Paul Walmsley2bc4ef72010-05-18 18:47:24 -0600480
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300481 if (!pwrdm)
482 return -EINVAL;
483
484 if (!(pwrdm->pwrsts_logic_ret & (1 << pwrst)))
485 return -EINVAL;
486
487 pr_debug("powerdomain: setting next logic powerstate for %s to %0x\n",
488 pwrdm->name, pwrst);
489
Rajendra Nayak12627572010-12-21 20:01:18 -0700490 if (arch_pwrdm && arch_pwrdm->pwrdm_set_logic_retst)
491 ret = arch_pwrdm->pwrdm_set_logic_retst(pwrdm, pwrst);
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300492
Rajendra Nayak12627572010-12-21 20:01:18 -0700493 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300494}
495
496/**
497 * pwrdm_set_mem_onst - set memory power state while powerdomain ON
498 * @pwrdm: struct powerdomain * to set
499 * @bank: memory bank number to set (0-3)
500 * @pwrst: one of the PWRDM_POWER_* macros
501 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700502 * Set the next power state @pwrst that memory bank @bank of the
503 * powerdomain @pwrdm will enter when the powerdomain enters the ON
504 * state. @bank will be a number from 0 to 3, and represents different
505 * types of memory, depending on the powerdomain. Returns -EINVAL if
506 * the powerdomain pointer is null or the target power state is not
507 * not supported for this memory bank, -EEXIST if the target memory
508 * bank does not exist or is not controllable, or returns 0 upon
509 * success.
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300510 */
511int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst)
512{
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700513 int ret = -EINVAL;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300514
515 if (!pwrdm)
516 return -EINVAL;
517
518 if (pwrdm->banks < (bank + 1))
519 return -EEXIST;
520
521 if (!(pwrdm->pwrsts_mem_on[bank] & (1 << pwrst)))
522 return -EINVAL;
523
524 pr_debug("powerdomain: setting next memory powerstate for domain %s "
525 "bank %0x while pwrdm-ON to %0x\n", pwrdm->name, bank, pwrst);
526
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700527 if (arch_pwrdm && arch_pwrdm->pwrdm_set_mem_onst)
528 ret = arch_pwrdm->pwrdm_set_mem_onst(pwrdm, bank, pwrst);
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300529
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700530 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300531}
532
533/**
534 * pwrdm_set_mem_retst - set memory power state while powerdomain in RET
535 * @pwrdm: struct powerdomain * to set
536 * @bank: memory bank number to set (0-3)
537 * @pwrst: one of the PWRDM_POWER_* macros
538 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700539 * Set the next power state @pwrst that memory bank @bank of the
540 * powerdomain @pwrdm will enter when the powerdomain enters the
541 * RETENTION state. Bank will be a number from 0 to 3, and represents
542 * different types of memory, depending on the powerdomain. @pwrst
543 * will be either RETENTION or OFF, if supported. Returns -EINVAL if
544 * the powerdomain pointer is null or the target power state is not
545 * not supported for this memory bank, -EEXIST if the target memory
546 * bank does not exist or is not controllable, or returns 0 upon
547 * success.
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300548 */
549int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst)
550{
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700551 int ret = -EINVAL;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300552
553 if (!pwrdm)
554 return -EINVAL;
555
556 if (pwrdm->banks < (bank + 1))
557 return -EEXIST;
558
559 if (!(pwrdm->pwrsts_mem_ret[bank] & (1 << pwrst)))
560 return -EINVAL;
561
562 pr_debug("powerdomain: setting next memory powerstate for domain %s "
563 "bank %0x while pwrdm-RET to %0x\n", pwrdm->name, bank, pwrst);
564
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700565 if (arch_pwrdm && arch_pwrdm->pwrdm_set_mem_retst)
566 ret = arch_pwrdm->pwrdm_set_mem_retst(pwrdm, bank, pwrst);
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300567
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700568 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300569}
570
571/**
572 * pwrdm_read_logic_pwrst - get current powerdomain logic retention power state
573 * @pwrdm: struct powerdomain * to get current logic retention power state
574 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700575 * Return the power state that the logic portion of powerdomain @pwrdm
576 * will enter when the powerdomain enters retention. Returns -EINVAL
577 * if the powerdomain pointer is null or returns the logic retention
578 * power state upon success.
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300579 */
580int pwrdm_read_logic_pwrst(struct powerdomain *pwrdm)
581{
Rajendra Nayak12627572010-12-21 20:01:18 -0700582 int ret = -EINVAL;
583
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300584 if (!pwrdm)
585 return -EINVAL;
586
Rajendra Nayak12627572010-12-21 20:01:18 -0700587 if (arch_pwrdm && arch_pwrdm->pwrdm_read_logic_pwrst)
588 ret = arch_pwrdm->pwrdm_read_logic_pwrst(pwrdm);
589
590 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300591}
592
593/**
594 * pwrdm_read_prev_logic_pwrst - get previous powerdomain logic power state
595 * @pwrdm: struct powerdomain * to get previous logic power state
596 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700597 * Return the powerdomain @pwrdm's previous logic power state. Returns
598 * -EINVAL if the powerdomain pointer is null or returns the previous
599 * logic power state upon success.
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300600 */
601int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm)
602{
Rajendra Nayak12627572010-12-21 20:01:18 -0700603 int ret = -EINVAL;
604
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300605 if (!pwrdm)
606 return -EINVAL;
607
Rajendra Nayak12627572010-12-21 20:01:18 -0700608 if (arch_pwrdm && arch_pwrdm->pwrdm_read_prev_logic_pwrst)
609 ret = arch_pwrdm->pwrdm_read_prev_logic_pwrst(pwrdm);
610
611 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300612}
613
614/**
Thara Gopinath1e3d0d22010-02-24 12:05:49 -0700615 * pwrdm_read_logic_retst - get next powerdomain logic power state
616 * @pwrdm: struct powerdomain * to get next logic power state
617 *
618 * Return the powerdomain pwrdm's logic power state. Returns -EINVAL
619 * if the powerdomain pointer is null or returns the next logic
620 * power state upon success.
621 */
622int pwrdm_read_logic_retst(struct powerdomain *pwrdm)
623{
Rajendra Nayak12627572010-12-21 20:01:18 -0700624 int ret = -EINVAL;
625
Thara Gopinath1e3d0d22010-02-24 12:05:49 -0700626 if (!pwrdm)
627 return -EINVAL;
628
Rajendra Nayak12627572010-12-21 20:01:18 -0700629 if (arch_pwrdm && arch_pwrdm->pwrdm_read_logic_retst)
630 ret = arch_pwrdm->pwrdm_read_logic_retst(pwrdm);
631
632 return ret;
Thara Gopinath1e3d0d22010-02-24 12:05:49 -0700633}
634
635/**
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300636 * pwrdm_read_mem_pwrst - get current memory bank power state
637 * @pwrdm: struct powerdomain * to get current memory bank power state
638 * @bank: memory bank number (0-3)
639 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700640 * Return the powerdomain @pwrdm's current memory power state for bank
641 * @bank. Returns -EINVAL if the powerdomain pointer is null, -EEXIST if
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300642 * the target memory bank does not exist or is not controllable, or
643 * returns the current memory power state upon success.
644 */
645int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank)
646{
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700647 int ret = -EINVAL;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300648
649 if (!pwrdm)
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700650 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300651
652 if (pwrdm->banks < (bank + 1))
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700653 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300654
Thara Gopinath3863c742009-12-08 16:33:15 -0700655 if (pwrdm->flags & PWRDM_HAS_MPU_QUIRK)
656 bank = 1;
657
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700658 if (arch_pwrdm && arch_pwrdm->pwrdm_read_mem_pwrst)
659 ret = arch_pwrdm->pwrdm_read_mem_pwrst(pwrdm, bank);
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300660
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700661 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300662}
663
664/**
665 * pwrdm_read_prev_mem_pwrst - get previous memory bank power state
666 * @pwrdm: struct powerdomain * to get previous memory bank power state
667 * @bank: memory bank number (0-3)
668 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700669 * Return the powerdomain @pwrdm's previous memory power state for
670 * bank @bank. Returns -EINVAL if the powerdomain pointer is null,
671 * -EEXIST if the target memory bank does not exist or is not
672 * controllable, or returns the previous memory power state upon
673 * success.
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300674 */
675int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank)
676{
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700677 int ret = -EINVAL;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300678
679 if (!pwrdm)
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700680 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300681
682 if (pwrdm->banks < (bank + 1))
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700683 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300684
Thara Gopinath3863c742009-12-08 16:33:15 -0700685 if (pwrdm->flags & PWRDM_HAS_MPU_QUIRK)
686 bank = 1;
687
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700688 if (arch_pwrdm && arch_pwrdm->pwrdm_read_prev_mem_pwrst)
689 ret = arch_pwrdm->pwrdm_read_prev_mem_pwrst(pwrdm, bank);
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300690
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700691 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300692}
693
694/**
Thara Gopinath1e3d0d22010-02-24 12:05:49 -0700695 * pwrdm_read_mem_retst - get next memory bank power state
696 * @pwrdm: struct powerdomain * to get mext memory bank power state
697 * @bank: memory bank number (0-3)
698 *
699 * Return the powerdomain pwrdm's next memory power state for bank
700 * x. Returns -EINVAL if the powerdomain pointer is null, -EEXIST if
701 * the target memory bank does not exist or is not controllable, or
702 * returns the next memory power state upon success.
703 */
704int pwrdm_read_mem_retst(struct powerdomain *pwrdm, u8 bank)
705{
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700706 int ret = -EINVAL;
Thara Gopinath1e3d0d22010-02-24 12:05:49 -0700707
708 if (!pwrdm)
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700709 return ret;
Thara Gopinath1e3d0d22010-02-24 12:05:49 -0700710
711 if (pwrdm->banks < (bank + 1))
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700712 return ret;
Thara Gopinath1e3d0d22010-02-24 12:05:49 -0700713
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700714 if (arch_pwrdm && arch_pwrdm->pwrdm_read_mem_retst)
715 ret = arch_pwrdm->pwrdm_read_mem_retst(pwrdm, bank);
Thara Gopinath1e3d0d22010-02-24 12:05:49 -0700716
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700717 return ret;
Thara Gopinath1e3d0d22010-02-24 12:05:49 -0700718}
719
720/**
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300721 * pwrdm_clear_all_prev_pwrst - clear previous powerstate register for a pwrdm
722 * @pwrdm: struct powerdomain * to clear
723 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700724 * Clear the powerdomain's previous power state register @pwrdm.
725 * Clears the entire register, including logic and memory bank
726 * previous power states. Returns -EINVAL if the powerdomain pointer
727 * is null, or returns 0 upon success.
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300728 */
729int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm)
730{
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700731 int ret = -EINVAL;
732
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300733 if (!pwrdm)
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700734 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300735
736 /*
737 * XXX should get the powerdomain's current state here;
738 * warn & fail if it is not ON.
739 */
740
741 pr_debug("powerdomain: clearing previous power state reg for %s\n",
742 pwrdm->name);
743
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700744 if (arch_pwrdm && arch_pwrdm->pwrdm_clear_all_prev_pwrst)
745 ret = arch_pwrdm->pwrdm_clear_all_prev_pwrst(pwrdm);
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300746
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700747 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300748}
749
750/**
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600751 * pwrdm_enable_hdwr_sar - enable automatic hardware SAR for a pwrdm
752 * @pwrdm: struct powerdomain *
753 *
754 * Enable automatic context save-and-restore upon power state change
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700755 * for some devices in the powerdomain @pwrdm. Warning: this only
756 * affects a subset of devices in a powerdomain; check the TRM
757 * closely. Returns -EINVAL if the powerdomain pointer is null or if
758 * the powerdomain does not support automatic save-and-restore, or
759 * returns 0 upon success.
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600760 */
761int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm)
762{
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700763 int ret = -EINVAL;
764
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600765 if (!pwrdm)
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700766 return ret;
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600767
768 if (!(pwrdm->flags & PWRDM_HAS_HDWR_SAR))
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700769 return ret;
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600770
771 pr_debug("powerdomain: %s: setting SAVEANDRESTORE bit\n",
772 pwrdm->name);
773
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700774 if (arch_pwrdm && arch_pwrdm->pwrdm_enable_hdwr_sar)
775 ret = arch_pwrdm->pwrdm_enable_hdwr_sar(pwrdm);
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600776
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700777 return ret;
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600778}
779
780/**
781 * pwrdm_disable_hdwr_sar - disable automatic hardware SAR for a pwrdm
782 * @pwrdm: struct powerdomain *
783 *
784 * Disable automatic context save-and-restore upon power state change
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700785 * for some devices in the powerdomain @pwrdm. Warning: this only
786 * affects a subset of devices in a powerdomain; check the TRM
787 * closely. Returns -EINVAL if the powerdomain pointer is null or if
788 * the powerdomain does not support automatic save-and-restore, or
789 * returns 0 upon success.
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600790 */
791int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm)
792{
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700793 int ret = -EINVAL;
794
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600795 if (!pwrdm)
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700796 return ret;
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600797
798 if (!(pwrdm->flags & PWRDM_HAS_HDWR_SAR))
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700799 return ret;
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600800
801 pr_debug("powerdomain: %s: clearing SAVEANDRESTORE bit\n",
802 pwrdm->name);
803
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700804 if (arch_pwrdm && arch_pwrdm->pwrdm_disable_hdwr_sar)
805 ret = arch_pwrdm->pwrdm_disable_hdwr_sar(pwrdm);
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600806
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700807 return ret;
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600808}
809
810/**
811 * pwrdm_has_hdwr_sar - test whether powerdomain supports hardware SAR
812 * @pwrdm: struct powerdomain *
813 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700814 * Returns 1 if powerdomain @pwrdm supports hardware save-and-restore
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600815 * for some devices, or 0 if it does not.
816 */
817bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm)
818{
819 return (pwrdm && pwrdm->flags & PWRDM_HAS_HDWR_SAR) ? 1 : 0;
820}
821
822/**
Rajendra Nayak90dbc7b2010-05-18 20:24:03 -0600823 * pwrdm_set_lowpwrstchange - Request a low power state change
824 * @pwrdm: struct powerdomain *
825 *
826 * Allows a powerdomain to transtion to a lower power sleep state
827 * from an existing sleep state without waking up the powerdomain.
828 * Returns -EINVAL if the powerdomain pointer is null or if the
829 * powerdomain does not support LOWPOWERSTATECHANGE, or returns 0
830 * upon success.
831 */
832int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm)
833{
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700834 int ret = -EINVAL;
835
Rajendra Nayak90dbc7b2010-05-18 20:24:03 -0600836 if (!pwrdm)
837 return -EINVAL;
838
839 if (!(pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE))
840 return -EINVAL;
841
842 pr_debug("powerdomain: %s: setting LOWPOWERSTATECHANGE bit\n",
843 pwrdm->name);
844
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700845 if (arch_pwrdm && arch_pwrdm->pwrdm_set_lowpwrstchange)
846 ret = arch_pwrdm->pwrdm_set_lowpwrstchange(pwrdm);
Rajendra Nayak90dbc7b2010-05-18 20:24:03 -0600847
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700848 return ret;
Rajendra Nayak90dbc7b2010-05-18 20:24:03 -0600849}
850
851/**
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300852 * pwrdm_wait_transition - wait for powerdomain power transition to finish
853 * @pwrdm: struct powerdomain * to wait for
854 *
Paul Walmsleyf0271d62010-01-26 20:13:02 -0700855 * If the powerdomain @pwrdm is in the process of a state transition,
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300856 * spin until it completes the power transition, or until an iteration
857 * bailout value is reached. Returns -EINVAL if the powerdomain
858 * pointer is null, -EAGAIN if the bailout value was reached, or
859 * returns 0 upon success.
860 */
861int pwrdm_wait_transition(struct powerdomain *pwrdm)
862{
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700863 int ret = -EINVAL;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300864
865 if (!pwrdm)
866 return -EINVAL;
867
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700868 if (arch_pwrdm && arch_pwrdm->pwrdm_wait_transition)
869 ret = arch_pwrdm->pwrdm_wait_transition(pwrdm);
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300870
Rajendra Nayak9b7fc902010-12-21 20:01:19 -0700871 return ret;
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300872}
873
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300874int pwrdm_state_switch(struct powerdomain *pwrdm)
875{
876 return _pwrdm_state_switch(pwrdm, PWRDM_STATE_NOW);
877}
878
879int pwrdm_clkdm_state_switch(struct clockdomain *clkdm)
880{
881 if (clkdm != NULL && clkdm->pwrdm.ptr != NULL) {
882 pwrdm_wait_transition(clkdm->pwrdm.ptr);
883 return pwrdm_state_switch(clkdm->pwrdm.ptr);
884 }
885
886 return -EINVAL;
887}
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300888
889int pwrdm_pre_transition(void)
890{
Peter 'p2' De Schrijver6199ab22008-10-15 18:13:49 +0300891 pwrdm_for_each(_pwrdm_pre_transition_cb, NULL);
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300892 return 0;
893}
894
895int pwrdm_post_transition(void)
896{
Peter 'p2' De Schrijver6199ab22008-10-15 18:13:49 +0300897 pwrdm_for_each(_pwrdm_post_transition_cb, NULL);
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300898 return 0;
899}