diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/pm.h | 8 | ||||
| -rw-r--r-- | include/linux/pm_runtime.h | 45 |
2 files changed, 53 insertions, 0 deletions
diff --git a/include/linux/pm.h b/include/linux/pm.h index abd81ffaba3c..40f3f45702ba 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h | |||
| @@ -444,6 +444,9 @@ enum rpm_status { | |||
| 444 | * | 444 | * |
| 445 | * RPM_REQ_SUSPEND Run the device bus type's ->runtime_suspend() callback | 445 | * RPM_REQ_SUSPEND Run the device bus type's ->runtime_suspend() callback |
| 446 | * | 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 | * | ||
| 447 | * RPM_REQ_RESUME Run the device bus type's ->runtime_resume() callback | 450 | * RPM_REQ_RESUME Run the device bus type's ->runtime_resume() callback |
| 448 | */ | 451 | */ |
| 449 | 452 | ||
| @@ -451,6 +454,7 @@ enum rpm_request { | |||
| 451 | RPM_REQ_NONE = 0, | 454 | RPM_REQ_NONE = 0, |
| 452 | RPM_REQ_IDLE, | 455 | RPM_REQ_IDLE, |
| 453 | RPM_REQ_SUSPEND, | 456 | RPM_REQ_SUSPEND, |
| 457 | RPM_REQ_AUTOSUSPEND, | ||
| 454 | RPM_REQ_RESUME, | 458 | RPM_REQ_RESUME, |
| 455 | }; | 459 | }; |
| 456 | 460 | ||
| @@ -482,9 +486,13 @@ struct dev_pm_info { | |||
| 482 | unsigned int run_wake:1; | 486 | unsigned int run_wake:1; |
| 483 | unsigned int runtime_auto:1; | 487 | unsigned int runtime_auto:1; |
| 484 | unsigned int no_callbacks:1; | 488 | unsigned int no_callbacks:1; |
| 489 | unsigned int use_autosuspend:1; | ||
| 490 | unsigned int timer_autosuspends:1; | ||
| 485 | enum rpm_request request; | 491 | enum rpm_request request; |
| 486 | enum rpm_status runtime_status; | 492 | enum rpm_status runtime_status; |
| 487 | int runtime_error; | 493 | int runtime_error; |
| 494 | int autosuspend_delay; | ||
| 495 | unsigned long last_busy; | ||
| 488 | unsigned long active_jiffies; | 496 | unsigned long active_jiffies; |
| 489 | unsigned long suspended_jiffies; | 497 | unsigned long suspended_jiffies; |
| 490 | unsigned long accounting_timestamp; | 498 | unsigned long accounting_timestamp; |
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); | |||
| 37 | extern int pm_generic_runtime_suspend(struct device *dev); | 40 | extern int pm_generic_runtime_suspend(struct device *dev); |
| 38 | extern int pm_generic_runtime_resume(struct device *dev); | 41 | extern int pm_generic_runtime_resume(struct device *dev); |
| 39 | extern void pm_runtime_no_callbacks(struct device *dev); | 42 | extern void pm_runtime_no_callbacks(struct device *dev); |
| 43 | extern void __pm_runtime_use_autosuspend(struct device *dev, bool use); | ||
| 44 | extern void pm_runtime_set_autosuspend_delay(struct device *dev, int delay); | ||
| 45 | extern unsigned long pm_runtime_autosuspend_expiration(struct device *dev); | ||
| 40 | 46 | ||
| 41 | static inline bool pm_children_suspended(struct device *dev) | 47 | static 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 | ||
| 83 | static 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 | ||
| 79 | static inline int __pm_runtime_idle(struct device *dev, int rpmflags) | 90 | static 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; } | |||
| 113 | static inline int pm_generic_runtime_resume(struct device *dev) { return 0; } | 124 | static inline int pm_generic_runtime_resume(struct device *dev) { return 0; } |
| 114 | static inline void pm_runtime_no_callbacks(struct device *dev) {} | 125 | static inline void pm_runtime_no_callbacks(struct device *dev) {} |
| 115 | 126 | ||
| 127 | static inline void pm_runtime_mark_last_busy(struct device *dev) {} | ||
| 128 | static inline void __pm_runtime_use_autosuspend(struct device *dev, | ||
| 129 | bool use) {} | ||
| 130 | static inline void pm_runtime_set_autosuspend_delay(struct device *dev, | ||
| 131 | int delay) {} | ||
| 132 | static 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 | ||
| 118 | static inline int pm_runtime_idle(struct device *dev) | 137 | static 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 | ||
| 147 | static inline int pm_runtime_autosuspend(struct device *dev) | ||
| 148 | { | ||
| 149 | return __pm_runtime_suspend(dev, RPM_AUTO); | ||
| 150 | } | ||
| 151 | |||
| 128 | static inline int pm_runtime_resume(struct device *dev) | 152 | static 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 | ||
| 182 | static 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 | |||
| 158 | static inline int pm_runtime_put_sync(struct device *dev) | 188 | static 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 | ||
| 193 | static inline int pm_runtime_put_sync_autosuspend(struct device *dev) | ||
| 194 | { | ||
| 195 | return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_AUTO); | ||
| 196 | } | ||
| 197 | |||
| 163 | static inline int pm_runtime_set_active(struct device *dev) | 198 | static 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 | ||
| 213 | static inline void pm_runtime_use_autosuspend(struct device *dev) | ||
| 214 | { | ||
| 215 | __pm_runtime_use_autosuspend(dev, true); | ||
| 216 | } | ||
| 217 | |||
| 218 | static inline void pm_runtime_dont_use_autosuspend(struct device *dev) | ||
| 219 | { | ||
| 220 | __pm_runtime_use_autosuspend(dev, false); | ||
| 221 | } | ||
| 222 | |||
| 178 | #endif | 223 | #endif |
