Blame view

include/linux/pm.h 32.1 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  /*
   *  pm.h - Power management interface
   *
   *  Copyright (C) 2000 Andrew Henroid
   *
   *  This program is free software; you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation; either version 2 of the License, or
   *  (at your option) any later version.
   *
   *  This program is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details.
   *
   *  You should have received a copy of the GNU General Public License
   *  along with this program; if not, write to the Free Software
   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   */
  
  #ifndef _LINUX_PM_H
  #define _LINUX_PM_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23
  #include <linux/list.h>
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
24
25
26
27
  #include <linux/workqueue.h>
  #include <linux/spinlock.h>
  #include <linux/wait.h>
  #include <linux/timer.h>
5af84b827   Rafael J. Wysocki   PM: Asynchronous ...
28
  #include <linux/completion.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
29
30
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
32
   * Callbacks for platform drivers to implement.
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33
  extern void (*pm_power_off)(void);
bd804eba1   Rafael J. Wysocki   PM: Introduce pm_...
34
  extern void (*pm_power_off_prepare)(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
35

f43f627d2   Jesse Barnes   PM: make VT switc...
36
37
38
39
40
41
42
43
44
45
46
47
  struct device; /* we have a circular dep with device.h */
  #ifdef CONFIG_VT_CONSOLE_SLEEP
  extern void pm_vt_switch_required(struct device *dev, bool required);
  extern void pm_vt_switch_unregister(struct device *dev);
  #else
  static inline void pm_vt_switch_required(struct device *dev, bool required)
  {
  }
  static inline void pm_vt_switch_unregister(struct device *dev)
  {
  }
  #endif /* CONFIG_VT_CONSOLE_SLEEP */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
48
49
50
51
52
  /*
   * Device power management
   */
  
  struct device;
7490e4423   Alan Stern   PM / Runtime: Add...
53
54
55
56
57
  #ifdef CONFIG_PM
  extern const char power_group_name[];		/* = "power" */
  #else
  #define power_group_name	NULL
  #endif
ca078bae8   Pavel Machek   [PATCH] swsusp: s...
58
59
60
  typedef struct pm_message {
  	int event;
  } pm_message_t;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
61

1eede070a   Rafael J. Wysocki   Introduce new top...
62
  /**
adf094931   Rafael J. Wysocki   PM: Simplify the ...
63
   * struct dev_pm_ops - device PM callbacks
1eede070a   Rafael J. Wysocki   Introduce new top...
64
   *
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
65
   * Several device power state transitions are externally visible, affecting
82bb67f2c   David Brownell   PM: define PM_EVE...
66
67
   * the state of pending I/O queues and (for drivers that touch hardware)
   * interrupts, wakeups, DMA, and other hardware state.  There may also be
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
68
   * internal transitions to various low-power modes which are transparent
82bb67f2c   David Brownell   PM: define PM_EVE...
69
70
   * to the rest of the driver stack (such as a driver that's ON gating off
   * clocks which are not in active use).
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71
   *
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
   * The externally visible transitions are handled with the help of callbacks
   * included in this structure in such a way that two levels of callbacks are
   * involved.  First, the PM core executes callbacks provided by PM domains,
   * device types, classes and bus types.  They are the subsystem-level callbacks
   * supposed to execute callbacks provided by device drivers, although they may
   * choose not to do that.  If the driver callbacks are executed, they have to
   * collaborate with the subsystem-level callbacks to achieve the goals
   * appropriate for the given system transition, given transition phase and the
   * subsystem the device belongs to.
   *
   * @prepare: The principal role of this callback is to prevent new children of
   *	the device from being registered after it has returned (the driver's
   *	subsystem and generally the rest of the kernel is supposed to prevent
   *	new calls to the probe method from being made too once @prepare() has
   *	succeeded).  If @prepare() detects a situation it cannot handle (e.g.
   *	registration of a child already in progress), it may return -EAGAIN, so
   *	that the PM core can execute it once again (e.g. after a new child has
   *	been registered) to recover from the race condition.
   *	This method is executed for all kinds of suspend transitions and is
   *	followed by one of the suspend callbacks: @suspend(), @freeze(), or
aae4518b3   Rafael J. Wysocki   PM / sleep: Mecha...
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
   *	@poweroff().  If the transition is a suspend to memory or standby (that
   *	is, not related to hibernation), the return value of @prepare() may be
   *	used to indicate to the PM core to leave the device in runtime suspend
   *	if applicable.  Namely, if @prepare() returns a positive number, the PM
   *	core will understand that as a declaration that the device appears to be
   *	runtime-suspended and it may be left in that state during the entire
   *	transition and during the subsequent resume if all of its descendants
   *	are left in runtime suspend too.  If that happens, @complete() will be
   *	executed directly after @prepare() and it must ensure the proper
   *	functioning of the device after the system resume.
   *	The PM core executes subsystem-level @prepare() for all devices before
   *	starting to invoke suspend callbacks for any of them, so generally
   *	devices may be assumed to be functional or to respond to runtime resume
   *	requests while @prepare() is being executed.  However, device drivers
   *	may NOT assume anything about the availability of user space at that
   *	time and it is NOT valid to request firmware from within @prepare()
   *	(it's too late to do that).  It also is NOT valid to allocate
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
109
110
111
   *	substantial amounts of memory from @prepare() in the GFP_KERNEL mode.
   *	[To work around these limitations, drivers may register suspend and
   *	hibernation notifiers to be executed before the freezing of tasks.]
1eede070a   Rafael J. Wysocki   Introduce new top...
112
113
114
115
   *
   * @complete: Undo the changes made by @prepare().  This method is executed for
   *	all kinds of resume transitions, following one of the resume callbacks:
   *	@resume(), @thaw(), @restore().  Also called if the state transition
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
116
117
   *	fails before the driver's suspend callback: @suspend(), @freeze() or
   *	@poweroff(), can be executed (e.g. if the suspend callback fails for one
1eede070a   Rafael J. Wysocki   Introduce new top...
118
119
   *	of the other devices that the PM core has unsuccessfully attempted to
   *	suspend earlier).
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
120
   *	The PM core executes subsystem-level @complete() after it has executed
aae4518b3   Rafael J. Wysocki   PM / sleep: Mecha...
121
122
123
124
125
126
127
128
129
130
   *	the appropriate resume callbacks for all devices.  If the corresponding
   *	@prepare() at the beginning of the suspend transition returned a
   *	positive number and the device was left in runtime suspend (without
   *	executing any suspend and resume callbacks for it), @complete() will be
   *	the only callback executed for the device during resume.  In that case,
   *	@complete() must be prepared to do whatever is necessary to ensure the
   *	proper functioning of the device after the system resume.  To this end,
   *	@complete() can check the power.direct_complete flag of the device to
   *	learn whether (unset) or not (set) the previous suspend and resume
   *	callbacks have been executed for it.
1eede070a   Rafael J. Wysocki   Introduce new top...
131
132
   *
   * @suspend: Executed before putting the system into a sleep state in which the
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
133
134
135
136
137
138
   *	contents of main memory are preserved.  The exact action to perform
   *	depends on the device's subsystem (PM domain, device type, class or bus
   *	type), but generally the device must be quiescent after subsystem-level
   *	@suspend() has returned, so that it doesn't do any I/O or DMA.
   *	Subsystem-level @suspend() is executed for all devices after invoking
   *	subsystem-level @prepare() for all of them.
1eede070a   Rafael J. Wysocki   Introduce new top...
139
   *
cf579dfb8   Rafael J. Wysocki   PM / Sleep: Intro...
140
141
142
143
   * @suspend_late: Continue operations started by @suspend().  For a number of
   *	devices @suspend_late() may point to the same callback routine as the
   *	runtime suspend callback.
   *
1eede070a   Rafael J. Wysocki   Introduce new top...
144
   * @resume: Executed after waking the system up from a sleep state in which the
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
145
146
147
148
149
150
151
152
153
154
   *	contents of main memory were preserved.  The exact action to perform
   *	depends on the device's subsystem, but generally the driver is expected
   *	to start working again, responding to hardware events and software
   *	requests (the device itself may be left in a low-power state, waiting
   *	for a runtime resume to occur).  The state of the device at the time its
   *	driver's @resume() callback is run depends on the platform and subsystem
   *	the device belongs to.  On most platforms, there are no restrictions on
   *	availability of resources like clocks during @resume().
   *	Subsystem-level @resume() is executed for all devices after invoking
   *	subsystem-level @resume_noirq() for all of them.
1eede070a   Rafael J. Wysocki   Introduce new top...
155
   *
cf579dfb8   Rafael J. Wysocki   PM / Sleep: Intro...
156
157
158
159
   * @resume_early: Prepare to execute @resume().  For a number of devices
   *	@resume_early() may point to the same callback routine as the runtime
   *	resume callback.
   *
1eede070a   Rafael J. Wysocki   Introduce new top...
160
   * @freeze: Hibernation-specific, executed before creating a hibernation image.
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
161
162
163
164
165
166
167
   *	Analogous to @suspend(), but it should not enable the device to signal
   *	wakeup events or change its power state.  The majority of subsystems
   *	(with the notable exception of the PCI bus type) expect the driver-level
   *	@freeze() to save the device settings in memory to be used by @restore()
   *	during the subsequent resume from hibernation.
   *	Subsystem-level @freeze() is executed for all devices after invoking
   *	subsystem-level @prepare() for all of them.
1eede070a   Rafael J. Wysocki   Introduce new top...
168
   *
cf579dfb8   Rafael J. Wysocki   PM / Sleep: Intro...
169
170
171
172
   * @freeze_late: Continue operations started by @freeze().  Analogous to
   *	@suspend_late(), but it should not enable the device to signal wakeup
   *	events or change its power state.
   *
1eede070a   Rafael J. Wysocki   Introduce new top...
173
   * @thaw: Hibernation-specific, executed after creating a hibernation image OR
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
174
   *	if the creation of an image has failed.  Also executed after a failing
1eede070a   Rafael J. Wysocki   Introduce new top...
175
176
177
   *	attempt to restore the contents of main memory from such an image.
   *	Undo the changes made by the preceding @freeze(), so the device can be
   *	operated in the same way as immediately before the call to @freeze().
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
178
179
180
   *	Subsystem-level @thaw() is executed for all devices after invoking
   *	subsystem-level @thaw_noirq() for all of them.  It also may be executed
   *	directly after @freeze() in case of a transition error.
1eede070a   Rafael J. Wysocki   Introduce new top...
181
   *
cf579dfb8   Rafael J. Wysocki   PM / Sleep: Intro...
182
183
184
   * @thaw_early: Prepare to execute @thaw().  Undo the changes made by the
   *	preceding @freeze_late().
   *
1eede070a   Rafael J. Wysocki   Introduce new top...
185
   * @poweroff: Hibernation-specific, executed after saving a hibernation image.
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
186
187
188
189
   *	Analogous to @suspend(), but it need not save the device's settings in
   *	memory.
   *	Subsystem-level @poweroff() is executed for all devices after invoking
   *	subsystem-level @prepare() for all of them.
1eede070a   Rafael J. Wysocki   Introduce new top...
190
   *
cf579dfb8   Rafael J. Wysocki   PM / Sleep: Intro...
191
192
193
   * @poweroff_late: Continue operations started by @poweroff().  Analogous to
   *	@suspend_late(), but it need not save the device's settings in memory.
   *
1eede070a   Rafael J. Wysocki   Introduce new top...
194
   * @restore: Hibernation-specific, executed after restoring the contents of main
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
195
196
   *	memory from a hibernation image, analogous to @resume().
   *
cf579dfb8   Rafael J. Wysocki   PM / Sleep: Intro...
197
198
   * @restore_early: Prepare to execute @restore(), analogous to @resume_early().
   *
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
199
200
201
202
203
204
205
206
207
   * @suspend_noirq: Complete the actions started by @suspend().  Carry out any
   *	additional operations required for suspending the device that might be
   *	racing with its driver's interrupt handler, which is guaranteed not to
   *	run while @suspend_noirq() is being executed.
   *	It generally is expected that the device will be in a low-power state
   *	(appropriate for the target system sleep state) after subsystem-level
   *	@suspend_noirq() has returned successfully.  If the device can generate
   *	system wakeup signals and is enabled to wake up the system, it should be
   *	configured to do so at that time.  However, depending on the platform
cf579dfb8   Rafael J. Wysocki   PM / Sleep: Intro...
208
209
210
211
   *	and device's subsystem, @suspend() or @suspend_late() may be allowed to
   *	put the device into the low-power state and configure it to generate
   *	wakeup signals, in which case it generally is not necessary to define
   *	@suspend_noirq().
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
212
213
214
215
216
217
218
219
220
221
   *
   * @resume_noirq: Prepare for the execution of @resume() by carrying out any
   *	operations required for resuming the device that might be racing with
   *	its driver's interrupt handler, which is guaranteed not to run while
   *	@resume_noirq() is being executed.
   *
   * @freeze_noirq: Complete the actions started by @freeze().  Carry out any
   *	additional operations required for freezing the device that might be
   *	racing with its driver's interrupt handler, which is guaranteed not to
   *	run while @freeze_noirq() is being executed.
cf579dfb8   Rafael J. Wysocki   PM / Sleep: Intro...
222
223
224
   *	The power state of the device should not be changed by either @freeze(),
   *	or @freeze_late(), or @freeze_noirq() and it should not be configured to
   *	signal system wakeup by any of these callbacks.
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
225
226
227
228
229
230
231
232
233
234
235
236
237
   *
   * @thaw_noirq: Prepare for the execution of @thaw() by carrying out any
   *	operations required for thawing the device that might be racing with its
   *	driver's interrupt handler, which is guaranteed not to run while
   *	@thaw_noirq() is being executed.
   *
   * @poweroff_noirq: Complete the actions started by @poweroff().  Analogous to
   *	@suspend_noirq(), but it need not save the device's settings in memory.
   *
   * @restore_noirq: Prepare for the execution of @restore() by carrying out any
   *	operations required for thawing the device that might be racing with its
   *	driver's interrupt handler, which is guaranteed not to run while
   *	@restore_noirq() is being executed.  Analogous to @resume_noirq().
1eede070a   Rafael J. Wysocki   Introduce new top...
238
   *
adf094931   Rafael J. Wysocki   PM: Simplify the ...
239
240
   * All of the above callbacks, except for @complete(), return error codes.
   * However, the error codes returned by the resume operations, @resume(),
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
241
   * @thaw(), @restore(), @resume_noirq(), @thaw_noirq(), and @restore_noirq(), do
adf094931   Rafael J. Wysocki   PM: Simplify the ...
242
   * not cause the PM core to abort the resume transition during which they are
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
243
   * returned.  The error codes returned in those cases are only printed by the PM
adf094931   Rafael J. Wysocki   PM: Simplify the ...
244
245
246
247
248
249
250
251
   * core to the system logs for debugging purposes.  Still, it is recommended
   * that drivers only return error codes from their resume methods in case of an
   * unrecoverable failure (i.e. when the device being handled refuses to resume
   * and becomes unusable) to allow us to modify the PM core in the future, so
   * that it can avoid attempting to handle devices that failed to resume and
   * their children.
   *
   * It is allowed to unregister devices while the above callbacks are being
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
252
253
254
255
256
257
258
   * executed.  However, a callback routine must NOT try to unregister the device
   * it was called for, although it may unregister children of that device (for
   * example, if it detects that a child was unplugged while the system was
   * asleep).
   *
   * Refer to Documentation/power/devices.txt for more information about the role
   * of the above callbacks in the system suspend process.
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
259
   *
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
260
261
262
263
264
265
   * There also are callbacks related to runtime power management of devices.
   * Again, these callbacks are executed by the PM core only for subsystems
   * (PM domains, device types, classes and bus types) and the subsystem-level
   * callbacks are supposed to invoke the driver callbacks.  Moreover, the exact
   * actions to be performed by a device driver's callbacks generally depend on
   * the platform and subsystem the device belongs to.
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
266
267
268
   *
   * @runtime_suspend: Prepare the device for a condition in which it won't be
   *	able to communicate with the CPU(s) and RAM due to power management.
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
269
   *	This need not mean that the device should be put into a low-power state.
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
270
271
   *	For example, if the device is behind a link which is about to be turned
   *	off, the device may remain at full power.  If the device does go to low
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
272
273
274
   *	power and is capable of generating runtime wakeup events, remote wakeup
   *	(i.e., a hardware mechanism allowing the device to request a change of
   *	its power state via an interrupt) should be enabled for it.
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
275
276
   *
   * @runtime_resume: Put the device into the fully active state in response to a
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
277
278
   *	wakeup event generated by hardware or at the request of software.  If
   *	necessary, put the device into the full-power state and restore its
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
279
280
   *	registers, so that it is fully operational.
   *
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
281
   * @runtime_idle: Device appears to be inactive and it might be put into a
651665dbf   Geert Uytterhoeven   PM / Runtime: Upd...
282
283
284
   *	low-power state if all of the necessary conditions are satisfied.
   *	Check these conditions, and return 0 if it's appropriate to let the PM
   *	core queue a suspend request for the device.
f7bc83d87   Rafael J. Wysocki   PM: Update commen...
285
286
287
288
   *
   * Refer to Documentation/power/runtime_pm.txt for more information about the
   * role of the above callbacks in device runtime power management.
   *
1eede070a   Rafael J. Wysocki   Introduce new top...
289
   */
adf094931   Rafael J. Wysocki   PM: Simplify the ...
290
291
292
293
294
295
296
297
298
  struct dev_pm_ops {
  	int (*prepare)(struct device *dev);
  	void (*complete)(struct device *dev);
  	int (*suspend)(struct device *dev);
  	int (*resume)(struct device *dev);
  	int (*freeze)(struct device *dev);
  	int (*thaw)(struct device *dev);
  	int (*poweroff)(struct device *dev);
  	int (*restore)(struct device *dev);
cf579dfb8   Rafael J. Wysocki   PM / Sleep: Intro...
299
300
301
302
303
304
  	int (*suspend_late)(struct device *dev);
  	int (*resume_early)(struct device *dev);
  	int (*freeze_late)(struct device *dev);
  	int (*thaw_early)(struct device *dev);
  	int (*poweroff_late)(struct device *dev);
  	int (*restore_early)(struct device *dev);
1eede070a   Rafael J. Wysocki   Introduce new top...
305
306
307
308
309
310
  	int (*suspend_noirq)(struct device *dev);
  	int (*resume_noirq)(struct device *dev);
  	int (*freeze_noirq)(struct device *dev);
  	int (*thaw_noirq)(struct device *dev);
  	int (*poweroff_noirq)(struct device *dev);
  	int (*restore_noirq)(struct device *dev);
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
311
312
313
  	int (*runtime_suspend)(struct device *dev);
  	int (*runtime_resume)(struct device *dev);
  	int (*runtime_idle)(struct device *dev);
1eede070a   Rafael J. Wysocki   Introduce new top...
314
  };
d690b2cd2   Rafael J. Wysocki   PM: Provide gener...
315
316
317
318
319
320
321
322
323
324
325
  #ifdef CONFIG_PM_SLEEP
  #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
  	.suspend = suspend_fn, \
  	.resume = resume_fn, \
  	.freeze = suspend_fn, \
  	.thaw = resume_fn, \
  	.poweroff = suspend_fn, \
  	.restore = resume_fn,
  #else
  #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
  #endif
f78c4cffb   Ulf Hansson   PM / Sleep: Add m...
326
327
328
329
330
331
332
333
334
335
336
  #ifdef CONFIG_PM_SLEEP
  #define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
  	.suspend_late = suspend_fn, \
  	.resume_early = resume_fn, \
  	.freeze_late = suspend_fn, \
  	.thaw_early = resume_fn, \
  	.poweroff_late = suspend_fn, \
  	.restore_early = resume_fn,
  #else
  #define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
  #endif
020af89a4   Grygorii Strashko   PM / sleep: Add m...
337
338
339
340
341
342
343
344
345
346
347
  #ifdef CONFIG_PM_SLEEP
  #define SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
  	.suspend_noirq = suspend_fn, \
  	.resume_noirq = resume_fn, \
  	.freeze_noirq = suspend_fn, \
  	.thaw_noirq = resume_fn, \
  	.poweroff_noirq = suspend_fn, \
  	.restore_noirq = resume_fn,
  #else
  #define SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
  #endif
6ed23b806   Rafael J. Wysocki   PM: Merge the SET...
348
  #ifdef CONFIG_PM
d690b2cd2   Rafael J. Wysocki   PM: Provide gener...
349
350
351
352
353
354
355
  #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
  	.runtime_suspend = suspend_fn, \
  	.runtime_resume = resume_fn, \
  	.runtime_idle = idle_fn,
  #else
  #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
  #endif
9d62ec6ca   Albin Tonnerre   PM: Add convenien...
356
357
358
359
360
  /*
   * Use this if you want to use the same suspend and resume callbacks for suspend
   * to RAM and hibernation.
   */
  #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
471452104   Alexey Dobriyan   const: constify r...
361
  const struct dev_pm_ops name = { \
d690b2cd2   Rafael J. Wysocki   PM: Provide gener...
362
363
364
365
366
  	SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
  }
  
  /*
   * Use this for defining a set of PM operations to be used in all situations
3e54d1518   Lad, Prabhakar   PM: fix typo in c...
367
   * (system suspend, hibernation or runtime PM).
c48825251   Rafael J. Wysocki   PM: Add comment d...
368
369
370
371
372
373
374
375
376
   * NOTE: In general, system suspend callbacks, .suspend() and .resume(), should
   * be different from the corresponding runtime PM callbacks, .runtime_suspend(),
   * and .runtime_resume(), because .runtime_suspend() always works on an already
   * quiescent device, while .suspend() should assume that the device may be doing
   * something when it is called (it should ensure that the device will be
   * quiescent after it has returned).  Therefore it's better to point the "late"
   * suspend and "early" resume callback pointers, .suspend_late() and
   * .resume_early(), to the same routines as .runtime_suspend() and
   * .runtime_resume(), respectively (and analogously for hibernation).
d690b2cd2   Rafael J. Wysocki   PM: Provide gener...
377
378
379
380
381
   */
  #define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
  const struct dev_pm_ops name = { \
  	SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
  	SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
9d62ec6ca   Albin Tonnerre   PM: Add convenien...
382
  }
1eede070a   Rafael J. Wysocki   Introduce new top...
383
384
385
386
387
388
389
390
391
392
  /**
   * PM_EVENT_ messages
   *
   * The following PM_EVENT_ messages are defined for the internal use of the PM
   * core, in order to provide a mechanism allowing the high level suspend and
   * hibernation code to convey the necessary information to the device PM core
   * code:
   *
   * ON		No transition.
   *
33fe0ad94   Geert Uytterhoeven   PM / sleep: Corre...
393
   * FREEZE	System is going to hibernate, call ->prepare() and ->freeze()
1eede070a   Rafael J. Wysocki   Introduce new top...
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
   *		for all devices.
   *
   * SUSPEND	System is going to suspend, call ->prepare() and ->suspend()
   *		for all devices.
   *
   * HIBERNATE	Hibernation image has been saved, call ->prepare() and
   *		->poweroff() for all devices.
   *
   * QUIESCE	Contents of main memory are going to be restored from a (loaded)
   *		hibernation image, call ->prepare() and ->freeze() for all
   *		devices.
   *
   * RESUME	System is resuming, call ->resume() and ->complete() for all
   *		devices.
   *
   * THAW		Hibernation image has been created, call ->thaw() and
   *		->complete() for all devices.
   *
   * RESTORE	Contents of main memory have been restored from a hibernation
   *		image, call ->restore() and ->complete() for all devices.
   *
   * RECOVER	Creation of a hibernation image or restoration of the main
   *		memory contents from a hibernation image has failed, call
   *		->thaw() and ->complete() for all devices.
8111d1b55   Alan Stern   pm: add new PM_EV...
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
   *
   * The following PM_EVENT_ messages are defined for internal use by
   * kernel subsystems.  They are never issued by the PM core.
   *
   * USER_SUSPEND		Manual selective suspend was issued by userspace.
   *
   * USER_RESUME		Manual selective resume was issued by userspace.
   *
   * REMOTE_WAKEUP	Remote-wakeup request was received from the device.
   *
   * AUTO_SUSPEND		Automatic (device idle) runtime suspend was
   *			initiated by the subsystem.
   *
   * AUTO_RESUME		Automatic (device needed) runtime resume was
   *			requested by a driver.
1eede070a   Rafael J. Wysocki   Introduce new top...
433
   */
1a9a91525   Rafael J. Wysocki   PM / QoS: Add fun...
434
  #define PM_EVENT_INVALID	(-1)
1eede070a   Rafael J. Wysocki   Introduce new top...
435
  #define PM_EVENT_ON		0x0000
33fe0ad94   Geert Uytterhoeven   PM / sleep: Corre...
436
  #define PM_EVENT_FREEZE		0x0001
1eede070a   Rafael J. Wysocki   Introduce new top...
437
438
439
440
441
442
443
  #define PM_EVENT_SUSPEND	0x0002
  #define PM_EVENT_HIBERNATE	0x0004
  #define PM_EVENT_QUIESCE	0x0008
  #define PM_EVENT_RESUME		0x0010
  #define PM_EVENT_THAW		0x0020
  #define PM_EVENT_RESTORE	0x0040
  #define PM_EVENT_RECOVER	0x0080
8111d1b55   Alan Stern   pm: add new PM_EV...
444
445
446
  #define PM_EVENT_USER		0x0100
  #define PM_EVENT_REMOTE		0x0200
  #define PM_EVENT_AUTO		0x0400
1eede070a   Rafael J. Wysocki   Introduce new top...
447

8111d1b55   Alan Stern   pm: add new PM_EV...
448
449
450
  #define PM_EVENT_SLEEP		(PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE)
  #define PM_EVENT_USER_SUSPEND	(PM_EVENT_USER | PM_EVENT_SUSPEND)
  #define PM_EVENT_USER_RESUME	(PM_EVENT_USER | PM_EVENT_RESUME)
7f4f5d451   Alan Stern   Fix misspellings ...
451
  #define PM_EVENT_REMOTE_RESUME	(PM_EVENT_REMOTE | PM_EVENT_RESUME)
8111d1b55   Alan Stern   pm: add new PM_EV...
452
453
  #define PM_EVENT_AUTO_SUSPEND	(PM_EVENT_AUTO | PM_EVENT_SUSPEND)
  #define PM_EVENT_AUTO_RESUME	(PM_EVENT_AUTO | PM_EVENT_RESUME)
1eede070a   Rafael J. Wysocki   Introduce new top...
454

1a9a91525   Rafael J. Wysocki   PM / QoS: Add fun...
455
  #define PMSG_INVALID	((struct pm_message){ .event = PM_EVENT_INVALID, })
8111d1b55   Alan Stern   pm: add new PM_EV...
456
  #define PMSG_ON		((struct pm_message){ .event = PM_EVENT_ON, })
1eede070a   Rafael J. Wysocki   Introduce new top...
457
458
459
460
461
462
463
464
  #define PMSG_FREEZE	((struct pm_message){ .event = PM_EVENT_FREEZE, })
  #define PMSG_QUIESCE	((struct pm_message){ .event = PM_EVENT_QUIESCE, })
  #define PMSG_SUSPEND	((struct pm_message){ .event = PM_EVENT_SUSPEND, })
  #define PMSG_HIBERNATE	((struct pm_message){ .event = PM_EVENT_HIBERNATE, })
  #define PMSG_RESUME	((struct pm_message){ .event = PM_EVENT_RESUME, })
  #define PMSG_THAW	((struct pm_message){ .event = PM_EVENT_THAW, })
  #define PMSG_RESTORE	((struct pm_message){ .event = PM_EVENT_RESTORE, })
  #define PMSG_RECOVER	((struct pm_message){ .event = PM_EVENT_RECOVER, })
7f4f5d451   Alan Stern   Fix misspellings ...
465
  #define PMSG_USER_SUSPEND	((struct pm_message) \
8111d1b55   Alan Stern   pm: add new PM_EV...
466
  					{ .event = PM_EVENT_USER_SUSPEND, })
