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>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user