aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/devfreq.h25
-rw-r--r--include/linux/pm.h59
-rw-r--r--include/linux/pm_domain.h25
-rw-r--r--include/linux/pm_qos.h64
-rw-r--r--include/linux/pm_wakeup.h22
-rw-r--r--include/linux/suspend.h4
6 files changed, 138 insertions, 61 deletions
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
index 98ce8124b1cc..281c72a3b9d5 100644
--- a/include/linux/devfreq.h
+++ b/include/linux/devfreq.h
@@ -44,6 +44,14 @@ struct devfreq_dev_status {
44 void *private_data; 44 void *private_data;
45}; 45};
46 46
47/*
48 * The resulting frequency should be at most this. (this bound is the
49 * least upper bound; thus, the resulting freq should be lower or same)
50 * If the flag is not set, the resulting frequency should be at most the
51 * bound (greatest lower bound)
52 */
53#define DEVFREQ_FLAG_LEAST_UPPER_BOUND 0x1
54
47/** 55/**
48 * struct devfreq_dev_profile - Devfreq's user device profile 56 * struct devfreq_dev_profile - Devfreq's user device profile
49 * @initial_freq The operating frequency when devfreq_add_device() is 57 * @initial_freq The operating frequency when devfreq_add_device() is
@@ -54,6 +62,8 @@ struct devfreq_dev_status {
54 * higher than any operable frequency, set maximum. 62 * higher than any operable frequency, set maximum.
55 * Before returning, target function should set 63 * Before returning, target function should set
56 * freq at the current frequency. 64 * freq at the current frequency.
65 * The "flags" parameter's possible values are
66 * explained above with "DEVFREQ_FLAG_*" macros.
57 * @get_dev_status The device should provide the current performance 67 * @get_dev_status The device should provide the current performance
58 * status to devfreq, which is used by governors. 68 * status to devfreq, which is used by governors.
59 * @exit An optional callback that is called when devfreq 69 * @exit An optional callback that is called when devfreq
@@ -66,7 +76,7 @@ struct devfreq_dev_profile {
66 unsigned long initial_freq; 76 unsigned long initial_freq;
67 unsigned int polling_ms; 77 unsigned int polling_ms;
68 78
69 int (*target)(struct device *dev, unsigned long *freq); 79 int (*target)(struct device *dev, unsigned long *freq, u32 flags);
70 int (*get_dev_status)(struct device *dev, 80 int (*get_dev_status)(struct device *dev,
71 struct devfreq_dev_status *stat); 81 struct devfreq_dev_status *stat);
72 void (*exit)(struct device *dev); 82 void (*exit)(struct device *dev);
@@ -124,6 +134,8 @@ struct devfreq_governor {
124 * touch this. 134 * touch this.
125 * @being_removed a flag to mark that this object is being removed in 135 * @being_removed a flag to mark that this object is being removed in
126 * order to prevent trying to remove the object multiple times. 136 * order to prevent trying to remove the object multiple times.
137 * @min_freq Limit minimum frequency requested by user (0: none)
138 * @max_freq Limit maximum frequency requested by user (0: none)
127 * 139 *
128 * This structure stores the devfreq information for a give device. 140 * This structure stores the devfreq information for a give device.
129 * 141 *
@@ -149,6 +161,9 @@ struct devfreq {
149 void *data; /* private data for governors */ 161 void *data; /* private data for governors */
150 162
151 bool being_removed; 163 bool being_removed;
164
165 unsigned long min_freq;
166 unsigned long max_freq;
152}; 167};
153 168
154#if defined(CONFIG_PM_DEVFREQ) 169#if defined(CONFIG_PM_DEVFREQ)
@@ -160,7 +175,7 @@ extern int devfreq_remove_device(struct devfreq *devfreq);
160 175
161/* Helper functions for devfreq user device driver with OPP. */ 176/* Helper functions for devfreq user device driver with OPP. */
162extern struct opp *devfreq_recommended_opp(struct device *dev, 177extern struct opp *devfreq_recommended_opp(struct device *dev,
163 unsigned long *freq); 178 unsigned long *freq, u32 flags);
164extern int devfreq_register_opp_notifier(struct device *dev, 179extern int devfreq_register_opp_notifier(struct device *dev,
165 struct devfreq *devfreq); 180 struct devfreq *devfreq);
166extern int devfreq_unregister_opp_notifier(struct device *dev, 181extern int devfreq_unregister_opp_notifier(struct device *dev,
@@ -200,18 +215,18 @@ struct devfreq_simple_ondemand_data {
200static struct devfreq *devfreq_add_device(struct device *dev, 215static struct devfreq *devfreq_add_device(struct device *dev,
201 struct devfreq_dev_profile *profile, 216 struct devfreq_dev_profile *profile,
202 struct devfreq_governor *governor, 217 struct devfreq_governor *governor,
203 void *data); 218 void *data)
204{ 219{
205 return NULL; 220 return NULL;
206} 221}
207 222
208static int devfreq_remove_device(struct devfreq *devfreq); 223static int devfreq_remove_device(struct devfreq *devfreq)
209{ 224{
210 return 0; 225 return 0;
211} 226}
212 227
213static struct opp *devfreq_recommended_opp(struct device *dev, 228static struct opp *devfreq_recommended_opp(struct device *dev,
214 unsigned long *freq) 229 unsigned long *freq, u32 flags)
215{ 230{
216 return -EINVAL; 231 return -EINVAL;
217} 232}
diff --git a/include/linux/pm.h b/include/linux/pm.h
index e4982ac3fbbc..715305e05123 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -110,6 +110,10 @@ typedef struct pm_message {
110 * Subsystem-level @suspend() is executed for all devices after invoking 110 * Subsystem-level @suspend() is executed for all devices after invoking
111 * subsystem-level @prepare() for all of them. 111 * subsystem-level @prepare() for all of them.
112 * 112 *
113 * @suspend_late: Continue operations started by @suspend(). For a number of
114 * devices @suspend_late() may point to the same callback routine as the
115 * runtime suspend callback.
116 *
113 * @resume: Executed after waking the system up from a sleep state in which the 117 * @resume: Executed after waking the system up from a sleep state in which the
114 * contents of main memory were preserved. The exact action to perform 118 * contents of main memory were preserved. The exact action to perform
115 * depends on the device's subsystem, but generally the driver is expected 119 * depends on the device's subsystem, but generally the driver is expected
@@ -122,6 +126,10 @@ typedef struct pm_message {
122 * Subsystem-level @resume() is executed for all devices after invoking 126 * Subsystem-level @resume() is executed for all devices after invoking
123 * subsystem-level @resume_noirq() for all of them. 127 * subsystem-level @resume_noirq() for all of them.
124 * 128 *
129 * @resume_early: Prepare to execute @resume(). For a number of devices
130 * @resume_early() may point to the same callback routine as the runtime
131 * resume callback.
132 *
125 * @freeze: Hibernation-specific, executed before creating a hibernation image. 133 * @freeze: Hibernation-specific, executed before creating a hibernation image.
126 * Analogous to @suspend(), but it should not enable the device to signal 134 * Analogous to @suspend(), but it should not enable the device to signal
127 * wakeup events or change its power state. The majority of subsystems 135 * wakeup events or change its power state. The majority of subsystems
@@ -131,6 +139,10 @@ typedef struct pm_message {
131 * Subsystem-level @freeze() is executed for all devices after invoking 139 * Subsystem-level @freeze() is executed for all devices after invoking
132 * subsystem-level @prepare() for all of them. 140 * subsystem-level @prepare() for all of them.
133 * 141 *
142 * @freeze_late: Continue operations started by @freeze(). Analogous to
143 * @suspend_late(), but it should not enable the device to signal wakeup
144 * events or change its power state.
145 *
134 * @thaw: Hibernation-specific, executed after creating a hibernation image OR 146 * @thaw: Hibernation-specific, executed after creating a hibernation image OR
135 * if the creation of an image has failed. Also executed after a failing 147 * if the creation of an image has failed. Also executed after a failing
136 * attempt to restore the contents of main memory from such an image. 148 * attempt to restore the contents of main memory from such an image.
@@ -140,15 +152,23 @@ typedef struct pm_message {
140 * subsystem-level @thaw_noirq() for all of them. It also may be executed 152 * subsystem-level @thaw_noirq() for all of them. It also may be executed
141 * directly after @freeze() in case of a transition error. 153 * directly after @freeze() in case of a transition error.
142 * 154 *
155 * @thaw_early: Prepare to execute @thaw(). Undo the changes made by the
156 * preceding @freeze_late().
157 *
143 * @poweroff: Hibernation-specific, executed after saving a hibernation image. 158 * @poweroff: Hibernation-specific, executed after saving a hibernation image.
144 * Analogous to @suspend(), but it need not save the device's settings in 159 * Analogous to @suspend(), but it need not save the device's settings in
145 * memory. 160 * memory.
146 * Subsystem-level @poweroff() is executed for all devices after invoking 161 * Subsystem-level @poweroff() is executed for all devices after invoking
147 * subsystem-level @prepare() for all of them. 162 * subsystem-level @prepare() for all of them.
148 * 163 *
164 * @poweroff_late: Continue operations started by @poweroff(). Analogous to
165 * @suspend_late(), but it need not save the device's settings in memory.
166 *
149 * @restore: Hibernation-specific, executed after restoring the contents of main 167 * @restore: Hibernation-specific, executed after restoring the contents of main
150 * memory from a hibernation image, analogous to @resume(). 168 * memory from a hibernation image, analogous to @resume().
151 * 169 *
170 * @restore_early: Prepare to execute @restore(), analogous to @resume_early().
171 *
152 * @suspend_noirq: Complete the actions started by @suspend(). Carry out any 172 * @suspend_noirq: Complete the actions started by @suspend(). Carry out any
153 * additional operations required for suspending the device that might be 173 * additional operations required for suspending the device that might be
154 * racing with its driver's interrupt handler, which is guaranteed not to 174 * racing with its driver's interrupt handler, which is guaranteed not to
@@ -158,9 +178,10 @@ typedef struct pm_message {
158 * @suspend_noirq() has returned successfully. If the device can generate 178 * @suspend_noirq() has returned successfully. If the device can generate
159 * system wakeup signals and is enabled to wake up the system, it should be 179 * system wakeup signals and is enabled to wake up the system, it should be
160 * configured to do so at that time. However, depending on the platform 180 * configured to do so at that time. However, depending on the platform
161 * and device's subsystem, @suspend() may be allowed to put the device into 181 * and device's subsystem, @suspend() or @suspend_late() may be allowed to
162 * the low-power state and configure it to generate wakeup signals, in 182 * put the device into the low-power state and configure it to generate
163 * which case it generally is not necessary to define @suspend_noirq(). 183 * wakeup signals, in which case it generally is not necessary to define
184 * @suspend_noirq().
164 * 185 *
165 * @resume_noirq: Prepare for the execution of @resume() by carrying out any 186 * @resume_noirq: Prepare for the execution of @resume() by carrying out any
166 * operations required for resuming the device that might be racing with 187 * operations required for resuming the device that might be racing with
@@ -171,9 +192,9 @@ typedef struct pm_message {
171 * additional operations required for freezing the device that might be 192 * additional operations required for freezing the device that might be
172 * racing with its driver's interrupt handler, which is guaranteed not to 193 * racing with its driver's interrupt handler, which is guaranteed not to
173 * run while @freeze_noirq() is being executed. 194 * run while @freeze_noirq() is being executed.
174 * The power state of the device should not be changed by either @freeze() 195 * The power state of the device should not be changed by either @freeze(),
175 * or @freeze_noirq() and it should not be configured to signal system 196 * or @freeze_late(), or @freeze_noirq() and it should not be configured to
176 * wakeup by any of these callbacks. 197 * signal system wakeup by any of these callbacks.
177 * 198 *
178 * @thaw_noirq: Prepare for the execution of @thaw() by carrying out any 199 * @thaw_noirq: Prepare for the execution of @thaw() by carrying out any
179 * operations required for thawing the device that might be racing with its 200 * operations required for thawing the device that might be racing with its
@@ -249,6 +270,12 @@ struct dev_pm_ops {
249 int (*thaw)(struct device *dev); 270 int (*thaw)(struct device *dev);
250 int (*poweroff)(struct device *dev); 271 int (*poweroff)(struct device *dev);
251 int (*restore)(struct device *dev); 272 int (*restore)(struct device *dev);
273 int (*suspend_late)(struct device *dev);
274 int (*resume_early)(struct device *dev);
275 int (*freeze_late)(struct device *dev);
276 int (*thaw_early)(struct device *dev);
277 int (*poweroff_late)(struct device *dev);
278 int (*restore_early)(struct device *dev);
252 int (*suspend_noirq)(struct device *dev); 279 int (*suspend_noirq)(struct device *dev);
253 int (*resume_noirq)(struct device *dev); 280 int (*resume_noirq)(struct device *dev);
254 int (*freeze_noirq)(struct device *dev); 281 int (*freeze_noirq)(struct device *dev);
@@ -293,6 +320,15 @@ const struct dev_pm_ops name = { \
293/* 320/*
294 * Use this for defining a set of PM operations to be used in all situations 321 * Use this for defining a set of PM operations to be used in all situations
295 * (sustem suspend, hibernation or runtime PM). 322 * (sustem suspend, hibernation or runtime PM).
323 * NOTE: In general, system suspend callbacks, .suspend() and .resume(), should
324 * be different from the corresponding runtime PM callbacks, .runtime_suspend(),
325 * and .runtime_resume(), because .runtime_suspend() always works on an already
326 * quiescent device, while .suspend() should assume that the device may be doing
327 * something when it is called (it should ensure that the device will be
328 * quiescent after it has returned). Therefore it's better to point the "late"
329 * suspend and "early" resume callback pointers, .suspend_late() and
330 * .resume_early(), to the same routines as .runtime_suspend() and
331 * .runtime_resume(), respectively (and analogously for hibernation).
296 */ 332 */
297#define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \ 333#define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
298const struct dev_pm_ops name = { \ 334const struct dev_pm_ops name = { \
@@ -510,6 +546,7 @@ struct dev_pm_info {
510 unsigned long accounting_timestamp; 546 unsigned long accounting_timestamp;
511 ktime_t suspend_time; 547 ktime_t suspend_time;
512 s64 max_time_suspended_ns; 548 s64 max_time_suspended_ns;
549 struct dev_pm_qos_request *pq_req;
513#endif 550#endif
514 struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ 551 struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */
515 struct pm_qos_constraints *constraints; 552 struct pm_qos_constraints *constraints;
@@ -584,13 +621,13 @@ struct dev_pm_domain {
584 621
585#ifdef CONFIG_PM_SLEEP 622#ifdef CONFIG_PM_SLEEP
586extern void device_pm_lock(void); 623extern void device_pm_lock(void);
587extern void dpm_resume_noirq(pm_message_t state); 624extern void dpm_resume_start(pm_message_t state);
588extern void dpm_resume_end(pm_message_t state); 625extern void dpm_resume_end(pm_message_t state);
589extern void dpm_resume(pm_message_t state); 626extern void dpm_resume(pm_message_t state);
590extern void dpm_complete(pm_message_t state); 627extern void dpm_complete(pm_message_t state);
591 628
592extern void device_pm_unlock(void); 629extern void device_pm_unlock(void);
593extern int dpm_suspend_noirq(pm_message_t state); 630extern int dpm_suspend_end(pm_message_t state);
594extern int dpm_suspend_start(pm_message_t state); 631extern int dpm_suspend_start(pm_message_t state);
595extern int dpm_suspend(pm_message_t state); 632extern int dpm_suspend(pm_message_t state);
596extern int dpm_prepare(pm_message_t state); 633extern int dpm_prepare(pm_message_t state);
@@ -605,17 +642,23 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
605extern int device_pm_wait_for_dev(struct device *sub, struct device *dev); 642extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);
606 643
607extern int pm_generic_prepare(struct device *dev); 644extern int pm_generic_prepare(struct device *dev);
645extern int pm_generic_suspend_late(struct device *dev);
608extern int pm_generic_suspend_noirq(struct device *dev); 646extern int pm_generic_suspend_noirq(struct device *dev);
609extern int pm_generic_suspend(struct device *dev); 647extern int pm_generic_suspend(struct device *dev);
648extern int pm_generic_resume_early(struct device *dev);
610extern int pm_generic_resume_noirq(struct device *dev); 649extern int pm_generic_resume_noirq(struct device *dev);
611extern int pm_generic_resume(struct device *dev); 650extern int pm_generic_resume(struct device *dev);
612extern int pm_generic_freeze_noirq(struct device *dev); 651extern int pm_generic_freeze_noirq(struct device *dev);
652extern int pm_generic_freeze_late(struct device *dev);
613extern int pm_generic_freeze(struct device *dev); 653extern int pm_generic_freeze(struct device *dev);
614extern int pm_generic_thaw_noirq(struct device *dev); 654extern int pm_generic_thaw_noirq(struct device *dev);
655extern int pm_generic_thaw_early(struct device *dev);
615extern int pm_generic_thaw(struct device *dev); 656extern int pm_generic_thaw(struct device *dev);
616extern int pm_generic_restore_noirq(struct device *dev); 657extern int pm_generic_restore_noirq(struct device *dev);
658extern int pm_generic_restore_early(struct device *dev);
617extern int pm_generic_restore(struct device *dev); 659extern int pm_generic_restore(struct device *dev);
618extern int pm_generic_poweroff_noirq(struct device *dev); 660extern int pm_generic_poweroff_noirq(struct device *dev);
661extern int pm_generic_poweroff_late(struct device *dev);
619extern int pm_generic_poweroff(struct device *dev); 662extern int pm_generic_poweroff(struct device *dev);
620extern void pm_generic_complete(struct device *dev); 663extern void pm_generic_complete(struct device *dev);
621 664
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index a03a0ad998b8..1236d262b3e8 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -11,6 +11,7 @@
11 11
12#include <linux/device.h> 12#include <linux/device.h>
13#include <linux/err.h> 13#include <linux/err.h>
14#include <linux/of.h>
14 15
15enum gpd_status { 16enum gpd_status {
16 GPD_STATE_ACTIVE = 0, /* PM domain is active */ 17 GPD_STATE_ACTIVE = 0, /* PM domain is active */
@@ -70,6 +71,7 @@ struct generic_pm_domain {
70 s64 break_even_ns; /* Power break even for the entire domain. */ 71 s64 break_even_ns; /* Power break even for the entire domain. */
71 s64 max_off_time_ns; /* Maximum allowed "suspended" time. */ 72 s64 max_off_time_ns; /* Maximum allowed "suspended" time. */
72 ktime_t power_off_time; 73 ktime_t power_off_time;
74 struct device_node *of_node; /* Node in device tree */
73}; 75};
74 76
75static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd) 77static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
@@ -97,14 +99,15 @@ struct generic_pm_domain_data {
97 struct gpd_dev_ops ops; 99 struct gpd_dev_ops ops;
98 struct gpd_timing_data td; 100 struct gpd_timing_data td;
99 bool need_restore; 101 bool need_restore;
102 bool always_on;
100}; 103};
101 104
105#ifdef CONFIG_PM_GENERIC_DOMAINS
102static inline struct generic_pm_domain_data *to_gpd_data(struct pm_domain_data *pdd) 106static inline struct generic_pm_domain_data *to_gpd_data(struct pm_domain_data *pdd)
103{ 107{
104 return container_of(pdd, struct generic_pm_domain_data, base); 108 return container_of(pdd, struct generic_pm_domain_data, base);
105} 109}
106 110
107#ifdef CONFIG_PM_GENERIC_DOMAINS
108static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) 111static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev)
109{ 112{
110 return to_gpd_data(dev->power.subsys_data->domain_data); 113 return to_gpd_data(dev->power.subsys_data->domain_data);
@@ -117,14 +120,25 @@ extern int __pm_genpd_add_device(struct generic_pm_domain *genpd,
117 struct device *dev, 120 struct device *dev,
118 struct gpd_timing_data *td); 121 struct gpd_timing_data *td);
119 122
123extern int __pm_genpd_of_add_device(struct device_node *genpd_node,
124 struct device *dev,
125 struct gpd_timing_data *td);
126
120static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, 127static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
121 struct device *dev) 128 struct device *dev)
122{ 129{
123 return __pm_genpd_add_device(genpd, dev, NULL); 130 return __pm_genpd_add_device(genpd, dev, NULL);
124} 131}
125 132
133static inline int pm_genpd_of_add_device(struct device_node *genpd_node,
134 struct device *dev)
135{
136 return __pm_genpd_of_add_device(genpd_node, dev, NULL);
137}
138
126extern int pm_genpd_remove_device(struct generic_pm_domain *genpd, 139extern int pm_genpd_remove_device(struct generic_pm_domain *genpd,
127 struct device *dev); 140 struct device *dev);
141extern void pm_genpd_dev_always_on(struct device *dev, bool val);
128extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, 142extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
129 struct generic_pm_domain *new_subdomain); 143 struct generic_pm_domain *new_subdomain);
130extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, 144extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
@@ -143,6 +157,10 @@ extern bool default_stop_ok(struct device *dev);
143extern struct dev_power_governor pm_domain_always_on_gov; 157extern struct dev_power_governor pm_domain_always_on_gov;
144#else 158#else
145 159
160static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev)
161{
162 return ERR_PTR(-ENOSYS);
163}
146static inline struct generic_pm_domain *dev_to_genpd(struct device *dev) 164static inline struct generic_pm_domain *dev_to_genpd(struct device *dev)
147{ 165{
148 return ERR_PTR(-ENOSYS); 166 return ERR_PTR(-ENOSYS);
@@ -163,6 +181,7 @@ static inline int pm_genpd_remove_device(struct generic_pm_domain *genpd,
163{ 181{
164 return -ENOSYS; 182 return -ENOSYS;
165} 183}
184static inline void pm_genpd_dev_always_on(struct device *dev, bool val) {}
166static inline int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, 185static inline int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
167 struct generic_pm_domain *new_sd) 186 struct generic_pm_domain *new_sd)
168{ 187{
@@ -183,7 +202,8 @@ static inline int __pm_genpd_remove_callbacks(struct device *dev, bool clear_td)
183{ 202{
184 return -ENOSYS; 203 return -ENOSYS;
185} 204}
186static inline void pm_genpd_init(struct generic_pm_domain *genpd, bool is_off) 205static inline void pm_genpd_init(struct generic_pm_domain *genpd,
206 struct dev_power_governor *gov, bool is_off)
187{ 207{
188} 208}
189static inline int pm_genpd_poweron(struct generic_pm_domain *genpd) 209static inline int pm_genpd_poweron(struct generic_pm_domain *genpd)
@@ -194,6 +214,7 @@ static inline bool default_stop_ok(struct device *dev)
194{ 214{
195 return false; 215 return false;
196} 216}
217#define simple_qos_governor NULL
197#define pm_domain_always_on_gov NULL 218#define pm_domain_always_on_gov NULL
198#endif 219#endif
199 220
diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
index 4d99e4e6ef83..2e9191a712f3 100644
--- a/include/linux/pm_qos.h
+++ b/include/linux/pm_qos.h
@@ -9,12 +9,16 @@
9#include <linux/miscdevice.h> 9#include <linux/miscdevice.h>
10#include <linux/device.h> 10#include <linux/device.h>
11 11
12#define PM_QOS_RESERVED 0 12enum {
13#define PM_QOS_CPU_DMA_LATENCY 1 13 PM_QOS_RESERVED = 0,
14#define PM_QOS_NETWORK_LATENCY 2 14 PM_QOS_CPU_DMA_LATENCY,
15#define PM_QOS_NETWORK_THROUGHPUT 3 15 PM_QOS_NETWORK_LATENCY,
16 PM_QOS_NETWORK_THROUGHPUT,
17
18 /* insert new class ID */
19 PM_QOS_NUM_CLASSES,
20};
16 21
17#define PM_QOS_NUM_CLASSES 4
18#define PM_QOS_DEFAULT_VALUE -1 22#define PM_QOS_DEFAULT_VALUE -1
19 23
20#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) 24#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
@@ -63,7 +67,6 @@ static inline int dev_pm_qos_request_active(struct dev_pm_qos_request *req)
63 return req->dev != 0; 67 return req->dev != 0;
64} 68}
65 69
66#ifdef CONFIG_PM
67int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node, 70int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
68 enum pm_qos_req_action action, int value); 71 enum pm_qos_req_action action, int value);
69void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class, 72void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
@@ -78,6 +81,7 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier);
78int pm_qos_request_active(struct pm_qos_request *req); 81int pm_qos_request_active(struct pm_qos_request *req);
79s32 pm_qos_read_value(struct pm_qos_constraints *c); 82s32 pm_qos_read_value(struct pm_qos_constraints *c);
80 83
84#ifdef CONFIG_PM
81s32 __dev_pm_qos_read_value(struct device *dev); 85s32 __dev_pm_qos_read_value(struct device *dev);
82s32 dev_pm_qos_read_value(struct device *dev); 86s32 dev_pm_qos_read_value(struct device *dev);
83int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, 87int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req,
@@ -95,45 +99,6 @@ void dev_pm_qos_constraints_destroy(struct device *dev);
95int dev_pm_qos_add_ancestor_request(struct device *dev, 99int dev_pm_qos_add_ancestor_request(struct device *dev,
96 struct dev_pm_qos_request *req, s32 value); 100 struct dev_pm_qos_request *req, s32 value);
97#else 101#else
98static inline int pm_qos_update_target(struct pm_qos_constraints *c,
99 struct plist_node *node,
100 enum pm_qos_req_action action,
101 int value)
102 { return 0; }
103static inline void pm_qos_add_request(struct pm_qos_request *req,
104 int pm_qos_class, s32 value)
105 { return; }
106static inline void pm_qos_update_request(struct pm_qos_request *req,
107 s32 new_value)
108 { return; }
109static inline void pm_qos_remove_request(struct pm_qos_request *req)
110 { return; }
111
112static inline int pm_qos_request(int pm_qos_class)
113{
114 switch (pm_qos_class) {
115 case PM_QOS_CPU_DMA_LATENCY:
116 return PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE;
117 case PM_QOS_NETWORK_LATENCY:
118 return PM_QOS_NETWORK_LAT_DEFAULT_VALUE;
119 case PM_QOS_NETWORK_THROUGHPUT:
120 return PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE;
121 default:
122 return PM_QOS_DEFAULT_VALUE;
123 }
124}
125
126static inline int pm_qos_add_notifier(int pm_qos_class,
127 struct notifier_block *notifier)
128 { return 0; }
129static inline int pm_qos_remove_notifier(int pm_qos_class,
130 struct notifier_block *notifier)
131 { return 0; }
132static inline int pm_qos_request_active(struct pm_qos_request *req)
133 { return 0; }
134static inline s32 pm_qos_read_value(struct pm_qos_constraints *c)
135 { return 0; }
136
137static inline s32 __dev_pm_qos_read_value(struct device *dev) 102static inline s32 __dev_pm_qos_read_value(struct device *dev)
138 { return 0; } 103 { return 0; }
139static inline s32 dev_pm_qos_read_value(struct device *dev) 104static inline s32 dev_pm_qos_read_value(struct device *dev)
@@ -172,4 +137,13 @@ static inline int dev_pm_qos_add_ancestor_request(struct device *dev,
172 { return 0; } 137 { return 0; }
173#endif 138#endif
174 139
140#ifdef CONFIG_PM_RUNTIME
141int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value);
142void dev_pm_qos_hide_latency_limit(struct device *dev);
143#else
144static inline int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value)
145 { return 0; }
146static inline void dev_pm_qos_hide_latency_limit(struct device *dev) {}
147#endif
148
175#endif 149#endif
diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h
index a32da962d693..d9f05113e5fb 100644
--- a/include/linux/pm_wakeup.h
+++ b/include/linux/pm_wakeup.h
@@ -41,7 +41,7 @@
41 * @active: Status of the wakeup source. 41 * @active: Status of the wakeup source.
42 */ 42 */
43struct wakeup_source { 43struct wakeup_source {
44 char *name; 44 const char *name;
45 struct list_head entry; 45 struct list_head entry;
46 spinlock_t lock; 46 spinlock_t lock;
47 struct timer_list timer; 47 struct timer_list timer;
@@ -73,7 +73,9 @@ static inline bool device_may_wakeup(struct device *dev)
73} 73}
74 74
75/* drivers/base/power/wakeup.c */ 75/* drivers/base/power/wakeup.c */
76extern void wakeup_source_prepare(struct wakeup_source *ws, const char *name);
76extern struct wakeup_source *wakeup_source_create(const char *name); 77extern struct wakeup_source *wakeup_source_create(const char *name);
78extern void wakeup_source_drop(struct wakeup_source *ws);
77extern void wakeup_source_destroy(struct wakeup_source *ws); 79extern void wakeup_source_destroy(struct wakeup_source *ws);
78extern void wakeup_source_add(struct wakeup_source *ws); 80extern void wakeup_source_add(struct wakeup_source *ws);
79extern void wakeup_source_remove(struct wakeup_source *ws); 81extern void wakeup_source_remove(struct wakeup_source *ws);
@@ -103,11 +105,16 @@ static inline bool device_can_wakeup(struct device *dev)
103 return dev->power.can_wakeup; 105 return dev->power.can_wakeup;
104} 106}
105 107
108static inline void wakeup_source_prepare(struct wakeup_source *ws,
109 const char *name) {}
110
106static inline struct wakeup_source *wakeup_source_create(const char *name) 111static inline struct wakeup_source *wakeup_source_create(const char *name)
107{ 112{
108 return NULL; 113 return NULL;
109} 114}
110 115
116static inline void wakeup_source_drop(struct wakeup_source *ws) {}
117
111static inline void wakeup_source_destroy(struct wakeup_source *ws) {} 118static inline void wakeup_source_destroy(struct wakeup_source *ws) {}
112 119
113static inline void wakeup_source_add(struct wakeup_source *ws) {} 120static inline void wakeup_source_add(struct wakeup_source *ws) {}
@@ -165,4 +172,17 @@ static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {}
165 172
166#endif /* !CONFIG_PM_SLEEP */ 173#endif /* !CONFIG_PM_SLEEP */
167 174
175static inline void wakeup_source_init(struct wakeup_source *ws,
176 const char *name)
177{
178 wakeup_source_prepare(ws, name);
179 wakeup_source_add(ws);
180}
181
182static inline void wakeup_source_trash(struct wakeup_source *ws)
183{
184 wakeup_source_remove(ws);
185 wakeup_source_drop(ws);
186}
187
168#endif /* _LINUX_PM_WAKEUP_H */ 188#endif /* _LINUX_PM_WAKEUP_H */
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 91784a4f8608..ac1c114c499d 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -42,8 +42,10 @@ enum suspend_stat_step {
42 SUSPEND_FREEZE = 1, 42 SUSPEND_FREEZE = 1,
43 SUSPEND_PREPARE, 43 SUSPEND_PREPARE,
44 SUSPEND_SUSPEND, 44 SUSPEND_SUSPEND,
45 SUSPEND_SUSPEND_LATE,
45 SUSPEND_SUSPEND_NOIRQ, 46 SUSPEND_SUSPEND_NOIRQ,
46 SUSPEND_RESUME_NOIRQ, 47 SUSPEND_RESUME_NOIRQ,
48 SUSPEND_RESUME_EARLY,
47 SUSPEND_RESUME 49 SUSPEND_RESUME
48}; 50};
49 51
@@ -53,8 +55,10 @@ struct suspend_stats {
53 int failed_freeze; 55 int failed_freeze;
54 int failed_prepare; 56 int failed_prepare;
55 int failed_suspend; 57 int failed_suspend;
58 int failed_suspend_late;
56 int failed_suspend_noirq; 59 int failed_suspend_noirq;
57 int failed_resume; 60 int failed_resume;
61 int failed_resume_early;
58 int failed_resume_noirq; 62 int failed_resume_noirq;
59#define REC_FAILED_NUM 2 63#define REC_FAILED_NUM 2
60 int last_failed_dev; 64 int last_failed_dev;