aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pm.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/pm.h')
-rw-r--r--include/linux/pm.h88
1 files changed, 31 insertions, 57 deletions
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 42de4003c4ee..de2e0a8f6728 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -41,7 +41,7 @@ typedef struct pm_message {
41} pm_message_t; 41} pm_message_t;
42 42
43/** 43/**
44 * struct pm_ops - device PM callbacks 44 * struct dev_pm_ops - device PM callbacks
45 * 45 *
46 * Several driver power state transitions are externally visible, affecting 46 * Several driver power state transitions are externally visible, affecting
47 * the state of pending I/O queues and (for drivers that touch hardware) 47 * the state of pending I/O queues and (for drivers that touch hardware)
@@ -126,46 +126,6 @@ typedef struct pm_message {
126 * On most platforms, there are no restrictions on availability of 126 * On most platforms, there are no restrictions on availability of
127 * resources like clocks during @restore(). 127 * resources like clocks during @restore().
128 * 128 *
129 * All of the above callbacks, except for @complete(), return error codes.
130 * However, the error codes returned by the resume operations, @resume(),
131 * @thaw(), and @restore(), do not cause the PM core to abort the resume
132 * transition during which they are returned. The error codes returned in
133 * that cases are only printed by the PM core to the system logs for debugging
134 * purposes. Still, it is recommended that drivers only return error codes
135 * from their resume methods in case of an unrecoverable failure (i.e. when the
136 * device being handled refuses to resume and becomes unusable) to allow us to
137 * modify the PM core in the future, so that it can avoid attempting to handle
138 * devices that failed to resume and their children.
139 *
140 * It is allowed to unregister devices while the above callbacks are being
141 * executed. However, it is not allowed to unregister a device from within any
142 * of its own callbacks.
143 */
144
145struct pm_ops {
146 int (*prepare)(struct device *dev);
147 void (*complete)(struct device *dev);
148 int (*suspend)(struct device *dev);
149 int (*resume)(struct device *dev);
150 int (*freeze)(struct device *dev);
151 int (*thaw)(struct device *dev);
152 int (*poweroff)(struct device *dev);
153 int (*restore)(struct device *dev);
154};
155
156/**
157 * struct pm_ext_ops - extended device PM callbacks
158 *
159 * Some devices require certain operations related to suspend and hibernation
160 * to be carried out with interrupts disabled. Thus, 'struct pm_ext_ops' below
161 * is defined, adding callbacks to be executed with interrupts disabled to
162 * 'struct pm_ops'.
163 *
164 * The following callbacks included in 'struct pm_ext_ops' are executed with
165 * the nonboot CPUs switched off and with interrupts disabled on the only
166 * functional CPU. They also are executed with the PM core list of devices
167 * locked, so they must NOT unregister any devices.
168 *
169 * @suspend_noirq: Complete the operations of ->suspend() by carrying out any 129 * @suspend_noirq: Complete the operations of ->suspend() by carrying out any
170 * actions required for suspending the device that need interrupts to be 130 * actions required for suspending the device that need interrupts to be
171 * disabled 131 * disabled
@@ -190,18 +150,32 @@ struct pm_ops {
190 * actions required for restoring the operations of the device that need 150 * actions required for restoring the operations of the device that need
191 * interrupts to be disabled 151 * interrupts to be disabled
192 * 152 *
193 * All of the above callbacks return error codes, but the error codes returned 153 * All of the above callbacks, except for @complete(), return error codes.
194 * by the resume operations, @resume_noirq(), @thaw_noirq(), and 154 * However, the error codes returned by the resume operations, @resume(),
195 * @restore_noirq(), do not cause the PM core to abort the resume transition 155 * @thaw(), @restore(), @resume_noirq(), @thaw_noirq(), and @restore_noirq() do
196 * during which they are returned. The error codes returned in that cases are 156 * not cause the PM core to abort the resume transition during which they are
197 * only printed by the PM core to the system logs for debugging purposes. 157 * returned. The error codes returned in that cases are only printed by the PM
198 * Still, as stated above, it is recommended that drivers only return error 158 * core to the system logs for debugging purposes. Still, it is recommended
199 * codes from their resume methods if the device being handled fails to resume 159 * that drivers only return error codes from their resume methods in case of an
200 * and is not usable any more. 160 * unrecoverable failure (i.e. when the device being handled refuses to resume
161 * and becomes unusable) to allow us to modify the PM core in the future, so
162 * that it can avoid attempting to handle devices that failed to resume and
163 * their children.
164 *
165 * It is allowed to unregister devices while the above callbacks are being
166 * executed. However, it is not allowed to unregister a device from within any
167 * of its own callbacks.
201 */ 168 */
202 169
203struct pm_ext_ops { 170struct dev_pm_ops {
204 struct pm_ops base; 171 int (*prepare)(struct device *dev);
172 void (*complete)(struct device *dev);
173 int (*suspend)(struct device *dev);
174 int (*resume)(struct device *dev);
175 int (*freeze)(struct device *dev);
176 int (*thaw)(struct device *dev);
177 int (*poweroff)(struct device *dev);
178 int (*restore)(struct device *dev);
205 int (*suspend_noirq)(struct device *dev); 179 int (*suspend_noirq)(struct device *dev);
206 int (*resume_noirq)(struct device *dev); 180 int (*resume_noirq)(struct device *dev);
207 int (*freeze_noirq)(struct device *dev); 181 int (*freeze_noirq)(struct device *dev);
@@ -278,7 +252,7 @@ struct pm_ext_ops {
278#define PM_EVENT_SLEEP (PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE) 252#define PM_EVENT_SLEEP (PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE)
279#define PM_EVENT_USER_SUSPEND (PM_EVENT_USER | PM_EVENT_SUSPEND) 253#define PM_EVENT_USER_SUSPEND (PM_EVENT_USER | PM_EVENT_SUSPEND)
280#define PM_EVENT_USER_RESUME (PM_EVENT_USER | PM_EVENT_RESUME) 254#define PM_EVENT_USER_RESUME (PM_EVENT_USER | PM_EVENT_RESUME)
281#define PM_EVENT_REMOTE_WAKEUP (PM_EVENT_REMOTE | PM_EVENT_RESUME) 255#define PM_EVENT_REMOTE_RESUME (PM_EVENT_REMOTE | PM_EVENT_RESUME)
282#define PM_EVENT_AUTO_SUSPEND (PM_EVENT_AUTO | PM_EVENT_SUSPEND) 256#define PM_EVENT_AUTO_SUSPEND (PM_EVENT_AUTO | PM_EVENT_SUSPEND)
283#define PM_EVENT_AUTO_RESUME (PM_EVENT_AUTO | PM_EVENT_RESUME) 257#define PM_EVENT_AUTO_RESUME (PM_EVENT_AUTO | PM_EVENT_RESUME)
284 258
@@ -291,15 +265,15 @@ struct pm_ext_ops {
291#define PMSG_THAW ((struct pm_message){ .event = PM_EVENT_THAW, }) 265#define PMSG_THAW ((struct pm_message){ .event = PM_EVENT_THAW, })
292#define PMSG_RESTORE ((struct pm_message){ .event = PM_EVENT_RESTORE, }) 266#define PMSG_RESTORE ((struct pm_message){ .event = PM_EVENT_RESTORE, })
293#define PMSG_RECOVER ((struct pm_message){ .event = PM_EVENT_RECOVER, }) 267#define PMSG_RECOVER ((struct pm_message){ .event = PM_EVENT_RECOVER, })
294#define PMSG_USER_SUSPEND ((struct pm_messge) \ 268#define PMSG_USER_SUSPEND ((struct pm_message) \
295 { .event = PM_EVENT_USER_SUSPEND, }) 269 { .event = PM_EVENT_USER_SUSPEND, })
296#define PMSG_USER_RESUME ((struct pm_messge) \ 270#define PMSG_USER_RESUME ((struct pm_message) \
297 { .event = PM_EVENT_USER_RESUME, }) 271 { .event = PM_EVENT_USER_RESUME, })
298#define PMSG_REMOTE_RESUME ((struct pm_messge) \ 272#define PMSG_REMOTE_RESUME ((struct pm_message) \
299 { .event = PM_EVENT_REMOTE_RESUME, }) 273 { .event = PM_EVENT_REMOTE_RESUME, })
300#define PMSG_AUTO_SUSPEND ((struct pm_messge) \ 274#define PMSG_AUTO_SUSPEND ((struct pm_message) \
301 { .event = PM_EVENT_AUTO_SUSPEND, }) 275 { .event = PM_EVENT_AUTO_SUSPEND, })
302#define PMSG_AUTO_RESUME ((struct pm_messge) \ 276#define PMSG_AUTO_RESUME ((struct pm_message) \
303 { .event = PM_EVENT_AUTO_RESUME, }) 277 { .event = PM_EVENT_AUTO_RESUME, })
304 278
305/** 279/**