diff options
Diffstat (limited to 'include/linux/pm.h')
| -rw-r--r-- | include/linux/pm.h | 73 |
1 files changed, 67 insertions, 6 deletions
diff --git a/include/linux/pm.h b/include/linux/pm.h index 198b8f9fe05e..52e8c55ff314 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) \ |
| 222 | const struct dev_pm_ops name = { \ | 244 | const struct dev_pm_ops name = { \ |
| 223 | .suspend = suspend_fn, \ | 245 | SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ |
| 224 | .resume = resume_fn, \ | ||
| 225 | .freeze = suspend_fn, \ | ||
| 226 | .thaw = resume_fn, \ | ||
| 227 | .poweroff = suspend_fn, \ | ||
| 228 | .restore = resume_fn, \ | ||
| 229 | } | 246 | } |
| 230 | 247 | ||
| 248 | /* | ||
| 249 | * Use this for defining a set of PM operations to be used in all situations | ||
| 250 | * (sustem suspend, hibernation or runtime PM). | ||
| 251 | */ | ||
| 252 | #define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \ | ||
| 253 | const 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) \ | ||
| 256 | } | ||
| 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 | ||
| 265 | extern 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,12 @@ 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; | ||
| 460 | unsigned long wakeup_count; | ||
| 418 | #endif | 461 | #endif |
| 419 | #ifdef CONFIG_PM_RUNTIME | 462 | #ifdef CONFIG_PM_RUNTIME |
| 420 | struct timer_list suspend_timer; | 463 | struct timer_list suspend_timer; |
| @@ -430,12 +473,19 @@ struct dev_pm_info { | |||
| 430 | unsigned int request_pending:1; | 473 | unsigned int request_pending:1; |
| 431 | unsigned int deferred_resume:1; | 474 | unsigned int deferred_resume:1; |
| 432 | unsigned int run_wake:1; | 475 | unsigned int run_wake:1; |
| 476 | unsigned int runtime_auto:1; | ||
| 433 | enum rpm_request request; | 477 | enum rpm_request request; |
| 434 | enum rpm_status runtime_status; | 478 | enum rpm_status runtime_status; |
| 435 | int runtime_error; | 479 | int runtime_error; |
| 480 | unsigned long active_jiffies; | ||
| 481 | unsigned long suspended_jiffies; | ||
| 482 | unsigned long accounting_timestamp; | ||
| 436 | #endif | 483 | #endif |
| 437 | }; | 484 | }; |
| 438 | 485 | ||
| 486 | extern void update_pm_runtime_accounting(struct device *dev); | ||
| 487 | |||
| 488 | |||
| 439 | /* | 489 | /* |
| 440 | * The PM_EVENT_ messages are also used by drivers implementing the legacy | 490 | * The PM_EVENT_ messages are also used by drivers implementing the legacy |
| 441 | * suspend framework, based on the ->suspend() and ->resume() callbacks common | 491 | * suspend framework, based on the ->suspend() and ->resume() callbacks common |
| @@ -508,6 +558,12 @@ extern void __suspend_report_result(const char *function, void *fn, int ret); | |||
| 508 | __suspend_report_result(__func__, fn, ret); \ | 558 | __suspend_report_result(__func__, fn, ret); \ |
| 509 | } while (0) | 559 | } while (0) |
| 510 | 560 | ||
| 561 | extern void device_pm_wait_for_dev(struct device *sub, struct device *dev); | ||
| 562 | |||
| 563 | /* drivers/base/power/wakeup.c */ | ||
| 564 | extern void pm_wakeup_event(struct device *dev, unsigned int msec); | ||
| 565 | extern void pm_stay_awake(struct device *dev); | ||
| 566 | extern void pm_relax(void); | ||
| 511 | #else /* !CONFIG_PM_SLEEP */ | 567 | #else /* !CONFIG_PM_SLEEP */ |
| 512 | 568 | ||
| 513 | #define device_pm_lock() do {} while (0) | 569 | #define device_pm_lock() do {} while (0) |
| @@ -520,6 +576,11 @@ static inline int dpm_suspend_start(pm_message_t state) | |||
| 520 | 576 | ||
| 521 | #define suspend_report_result(fn, ret) do {} while (0) | 577 | #define suspend_report_result(fn, ret) do {} while (0) |
| 522 | 578 | ||
| 579 | static inline void device_pm_wait_for_dev(struct device *a, struct device *b) {} | ||
| 580 | |||
| 581 | static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {} | ||
| 582 | static inline void pm_stay_awake(struct device *dev) {} | ||
| 583 | static inline void pm_relax(void) {} | ||
| 523 | #endif /* !CONFIG_PM_SLEEP */ | 584 | #endif /* !CONFIG_PM_SLEEP */ |
| 524 | 585 | ||
| 525 | /* How to reorder dpm_list after device_move() */ | 586 | /* How to reorder dpm_list after device_move() */ |
