diff options
Diffstat (limited to 'include/linux/pm.h')
-rw-r--r-- | include/linux/pm.h | 67 |
1 files changed, 57 insertions, 10 deletions
diff --git a/include/linux/pm.h b/include/linux/pm.h index 3b7e04b95bd2..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. |
@@ -178,9 +179,10 @@ typedef struct pm_message { | |||
178 | * This need not mean that the device should be put into a low power state. | 179 | * This need not mean that the device should be put into a low power state. |
179 | * For example, if the device is behind a link which is about to be turned | 180 | * For example, if the device is behind a link which is about to be turned |
180 | * off, the device may remain at full power. If the device does go to low | 181 | * off, the device may remain at full power. If the device does go to low |
181 | * power and if device_may_wakeup(dev) is true, remote wake-up (i.e., a | 182 | * power and is capable of generating run-time wake-up events, remote |
182 | * hardware mechanism allowing the device to request a change of its power | 183 | * wake-up (i.e., a hardware mechanism allowing the device to request a |
183 | * state, such as PCI PME) should be enabled for it. | 184 | * change of its power state via a wake-up event, such as PCI PME) should |
185 | * be enabled for it. | ||
184 | * | 186 | * |
185 | * @runtime_resume: Put the device into the fully active state in response to a | 187 | * @runtime_resume: Put the device into the fully active state in response to a |
186 | * wake-up event generated by hardware or at the request of software. If | 188 | * wake-up event generated by hardware or at the request of software. If |
@@ -213,20 +215,59 @@ struct dev_pm_ops { | |||
213 | int (*runtime_idle)(struct device *dev); | 215 | int (*runtime_idle)(struct device *dev); |
214 | }; | 216 | }; |
215 | 217 | ||
216 | /* | 218 | #ifdef CONFIG_PM_SLEEP |
217 | * Use this if you want to use the same suspend and resume callbacks for suspend | 219 | #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ |
218 | * to RAM and hibernation. | ||
219 | */ | ||
220 | #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ | ||
221 | struct dev_pm_ops name = { \ | ||
222 | .suspend = suspend_fn, \ | 220 | .suspend = suspend_fn, \ |
223 | .resume = resume_fn, \ | 221 | .resume = resume_fn, \ |
224 | .freeze = suspend_fn, \ | 222 | .freeze = suspend_fn, \ |
225 | .thaw = resume_fn, \ | 223 | .thaw = resume_fn, \ |
226 | .poweroff = suspend_fn, \ | 224 | .poweroff = suspend_fn, \ |
227 | .restore = resume_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 | |||
239 | /* | ||
240 | * Use this if you want to use the same suspend and resume callbacks for suspend | ||
241 | * to RAM and hibernation. | ||
242 | */ | ||
243 | #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ | ||
244 | const struct dev_pm_ops name = { \ | ||
245 | SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ | ||
246 | } | ||
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) \ | ||
228 | } | 256 | } |
229 | 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 | |||
230 | /** | 271 | /** |
231 | * PM_EVENT_ messages | 272 | * PM_EVENT_ messages |
232 | * | 273 | * |
@@ -411,9 +452,11 @@ struct dev_pm_info { | |||
411 | pm_message_t power_state; | 452 | pm_message_t power_state; |
412 | unsigned int can_wakeup:1; | 453 | unsigned int can_wakeup:1; |
413 | unsigned int should_wakeup:1; | 454 | unsigned int should_wakeup:1; |
455 | unsigned async_suspend:1; | ||
414 | enum dpm_state status; /* Owned by the PM core */ | 456 | enum dpm_state status; /* Owned by the PM core */ |
415 | #ifdef CONFIG_PM_SLEEP | 457 | #ifdef CONFIG_PM_SLEEP |
416 | struct list_head entry; | 458 | struct list_head entry; |
459 | struct completion completion; | ||
417 | #endif | 460 | #endif |
418 | #ifdef CONFIG_PM_RUNTIME | 461 | #ifdef CONFIG_PM_RUNTIME |
419 | struct timer_list suspend_timer; | 462 | struct timer_list suspend_timer; |
@@ -428,6 +471,8 @@ struct dev_pm_info { | |||
428 | unsigned int idle_notification:1; | 471 | unsigned int idle_notification:1; |
429 | unsigned int request_pending:1; | 472 | unsigned int request_pending:1; |
430 | unsigned int deferred_resume:1; | 473 | unsigned int deferred_resume:1; |
474 | unsigned int run_wake:1; | ||
475 | unsigned int runtime_auto:1; | ||
431 | enum rpm_request request; | 476 | enum rpm_request request; |
432 | enum rpm_status runtime_status; | 477 | enum rpm_status runtime_status; |
433 | int runtime_error; | 478 | int runtime_error; |
@@ -506,6 +551,7 @@ extern void __suspend_report_result(const char *function, void *fn, int ret); | |||
506 | __suspend_report_result(__func__, fn, ret); \ | 551 | __suspend_report_result(__func__, fn, ret); \ |
507 | } while (0) | 552 | } while (0) |
508 | 553 | ||
554 | extern void device_pm_wait_for_dev(struct device *sub, struct device *dev); | ||
509 | #else /* !CONFIG_PM_SLEEP */ | 555 | #else /* !CONFIG_PM_SLEEP */ |
510 | 556 | ||
511 | #define device_pm_lock() do {} while (0) | 557 | #define device_pm_lock() do {} while (0) |
@@ -518,6 +564,7 @@ static inline int dpm_suspend_start(pm_message_t state) | |||
518 | 564 | ||
519 | #define suspend_report_result(fn, ret) do {} while (0) | 565 | #define suspend_report_result(fn, ret) do {} while (0) |
520 | 566 | ||
567 | static inline void device_pm_wait_for_dev(struct device *a, struct device *b) {} | ||
521 | #endif /* !CONFIG_PM_SLEEP */ | 568 | #endif /* !CONFIG_PM_SLEEP */ |
522 | 569 | ||
523 | /* How to reorder dpm_list after device_move() */ | 570 | /* How to reorder dpm_list after device_move() */ |