linux/include/linux/pm.h
<<
>>
Prefs
   1/*
   2 *  pm.h - Power management interface
   3 *
   4 *  Copyright (C) 2000 Andrew Henroid
   5 *
   6 *  This program is free software; you can redistribute it and/or modify
   7 *  it under the terms of the GNU General Public License as published by
   8 *  the Free Software Foundation; either version 2 of the License, or
   9 *  (at your option) any later version.
  10 *
  11 *  This program is distributed in the hope that it will be useful,
  12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14 *  GNU General Public License for more details.
  15 *
  16 *  You should have received a copy of the GNU General Public License
  17 *  along with this program; if not, write to the Free Software
  18 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19 */
  20
  21#ifndef _LINUX_PM_H
  22#define _LINUX_PM_H
  23
  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>
  29#include <linux/completion.h>
  30
  31/*
  32 * Callbacks for platform drivers to implement.
  33 */
  34extern void (*pm_idle)(void);
  35extern void (*pm_power_off)(void);
  36extern void (*pm_power_off_prepare)(void);
  37
  38/*
  39 * Device power management
  40 */
  41
  42struct device;
  43
  44typedef struct pm_message {
  45        int event;
  46} pm_message_t;
  47
  48/**
  49 * struct dev_pm_ops - device PM callbacks
  50 *
  51 * Several driver power state transitions are externally visible, affecting
  52 * the state of pending I/O queues and (for drivers that touch hardware)
  53 * interrupts, wakeups, DMA, and other hardware state.  There may also be
  54 * internal transitions to various low power modes, which are transparent
  55 * to the rest of the driver stack (such as a driver that's ON gating off
  56 * clocks which are not in active use).
  57 *
  58 * The externally visible transitions are handled with the help of the following
  59 * callbacks included in this structure:
  60 *
  61 * @prepare: Prepare the device for the upcoming transition, but do NOT change
  62 *      its hardware state.  Prevent new children of the device from being
  63 *      registered after @prepare() returns (the driver's subsystem and
  64 *      generally the rest of the kernel is supposed to prevent new calls to the
  65 *      probe method from being made too once @prepare() has succeeded).  If
  66 *      @prepare() detects a situation it cannot handle (e.g. registration of a
  67 *      child already in progress), it may return -EAGAIN, so that the PM core
  68 *      can execute it once again (e.g. after the new child has been registered)
  69 *      to recover from the race condition.  This method is executed for all
  70 *      kinds of suspend transitions and is followed by one of the suspend
  71 *      callbacks: @suspend(), @freeze(), or @poweroff().
  72 *      The PM core executes @prepare() for all devices before starting to
  73 *      execute suspend callbacks for any of them, so drivers may assume all of
  74 *      the other devices to be present and functional while @prepare() is being
  75 *      executed.  In particular, it is safe to make GFP_KERNEL memory
  76 *      allocations from within @prepare().  However, drivers may NOT assume
  77 *      anything about the availability of the user space at that time and it
  78 *      is not correct to request firmware from within @prepare() (it's too
  79 *      late to do that).  [To work around this limitation, drivers may
  80 *      register suspend and hibernation notifiers that are executed before the
  81 *      freezing of tasks.]
  82 *
  83 * @complete: Undo the changes made by @prepare().  This method is executed for
  84 *      all kinds of resume transitions, following one of the resume callbacks:
  85 *      @resume(), @thaw(), @restore().  Also called if the state transition
  86 *      fails before the driver's suspend callback (@suspend(), @freeze(),
  87 *      @poweroff()) can be executed (e.g. if the suspend callback fails for one
  88 *      of the other devices that the PM core has unsuccessfully attempted to
  89 *      suspend earlier).
  90 *      The PM core executes @complete() after it has executed the appropriate
  91 *      resume callback for all devices.
  92 *
  93 * @suspend: Executed before putting the system into a sleep state in which the
  94 *      contents of main memory are preserved.  Quiesce the device, put it into
  95 *      a low power state appropriate for the upcoming system state (such as
  96 *      PCI_D3hot), and enable wakeup events as appropriate.
  97 *
  98 * @resume: Executed after waking the system up from a sleep state in which the
  99 *      contents of main memory were preserved.  Put the device into the
 100 *      appropriate state, according to the information saved in memory by the
 101 *      preceding @suspend().  The driver starts working again, responding to
 102 *      hardware events and software requests.  The hardware may have gone
 103 *      through a power-off reset, or it may have maintained state from the
 104 *      previous suspend() which the driver may rely on while resuming.  On most
 105 *      platforms, there are no restrictions on availability of resources like
 106 *      clocks during @resume().
 107 *
 108 * @freeze: Hibernation-specific, executed before creating a hibernation image.
 109 *      Quiesce operations so that a consistent image can be created, but do NOT
 110 *      otherwise put the device into a low power device state and do NOT emit
 111 *      system wakeup events.  Save in main memory the device settings to be
 112 *      used by @restore() during the subsequent resume from hibernation or by
 113 *      the subsequent @thaw(), if the creation of the image or the restoration
 114 *      of main memory contents from it fails.
 115 *
 116 * @thaw: Hibernation-specific, executed after creating a hibernation image OR
 117 *      if the creation of the image fails.  Also executed after a failing
 118 *      attempt to restore the contents of main memory from such an image.
 119 *      Undo the changes made by the preceding @freeze(), so the device can be
 120 *      operated in the same way as immediately before the call to @freeze().
 121 *
 122 * @poweroff: Hibernation-specific, executed after saving a hibernation image.
 123 *      Quiesce the device, put it into a low power state appropriate for the
 124 *      upcoming system state (such as PCI_D3hot), and enable wakeup events as
 125 *      appropriate.
 126 *
 127 * @restore: Hibernation-specific, executed after restoring the contents of main
 128 *      memory from a hibernation image.  Driver starts working again,
 129 *      responding to hardware events and software requests.  Drivers may NOT
 130 *      make ANY assumptions about the hardware state right prior to @restore().
 131 *      On most platforms, there are no restrictions on availability of
 132 *      resources like clocks during @restore().
 133 *
 134 * @suspend_noirq: Complete the operations of ->suspend() by carrying out any
 135 *      actions required for suspending the device that need interrupts to be
 136 *      disabled
 137 *
 138 * @resume_noirq: Prepare for the execution of ->resume() by carrying out any
 139 *      actions required for resuming the device that need interrupts to be
 140 *      disabled
 141 *
 142 * @freeze_noirq: Complete the operations of ->freeze() by carrying out any
 143 *      actions required for freezing the device that need interrupts to be
 144 *      disabled
 145 *
 146 * @thaw_noirq: Prepare for the execution of ->thaw() by carrying out any
 147 *      actions required for thawing the device that need interrupts to be
 148 *      disabled
 149 *
 150 * @poweroff_noirq: Complete the operations of ->poweroff() by carrying out any
 151 *      actions required for handling the device that need interrupts to be
 152 *      disabled
 153 *
 154 * @restore_noirq: Prepare for the execution of ->restore() by carrying out any
 155 *      actions required for restoring the operations of the device that need
 156 *      interrupts to be disabled
 157 *
 158 * All of the above callbacks, except for @complete(), return error codes.
 159 * However, the error codes returned by the resume operations, @resume(),
 160 * @thaw(), @restore(), @resume_noirq(), @thaw_noirq(), and @restore_noirq() do
 161 * not cause the PM core to abort the resume transition during which they are
 162 * returned.  The error codes returned in that cases are only printed by the PM
 163 * core to the system logs for debugging purposes.  Still, it is recommended
 164 * that drivers only return error codes from their resume methods in case of an
 165 * unrecoverable failure (i.e. when the device being handled refuses to resume
 166 * and becomes unusable) to allow us to modify the PM core in the future, so
 167 * that it can avoid attempting to handle devices that failed to resume and
 168 * their children.
 169 *
 170 * It is allowed to unregister devices while the above callbacks are being
 171 * executed.  However, it is not allowed to unregister a device from within any
 172 * of its own callbacks.
 173 *
 174 * There also are the following callbacks related to run-time power management
 175 * of devices:
 176 *
 177 * @runtime_suspend: Prepare the device for a condition in which it won't be
 178 *      able to communicate with the CPU(s) and RAM due to power management.
 179 *      This need not mean that the device should be put into a low power state.
 180 *      For example, if the device is behind a link which is about to be turned
 181 *      off, the device may remain at full power.  If the device does go to low
 182 *      power and is capable of generating run-time wake-up events, remote
 183 *      wake-up (i.e., a hardware mechanism allowing the device to request a
 184 *      change of its power state via a wake-up event, such as PCI PME) should
 185 *      be enabled for it.
 186 *
 187 * @runtime_resume: Put the device into the fully active state in response to a
 188 *      wake-up event generated by hardware or at the request of software.  If
 189 *      necessary, put the device into the full power state and restore its
 190 *      registers, so that it is fully operational.
 191 *
 192 * @runtime_idle: Device appears to be inactive and it might be put into a low
 193 *      power state if all of the necessary conditions are satisfied.  Check
 194 *      these conditions and handle the device as appropriate, possibly queueing
 195 *      a suspend request for it.  The return value is ignored by the PM core.
 196 */
 197
 198struct dev_pm_ops {
 199        int (*prepare)(struct device *dev);
 200        void (*complete)(struct device *dev);
 201        int (*suspend)(struct device *dev);
 202        int (*resume)(struct device *dev);
 203        int (*freeze)(struct device *dev);
 204        int (*thaw)(struct device *dev);
 205        int (*poweroff)(struct device *dev);
 206        int (*restore)(struct device *dev);
 207        int (*suspend_noirq)(struct device *dev);
 208        int (*resume_noirq)(struct device *dev);
 209        int (*freeze_noirq)(struct device *dev);
 210        int (*thaw_noirq)(struct device *dev);
 211        int (*poweroff_noirq)(struct device *dev);
 212        int (*restore_noirq)(struct device *dev);
 213        int (*runtime_suspend)(struct device *dev);
 214        int (*runtime_resume)(struct device *dev);
 215        int (*runtime_idle)(struct device *dev);
 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
 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) \
 244const 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) \
 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) \
 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
 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
 271/**
 272 * PM_EVENT_ messages
 273 *
 274 * The following PM_EVENT_ messages are defined for the internal use of the PM
 275 * core, in order to provide a mechanism allowing the high level suspend and
 276 * hibernation code to convey the necessary information to the device PM core
 277 * code:
 278 *
 279 * ON           No transition.
 280 *
 281 * FREEZE       System is going to hibernate, call ->prepare() and ->freeze()
 282 *              for all devices.
 283 *
 284 * SUSPEND      System is going to suspend, call ->prepare() and ->suspend()
 285 *              for all devices.
 286 *
 287 * HIBERNATE    Hibernation image has been saved, call ->prepare() and
 288 *              ->poweroff() for all devices.
 289 *
 290 * QUIESCE      Contents of main memory are going to be restored from a (loaded)
 291 *              hibernation image, call ->prepare() and ->freeze() for all
 292 *              devices.
 293 *
 294 * RESUME       System is resuming, call ->resume() and ->complete() for all
 295 *              devices.
 296 *
 297 * THAW         Hibernation image has been created, call ->thaw() and
 298 *              ->complete() for all devices.
 299 *
 300 * RESTORE      Contents of main memory have been restored from a hibernation
 301 *              image, call ->restore() and ->complete() for all devices.
 302 *
 303 * RECOVER      Creation of a hibernation image or restoration of the main
 304 *              memory contents from a hibernation image has failed, call
 305 *              ->thaw() and ->complete() for all devices.
 306 *
 307 * The following PM_EVENT_ messages are defined for internal use by
 308 * kernel subsystems.  They are never issued by the PM core.
 309 *
 310 * USER_SUSPEND         Manual selective suspend was issued by userspace.
 311 *
 312 * USER_RESUME          Manual selective resume was issued by userspace.
 313 *
 314 * REMOTE_WAKEUP        Remote-wakeup request was received from the device.
 315 *
 316 * AUTO_SUSPEND         Automatic (device idle) runtime suspend was
 317 *                      initiated by the subsystem.
 318 *
 319 * AUTO_RESUME          Automatic (device needed) runtime resume was
 320 *                      requested by a driver.
 321 */
 322
 323#define PM_EVENT_ON             0x0000
 324#define PM_EVENT_FREEZE         0x0001
 325#define PM_EVENT_SUSPEND        0x0002
 326#define PM_EVENT_HIBERNATE      0x0004
 327#define PM_EVENT_QUIESCE        0x0008
 328#define PM_EVENT_RESUME         0x0010
 329#define PM_EVENT_THAW           0x0020
 330#define PM_EVENT_RESTORE        0x0040
 331#define PM_EVENT_RECOVER        0x0080
 332#define PM_EVENT_USER           0x0100
 333#define PM_EVENT_REMOTE         0x0200
 334#define PM_EVENT_AUTO           0x0400
 335
 336#define PM_EVENT_SLEEP          (PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE)
 337#define PM_EVENT_USER_SUSPEND   (PM_EVENT_USER | PM_EVENT_SUSPEND)
 338#define PM_EVENT_USER_RESUME    (PM_EVENT_USER | PM_EVENT_RESUME)
 339#define PM_EVENT_REMOTE_RESUME  (PM_EVENT_REMOTE | PM_EVENT_RESUME)
 340#define PM_EVENT_AUTO_SUSPEND   (PM_EVENT_AUTO | PM_EVENT_SUSPEND)
 341#define PM_EVENT_AUTO_RESUME    (PM_EVENT_AUTO | PM_EVENT_RESUME)
 342
 343#define PMSG_ON         ((struct pm_message){ .event = PM_EVENT_ON, })
 344#define PMSG_FREEZE     ((struct pm_message){ .event = PM_EVENT_FREEZE, })
 345#define PMSG_QUIESCE    ((struct pm_message){ .event = PM_EVENT_QUIESCE, })
 346#define PMSG_SUSPEND    ((struct pm_message){ .event = PM_EVENT_SUSPEND, })
 347#define PMSG_HIBERNATE  ((struct pm_message){ .event = PM_EVENT_HIBERNATE, })
 348#define PMSG_RESUME     ((struct pm_message){ .event = PM_EVENT_RESUME, })
 349#define PMSG_THAW       ((struct pm_message){ .event = PM_EVENT_THAW, })
 350#define PMSG_RESTORE    ((struct pm_message){ .event = PM_EVENT_RESTORE, })
 351#define PMSG_RECOVER    ((struct pm_message){ .event = PM_EVENT_RECOVER, })
 352#define PMSG_USER_SUSPEND       ((struct pm_message) \
 353                                        { .event = PM_EVENT_USER_SUSPEND, })
 354#define PMSG_USER_RESUME        ((struct pm_message) \
 355                                        { .event = PM_EVENT_USER_RESUME, })
 356#define PMSG_REMOTE_RESUME      ((struct pm_message) \
 357                                        { .event = PM_EVENT_REMOTE_RESUME, })
 358#define PMSG_AUTO_SUSPEND       ((struct pm_message) \
 359                                        { .event = PM_EVENT_AUTO_SUSPEND, })
 360#define PMSG_AUTO_RESUME        ((struct pm_message) \
 361                                        { .event = PM_EVENT_AUTO_RESUME, })
 362
 363/**
 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.
 404 *
 405 * These status labels are used internally by the PM core to indicate the
 406 * current status of a device with respect to the PM core operations.  They do
 407 * not reflect the actual power state of the device or its status as seen by the
 408 * driver.
 409 *
 410 * RPM_ACTIVE           Device is fully operational.  Indicates that the device
 411 *                      bus type's ->runtime_resume() callback has completed
 412 *                      successfully.
 413 *
 414 * RPM_SUSPENDED        Device bus type's ->runtime_suspend() callback has
 415 *                      completed successfully.  The device is regarded as
 416 *                      suspended.
 417 *
 418 * RPM_RESUMING         Device bus type's ->runtime_resume() callback is being
 419 *                      executed.
 420 *
 421 * RPM_SUSPENDING       Device bus type's ->runtime_suspend() callback is being
 422 *                      executed.
 423 */
 424
 425enum rpm_status {
 426        RPM_ACTIVE = 0,
 427        RPM_RESUMING,
 428        RPM_SUSPENDED,
 429        RPM_SUSPENDING,
 430};
 431
 432/**
 433 * Device run-time power management request types.
 434 *
 435 * RPM_REQ_NONE         Do nothing.
 436 *
 437 * RPM_REQ_IDLE         Run the device bus type's ->runtime_idle() callback
 438 *
 439 * RPM_REQ_SUSPEND      Run the device bus type's ->runtime_suspend() callback
 440 *
 441 * RPM_REQ_RESUME       Run the device bus type's ->runtime_resume() callback
 442 */
 443
 444enum rpm_request {
 445        RPM_REQ_NONE = 0,
 446        RPM_REQ_IDLE,
 447        RPM_REQ_SUSPEND,
 448        RPM_REQ_RESUME,
 449};
 450
 451struct dev_pm_info {
 452        pm_message_t            power_state;
 453        unsigned int            can_wakeup:1;
 454        unsigned int            should_wakeup:1;
 455        unsigned                async_suspend:1;
 456        enum dpm_state          status;         /* Owned by the PM core */
 457#ifdef CONFIG_PM_SLEEP
 458        struct list_head        entry;
 459        struct completion       completion;
 460#endif
 461#ifdef CONFIG_PM_RUNTIME
 462        struct timer_list       suspend_timer;
 463        unsigned long           timer_expires;
 464        struct work_struct      work;
 465        wait_queue_head_t       wait_queue;
 466        spinlock_t              lock;
 467        atomic_t                usage_count;
 468        atomic_t                child_count;
 469        unsigned int            disable_depth:3;
 470        unsigned int            ignore_children:1;
 471        unsigned int            idle_notification:1;
 472        unsigned int            request_pending:1;
 473        unsigned int            deferred_resume:1;
 474        unsigned int            run_wake:1;
 475        unsigned int            runtime_auto:1;
 476        enum rpm_request        request;
 477        enum rpm_status         runtime_status;
 478        int                     runtime_error;
 479#endif
 480};
 481
 482/*
 483 * The PM_EVENT_ messages are also used by drivers implementing the legacy
 484 * suspend framework, based on the ->suspend() and ->resume() callbacks common
 485 * for suspend and hibernation transitions, according to the rules below.
 486 */
 487
 488/* Necessary, because several drivers use PM_EVENT_PRETHAW */
 489#define PM_EVENT_PRETHAW PM_EVENT_QUIESCE
 490
 491/*
 492 * One transition is triggered by resume(), after a suspend() call; the
 493 * message is implicit:
 494 *
 495 * ON           Driver starts working again, responding to hardware events
 496 *              and software requests.  The hardware may have gone through
 497 *              a power-off reset, or it may have maintained state from the
 498 *              previous suspend() which the driver will rely on while
 499 *              resuming.  On most platforms, there are no restrictions on
 500 *              availability of resources like clocks during resume().
 501 *
 502 * Other transitions are triggered by messages sent using suspend().  All
 503 * these transitions quiesce the driver, so that I/O queues are inactive.
 504 * That commonly entails turning off IRQs and DMA; there may be rules
 505 * about how to quiesce that are specific to the bus or the device's type.
 506 * (For example, network drivers mark the link state.)  Other details may
 507 * differ according to the message:
 508 *
 509 * SUSPEND      Quiesce, enter a low power device state appropriate for
 510 *              the upcoming system state (such as PCI_D3hot), and enable
 511 *              wakeup events as appropriate.
 512 *
 513 * HIBERNATE    Enter a low power device state appropriate for the hibernation
 514 *              state (eg. ACPI S4) and enable wakeup events as appropriate.
 515 *
 516 * FREEZE       Quiesce operations so that a consistent image can be saved;
 517 *              but do NOT otherwise enter a low power device state, and do
 518 *              NOT emit system wakeup events.
 519 *
 520 * PRETHAW      Quiesce as if for FREEZE; additionally, prepare for restoring
 521 *              the system from a snapshot taken after an earlier FREEZE.
 522 *              Some drivers will need to reset their hardware state instead
 523 *              of preserving it, to ensure that it's never mistaken for the
 524 *              state which that earlier snapshot had set up.
 525 *
 526 * A minimally power-aware driver treats all messages as SUSPEND, fully
 527 * reinitializes its device during resume() -- whether or not it was reset
 528 * during the suspend/resume cycle -- and can't issue wakeup events.
 529 *
 530 * More power-aware drivers may also use low power states at runtime as
 531 * well as during system sleep states like PM_SUSPEND_STANDBY.  They may
 532 * be able to use wakeup events to exit from runtime low-power states,
 533 * or from system low-power states such as standby or suspend-to-RAM.
 534 */
 535
 536#ifdef CONFIG_PM_SLEEP
 537extern void device_pm_lock(void);
 538extern int sysdev_resume(void);
 539extern void dpm_resume_noirq(pm_message_t state);
 540extern void dpm_resume_end(pm_message_t state);
 541
 542extern void device_pm_unlock(void);
 543extern int sysdev_suspend(pm_message_t state);
 544extern int dpm_suspend_noirq(pm_message_t state);
 545extern int dpm_suspend_start(pm_message_t state);
 546
 547extern void __suspend_report_result(const char *function, void *fn, int ret);
 548
 549#define suspend_report_result(fn, ret)                                  \
 550        do {                                                            \
 551                __suspend_report_result(__func__, fn, ret);             \
 552        } while (0)
 553
 554extern void device_pm_wait_for_dev(struct device *sub, struct device *dev);
 555#else /* !CONFIG_PM_SLEEP */
 556
 557#define device_pm_lock() do {} while (0)
 558#define device_pm_unlock() do {} while (0)
 559
 560static inline int dpm_suspend_start(pm_message_t state)
 561{
 562        return 0;
 563}
 564
 565#define suspend_report_result(fn, ret)          do {} while (0)
 566
 567static inline void device_pm_wait_for_dev(struct device *a, struct device *b) {}
 568#endif /* !CONFIG_PM_SLEEP */
 569
 570/* How to reorder dpm_list after device_move() */
 571enum dpm_order {
 572        DPM_ORDER_NONE,
 573        DPM_ORDER_DEV_AFTER_PARENT,
 574        DPM_ORDER_PARENT_BEFORE_DEV,
 575        DPM_ORDER_DEV_LAST,
 576};
 577
 578/*
 579 * Global Power Management flags
 580 * Used to keep APM and ACPI from both being active
 581 */
 582extern unsigned int     pm_flags;
 583
 584#define PM_APM  1
 585#define PM_ACPI 2
 586
 587#endif /* _LINUX_PM_H */
 588
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.