aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pm_runtime.h
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2010-09-25 17:35:21 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2010-10-16 19:57:48 -0400
commit15bcb91d7e607d8a2e060f01f7784a7454668da4 (patch)
tree6d59964cb78ab4b7c93a3c4d06f0dad256b99140 /include/linux/pm_runtime.h
parent7490e44239e60293bca0c2663229050c36c660c2 (diff)
PM / Runtime: Implement autosuspend support
This patch (as1427) implements the "autosuspend" facility for runtime PM. A few new fields are added to the dev_pm_info structure and several new PM helper functions are defined, for telling the PM core whether or not a device uses autosuspend, for setting the autosuspend delay, and for marking periods of device activity. Drivers that do not want to use autosuspend can continue using the same helper functions as before; their behavior will not change. In addition, drivers supporting autosuspend can also call the old helper functions to get the old behavior. The details are all explained in Documentation/power/runtime_pm.txt and Documentation/ABI/testing/sysfs-devices-power. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'include/linux/pm_runtime.h')
-rw-r--r--include/linux/pm_runtime.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 8ca52f7c357e..99ed1aa8f933 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -12,12 +12,15 @@
12#include <linux/device.h> 12#include <linux/device.h>
13#include <linux/pm.h> 13#include <linux/pm.h>
14 14
15#include <linux/jiffies.h>
16
15/* Runtime PM flag argument bits */ 17/* Runtime PM flag argument bits */
16#define RPM_ASYNC 0x01 /* Request is asynchronous */ 18#define RPM_ASYNC 0x01 /* Request is asynchronous */
17#define RPM_NOWAIT 0x02 /* Don't wait for concurrent 19#define RPM_NOWAIT 0x02 /* Don't wait for concurrent
18 state change */ 20 state change */
19#define RPM_GET_PUT 0x04 /* Increment/decrement the 21#define RPM_GET_PUT 0x04 /* Increment/decrement the
20 usage_count */ 22 usage_count */
23#define RPM_AUTO 0x08 /* Use autosuspend_delay */
21 24
22#ifdef CONFIG_PM_RUNTIME 25#ifdef CONFIG_PM_RUNTIME
23 26
@@ -37,6 +40,9 @@ extern int pm_generic_runtime_idle(struct device *dev);
37extern int pm_generic_runtime_suspend(struct device *dev); 40extern int pm_generic_runtime_suspend(struct device *dev);
38extern int pm_generic_runtime_resume(struct device *dev); 41extern int pm_generic_runtime_resume(struct device *dev);
39extern void pm_runtime_no_callbacks(struct device *dev); 42extern void pm_runtime_no_callbacks(struct device *dev);
43extern void __pm_runtime_use_autosuspend(struct device *dev, bool use);
44extern void pm_runtime_set_autosuspend_delay(struct device *dev, int delay);
45extern unsigned long pm_runtime_autosuspend_expiration(struct device *dev);
40 46
41static inline bool pm_children_suspended(struct device *dev) 47static inline bool pm_children_suspended(struct device *dev)
42{ 48{
@@ -74,6 +80,11 @@ static inline bool pm_runtime_suspended(struct device *dev)
74 return dev->power.runtime_status == RPM_SUSPENDED; 80 return dev->power.runtime_status == RPM_SUSPENDED;
75} 81}
76 82
83static inline void pm_runtime_mark_last_busy(struct device *dev)
84{
85 ACCESS_ONCE(dev->power.last_busy) = jiffies;
86}
87
77#else /* !CONFIG_PM_RUNTIME */ 88#else /* !CONFIG_PM_RUNTIME */
78 89
79static inline int __pm_runtime_idle(struct device *dev, int rpmflags) 90static inline int __pm_runtime_idle(struct device *dev, int rpmflags)
@@ -113,6 +124,14 @@ static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
113static inline int pm_generic_runtime_resume(struct device *dev) { return 0; } 124static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
114static inline void pm_runtime_no_callbacks(struct device *dev) {} 125static inline void pm_runtime_no_callbacks(struct device *dev) {}
115 126
127static inline void pm_runtime_mark_last_busy(struct device *dev) {}
128static inline void __pm_runtime_use_autosuspend(struct device *dev,
129 bool use) {}
130static inline void pm_runtime_set_autosuspend_delay(struct device *dev,
131 int delay) {}
132static inline unsigned long pm_runtime_autosuspend_expiration(
133 struct device *dev) { return 0; }
134
116#endif /* !CONFIG_PM_RUNTIME */ 135#endif /* !CONFIG_PM_RUNTIME */
117 136
118static inline int pm_runtime_idle(struct device *dev) 137static inline int pm_runtime_idle(struct device *dev)
@@ -125,6 +144,11 @@ static inline int pm_runtime_suspend(struct device *dev)
125 return __pm_runtime_suspend(dev, 0); 144 return __pm_runtime_suspend(dev, 0);
126} 145}
127 146
147static inline int pm_runtime_autosuspend(struct device *dev)
148{
149 return __pm_runtime_suspend(dev, RPM_AUTO);
150}
151
128static inline int pm_runtime_resume(struct device *dev) 152static inline int pm_runtime_resume(struct device *dev)
129{ 153{
130 return __pm_runtime_resume(dev, 0); 154 return __pm_runtime_resume(dev, 0);
@@ -155,11 +179,22 @@ static inline int pm_runtime_put(struct device *dev)
155 return __pm_runtime_idle(dev, RPM_GET_PUT | RPM_ASYNC); 179 return __pm_runtime_idle(dev, RPM_GET_PUT | RPM_ASYNC);
156} 180}
157 181
182static inline int pm_runtime_put_autosuspend(struct device *dev)
183{
184 return __pm_runtime_suspend(dev,
185 RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
186}
187
158static inline int pm_runtime_put_sync(struct device *dev) 188static inline int pm_runtime_put_sync(struct device *dev)
159{ 189{
160 return __pm_runtime_idle(dev, RPM_GET_PUT); 190 return __pm_runtime_idle(dev, RPM_GET_PUT);
161} 191}
162 192
193static inline int pm_runtime_put_sync_autosuspend(struct device *dev)
194{
195 return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_AUTO);
196}
197
163static inline int pm_runtime_set_active(struct device *dev) 198static inline int pm_runtime_set_active(struct device *dev)
164{ 199{
165 return __pm_runtime_set_status(dev, RPM_ACTIVE); 200 return __pm_runtime_set_status(dev, RPM_ACTIVE);
@@ -175,4 +210,14 @@ static inline void pm_runtime_disable(struct device *dev)
175 __pm_runtime_disable(dev, true); 210 __pm_runtime_disable(dev, true);
176} 211}
177 212
213static inline void pm_runtime_use_autosuspend(struct device *dev)
214{
215 __pm_runtime_use_autosuspend(dev, true);
216}
217
218static inline void pm_runtime_dont_use_autosuspend(struct device *dev)
219{
220 __pm_runtime_use_autosuspend(dev, false);
221}
222
178#endif 223#endif