7f4f5d451   Alan Stern   Fix misspellings ...
467
  #define PMSG_USER_RESUME	((struct pm_message) \
8111d1b55   Alan Stern   pm: add new PM_EV...
468
  					{ .event = PM_EVENT_USER_RESUME, })
7f4f5d451   Alan Stern   Fix misspellings ...
469
  #define PMSG_REMOTE_RESUME	((struct pm_message) \
8111d1b55   Alan Stern   pm: add new PM_EV...
470
  					{ .event = PM_EVENT_REMOTE_RESUME, })
7f4f5d451   Alan Stern   Fix misspellings ...
471
  #define PMSG_AUTO_SUSPEND	((struct pm_message) \
8111d1b55   Alan Stern   pm: add new PM_EV...
472
  					{ .event = PM_EVENT_AUTO_SUSPEND, })
7f4f5d451   Alan Stern   Fix misspellings ...
473
  #define PMSG_AUTO_RESUME	((struct pm_message) \
8111d1b55   Alan Stern   pm: add new PM_EV...
474
  					{ .event = PM_EVENT_AUTO_RESUME, })
1eede070a   Rafael J. Wysocki   Introduce new top...
475

5b1b0b812   Alan Stern   PM / Runtime: Add...
476
  #define PMSG_IS_AUTO(msg)	(((msg).event & PM_EVENT_AUTO) != 0)
