summaryrefslogtreecommitdiff
path: root/drivers/devfreq/governor_simpleondemand.c
diff options
context:
space:
mode:
authorMyungJoo Ham <myungjoo.ham@samsung.com>2011-12-09 16:42:19 +0900
committerMyungJoo Ham <myungjoo.ham@samsung.com>2012-01-20 10:12:38 +0900
commit6530b9dea1b7f33eaf79ba625e3a99f2455f3eb1 (patch)
tree70beddf04779d5941ba6ef851b30e02c7fa0c86c /drivers/devfreq/governor_simpleondemand.c
parenta95e1f5dbca385908aa4087bb98470b0e0ac58d8 (diff)
PM / devfreq: add min/max_freq limit requested by users.
The frequency requested to devfreq device driver from devfreq governors is restricted by min_freq and max_freq input. Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Diffstat (limited to 'drivers/devfreq/governor_simpleondemand.c')
-rw-r--r--drivers/devfreq/governor_simpleondemand.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
index efad8dcf9028..a2e3eae79011 100644
--- a/drivers/devfreq/governor_simpleondemand.c
+++ b/drivers/devfreq/governor_simpleondemand.c
@@ -25,6 +25,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
unsigned int dfso_upthreshold = DFSO_UPTHRESHOLD;
unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;
struct devfreq_simple_ondemand_data *data = df->data;
+ unsigned long max = (df->max_freq) ? df->max_freq : UINT_MAX;
if (err)
return err;
@@ -41,7 +42,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
/* Assume MAX if it is going to be divided by zero */
if (stat.total_time == 0) {
- *freq = UINT_MAX;
+ *freq = max;
return 0;
}
@@ -54,13 +55,13 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
/* Set MAX if it's busy enough */
if (stat.busy_time * 100 >
stat.total_time * dfso_upthreshold) {
- *freq = UINT_MAX;
+ *freq = max;
return 0;
}
/* Set MAX if we do not know the initial frequency */
if (stat.current_frequency == 0) {
- *freq = UINT_MAX;
+ *freq = max;
return 0;
}
@@ -79,6 +80,11 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
b = div_u64(b, (dfso_upthreshold - dfso_downdifferential / 2));
*freq = (unsigned long) b;
+ if (df->min_freq && *freq < df->min_freq)
+ *freq = df->min_freq;
+ if (df->max_freq && *freq > df->max_freq)
+ *freq = df->max_freq;
+
return 0;
}