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.h126
1 files changed, 61 insertions, 65 deletions
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 52e8c55ff314..411e4f4be52b 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -41,6 +41,12 @@ extern void (*pm_power_off_prepare)(void);
41 41
42struct device; 42struct device;
43 43
44#ifdef CONFIG_PM
45extern const char power_group_name[]; /* = "power" */
46#else
47#define power_group_name NULL
48#endif
49
44typedef struct pm_message { 50typedef struct pm_message {
45 int event; 51 int event;
46} pm_message_t; 52} pm_message_t;
@@ -261,7 +267,7 @@ const struct dev_pm_ops name = { \
261 * callbacks provided by device drivers supporting both the system sleep PM and 267 * 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. 268 * runtime PM, make the pm member point to generic_subsys_pm_ops.
263 */ 269 */
264#ifdef CONFIG_PM_OPS 270#ifdef CONFIG_PM
265extern struct dev_pm_ops generic_subsys_pm_ops; 271extern struct dev_pm_ops generic_subsys_pm_ops;
266#define GENERIC_SUBSYS_PM_OPS (&generic_subsys_pm_ops) 272#define GENERIC_SUBSYS_PM_OPS (&generic_subsys_pm_ops)
267#else 273#else
@@ -361,45 +367,6 @@ extern struct dev_pm_ops generic_subsys_pm_ops;
361 { .event = PM_EVENT_AUTO_RESUME, }) 367 { .event = PM_EVENT_AUTO_RESUME, })
362 368
363/** 369/**
364 * Device power management states
365 *
366 * These state labels are used internally by the PM core to indicate the current
367 * status of a device with respect to the PM core operations.
368 *
369 * DPM_ON Device is regarded as operational. Set this way
370 * initially and when ->complete() is about to be called.
371 * Also set when ->prepare() fails.
372 *
373 * DPM_PREPARING Device is going to be prepared for a PM transition. Set
374 * when ->prepare() is about to be called.
375 *
376 * DPM_RESUMING Device is going to be resumed. Set when ->resume(),
377 * ->thaw(), or ->restore() is about to be called.
378 *
379 * DPM_SUSPENDING Device has been prepared for a power transition. Set
380 * when ->prepare() has just succeeded.
381 *
382 * DPM_OFF Device is regarded as inactive. Set immediately after
383 * ->suspend(), ->freeze(), or ->poweroff() has succeeded.
384 * Also set when ->resume()_noirq, ->thaw_noirq(), or
385 * ->restore_noirq() is about to be called.
386 *
387 * DPM_OFF_IRQ Device is in a "deep sleep". Set immediately after
388 * ->suspend_noirq(), ->freeze_noirq(), or
389 * ->poweroff_noirq() has just succeeded.
390 */
391
392enum dpm_state {
393 DPM_INVALID,
394 DPM_ON,
395 DPM_PREPARING,
396 DPM_RESUMING,
397 DPM_SUSPENDING,
398 DPM_OFF,
399 DPM_OFF_IRQ,
400};
401
402/**
403 * Device run-time power management status. 370 * Device run-time power management status.
404 * 371 *
405 * These status labels are used internally by the PM core to indicate the 372 * These status labels are used internally by the PM core to indicate the
@@ -438,6 +405,9 @@ enum rpm_status {
438 * 405 *
439 * RPM_REQ_SUSPEND Run the device bus type's ->runtime_suspend() callback 406 * RPM_REQ_SUSPEND Run the device bus type's ->runtime_suspend() callback
440 * 407 *
408 * RPM_REQ_AUTOSUSPEND Same as RPM_REQ_SUSPEND, but not until the device has
409 * been inactive for as long as power.autosuspend_delay
410 *
441 * RPM_REQ_RESUME Run the device bus type's ->runtime_resume() callback 411 * RPM_REQ_RESUME Run the device bus type's ->runtime_resume() callback
442 */ 412 */
443 413
@@ -445,26 +415,31 @@ enum rpm_request {
445 RPM_REQ_NONE = 0, 415 RPM_REQ_NONE = 0,
446 RPM_REQ_IDLE, 416 RPM_REQ_IDLE,
447 RPM_REQ_SUSPEND, 417 RPM_REQ_SUSPEND,
418 RPM_REQ_AUTOSUSPEND,
448 RPM_REQ_RESUME, 419 RPM_REQ_RESUME,
449}; 420};
450 421
422struct wakeup_source;
423
451struct dev_pm_info { 424struct dev_pm_info {
452 pm_message_t power_state; 425 pm_message_t power_state;
453 unsigned int can_wakeup:1; 426 unsigned int can_wakeup:1;
454 unsigned int should_wakeup:1; 427 unsigned int async_suspend:1;
455 unsigned async_suspend:1; 428 bool is_prepared:1; /* Owned by the PM core */
456 enum dpm_state status; /* Owned by the PM core */ 429 bool is_suspended:1; /* Ditto */
430 spinlock_t lock;
457#ifdef CONFIG_PM_SLEEP 431#ifdef CONFIG_PM_SLEEP
458 struct list_head entry; 432 struct list_head entry;
459 struct completion completion; 433 struct completion completion;
460 unsigned long wakeup_count; 434 struct wakeup_source *wakeup;
435#else
436 unsigned int should_wakeup:1;
461#endif 437#endif
462#ifdef CONFIG_PM_RUNTIME 438#ifdef CONFIG_PM_RUNTIME
463 struct timer_list suspend_timer; 439 struct timer_list suspend_timer;
464 unsigned long timer_expires; 440 unsigned long timer_expires;
465 struct work_struct work; 441 struct work_struct work;
466 wait_queue_head_t wait_queue; 442 wait_queue_head_t wait_queue;
467 spinlock_t lock;
468 atomic_t usage_count; 443 atomic_t usage_count;
469 atomic_t child_count; 444 atomic_t child_count;
470 unsigned int disable_depth:3; 445 unsigned int disable_depth:3;
@@ -474,17 +449,32 @@ struct dev_pm_info {
474 unsigned int deferred_resume:1; 449 unsigned int deferred_resume:1;
475 unsigned int run_wake:1; 450 unsigned int run_wake:1;
476 unsigned int runtime_auto:1; 451 unsigned int runtime_auto:1;
452 unsigned int no_callbacks:1;
453 unsigned int irq_safe:1;
454 unsigned int use_autosuspend:1;
455 unsigned int timer_autosuspends:1;
477 enum rpm_request request; 456 enum rpm_request request;
478 enum rpm_status runtime_status; 457 enum rpm_status runtime_status;
479 int runtime_error; 458 int runtime_error;
459 int autosuspend_delay;
460 unsigned long last_busy;
480 unsigned long active_jiffies; 461 unsigned long active_jiffies;
481 unsigned long suspended_jiffies; 462 unsigned long suspended_jiffies;
482 unsigned long accounting_timestamp; 463 unsigned long accounting_timestamp;
464 void *subsys_data; /* Owned by the subsystem. */
483#endif 465#endif
484}; 466};
485 467
486extern void update_pm_runtime_accounting(struct device *dev); 468extern void update_pm_runtime_accounting(struct device *dev);
487 469
470/*
471 * Power domains provide callbacks that are executed during system suspend,
472 * hibernation, system resume and during runtime PM transitions along with
473 * subsystem-level and driver-level callbacks.
474 */
475struct dev_power_domain {
476 struct dev_pm_ops ops;
477};
488 478
489/* 479/*
490 * The PM_EVENT_ messages are also used by drivers implementing the legacy 480 * The PM_EVENT_ messages are also used by drivers implementing the legacy
@@ -542,14 +532,16 @@ extern void update_pm_runtime_accounting(struct device *dev);
542 532
543#ifdef CONFIG_PM_SLEEP 533#ifdef CONFIG_PM_SLEEP
544extern void device_pm_lock(void); 534extern void device_pm_lock(void);
545extern int sysdev_resume(void);
546extern void dpm_resume_noirq(pm_message_t state); 535extern void dpm_resume_noirq(pm_message_t state);
547extern void dpm_resume_end(pm_message_t state); 536extern void dpm_resume_end(pm_message_t state);
537extern void dpm_resume(pm_message_t state);
538extern void dpm_complete(pm_message_t state);
548 539
549extern void device_pm_unlock(void); 540extern void device_pm_unlock(void);
550extern int sysdev_suspend(pm_message_t state);
551extern int dpm_suspend_noirq(pm_message_t state); 541extern int dpm_suspend_noirq(pm_message_t state);
552extern int dpm_suspend_start(pm_message_t state); 542extern int dpm_suspend_start(pm_message_t state);
543extern int dpm_suspend(pm_message_t state);
544extern int dpm_prepare(pm_message_t state);
553 545
554extern void __suspend_report_result(const char *function, void *fn, int ret); 546extern void __suspend_report_result(const char *function, void *fn, int ret);
555 547
@@ -558,12 +550,17 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
558 __suspend_report_result(__func__, fn, ret); \ 550 __suspend_report_result(__func__, fn, ret); \
559 } while (0) 551 } while (0)
560 552
561extern void device_pm_wait_for_dev(struct device *sub, struct device *dev); 553extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);
554
555extern int pm_generic_prepare(struct device *dev);
556extern int pm_generic_suspend(struct device *dev);
557extern int pm_generic_resume(struct device *dev);
558extern int pm_generic_freeze(struct device *dev);
559extern int pm_generic_thaw(struct device *dev);
560extern int pm_generic_restore(struct device *dev);
561extern int pm_generic_poweroff(struct device *dev);
562extern void pm_generic_complete(struct device *dev);
562 563
563/* drivers/base/power/wakeup.c */
564extern void pm_wakeup_event(struct device *dev, unsigned int msec);
565extern void pm_stay_awake(struct device *dev);
566extern void pm_relax(void);
567#else /* !CONFIG_PM_SLEEP */ 564#else /* !CONFIG_PM_SLEEP */
568 565
569#define device_pm_lock() do {} while (0) 566#define device_pm_lock() do {} while (0)
@@ -576,11 +573,19 @@ static inline int dpm_suspend_start(pm_message_t state)
576 573
577#define suspend_report_result(fn, ret) do {} while (0) 574#define suspend_report_result(fn, ret) do {} while (0)
578 575
579static inline void device_pm_wait_for_dev(struct device *a, struct device *b) {} 576static inline int device_pm_wait_for_dev(struct device *a, struct device *b)
577{
578 return 0;
579}
580 580
581static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {} 581#define pm_generic_prepare NULL
582static inline void pm_stay_awake(struct device *dev) {} 582#define pm_generic_suspend NULL
583static inline void pm_relax(void) {} 583#define pm_generic_resume NULL
584#define pm_generic_freeze NULL
585#define pm_generic_thaw NULL
586#define pm_generic_restore NULL
587#define pm_generic_poweroff NULL
588#define pm_generic_complete NULL
584#endif /* !CONFIG_PM_SLEEP */ 589#endif /* !CONFIG_PM_SLEEP */
585 590
586/* How to reorder dpm_list after device_move() */ 591/* How to reorder dpm_list after device_move() */
@@ -591,13 +596,4 @@ enum dpm_order {
591 DPM_ORDER_DEV_LAST, 596 DPM_ORDER_DEV_LAST,
592}; 597};
593 598
594/*
595 * Global Power Management flags
596 * Used to keep APM and ACPI from both being active
597 */
598extern unsigned int pm_flags;
599
600#define PM_APM 1
601#define PM_ACPI 2
602
603#endif /* _LINUX_PM_H */ 599#endif /* _LINUX_PM_H */