1eede070a   Rafael J. Wysocki   Introduce new top...
477
  /**
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
   * Device run-time power management status.
   *
   * These status labels are used internally by the PM core to indicate the
   * current status of a device with respect to the PM core operations.  They do
   * not reflect the actual power state of the device or its status as seen by the
   * driver.
   *
   * RPM_ACTIVE		Device is fully operational.  Indicates that the device
   *			bus type's ->runtime_resume() callback has completed
   *			successfully.
   *
   * RPM_SUSPENDED	Device bus type's ->runtime_suspend() callback has
   *			completed successfully.  The device is regarded as
   *			suspended.
   *
   * RPM_RESUMING		Device bus type's ->runtime_resume() callback is being
   *			executed.
   *
   * RPM_SUSPENDING	Device bus type's ->runtime_suspend() callback is being
   *			executed.
   */
  
  enum rpm_status {
  	RPM_ACTIVE = 0,
  	RPM_RESUMING,
  	RPM_SUSPENDED,
  	RPM_SUSPENDING,
  };
  
  /**
   * Device run-time power management request types.
   *
   * RPM_REQ_NONE		Do nothing.
   *
   * RPM_REQ_IDLE		Run the device bus type's ->runtime_idle() callback
   *
   * RPM_REQ_SUSPEND	Run the device bus type's ->runtime_suspend() callback
   *
15bcb91d7   Alan Stern   PM / Runtime: Imp...
516
517
518
   * RPM_REQ_AUTOSUSPEND	Same as RPM_REQ_SUSPEND, but not until the device has
   *			been inactive for as long as power.autosuspend_delay
   *
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
519
520
521
522
523
524
525
   * RPM_REQ_RESUME	Run the device bus type's ->runtime_resume() callback
   */
  
  enum rpm_request {
  	RPM_REQ_NONE = 0,
  	RPM_REQ_IDLE,
  	RPM_REQ_SUSPEND,
15bcb91d7   Alan Stern   PM / Runtime: Imp...
526
  	RPM_REQ_AUTOSUSPEND,
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
527
528
  	RPM_REQ_RESUME,
  };
