diff options
Diffstat (limited to 'include/linux/pm.h')
-rw-r--r-- | include/linux/pm.h | 115 |
1 files changed, 112 insertions, 3 deletions
diff --git a/include/linux/pm.h b/include/linux/pm.h index b3f74764a586..3b7e04b95bd2 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h | |||
@@ -22,6 +22,10 @@ | |||
22 | #define _LINUX_PM_H | 22 | #define _LINUX_PM_H |
23 | 23 | ||
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | #include <linux/workqueue.h> | ||
26 | #include <linux/spinlock.h> | ||
27 | #include <linux/wait.h> | ||
28 | #include <linux/timer.h> | ||
25 | 29 | ||
26 | /* | 30 | /* |
27 | * Callbacks for platform drivers to implement. | 31 | * Callbacks for platform drivers to implement. |
@@ -165,6 +169,28 @@ typedef struct pm_message { | |||
165 | * It is allowed to unregister devices while the above callbacks are being | 169 | * It is allowed to unregister devices while the above callbacks are being |
166 | * executed. However, it is not allowed to unregister a device from within any | 170 | * executed. However, it is not allowed to unregister a device from within any |
167 | * of its own callbacks. | 171 | * of its own callbacks. |
172 | * | ||
173 | * There also are the following callbacks related to run-time power management | ||
174 | * of devices: | ||
175 | * | ||
176 | * @runtime_suspend: Prepare the device for a condition in which it won't be | ||
177 | * able to communicate with the CPU(s) and RAM due to power management. | ||
178 | * 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 | * 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 | * hardware mechanism allowing the device to request a change of its power | ||
183 | * state, such as PCI PME) should be enabled for it. | ||
184 | * | ||
185 | * @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 | ||
187 | * necessary, put the device into the full power state and restore its | ||
188 | * registers, so that it is fully operational. | ||
189 | * | ||
190 | * @runtime_idle: Device appears to be inactive and it might be put into a low | ||
191 | * power state if all of the necessary conditions are satisfied. Check | ||
192 | * these conditions and handle the device as appropriate, possibly queueing | ||
193 | * a suspend request for it. The return value is ignored by the PM core. | ||
168 | */ | 194 | */ |
169 | 195 | ||
170 | struct dev_pm_ops { | 196 | struct dev_pm_ops { |
@@ -182,8 +208,25 @@ struct dev_pm_ops { | |||
182 | int (*thaw_noirq)(struct device *dev); | 208 | int (*thaw_noirq)(struct device *dev); |
183 | int (*poweroff_noirq)(struct device *dev); | 209 | int (*poweroff_noirq)(struct device *dev); |
184 | int (*restore_noirq)(struct device *dev); | 210 | int (*restore_noirq)(struct device *dev); |
211 | int (*runtime_suspend)(struct device *dev); | ||
212 | int (*runtime_resume)(struct device *dev); | ||
213 | int (*runtime_idle)(struct device *dev); | ||
185 | }; | 214 | }; |
186 | 215 | ||
216 | /* | ||
217 | * Use this if you want to use the same suspend and resume callbacks for suspend | ||
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, \ | ||
223 | .resume = resume_fn, \ | ||
224 | .freeze = suspend_fn, \ | ||
225 | .thaw = resume_fn, \ | ||
226 | .poweroff = suspend_fn, \ | ||
227 | .restore = resume_fn, \ | ||
228 | } | ||
229 | |||
187 | /** | 230 | /** |
188 | * PM_EVENT_ messages | 231 | * PM_EVENT_ messages |
189 | * | 232 | * |
@@ -315,14 +358,80 @@ enum dpm_state { | |||
315 | DPM_OFF_IRQ, | 358 | DPM_OFF_IRQ, |
316 | }; | 359 | }; |
317 | 360 | ||
361 | /** | ||
362 | * Device run-time power management status. | ||
363 | * | ||
364 | * These status labels are used internally by the PM core to indicate the | ||
365 | * current status of a device with respect to the PM core operations. They do | ||
366 | * not reflect the actual power state of the device or its status as seen by the | ||
367 | * driver. | ||
368 | * | ||
369 | * RPM_ACTIVE Device is fully operational. Indicates that the device | ||
370 | * bus type's ->runtime_resume() callback has completed | ||
371 | * successfully. | ||
372 | * | ||
373 | * RPM_SUSPENDED Device bus type's ->runtime_suspend() callback has | ||
374 | * completed successfully. The device is regarded as | ||
375 | * suspended. | ||
376 | * | ||
377 | * RPM_RESUMING Device bus type's ->runtime_resume() callback is being | ||
378 | * executed. | ||
379 | * | ||
380 | * RPM_SUSPENDING Device bus type's ->runtime_suspend() callback is being | ||
381 | * executed. | ||
382 | */ | ||
383 | |||
384 | enum rpm_status { | ||
385 | RPM_ACTIVE = 0, | ||
386 | RPM_RESUMING, | ||
387 | RPM_SUSPENDED, | ||
388 | RPM_SUSPENDING, | ||
389 | }; | ||
390 | |||
391 | /** | ||
392 | * Device run-time power management request types. | ||
393 | * | ||
394 | * RPM_REQ_NONE Do nothing. | ||
395 | * | ||
396 | * RPM_REQ_IDLE Run the device bus type's ->runtime_idle() callback | ||
397 | * | ||
398 | * RPM_REQ_SUSPEND Run the device bus type's ->runtime_suspend() callback | ||
399 | * | ||
400 | * RPM_REQ_RESUME Run the device bus type's ->runtime_resume() callback | ||
401 | */ | ||
402 | |||
403 | enum rpm_request { | ||
404 | RPM_REQ_NONE = 0, | ||
405 | RPM_REQ_IDLE, | ||
406 | RPM_REQ_SUSPEND, | ||
407 | RPM_REQ_RESUME, | ||
408 | }; | ||
409 | |||
318 | struct dev_pm_info { | 410 | struct dev_pm_info { |
319 | pm_message_t power_state; | 411 | pm_message_t power_state; |
320 | unsigned can_wakeup:1; | 412 | unsigned int can_wakeup:1; |
321 | unsigned should_wakeup:1; | 413 | unsigned int should_wakeup:1; |
322 | enum dpm_state status; /* Owned by the PM core */ | 414 | enum dpm_state status; /* Owned by the PM core */ |
323 | #ifdef CONFIG_PM_SLEEP | 415 | #ifdef CONFIG_PM_SLEEP |
324 | struct list_head entry; | 416 | struct list_head entry; |
325 | #endif | 417 | #endif |
418 | #ifdef CONFIG_PM_RUNTIME | ||
419 | struct timer_list suspend_timer; | ||
420 | unsigned long timer_expires; | ||
421 | struct work_struct work; | ||
422 | wait_queue_head_t wait_queue; | ||
423 | spinlock_t lock; | ||
424 | atomic_t usage_count; | ||
425 | atomic_t child_count; | ||
426 | unsigned int disable_depth:3; | ||
427 | unsigned int ignore_children:1; | ||
428 | unsigned int idle_notification:1; | ||
429 | unsigned int request_pending:1; | ||
430 | unsigned int deferred_resume:1; | ||
431 | enum rpm_request request; | ||
432 | enum rpm_status runtime_status; | ||
433 | int runtime_error; | ||
434 | #endif | ||
326 | }; | 435 | }; |
327 | 436 | ||
328 | /* | 437 | /* |