- Kai Germaschewski: ymfpci cleanups and resource leak fixes
[davej-history.git] / include / linux / pm.h
blobce31f81a640bee7ed10c329485cb3b633e4a78cf
1 /*
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
21 #ifndef _LINUX_PM_H
22 #define _LINUX_PM_H
24 #ifdef __KERNEL__
26 #include <linux/config.h>
27 #include <linux/list.h>
30 * Power management requests
32 enum
34 PM_SUSPEND, /* enter D1-D3 */
35 PM_RESUME, /* enter D0 */
37 /* enable wake-on */
38 PM_SET_WAKEUP,
40 /* bus resource management */
41 PM_GET_RESOURCES,
42 PM_SET_RESOURCES,
44 /* base station management */
45 PM_EJECT,
46 PM_LOCK,
49 typedef int pm_request_t;
52 * Device types
54 enum
56 PM_UNKNOWN_DEV = 0, /* generic */
57 PM_SYS_DEV, /* system device (fan, KB controller, ...) */
58 PM_PCI_DEV, /* PCI device */
59 PM_USB_DEV, /* USB device */
60 PM_SCSI_DEV, /* SCSI device */
61 PM_ISA_DEV, /* ISA device */
62 PM_MTD_DEV, /* Memory Technology Device */
65 typedef int pm_dev_t;
68 * System device hardware ID (PnP) values
70 enum
72 PM_SYS_UNKNOWN = 0x00000000, /* generic */
73 PM_SYS_KBC = 0x41d00303, /* keyboard controller */
74 PM_SYS_COM = 0x41d00500, /* serial port */
75 PM_SYS_IRDA = 0x41d00510, /* IRDA controller */
76 PM_SYS_FDC = 0x41d00700, /* floppy controller */
77 PM_SYS_VGA = 0x41d00900, /* VGA controller */
78 PM_SYS_PCMCIA = 0x41d00e00, /* PCMCIA controller */
82 * Device identifier
84 #define PM_PCI_ID(dev) ((dev)->bus->number << 16 | (dev)->devfn)
87 * Request handler callback
89 struct pm_dev;
91 typedef int (*pm_callback)(struct pm_dev *dev, pm_request_t rqst, void *data);
94 * Dynamic device information
96 struct pm_dev
98 pm_dev_t type;
99 unsigned long id;
100 pm_callback callback;
101 void *data;
103 unsigned long flags;
104 int state;
105 int prev_state;
107 struct list_head entry;
110 #ifdef CONFIG_PM
112 extern int pm_active;
114 #define PM_IS_ACTIVE() (pm_active != 0)
117 * Register a device with power management
119 struct pm_dev *pm_register(pm_dev_t type,
120 unsigned long id,
121 pm_callback callback);
124 * Unregister a device with power management
126 void pm_unregister(struct pm_dev *dev);
129 * Unregister all devices with matching callback
131 void pm_unregister_all(pm_callback callback);
134 * Send a request to a single device
136 int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data);
139 * Send a request to all devices
141 int pm_send_all(pm_request_t rqst, void *data);
144 * Find a device
146 struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from);
148 extern inline void pm_access(struct pm_dev *dev) {}
149 extern inline void pm_dev_idle(struct pm_dev *dev) {}
151 #else /* CONFIG_PM */
153 #define PM_IS_ACTIVE() 0
155 extern inline struct pm_dev *pm_register(pm_dev_t type,
156 unsigned long id,
157 pm_callback callback)
159 return 0;
162 extern inline void pm_unregister(struct pm_dev *dev) {}
164 extern inline void pm_unregister_all(pm_callback callback) {}
166 extern inline int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data)
168 return 0;
171 extern inline int pm_send_all(pm_request_t rqst, void *data)
173 return 0;
176 extern inline struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from)
178 return 0;
181 extern inline void pm_access(struct pm_dev *dev) {}
182 extern inline void pm_dev_idle(struct pm_dev *dev) {}
184 #endif /* CONFIG_PM */
186 extern void (*pm_idle)(void);
187 extern void (*pm_power_off)(void);
189 #endif /* __KERNEL__ */
191 #endif /* _LINUX_PM_H */