074037ec7   Rafael J. Wysocki   PM / Wakeup: Intr...
529
  struct wakeup_source;
4990d4fe3   Tony Lindgren   PM / Wakeirq: Add...
530
  struct wake_irq;
00e7c2959   Ulf Hansson   PM / Domains: Mov...
531
  struct pm_domain_data;
4605ab653   Rafael J. Wysocki   PM / Domains: Use...
532

5c095a0e0   Rafael J. Wysocki   PM: Introduce str...
533
534
  struct pm_subsys_data {
  	spinlock_t lock;
ef27bed18   Rafael J. Wysocki   PM: Reference cou...
535
  	unsigned int refcount;
5c095a0e0   Rafael J. Wysocki   PM: Introduce str...
536
537
538
  #ifdef CONFIG_PM_CLK
  	struct list_head clock_list;
  #endif
4605ab653   Rafael J. Wysocki   PM / Domains: Use...
539
  #ifdef CONFIG_PM_GENERIC_DOMAINS
cd0ea672f   Rafael J. Wysocki   PM / Domains: Spl...
540
  	struct pm_domain_data *domain_data;
4605ab653   Rafael J. Wysocki   PM / Domains: Use...
541
  #endif
5c095a0e0   Rafael J. Wysocki   PM: Introduce str...
542
  };
