aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2015-07-09 11:43:35 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-08-06 21:17:06 -0400
commit19445b25e350ebebaa304bb2135619f643302947 (patch)
treee2aff00939a1ac4e67de9a5e5de6aa15fc78a929
parent8d4d4e98acd68c31435ebb7beea591dbf60b9eb2 (diff)
PM / OPP: add dev_pm_opp_is_turbo() helper
Add dev_pm_opp_is_turbo() helper to verify if an opp is to be used only for turbo mode or not. Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/base/power/opp.c34
-rw-r--r--include/linux/pm_opp.h7
2 files changed, 41 insertions, 0 deletions
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 663aae1c9834..204c6c945168 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -281,6 +281,40 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
281EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq); 281EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq);
282 282
283/** 283/**
284 * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not
285 * @opp: opp for which turbo mode is being verified
286 *
287 * Turbo OPPs are not for normal use, and can be enabled (under certain
288 * conditions) for short duration of times to finish high throughput work
289 * quickly. Running on them for longer times may overheat the chip.
290 *
291 * Return: true if opp is turbo opp, else false.
292 *
293 * Locking: This function must be called under rcu_read_lock(). opp is a rcu
294 * protected pointer. This means that opp which could have been fetched by
295 * opp_find_freq_{exact,ceil,floor} functions is valid as long as we are
296 * under RCU lock. The pointer returned by the opp_find_freq family must be
297 * used in the same section as the usage of this function with the pointer
298 * prior to unlocking with rcu_read_unlock() to maintain the integrity of the
299 * pointer.
300 */
301bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp)
302{
303 struct dev_pm_opp *tmp_opp;
304
305 opp_rcu_lockdep_assert();
306
307 tmp_opp = rcu_dereference(opp);
308 if (IS_ERR_OR_NULL(tmp_opp) || !tmp_opp->available) {
309 pr_err("%s: Invalid parameters\n", __func__);
310 return false;
311 }
312
313 return tmp_opp->turbo;
314}
315EXPORT_SYMBOL_GPL(dev_pm_opp_is_turbo);
316
317/**
284 * dev_pm_opp_get_max_clock_latency() - Get max clock latency in nanoseconds 318 * dev_pm_opp_get_max_clock_latency() - Get max clock latency in nanoseconds
285 * @dev: device for which we do this operation 319 * @dev: device for which we do this operation
286 * 320 *
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index bb52fae5b921..cab7ba55bedb 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -30,6 +30,8 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
30 30
31unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); 31unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
32 32
33bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp);
34
33int dev_pm_opp_get_opp_count(struct device *dev); 35int dev_pm_opp_get_opp_count(struct device *dev);
34unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev); 36unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev);
35 37
@@ -63,6 +65,11 @@ static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
63 return 0; 65 return 0;
64} 66}
65 67
68static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp)
69{
70 return false;
71}
72
66static inline int dev_pm_opp_get_opp_count(struct device *dev) 73static inline int dev_pm_opp_get_opp_count(struct device *dev)
67{ 74{
68 return 0; 75 return 0;