linux-bk/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#ifdef __KERNEL__
  25
  26#include <linux/config.h>
  27#include <linux/list.h>
  28#include <asm/atomic.h>
  29
  30/*
  31 * Power management requests
  32 */
  33enum
  34{
  35        PM_SUSPEND, /* enter D1-D3 */
  36        PM_RESUME,  /* enter D0 */
  37
  38        PM_SAVE_STATE,  /* save device's state */
  39
  40        /* enable wake-on */
  41        PM_SET_WAKEUP,
  42
  43        /* bus resource management */
  44        PM_GET_RESOURCES,
  45        PM_SET_RESOURCES,
  46
  47        /* base station management */
  48        PM_EJECT,
  49        PM_LOCK,
  50};
  51
  52typedef int pm_request_t;
  53
  54/*
  55 * Device types
  56 */
  57enum
  58{
  59        PM_UNKNOWN_DEV = 0, /* generic */
  60        PM_SYS_DEV,         /* system device (fan, KB controller, ...) */
  61        PM_PCI_DEV,         /* PCI device */
  62        PM_USB_DEV,         /* USB device */
  63        PM_SCSI_DEV,        /* SCSI device */
  64        PM_ISA_DEV,         /* ISA device */
  65        PM_MTD_DEV,         /* Memory Technology Device */
  66};
  67
  68typedef int pm_dev_t;
  69
  70/*
  71 * System device hardware ID (PnP) values
  72 */
  73enum
  74{
  75        PM_SYS_UNKNOWN = 0x00000000, /* generic */
  76        PM_SYS_KBC =     0x41d00303, /* keyboard controller */
  77        PM_SYS_COM =     0x41d00500, /* serial port */
  78        PM_SYS_IRDA =    0x41d00510, /* IRDA controller */
  79        PM_SYS_FDC =     0x41d00700, /* floppy controller */
  80        PM_SYS_VGA =     0x41d00900, /* VGA controller */
  81        PM_SYS_PCMCIA =  0x41d00e00, /* PCMCIA controller */
  82};
  83
  84/*
  85 * Device identifier
  86 */
  87#define PM_PCI_ID(dev) ((dev)->bus->number << 16 | (dev)->devfn)
  88
  89/*
  90 * Request handler callback
  91 */
  92struct pm_dev;
  93
  94typedef int (*pm_callback)(struct pm_dev *dev, pm_request_t rqst, void *data);
  95
  96/*
  97 * Dynamic device information
  98 */
  99struct pm_dev
 100{
 101        pm_dev_t         type;
 102        unsigned long    id;
 103        pm_callback      callback;
 104        void            *data;
 105
 106        unsigned long    flags;
 107        unsigned long    state;
 108        unsigned long    prev_state;
 109
 110        struct list_head entry;
 111};
 112
 113#ifdef CONFIG_PM
 114
 115extern int pm_active;
 116
 117#define PM_IS_ACTIVE() (pm_active != 0)
 118
 119/*
 120 * Register a device with power management
 121 */
 122struct pm_dev *pm_register(pm_dev_t type,
 123                           unsigned long id,
 124                           pm_callback callback);
 125
 126/*
 127 * Unregister a device with power management
 128 */
 129void pm_unregister(struct pm_dev *dev);
 130
 131/*
 132 * Unregister all devices with matching callback
 133 */
 134void pm_unregister_all(pm_callback callback);
 135
 136/*
 137 * Send a request to a single device
 138 */
 139int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data);
 140
 141/*
 142 * Send a request to all devices
 143 */
 144int pm_send_all(pm_request_t rqst, void *data);
 145
 146/*
 147 * Find a device
 148 */
 149struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from);
 150
 151static inline void pm_access(struct pm_dev *dev) {}
 152static inline void pm_dev_idle(struct pm_dev *dev) {}
 153
 154#else /* CONFIG_PM */
 155
 156#define PM_IS_ACTIVE() 0
 157
 158static inline struct pm_dev *pm_register(pm_dev_t type,
 159                                         unsigned long id,
 160                                         pm_callback callback)
 161{
 162        return NULL;
 163}
 164
 165static inline void pm_unregister(struct pm_dev *dev) {}
 166
 167static inline void pm_unregister_all(pm_callback callback) {}
 168
 169static inline int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data)
 170{
 171        return 0;
 172}
 173
 174static inline int pm_send_all(pm_request_t rqst, void *data)
 175{
 176        return 0;
 177}
 178
 179static inline struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from)
 180{
 181        return 0;
 182}
 183
 184static inline void pm_access(struct pm_dev *dev) {}
 185static inline void pm_dev_idle(struct pm_dev *dev) {}
 186
 187#endif /* CONFIG_PM */
 188
 189
 190/*
 191 * Callbacks for platform drivers to implement.
 192 */
 193extern void (*pm_idle)(void);
 194extern void (*pm_power_off)(void);
 195
 196enum {
 197        PM_SUSPEND_ON,
 198        PM_SUSPEND_STANDBY,
 199        PM_SUSPEND_MEM,
 200        PM_SUSPEND_DISK,
 201        PM_SUSPEND_MAX,
 202};
 203
 204enum {
 205        PM_DISK_FIRMWARE = 1,
 206        PM_DISK_PLATFORM,
 207        PM_DISK_SHUTDOWN,
 208        PM_DISK_REBOOT,
 209        PM_DISK_MAX,
 210};
 211
 212
 213struct pm_ops {
 214        u32     pm_disk_mode;
 215        int (*prepare)(u32 state);
 216        int (*enter)(u32 state);
 217        int (*finish)(u32 state);
 218};
 219
 220extern void pm_set_ops(struct pm_ops *);
 221
 222extern int pm_suspend(u32 state);
 223
 224
 225/*
 226 * Device power management
 227 */
 228
 229struct device;
 230
 231struct dev_pm_info {
 232        u32                     power_state;
 233#ifdef  CONFIG_PM
 234        u32                     prev_state;
 235        u8                      * saved_state;
 236        atomic_t                pm_users;
 237        struct device           * pm_parent;
 238        struct list_head        entry;
 239#endif
 240};
 241
 242extern void device_pm_set_parent(struct device * dev, struct device * parent);
 243
 244extern int device_suspend(u32 state);
 245extern int device_power_down(u32 state);
 246extern void device_power_up(void);
 247extern void device_resume(void);
 248
 249
 250#endif /* __KERNEL__ */
 251
 252#endif /* _LINUX_PM_H */
 253
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.