1eede070a   Rafael J. Wysocki   Introduce new top...
543
544
  struct dev_pm_info {
  	pm_message_t		power_state;
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
545
  	unsigned int		can_wakeup:1;
b8c76f6ae   Rafael J. Wysocki   PM: Replace the d...
546
  	unsigned int		async_suspend:1;
f76b168b6   Alan Stern   PM: Rename dev_pm...
547
  	bool			is_prepared:1;	/* Owned by the PM core */
6d0e0e84f   Alan Stern   PM: Fix async res...
548
  	bool			is_suspended:1;	/* Ditto */
3d2699bc1   Liu, Chuansheng   PM / sleep: Two f...
549
550
  	bool			is_noirq_suspended:1;
  	bool			is_late_suspended:1;
bed2b42d9   Rafael J. Wysocki   PM / Runtime: All...
551
  	bool			early_init:1;	/* Owned by the PM core */
aae4518b3   Rafael J. Wysocki   PM / sleep: Mecha...
552
  	bool			direct_complete:1;	/* Owned by the PM core */
074037ec7   Rafael J. Wysocki   PM / Wakeup: Intr...
553
  	spinlock_t		lock;
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
554
  #ifdef CONFIG_PM_SLEEP
1eede070a   Rafael J. Wysocki   Introduce new top...
555
  	struct list_head	entry;
5af84b827   Rafael J. Wysocki   PM: Asynchronous ...
556
  	struct completion	completion;
074037ec7   Rafael J. Wysocki   PM / Wakeup: Intr...
557
  	struct wakeup_source	*wakeup;
4ca46ff3e   Rafael J. Wysocki   PM / Sleep: Mark ...
558
  	bool			wakeup_path:1;
feb70af0e   Rafael J. Wysocki   PM: Do not use th...
559
  	bool			syscore:1;
aa8e54b55   Tomeu Vizoso   PM / sleep: Go di...
560
  	bool			no_pm_callbacks:1;	/* Owned by the PM core */
805bdaec1   Rafael J. Wysocki   PM: Make ACPI wak...
561
562
  #else
  	unsigned int		should_wakeup:1;
1eede070a   Rafael J. Wysocki   Introduce new top...
563
  #endif
d30d819dc   Rafael J. Wysocki   PM: Drop CONFIG_P...
564
  #ifdef CONFIG_PM
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
565
566
567
568
  	struct timer_list	suspend_timer;
  	unsigned long		timer_expires;
  	struct work_struct	work;
  	wait_queue_head_t	wait_queue;
4990d4fe3   Tony Lindgren   PM / Wakeirq: Add...
569
  	struct wake_irq		*wakeirq;
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
570
571
572
  	atomic_t		usage_count;
  	atomic_t		child_count;
  	unsigned int		disable_depth:3;
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
573
574
575
  	unsigned int		idle_notification:1;
  	unsigned int		request_pending:1;
  	unsigned int		deferred_resume:1;
7a1a8eb58   Rafael J. Wysocki   PM: Add flag for ...
576
  	unsigned int		run_wake:1;
538236391   Rafael J. Wysocki   PM / Runtime: Add...
577
  	unsigned int		runtime_auto:1;
372a12ed9   Ulf Hansson   PM / Runtime: Mov...
578
  	bool			ignore_children:1;
7490e4423   Alan Stern   PM / Runtime: Add...
579
  	unsigned int		no_callbacks:1;
c7b61de5b   Alan Stern   PM / Runtime: Add...
580
  	unsigned int		irq_safe:1;
15bcb91d7   Alan Stern   PM / Runtime: Imp...
581
582
  	unsigned int		use_autosuspend:1;
  	unsigned int		timer_autosuspends:1;
e823407f7   Ming Lei   pm / runtime: int...
583
  	unsigned int		memalloc_noio:1;
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
584
585
586
  	enum rpm_request	request;
  	enum rpm_status		runtime_status;
  	int			runtime_error;
15bcb91d7   Alan Stern   PM / Runtime: Imp...
587
588
  	int			autosuspend_delay;
  	unsigned long		last_busy;
8d4b9d1bf   Arjan van de Ven   PM / Runtime: Add...
589
590
591
  	unsigned long		active_jiffies;
  	unsigned long		suspended_jiffies;
  	unsigned long		accounting_timestamp;
5e928f77a   Rafael J. Wysocki   PM: Introduce cor...
592
  #endif
5c095a0e0   Rafael J. Wysocki   PM: Introduce str...
593
  	struct pm_subsys_data	*subsys_data;  /* Owned by the subsystem. */
2d984ad13   Rafael J. Wysocki   PM / QoS: Introcu...
594
  	void (*set_latency_tolerance)(struct device *, s32);
5f986c590   Rafael J. Wysocki   PM / QoS: Prepare...
595
  	struct dev_pm_qos	*qos;
1eede070a   Rafael J. Wysocki   Introduce new top...
596
  };
