aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pm.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/pm.h')
-rw-r--r--include/linux/pm.h57
1 files changed, 51 insertions, 6 deletions
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 198b8f9fe05e..8e258c727971 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -26,6 +26,7 @@
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/wait.h> 27#include <linux/wait.h>
28#include <linux/timer.h> 28#include <linux/timer.h>
29#include <linux/completion.h>
29 30
30/* 31/*
31 * Callbacks for platform drivers to implement. 32 * Callbacks for platform drivers to implement.
@@ -214,20 +215,59 @@ struct dev_pm_ops {
214 int (*runtime_idle)(struct device *dev); 215 int (*runtime_idle)(struct device *dev);
215}; 216};
216 217
218#ifdef CONFIG_PM_SLEEP
219#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
220 .suspend = suspend_fn, \
221 .resume = resume_fn, \
222 .freeze = suspend_fn, \
223 .thaw = resume_fn, \
224 .poweroff = suspend_fn, \
225 .restore = resume_fn,
226#else
227#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
228#endif
229
230#ifdef CONFIG_PM_RUNTIME
231#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
232 .runtime_suspend = suspend_fn, \
233 .runtime_resume = resume_fn, \
234 .runtime_idle = idle_fn,
235#else
236#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
237#endif
238
217/* 239/*
218 * Use this if you want to use the same suspend and resume callbacks for suspend 240 * Use this if you want to use the same suspend and resume callbacks for suspend
219 * to RAM and hibernation. 241 * to RAM and hibernation.
220 */ 242 */
221#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ 243#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
222const struct dev_pm_ops name = { \ 244const struct dev_pm_ops name = { \
223 .suspend = suspend_fn, \ 245 SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
224 .resume = resume_fn, \ 246}
225 .freeze = suspend_fn, \ 247
226 .thaw = resume_fn, \ 248/*
227 .poweroff = suspend_fn, \ 249 * Use this for defining a set of PM operations to be used in all situations
228 .restore = resume_fn, \ 250 * (sustem suspend, hibernation or runtime PM).
251 */
252#define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
253const struct dev_pm_ops name = { \
254 SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
255 SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
229} 256}
230 257
258/*
259 * Use this for subsystems (bus types, device types, device classes) that don't
260 * need any special suspend/resume handling in addition to invoking the PM
261 * callbacks provided by device drivers supporting both the system sleep PM and
262 * runtime PM, make the pm member point to generic_subsys_pm_ops.
263 */
264#ifdef CONFIG_PM_OPS
265extern struct dev_pm_ops generic_subsys_pm_ops;
266#define GENERIC_SUBSYS_PM_OPS (&generic_subsys_pm_ops)
267#else
268#define GENERIC_SUBSYS_PM_OPS NULL
269#endif
270
231/** 271/**
232 * PM_EVENT_ messages 272 * PM_EVENT_ messages
233 * 273 *
@@ -412,9 +452,11 @@ struct dev_pm_info {
412 pm_message_t power_state; 452 pm_message_t power_state;
413 unsigned int can_wakeup:1; 453 unsigned int can_wakeup:1;
414 unsigned int should_wakeup:1; 454 unsigned int should_wakeup:1;
455 unsigned async_suspend:1;
415 enum dpm_state status; /* Owned by the PM core */ 456 enum dpm_state status; /* Owned by the PM core */
416#ifdef CONFIG_PM_SLEEP 457#ifdef CONFIG_PM_SLEEP
417 struct list_head entry; 458 struct list_head entry;
459 struct completion completion;
418#endif 460#endif
419#ifdef CONFIG_PM_RUNTIME 461#ifdef CONFIG_PM_RUNTIME
420 struct timer_list suspend_timer; 462 struct timer_list suspend_timer;
@@ -430,6 +472,7 @@ struct dev_pm_info {
430 unsigned int request_pending:1; 472 unsigned int request_pending:1;
431 unsigned int deferred_resume:1; 473 unsigned int deferred_resume:1;
432 unsigned int run_wake:1; 474 unsigned int run_wake:1;
475 unsigned int runtime_auto:1;
433 enum rpm_request request; 476 enum rpm_request request;
434 enum rpm_status runtime_status; 477 enum rpm_status runtime_status;
435 int runtime_error; 478 int runtime_error;
@@ -508,6 +551,7 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
508 __suspend_report_result(__func__, fn, ret); \ 551 __suspend_report_result(__func__, fn, ret); \
509 } while (0) 552 } while (0)
510 553
554extern void device_pm_wait_for_dev(struct device *sub, struct device *dev);
511#else /* !CONFIG_PM_SLEEP */ 555#else /* !CONFIG_PM_SLEEP */
512 556
513#define device_pm_lock() do {} while (0) 557#define device_pm_lock() do {} while (0)
@@ -520,6 +564,7 @@ static inline int dpm_suspend_start(pm_message_t state)
520 564
521#define suspend_report_result(fn, ret) do {} while (0) 565#define suspend_report_result(fn, ret) do {} while (0)
522 566
567static inline void device_pm_wait_for_dev(struct device *a, struct device *b) {}
523#endif /* !CONFIG_PM_SLEEP */ 568#endif /* !CONFIG_PM_SLEEP */
524 569
525/* How to reorder dpm_list after device_move() */ 570/* How to reorder dpm_list after device_move() */