pm.h revision c7b61de5b7b17f0df34dc7d2f8b9576f8bd36fce
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 <linux/workqueue.h>
26#include <linux/spinlock.h>
27#include <linux/wait.h>
28#include <linux/timer.h>
29#include <linux/completion.h>
30
31/*
32 * Callbacks for platform drivers to implement.
33 */
34extern void (*pm_idle)(void);
35extern void (*pm_power_off)(void);
36extern void (*pm_power_off_prepare)(void);
37
38/*
39 * Device power management
40 */
41
42struct device;
43
44#ifdef CONFIG_PM
45extern const char power_group_name[];		/* = "power" */
46#else
47#define power_group_name	NULL
48#endif
49
50typedef struct pm_message {
51	int event;
52} pm_message_t;
53
54/**
55 * struct dev_pm_ops - device PM callbacks
56 *
57 * Several driver power state transitions are externally visible, affecting
58 * the state of pending I/O queues and (for drivers that touch hardware)
59 * interrupts, wakeups, DMA, and other hardware state.  There may also be
60 * internal transitions to various low power modes, which are transparent
61 * to the rest of the driver stack (such as a driver that's ON gating off
62 * clocks which are not in active use).
63 *
64 * The externally visible transitions are handled with the help of the following
65 * callbacks included in this structure:
66 *
67 * @prepare: Prepare the device for the upcoming transition, but do NOT change
68 *	its hardware state.  Prevent new children of the device from being
69 *	registered after @prepare() returns (the driver's subsystem and
70 *	generally the rest of the kernel is supposed to prevent new calls to the
71 *	probe method from being made too once @prepare() has succeeded).  If
72 *	@prepare() detects a situation it cannot handle (e.g. registration of a
73 *	child already in progress), it may return -EAGAIN, so that the PM core
74 *	can execute it once again (e.g. after the new child has been registered)
75 *	to recover from the race condition.  This method is executed for all
76 *	kinds of suspend transitions and is followed by one of the suspend
77 *	callbacks: @suspend(), @freeze(), or @poweroff().
78 *	The PM core executes @prepare() for all devices before starting to
79 *	execute suspend callbacks for any of them, so drivers may assume all of
80 *	the other devices to be present and functional while @prepare() is being
81 *	executed.  In particular, it is safe to make GFP_KERNEL memory
82 *	allocations from within @prepare().  However, drivers may NOT assume
83 *	anything about the availability of the user space at that time and it
84 *	is not correct to request firmware from within @prepare() (it's too
85 *	late to do that).  [To work around this limitation, drivers may
86 *	register suspend and hibernation notifiers that are executed before the
87 *	freezing of tasks.]
88 *
89 * @complete: Undo the changes made by @prepare().  This method is executed for
90 *	all kinds of resume transitions, following one of the resume callbacks:
91 *	@resume(), @thaw(), @restore().  Also called if the state transition
92 *	fails before the driver's suspend callback (@suspend(), @freeze(),
93 *	@poweroff()) can be executed (e.g. if the suspend callback fails for one
94 *	of the other devices that the PM core has unsuccessfully attempted to
95 *	suspend earlier).
96 *	The PM core executes @complete() after it has executed the appropriate
97 *	resume callback for all devices.
98 *
99 * @suspend: Executed before putting the system into a sleep state in which the
100 *	contents of main memory are preserved.  Quiesce the device, put it into
101 *	a low power state appropriate for the upcoming system state (such as
102 *	PCI_D3hot), and enable wakeup events as appropriate.
103 *
104 * @resume: Executed after waking the system up from a sleep state in which the
105 *	contents of main memory were preserved.  Put the device into the
106 *	appropriate state, according to the information saved in memory by the
107 *	preceding @suspend().  The driver starts working again, responding to
108 *	hardware events and software requests.  The hardware may have gone
109 *	through a power-off reset, or it may have maintained state from the
110 *	previous suspend() which the driver may rely on while resuming.  On most
111 *	platforms, there are no restrictions on availability of resources like
112 *	clocks during @resume().
113 *
114 * @freeze: Hibernation-specific, executed before creating a hibernation image.
115 *	Quiesce operations so that a consistent image can be created, but do NOT
116 *	otherwise put the device into a low power device state and do NOT emit
117 *	system wakeup events.  Save in main memory the device settings to be
118 *	used by @restore() during the subsequent resume from hibernation or by
119 *	the subsequent @thaw(), if the creation of the image or the restoration
120 *	of main memory contents from it fails.
121 *
122 * @thaw: Hibernation-specific, executed after creating a hibernation image OR
123 *	if the creation of the image fails.  Also executed after a failing
124 *	attempt to restore the contents of main memory from such an image.
125 *	Undo the changes made by the preceding @freeze(), so the device can be
126 *	operated in the same way as immediately before the call to @freeze().
127 *
128 * @poweroff: Hibernation-specific, executed after saving a hibernation image.
129 *	Quiesce the device, put it into a low power state appropriate for the
130 *	upcoming system state (such as PCI_D3hot), and enable wakeup events as
131 *	appropriate.
132 *
133 * @restore: Hibernation-specific, executed after restoring the contents of main
134 *	memory from a hibernation image.  Driver starts working again,
135 *	responding to hardware events and software requests.  Drivers may NOT
136 *	make ANY assumptions about the hardware state right prior to @restore().
137 *	On most platforms, there are no restrictions on availability of
138 *	resources like clocks during @restore().
139 *
140 * @suspend_noirq: Complete the operations of ->suspend() by carrying out any
141 *	actions required for suspending the device that need interrupts to be
142 *	disabled
143 *
144 * @resume_noirq: Prepare for the execution of ->resume() by carrying out any
145 *	actions required for resuming the device that need interrupts to be
146 *	disabled
147 *
148 * @freeze_noirq: Complete the operations of ->freeze() by carrying out any
149 *	actions required for freezing the device that need interrupts to be
150 *	disabled
151 *
152 * @thaw_noirq: Prepare for the execution of ->thaw() by carrying out any
153 *	actions required for thawing the device that need interrupts to be
154 *	disabled
155 *
156 * @poweroff_noirq: Complete the operations of ->poweroff() by carrying out any
157 *	actions required for handling the device that need interrupts to be
158 *	disabled
159 *
160 * @restore_noirq: Prepare for the execution of ->restore() by carrying out any
161 *	actions required for restoring the operations of the device that need
162 *	interrupts to be disabled
163 *
164 * All of the above callbacks, except for @complete(), return error codes.
165 * However, the error codes returned by the resume operations, @resume(),
166 * @thaw(), @restore(), @resume_noirq(), @thaw_noirq(), and @restore_noirq() do
167 * not cause the PM core to abort the resume transition during which they are
168 * returned.  The error codes returned in that cases are only printed by the PM
169 * core to the system logs for debugging purposes.  Still, it is recommended
170 * that drivers only return error codes from their resume methods in case of an
171 * unrecoverable failure (i.e. when the device being handled refuses to resume
172 * and becomes unusable) to allow us to modify the PM core in the future, so
173 * that it can avoid attempting to handle devices that failed to resume and
174 * their children.
175 *
176 * It is allowed to unregister devices while the above callbacks are being
177 * executed.  However, it is not allowed to unregister a device from within any
178 * of its own callbacks.
179 *
180 * There also are the following callbacks related to run-time power management
181 * of devices:
182 *
183 * @runtime_suspend: Prepare the device for a condition in which it won't be
184 *	able to communicate with the CPU(s) and RAM due to power management.
185 *	This need not mean that the device should be put into a low power state.
186 *	For example, if the device is behind a link which is about to be turned
187 *	off, the device may remain at full power.  If the device does go to low
188 *	power and is capable of generating run-time wake-up events, remote
189 *	wake-up (i.e., a hardware mechanism allowing the device to request a
190 *	change of its power state via a wake-up event, such as PCI PME) should
191 *	be enabled for it.
192 *
193 * @runtime_resume: Put the device into the fully active state in response to a
194 *	wake-up event generated by hardware or at the request of software.  If
195 *	necessary, put the device into the full power state and restore its
196 *	registers, so that it is fully operational.
197 *
198 * @runtime_idle: Device appears to be inactive and it might be put into a low
199 *	power state if all of the necessary conditions are satisfied.  Check
200 *	these conditions and handle the device as appropriate, possibly queueing
201 *	a suspend request for it.  The return value is ignored by the PM core.
202 */
203
204struct dev_pm_ops {
205	int (*prepare)(struct device *dev);
206	void (*complete)(struct device *dev);
207	int (*suspend)(struct device *dev);
208	int (*resume)(struct device *dev);
209	int (*freeze)(struct device *dev);
210	int (*thaw)(struct device *dev);
211	int (*poweroff)(struct device *dev);
212	int (*restore)(struct device *dev);
213	int (*suspend_noirq)(struct device *dev);
214	int (*resume_noirq)(struct device *dev);
215	int (*freeze_noirq)(struct device *dev);
216	int (*thaw_noirq)(struct device *dev);
217	int (*poweroff_noirq)(struct device *dev);
218	int (*restore_noirq)(struct device *dev);
219	int (*runtime_suspend)(struct device *dev);
220	int (*runtime_resume)(struct device *dev);
221	int (*runtime_idle)(struct device *dev);
222};
223
224#ifdef CONFIG_PM_SLEEP
225#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
226	.suspend = suspend_fn, \
227	.resume = resume_fn, \
228	.freeze = suspend_fn, \
229	.thaw = resume_fn, \
230	.poweroff = suspend_fn, \
231	.restore = resume_fn,
232#else
233#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
234#endif
235
236#ifdef CONFIG_PM_RUNTIME
237#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
238	.runtime_suspend = suspend_fn, \
239	.runtime_resume = resume_fn, \
240	.runtime_idle = idle_fn,
241#else
242#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
243#endif
244
245/*
246 * Use this if you want to use the same suspend and resume callbacks for suspend
247 * to RAM and hibernation.
248 */
249#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
250const struct dev_pm_ops name = { \
251	SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
252}
253
254/*
255 * Use this for defining a set of PM operations to be used in all situations
256 * (sustem suspend, hibernation or runtime PM).
257 */
258#define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
259const struct dev_pm_ops name = { \
260	SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
261	SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
262}
263
264/*
265 * Use this for subsystems (bus types, device types, device classes) that don't
266 * need any special suspend/resume handling in addition to invoking the PM
267 * callbacks provided by device drivers supporting both the system sleep PM and
268 * runtime PM, make the pm member point to generic_subsys_pm_ops.
269 */
270#ifdef CONFIG_PM_OPS
271extern struct dev_pm_ops generic_subsys_pm_ops;
272#define GENERIC_SUBSYS_PM_OPS	(&generic_subsys_pm_ops)
273#else
274#define GENERIC_SUBSYS_PM_OPS	NULL
275#endif
276
277/**
278 * PM_EVENT_ messages
279 *
280 * The following PM_EVENT_ messages are defined for the internal use of the PM
281 * core, in order to provide a mechanism allowing the high level suspend and
282 * hibernation code to convey the necessary information to the device PM core
283 * code:
284 *
285 * ON		No transition.
286 *
287 * FREEZE 	System is going to hibernate, call ->prepare() and ->freeze()
288 *		for all devices.
289 *
290 * SUSPEND	System is going to suspend, call ->prepare() and ->suspend()
291 *		for all devices.
292 *
293 * HIBERNATE	Hibernation image has been saved, call ->prepare() and
294 *		->poweroff() for all devices.
295 *
296 * QUIESCE	Contents of main memory are going to be restored from a (loaded)
297 *		hibernation image, call ->prepare() and ->freeze() for all
298 *		devices.
299 *
300 * RESUME	System is resuming, call ->resume() and ->complete() for all
301 *		devices.
302 *
303 * THAW		Hibernation image has been created, call ->thaw() and
304 *		->complete() for all devices.
305 *
306 * RESTORE	Contents of main memory have been restored from a hibernation
307 *		image, call ->restore() and ->complete() for all devices.
308 *
309 * RECOVER	Creation of a hibernation image or restoration of the main
310 *		memory contents from a hibernation image has failed, call
311 *		->thaw() and ->complete() for all devices.
312 *
313 * The following PM_EVENT_ messages are defined for internal use by
314 * kernel subsystems.  They are never issued by the PM core.
315 *
316 * USER_SUSPEND		Manual selective suspend was issued by userspace.
317 *
318 * USER_RESUME		Manual selective resume was issued by userspace.
319 *
320 * REMOTE_WAKEUP	Remote-wakeup request was received from the device.
321 *
322 * AUTO_SUSPEND		Automatic (device idle) runtime suspend was
323 *			initiated by the subsystem.
324 *
325 * AUTO_RESUME		Automatic (device needed) runtime resume was
326 *			requested by a driver.
327 */
328
329#define PM_EVENT_ON		0x0000
330#define PM_EVENT_FREEZE 	0x0001
331#define PM_EVENT_SUSPEND	0x0002
332#define PM_EVENT_HIBERNATE	0x0004
333#define PM_EVENT_QUIESCE	0x0008
334#define PM_EVENT_RESUME		0x0010
335#define PM_EVENT_THAW		0x0020
336#define PM_EVENT_RESTORE	0x0040
337#define PM_EVENT_RECOVER	0x0080
338#define PM_EVENT_USER		0x0100
339#define PM_EVENT_REMOTE		0x0200
340#define PM_EVENT_AUTO		0x0400
341
342#define PM_EVENT_SLEEP		(PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE)
343#define PM_EVENT_USER_SUSPEND	(PM_EVENT_USER | PM_EVENT_SUSPEND)
344#define PM_EVENT_USER_RESUME	(PM_EVENT_USER | PM_EVENT_RESUME)
345#define PM_EVENT_REMOTE_RESUME	(PM_EVENT_REMOTE | PM_EVENT_RESUME)
346#define PM_EVENT_AUTO_SUSPEND	(PM_EVENT_AUTO | PM_EVENT_SUSPEND)
347#define PM_EVENT_AUTO_RESUME	(PM_EVENT_AUTO | PM_EVENT_RESUME)
348
349#define PMSG_ON		((struct pm_message){ .event = PM_EVENT_ON, })
350#define PMSG_FREEZE	((struct pm_message){ .event = PM_EVENT_FREEZE, })
351#define PMSG_QUIESCE	((struct pm_message){ .event = PM_EVENT_QUIESCE, })
352#define PMSG_SUSPEND	((struct pm_message){ .event = PM_EVENT_SUSPEND, })
353#define PMSG_HIBERNATE	((struct pm_message){ .event = PM_EVENT_HIBERNATE, })
354#define PMSG_RESUME	((struct pm_message){ .event = PM_EVENT_RESUME, })
355#define PMSG_THAW	((struct pm_message){ .event = PM_EVENT_THAW, })
356#define PMSG_RESTORE	((struct pm_message){ .event = PM_EVENT_RESTORE, })
357#define PMSG_RECOVER	((struct pm_message){ .event = PM_EVENT_RECOVER, })
358#define PMSG_USER_SUSPEND	((struct pm_message) \
359					{ .event = PM_EVENT_USER_SUSPEND, })
360#define PMSG_USER_RESUME	((struct pm_message) \
361					{ .event = PM_EVENT_USER_RESUME, })
362#define PMSG_REMOTE_RESUME	((struct pm_message) \
363					{ .event = PM_EVENT_REMOTE_RESUME, })
364#define PMSG_AUTO_SUSPEND	((struct pm_message) \
365					{ .event = PM_EVENT_AUTO_SUSPEND, })
366#define PMSG_AUTO_RESUME	((struct pm_message) \
367					{ .event = PM_EVENT_AUTO_RESUME, })
368
369/**
370 * Device power management states
371 *
372 * These state labels are used internally by the PM core to indicate the current
373 * status of a device with respect to the PM core operations.
374 *
375 * DPM_ON		Device is regarded as operational.  Set this way
376 *			initially and when ->complete() is about to be called.
377 *			Also set when ->prepare() fails.
378 *
379 * DPM_PREPARING	Device is going to be prepared for a PM transition.  Set
380 *			when ->prepare() is about to be called.
381 *
382 * DPM_RESUMING		Device is going to be resumed.  Set when ->resume(),
383 *			->thaw(), or ->restore() is about to be called.
384 *
385 * DPM_SUSPENDING	Device has been prepared for a power transition.  Set
386 *			when ->prepare() has just succeeded.
387 *
388 * DPM_OFF		Device is regarded as inactive.  Set immediately after
389 *			->suspend(), ->freeze(), or ->poweroff() has succeeded.
390 *			Also set when ->resume()_noirq, ->thaw_noirq(), or
391 *			->restore_noirq() is about to be called.
392 *
393 * DPM_OFF_IRQ		Device is in a "deep sleep".  Set immediately after
394 *			->suspend_noirq(), ->freeze_noirq(), or
395 *			->poweroff_noirq() has just succeeded.
396 */
397
398enum dpm_state {
399	DPM_INVALID,
400	DPM_ON,
401	DPM_PREPARING,
402	DPM_RESUMING,
403	DPM_SUSPENDING,
404	DPM_OFF,
405	DPM_OFF_IRQ,
406};
407
408/**
409 * Device run-time power management status.
410 *
411 * These status labels are used internally by the PM core to indicate the
412 * current status of a device with respect to the PM core operations.  They do
413 * not reflect the actual power state of the device or its status as seen by the
414 * driver.
415 *
416 * RPM_ACTIVE		Device is fully operational.  Indicates that the device
417 *			bus type's ->runtime_resume() callback has completed
418 *			successfully.
419 *
420 * RPM_SUSPENDED	Device bus type's ->runtime_suspend() callback has
421 *			completed successfully.  The device is regarded as
422 *			suspended.
423 *
424 * RPM_RESUMING		Device bus type's ->runtime_resume() callback is being
425 *			executed.
426 *
427 * RPM_SUSPENDING	Device bus type's ->runtime_suspend() callback is being
428 *			executed.
429 */
430
431enum rpm_status {
432	RPM_ACTIVE = 0,
433	RPM_RESUMING,
434	RPM_SUSPENDED,
435	RPM_SUSPENDING,
436};
437
438/**
439 * Device run-time power management request types.
440 *
441 * RPM_REQ_NONE		Do nothing.
442 *
443 * RPM_REQ_IDLE		Run the device bus type's ->runtime_idle() callback
444 *
445 * RPM_REQ_SUSPEND	Run the device bus type's ->runtime_suspend() callback
446 *
447 * RPM_REQ_AUTOSUSPEND	Same as RPM_REQ_SUSPEND, but not until the device has
448 *			been inactive for as long as power.autosuspend_delay
449 *
450 * RPM_REQ_RESUME	Run the device bus type's ->runtime_resume() callback
451 */
452
453enum rpm_request {
454	RPM_REQ_NONE = 0,
455	RPM_REQ_IDLE,
456	RPM_REQ_SUSPEND,
457	RPM_REQ_AUTOSUSPEND,
458	RPM_REQ_RESUME,
459};
460
461struct wakeup_source;
462
463struct dev_pm_info {
464	pm_message_t		power_state;
465	unsigned int		can_wakeup:1;
466	unsigned		async_suspend:1;
467	enum dpm_state		status;		/* Owned by the PM core */
468	spinlock_t		lock;
469#ifdef CONFIG_PM_SLEEP
470	struct list_head	entry;
471	struct completion	completion;
472	struct wakeup_source	*wakeup;
473#endif
474#ifdef CONFIG_PM_RUNTIME
475	struct timer_list	suspend_timer;
476	unsigned long		timer_expires;
477	struct work_struct	work;
478	wait_queue_head_t	wait_queue;
479	atomic_t		usage_count;
480	atomic_t		child_count;
481	unsigned int		disable_depth:3;
482	unsigned int		ignore_children:1;
483	unsigned int		idle_notification:1;
484	unsigned int		request_pending:1;
485	unsigned int		deferred_resume:1;
486	unsigned int		run_wake:1;
487	unsigned int		runtime_auto:1;
488	unsigned int		no_callbacks:1;
489	unsigned int		irq_safe:1;
490	unsigned int		use_autosuspend:1;
491	unsigned int		timer_autosuspends:1;
492	enum rpm_request	request;
493	enum rpm_status		runtime_status;
494	int			runtime_error;
495	int			autosuspend_delay;
496	unsigned long		last_busy;
497	unsigned long		active_jiffies;
498	unsigned long		suspended_jiffies;
499	unsigned long		accounting_timestamp;
500#endif
501};
502
503extern void update_pm_runtime_accounting(struct device *dev);
504
505
506/*
507 * The PM_EVENT_ messages are also used by drivers implementing the legacy
508 * suspend framework, based on the ->suspend() and ->resume() callbacks common
509 * for suspend and hibernation transitions, according to the rules below.
510 */
511
512/* Necessary, because several drivers use PM_EVENT_PRETHAW */
513#define PM_EVENT_PRETHAW PM_EVENT_QUIESCE
514
515/*
516 * One transition is triggered by resume(), after a suspend() call; the
517 * message is implicit:
518 *
519 * ON		Driver starts working again, responding to hardware events
520 * 		and software requests.  The hardware may have gone through
521 * 		a power-off reset, or it may have maintained state from the
522 * 		previous suspend() which the driver will rely on while
523 * 		resuming.  On most platforms, there are no restrictions on
524 * 		availability of resources like clocks during resume().
525 *
526 * Other transitions are triggered by messages sent using suspend().  All
527 * these transitions quiesce the driver, so that I/O queues are inactive.
528 * That commonly entails turning off IRQs and DMA; there may be rules
529 * about how to quiesce that are specific to the bus or the device's type.
530 * (For example, network drivers mark the link state.)  Other details may
531 * differ according to the message:
532 *
533 * SUSPEND	Quiesce, enter a low power device state appropriate for
534 * 		the upcoming system state (such as PCI_D3hot), and enable
535 * 		wakeup events as appropriate.
536 *
537 * HIBERNATE	Enter a low power device state appropriate for the hibernation
538 * 		state (eg. ACPI S4) and enable wakeup events as appropriate.
539 *
540 * FREEZE	Quiesce operations so that a consistent image can be saved;
541 * 		but do NOT otherwise enter a low power device state, and do
542 * 		NOT emit system wakeup events.
543 *
544 * PRETHAW	Quiesce as if for FREEZE; additionally, prepare for restoring
545 * 		the system from a snapshot taken after an earlier FREEZE.
546 * 		Some drivers will need to reset their hardware state instead
547 * 		of preserving it, to ensure that it's never mistaken for the
548 * 		state which that earlier snapshot had set up.
549 *
550 * A minimally power-aware driver treats all messages as SUSPEND, fully
551 * reinitializes its device during resume() -- whether or not it was reset
552 * during the suspend/resume cycle -- and can't issue wakeup events.
553 *
554 * More power-aware drivers may also use low power states at runtime as
555 * well as during system sleep states like PM_SUSPEND_STANDBY.  They may
556 * be able to use wakeup events to exit from runtime low-power states,
557 * or from system low-power states such as standby or suspend-to-RAM.
558 */
559
560#ifdef CONFIG_PM_SLEEP
561extern void device_pm_lock(void);
562extern int sysdev_resume(void);
563extern void dpm_resume_noirq(pm_message_t state);
564extern void dpm_resume_end(pm_message_t state);
565
566extern void device_pm_unlock(void);
567extern int sysdev_suspend(pm_message_t state);
568extern int dpm_suspend_noirq(pm_message_t state);
569extern int dpm_suspend_start(pm_message_t state);
570
571extern void __suspend_report_result(const char *function, void *fn, int ret);
572
573#define suspend_report_result(fn, ret)					\
574	do {								\
575		__suspend_report_result(__func__, fn, ret);		\
576	} while (0)
577
578extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);
579#else /* !CONFIG_PM_SLEEP */
580
581#define device_pm_lock() do {} while (0)
582#define device_pm_unlock() do {} while (0)
583
584static inline int dpm_suspend_start(pm_message_t state)
585{
586	return 0;
587}
588
589#define suspend_report_result(fn, ret)		do {} while (0)
590
591static inline int device_pm_wait_for_dev(struct device *a, struct device *b)
592{
593	return 0;
594}
595#endif /* !CONFIG_PM_SLEEP */
596
597/* How to reorder dpm_list after device_move() */
598enum dpm_order {
599	DPM_ORDER_NONE,
600	DPM_ORDER_DEV_AFTER_PARENT,
601	DPM_ORDER_PARENT_BEFORE_DEV,
602	DPM_ORDER_DEV_LAST,
603};
604
605/*
606 * Global Power Management flags
607 * Used to keep APM and ACPI from both being active
608 */
609extern unsigned int	pm_flags;
610
611#define PM_APM	1
612#define PM_ACPI	2
613
614#endif /* _LINUX_PM_H */
615