2 * pm.h - Power management interface
4 * Copyright (C) 2000 Andrew Henroid
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.
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.
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
26 #include <linux/config.h>
27 #include <linux/list.h>
28 #include <asm/atomic.h>
31 * Power management requests
35 PM_SUSPEND, /* enter D1-D3 */
36 PM_RESUME, /* enter D0 */
38 PM_SAVE_STATE, /* save device's state */
43 /* bus resource management */
47 /* base station management */
52 typedef int pm_request_t;
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 */
71 * System device hardware ID (PnP) values
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 */
87 #define PM_PCI_ID(dev) ((dev)->bus->number << 16 | (dev)->devfn)
90 * Request handler callback
94 typedef int (*pm_callback)(struct pm_dev *dev, pm_request_t rqst, void *data);
97 * Dynamic device information
103 pm_callback callback;
108 unsigned long prev_state;
110 struct list_head entry;
115 extern int pm_active;
117 #define PM_IS_ACTIVE() (pm_active != 0)
120 * Register a device with power management
122 struct pm_dev *pm_register(pm_dev_t type,
124 pm_callback callback);
127 * Unregister a device with power management
129 void pm_unregister(struct pm_dev *dev);
132 * Unregister all devices with matching callback
134 void pm_unregister_all(pm_callback callback);
137 * Send a request to a single device
139 int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data);
142 * Send a request to all devices
144 int pm_send_all(pm_request_t rqst, void *data);
146 static inline void pm_access(struct pm_dev *dev) {}
147 static inline void pm_dev_idle(struct pm_dev *dev) {}
149 #else /* CONFIG_PM */
151 #define PM_IS_ACTIVE() 0
153 static inline struct pm_dev *pm_register(pm_dev_t type,
155 pm_callback callback)
160 static inline void pm_unregister(struct pm_dev *dev) {}
162 static inline void pm_unregister_all(pm_callback callback) {}
164 static inline int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data)
169 static inline int pm_send_all(pm_request_t rqst, void *data)
174 static inline struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from)
179 static inline void pm_access(struct pm_dev *dev) {}
180 static inline void pm_dev_idle(struct pm_dev *dev) {}
182 #endif /* CONFIG_PM */
186 * Callbacks for platform drivers to implement.
188 extern void (*pm_idle)(void);
189 extern void (*pm_power_off)(void);
191 typedef int __bitwise suspend_state_t;
193 #define PM_SUSPEND_ON ((__force suspend_state_t) 0)
194 #define PM_SUSPEND_STANDBY ((__force suspend_state_t) 1)
195 #define PM_SUSPEND_MEM ((__force suspend_state_t) 3)
196 #define PM_SUSPEND_DISK ((__force suspend_state_t) 4)
197 #define PM_SUSPEND_MAX ((__force suspend_state_t) 5)
199 typedef int __bitwise suspend_disk_method_t;
201 #define PM_DISK_FIRMWARE ((__force suspend_disk_method_t) 1)
202 #define PM_DISK_PLATFORM ((__force suspend_disk_method_t) 2)
203 #define PM_DISK_SHUTDOWN ((__force suspend_disk_method_t) 3)
204 #define PM_DISK_REBOOT ((__force suspend_disk_method_t) 4)
205 #define PM_DISK_MAX ((__force suspend_disk_method_t) 5)
208 suspend_disk_method_t pm_disk_mode;
209 int (*prepare)(suspend_state_t state);
210 int (*enter)(suspend_state_t state);
211 int (*finish)(suspend_state_t state);
214 extern void pm_set_ops(struct pm_ops *);
216 extern int pm_suspend(suspend_state_t state);
220 * Device power management
231 struct device * pm_parent;
232 struct list_head entry;
236 extern void device_pm_set_parent(struct device * dev, struct device * parent);
238 extern int device_suspend(u32 state);
239 extern int device_power_down(u32 state);
240 extern void device_power_up(void);
241 extern void device_resume(void);
244 #endif /* __KERNEL__ */
246 #endif /* _LINUX_PM_H */