source: GPL/trunk/include/linux/pm.h@ 679

Last change on this file since 679 was 679, checked in by David Azarewicz, 4 years ago

Merge changes from Paul's uniaud32next branch.

File size: 7.0 KB
Line 
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 <asm/atomic.h>
26#include <linux/workqueue.h>
27
28enum rpm_status {
29 RPM_ACTIVE = 0,
30 RPM_RESUMING,
31 RPM_SUSPENDED,
32 RPM_SUSPENDING,
33};
34
35/*
36 * Power management requests
37 */
38enum
39{
40 PM_SUSPEND, /* enter D1-D3 */
41 PM_RESUME, /* enter D0 */
42
43 PM_SAVE_STATE, /* save device's state */
44
45 /* enable wake-on */
46 PM_SET_WAKEUP,
47
48 /* bus resource management */
49 PM_GET_RESOURCES,
50 PM_SET_RESOURCES,
51
52 /* base station management */
53 PM_EJECT,
54 PM_LOCK,
55};
56
57typedef int pm_request_t;
58
59/*
60 * Device types
61 */
62enum
63{
64 PM_UNKNOWN_DEV = 0, /* generic */
65 PM_SYS_DEV, /* system device (fan, KB controller, ...) */
66 PM_PCI_DEV, /* PCI device */
67 PM_USB_DEV, /* USB device */
68 PM_SCSI_DEV, /* SCSI device */
69 PM_ISA_DEV, /* ISA device */
70 PM_MTD_DEV, /* Memory Technology Device */
71};
72
73typedef int pm_dev_t;
74
75/*
76 * System device hardware ID (PnP) values
77 */
78enum
79{
80 PM_SYS_UNKNOWN = 0x00000000, /* generic */
81 PM_SYS_KBC = 0x41d00303, /* keyboard controller */
82 PM_SYS_COM = 0x41d00500, /* serial port */
83 PM_SYS_IRDA = 0x41d00510, /* IRDA controller */
84 PM_SYS_FDC = 0x41d00700, /* floppy controller */
85 PM_SYS_VGA = 0x41d00900, /* VGA controller */
86 PM_SYS_PCMCIA = 0x41d00e00, /* PCMCIA controller */
87};
88
89/*
90 * Device identifier
91 */
92#define PM_PCI_ID(dev) ((dev)->bus->number << 16 | (dev)->devfn)
93
94/*
95 * Request handler callback
96 */
97struct pm_dev;
98
99typedef int (*pm_callback)(struct pm_dev *dev, pm_request_t rqst, void *data);
100
101/*
102 * Dynamic device information
103 */
104struct pm_dev
105{
106 pm_dev_t type;
107 unsigned long id;
108 pm_callback callback;
109 void *data;
110
111 unsigned long flags;
112 unsigned long state;
113 unsigned long prev_state;
114
115 struct list_head entry;
116};
117
118#ifdef CONFIG_PM
119
120extern int pm_active;
121
122#define PM_IS_ACTIVE() (pm_active != 0)
123
124/*
125 * Register a device with power management
126 */
127struct pm_dev *pm_register(pm_dev_t type,
128 unsigned long id,
129 pm_callback callback);
130
131/*
132 * Unregister a device with power management
133 */
134void pm_unregister(struct pm_dev *dev);
135
136/*
137 * Unregister all devices with matching callback
138 */
139void pm_unregister_all(pm_callback callback);
140
141/*
142 * Send a request to a single device
143 */
144int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data);
145
146/*
147 * Send a request to all devices
148 */
149int pm_send_all(pm_request_t rqst, void *data);
150
151/*
152 * Find a device
153 */
154struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from);
155
156static inline void pm_access(struct pm_dev *dev) {}
157static inline void pm_dev_idle(struct pm_dev *dev) {}
158
159#else /* CONFIG_PM */
160
161#define PM_IS_ACTIVE() 0
162
163static inline struct pm_dev *pm_register(pm_dev_t type,
164 unsigned long id,
165 pm_callback callback)
166{
167 return 0;
168}
169
170static inline void pm_unregister(struct pm_dev *dev) {}
171
172static inline void pm_unregister_all(pm_callback callback) {}
173
174static inline int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data)
175{
176 return 0;
177}
178
179static inline int pm_send_all(pm_request_t rqst, void *data)
180{
181 return 0;
182}
183
184static inline struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from)
185{
186 return 0;
187}
188
189static inline void pm_access(struct pm_dev *dev) {}
190static inline void pm_dev_idle(struct pm_dev *dev) {}
191
192#endif /* CONFIG_PM */
193
194
195/*
196 * Callbacks for platform drivers to implement.
197 */
198extern void (*pm_idle)(void);
199extern void (*pm_power_off)(void);
200
201enum {
202 PM_SUSPEND_ON,
203 PM_SUSPEND_STANDBY,
204 PM_SUSPEND_MEM,
205 PM_SUSPEND_DISK,
206 PM_SUSPEND_MAX,
207};
208
209enum {
210 PM_DISK_FIRMWARE = 1,
211 PM_DISK_PLATFORM,
212 PM_DISK_SHUTDOWN,
213 PM_DISK_REBOOT,
214 PM_DISK_MAX,
215};
216
217
218struct pm_ops {
219 u32 pm_disk_mode;
220 int (*prepare)(u32 state);
221 int (*enter)(u32 state);
222 int (*finish)(u32 state);
223};
224
225extern void pm_set_ops(struct pm_ops *);
226
227extern int pm_suspend(u32 state);
228
229
230/*
231 * Device power management
232 */
233
234struct device;
235
236struct dev_pm_info {
237 unsigned int async_suspend:1;
238 bool is_prepared:1; /* Owned by the PM core */
239 u32 power_state;
240 u8 * saved_state;
241 atomic_t pm_users;
242 struct device * pm_parent;
243 struct list_head entry;
244};
245
246extern void device_pm_set_parent(struct device * dev, struct device * parent);
247
248extern int device_suspend(u32 state);
249extern int device_power_down(u32 state);
250extern void device_power_up(void);
251extern void device_resume(void);
252
253
254typedef struct pm_message {
255 int event;
256} pm_message_t;
257
258#define PMSG_FREEZE 3
259#define PMSG_SUSPEND 3
260#define PMSG_ON 0
261#define PMSG_RESUME 0
262#define PMSG_THAW 0
263#define PMSG_RESTORE 0
264
265
266struct dev_pm_ops {
267 int (*prepare)(struct device *dev);
268 void (*complete)(struct device *dev);
269 int (*suspend)(struct device *dev);
270 int (*resume)(struct device *dev);
271 int (*freeze)(struct device *dev);
272 int (*thaw)(struct device *dev);
273 int (*poweroff)(struct device *dev);
274 int (*restore)(struct device *dev);
275 int (*suspend_late)(struct device *dev);
276 int (*resume_early)(struct device *dev);
277 int (*freeze_late)(struct device *dev);
278 int (*thaw_early)(struct device *dev);
279 int (*poweroff_late)(struct device *dev);
280 int (*restore_early)(struct device *dev);
281 int (*suspend_noirq)(struct device *dev);
282 int (*resume_noirq)(struct device *dev);
283 int (*freeze_noirq)(struct device *dev);
284 int (*thaw_noirq)(struct device *dev);
285 int (*poweroff_noirq)(struct device *dev);
286 int (*restore_noirq)(struct device *dev);
287 int (*runtime_suspend)(struct device *dev);
288 int (*runtime_resume)(struct device *dev);
289 int (*runtime_idle)(struct device *dev);
290};
291
292#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
293 .suspend = suspend_fn, \
294 .resume = resume_fn, \
295 .freeze = suspend_fn, \
296 .thaw = resume_fn, \
297 .poweroff = suspend_fn, \
298 .restore = resume_fn,
299
300/*
301 * Use this if you want to use the same suspend and resume callbacks for suspend
302 * to RAM and hibernation.
303 */
304#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
305const struct dev_pm_ops name = { \
306 SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
307}
308
309#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
310 .runtime_suspend = suspend_fn, \
311 .runtime_resume = resume_fn, \
312 .runtime_idle = idle_fn,
313
314
315/*
316 * Power domains provide callbacks that are executed during system suspend,
317 * hibernation, system resume and during runtime PM transitions along with
318 * subsystem-level and driver-level callbacks.
319 */
320struct dev_pm_domain {
321 struct dev_pm_ops ops;
322};
323
324#define PM_EVENT_RESTORE 0x0040
325
326#endif /* _LINUX_PM_H */
Note: See TracBrowser for help on using the repository browser.