8d4b9d1bf   Arjan van de Ven   PM / Runtime: Add...
597
  extern void update_pm_runtime_accounting(struct device *dev);
ef27bed18   Rafael J. Wysocki   PM: Reference cou...
598
  extern int dev_pm_get_subsys_data(struct device *dev);
1e95e3b2d   Ulf Hansson   PM: Convert dev_p...
599
  extern void dev_pm_put_subsys_data(struct device *dev);
8d4b9d1bf   Arjan van de Ven   PM / Runtime: Add...
600

7538e3db6   Rafael J. Wysocki   PM: Add support f...
601
602
603
604
  /*
   * Power domains provide callbacks that are executed during system suspend,
   * hibernation, system resume and during runtime PM transitions along with
   * subsystem-level and driver-level callbacks.
e90d55327   Rafael J. Wysocki   driver core / PM:...
605
606
607
608
609
   *
   * @detach: Called when removing a device from the domain.
   * @activate: Called before executing probe routines for bus types and drivers.
   * @sync: Called after successful driver probe.
   * @dismiss: Called after unsuccessful driver probe and after driver removal.
7538e3db6   Rafael J. Wysocki   PM: Add support f...
610
   */
564b905ab   Rafael J. Wysocki   PM / Domains: Ren...
611
  struct dev_pm_domain {
7538e3db6   Rafael J. Wysocki   PM: Add support f...
612
  	struct dev_pm_ops	ops;
c3099a529   Ulf Hansson   PM / Domains: Add...
613
  	void (*detach)(struct device *dev, bool power_off);
e90d55327   Rafael J. Wysocki   driver core / PM:...
614
615
616
  	int (*activate)(struct device *dev);
  	void (*sync)(struct device *dev);
  	void (*dismiss)(struct device *dev);
7538e3db6   Rafael J. Wysocki   PM: Add support f...
617
  };
8d4b9d1bf   Arjan van de Ven   PM / Runtime: Add...
618

1eede070a   Rafael J. Wysocki   Introduce new top...
619
620
621
622
623
624
625
626
627
628
  /*
   * The PM_EVENT_ messages are also used by drivers implementing the legacy
   * suspend framework, based on the ->suspend() and ->resume() callbacks common
   * for suspend and hibernation transitions, according to the rules below.
   */
  
  /* Necessary, because several drivers use PM_EVENT_PRETHAW */
  #define PM_EVENT_PRETHAW PM_EVENT_QUIESCE
  
  /*
82bb67f2c   David Brownell   PM: define PM_EVE...
629
630
631
632
   * One transition is triggered by resume(), after a suspend() call; the
   * message is implicit:
   *
   * ON		Driver starts working again, responding to hardware events
33fe0ad94   Geert Uytterhoeven   PM / sleep: Corre...
633
634
635
636
637
   *		and software requests.  The hardware may have gone through
   *		a power-off reset, or it may have maintained state from the
   *		previous suspend() which the driver will rely on while
   *		resuming.  On most platforms, there are no restrictions on
   *		availability of resources like clocks during resume().
82bb67f2c   David Brownell   PM: define PM_EVE...
638
639
640
641
642
643
644
645
646
   *
   * Other transitions are triggered by messages sent using suspend().  All
   * these transitions quiesce the driver, so that I/O queues are inactive.
   * That commonly entails turning off IRQs and DMA; there may be rules
   * about how to quiesce that are specific to the bus or the device's type.
   * (For example, network drivers mark the link state.)  Other details may
   * differ according to the message:
   *
   * SUSPEND	Quiesce, enter a low power device state appropriate for
33fe0ad94   Geert Uytterhoeven   PM / sleep: Corre...
647
648
   *		the upcoming system state (such as PCI_D3hot), and enable
   *		wakeup events as appropriate.
82bb67f2c   David Brownell   PM: define PM_EVE...
649
   *
3a2d5b700   Rafael J. Wysocki   PM: Introduce PM_...
650
   * HIBERNATE	Enter a low power device state appropriate for the hibernation
33fe0ad94   Geert Uytterhoeven   PM / sleep: Corre...
651
   *		state (eg. ACPI S4) and enable wakeup events as appropriate.
3a2d5b700   Rafael J. Wysocki   PM: Introduce PM_...
652
   *
82bb67f2c   David Brownell   PM: define PM_EVE...
653
   * FREEZE	Quiesce operations so that a consistent image can be saved;
33fe0ad94   Geert Uytterhoeven   PM / sleep: Corre...
654
655
   *		but do NOT otherwise enter a low power device state, and do
   *		NOT emit system wakeup events.
82bb67f2c   David Brownell   PM: define PM_EVE...
656
657
   *
   * PRETHAW	Quiesce as if for FREEZE; additionally, prepare for restoring
33fe0ad94   Geert Uytterhoeven   PM / sleep: Corre...
658
659
660
661
   *		the system from a snapshot taken after an earlier FREEZE.
   *		Some drivers will need to reset their hardware state instead
   *		of preserving it, to ensure that it's never mistaken for the
   *		state which that earlier snapshot had set up.
82bb67f2c   David Brownell   PM: define PM_EVE...
662
663
664
665
666
667
668
669
670
   *
   * A minimally power-aware driver treats all messages as SUSPEND, fully
   * reinitializes its device during resume() -- whether or not it was reset
   * during the suspend/resume cycle -- and can't issue wakeup events.
   *
   * More power-aware drivers may also use low power states at runtime as
   * well as during system sleep states like PM_SUSPEND_STANDBY.  They may
   * be able to use wakeup events to exit from runtime low-power states,
   * or from system low-power states such as standby or suspend-to-RAM.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
671
   */
1eede070a   Rafael J. Wysocki   Introduce new top...
672
  #ifdef CONFIG_PM_SLEEP
d47d81c0e   Rafael J. Wysocki   Introduce ARCH_NO...
673
  extern void device_pm_lock(void);
cf579dfb8   Rafael J. Wysocki   PM / Sleep: Intro...
674
  extern void dpm_resume_start(pm_message_t state);
d16163029   Alan Stern   PM core: rename s...
675
  extern void dpm_resume_end(pm_message_t state);
2a8a8ce65   Rafael J. Wysocki   PM / sleep: Expor...
676
677
  extern void dpm_resume_noirq(pm_message_t state);
  extern void dpm_resume_early(pm_message_t state);
91e7c75ba   Rafael J. Wysocki   PM: Allow drivers...
678
679
  extern void dpm_resume(pm_message_t state);
  extern void dpm_complete(pm_message_t state);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
680

1eede070a   Rafael J. Wysocki   Introduce new top...
681
  extern void device_pm_unlock(void);
cf579dfb8   Rafael J. Wysocki   PM / Sleep: Intro...
682
  extern int dpm_suspend_end(pm_message_t state);
d16163029   Alan Stern   PM core: rename s...
683
  extern int dpm_suspend_start(pm_message_t state);
2a8a8ce65   Rafael J. Wysocki   PM / sleep: Expor...
684
685
  extern int dpm_suspend_noirq(pm_message_t state);
  extern int dpm_suspend_late(pm_message_t state);
91e7c75ba   Rafael J. Wysocki   PM: Allow drivers...
686
687
  extern int dpm_suspend(pm_message_t state);
  extern int dpm_prepare(pm_message_t state);
0ac85241e   David Brownell   [PATCH] driver mo...
688

026694920   Andrew Morton   [PATCH] pm: print...
689
690
691
692
  extern void __suspend_report_result(const char *function, void *fn, int ret);
  
  #define suspend_report_result(fn, ret)					\
  	do {								\
d5c003b4d   Harvey Harrison   include: replace ...
693
  		__suspend_report_result(__func__, fn, ret);		\
026694920   Andrew Morton   [PATCH] pm: print...
694
  	} while (0)
9a7834d06   Andrew Morton   [PATCH] USB: fix ...
695

098dff738   Rafael J. Wysocki   PM: Fix potential...
696
  extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);
dfe3212e0   Ming Lei   PM / Sleep: intro...
697
  extern void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *));
6538df801   Rafael J. Wysocki   PM: Introduce gen...
698
699
  
  extern int pm_generic_prepare(struct device *dev);
e470d0665   Rafael J. Wysocki   PM / Sleep: Intro...
700
  extern int pm_generic_suspend_late(struct device *dev);
e52919288   Rafael J. Wysocki   PM: Introduce gen...
701
  extern int pm_generic_suspend_noirq(struct device *dev);
6538df801   Rafael J. Wysocki   PM: Introduce gen...
702
  extern int pm_generic_suspend(struct device *dev);
e470d0665   Rafael J. Wysocki   PM / Sleep: Intro...
703
  extern int pm_generic_resume_early(struct device *dev);
e52919288   Rafael J. Wysocki   PM: Introduce gen...
704
  extern int pm_generic_resume_noirq(struct device *dev);
6538df801   Rafael J. Wysocki   PM: Introduce gen...
705
  extern int pm_generic_resume(struct device *dev);
e52919288   Rafael J. Wysocki   PM: Introduce gen...
706
  extern int pm_generic_freeze_noirq(struct device *dev);
e470d0665   Rafael J. Wysocki   PM / Sleep: Intro...
707
  extern int pm_generic_freeze_late(struct device *dev);
6538df801   Rafael J. Wysocki   PM: Introduce gen...
708
  extern int pm_generic_freeze(struct device *dev);
e52919288   Rafael J. Wysocki   PM: Introduce gen...
709
  extern int pm_generic_thaw_noirq(struct device *dev);
e470d0665   Rafael J. Wysocki   PM / Sleep: Intro...
710
  extern int pm_generic_thaw_early(struct device *dev);
6538df801   Rafael J. Wysocki   PM: Introduce gen...
711
  extern int pm_generic_thaw(struct device *dev);
e52919288   Rafael J. Wysocki   PM: Introduce gen...
712
  extern int pm_generic_restore_noirq(struct device *dev);
e470d0665   Rafael J. Wysocki   PM / Sleep: Intro...
713
  extern int pm_generic_restore_early(struct device *dev);
6538df801   Rafael J. Wysocki   PM: Introduce gen...
714
  extern int pm_generic_restore(struct device *dev);
e52919288   Rafael J. Wysocki   PM: Introduce gen...
715
  extern int pm_generic_poweroff_noirq(struct device *dev);
e470d0665   Rafael J. Wysocki   PM / Sleep: Intro...
716
  extern int pm_generic_poweroff_late(struct device *dev);
6538df801   Rafael J. Wysocki   PM: Introduce gen...
717
718
  extern int pm_generic_poweroff(struct device *dev);
  extern void pm_generic_complete(struct device *dev);
58a1fbbb2   Rafael J. Wysocki   PM / PCI / ACPI: ...
719
  extern void pm_complete_with_resume_check(struct device *dev);
6538df801   Rafael J. Wysocki   PM: Introduce gen...
720

d288e47c4   Alan Stern   PM: Make wakeup f...
721
  #else /* !CONFIG_PM_SLEEP */
ffa6a7054   Cornelia Huck   Driver core: Fix ...
722
723
  #define device_pm_lock() do {} while (0)
  #define device_pm_unlock() do {} while (0)
d16163029   Alan Stern   PM core: rename s...
724
  static inline int dpm_suspend_start(pm_message_t state)
d288e47c4   Alan Stern   PM: Make wakeup f...
725
726
727
  {
  	return 0;
  }
9a3df1f7d   Alan Stern   PM: Convert wakeu...
728
  #define suspend_report_result(fn, ret)		do {} while (0)
d288e47c4   Alan Stern   PM: Make wakeup f...
729

098dff738   Rafael J. Wysocki   PM: Fix potential...
730
731
732
733
  static inline int device_pm_wait_for_dev(struct device *a, struct device *b)
  {
  	return 0;
  }
6538df801   Rafael J. Wysocki   PM: Introduce gen...
734

dfe3212e0   Ming Lei   PM / Sleep: intro...
735
736
737
  static inline void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *))
  {
  }
0a9efc4d9   Ulf Hansson   PM / sleep: Set p...
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
  #define pm_generic_prepare		NULL
  #define pm_generic_suspend_late		NULL
  #define pm_generic_suspend_noirq	NULL
  #define pm_generic_suspend		NULL
  #define pm_generic_resume_early		NULL
  #define pm_generic_resume_noirq		NULL
  #define pm_generic_resume		NULL
  #define pm_generic_freeze_noirq		NULL
  #define pm_generic_freeze_late		NULL
  #define pm_generic_freeze		NULL
  #define pm_generic_thaw_noirq		NULL
  #define pm_generic_thaw_early		NULL
  #define pm_generic_thaw			NULL
  #define pm_generic_restore_noirq	NULL
  #define pm_generic_restore_early	NULL
  #define pm_generic_restore		NULL
  #define pm_generic_poweroff_noirq	NULL
  #define pm_generic_poweroff_late	NULL
  #define pm_generic_poweroff		NULL
  #define pm_generic_complete		NULL
d288e47c4   Alan Stern   PM: Make wakeup f...
758
  #endif /* !CONFIG_PM_SLEEP */
ffa6a7054   Cornelia Huck   Driver core: Fix ...
759
760
761
762
763
764
765
  /* How to reorder dpm_list after device_move() */
  enum dpm_order {
  	DPM_ORDER_NONE,
  	DPM_ORDER_DEV_AFTER_PARENT,
  	DPM_ORDER_PARENT_BEFORE_DEV,
  	DPM_ORDER_DEV_LAST,
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
766
  #endif /* _LINUX_PM_H */