Skip to content

Commit ba7b484

Browse files
vireshkAlex Shi
authored andcommitted
cpufreq: dt: Reuse dev_pm_opp_get_max_transition_latency()
OPP layer has all the information now to calculate transition latency (clock_latency + voltage_latency). Lets reuse the OPP layer helper dev_pm_opp_get_max_transition_latency() instead of open coding the same in cpufreq-dt driver. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 755b888ff098c9f762717a9fbda7e05b16619069) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent 70969a8 commit ba7b484

1 file changed

Lines changed: 4 additions & 44 deletions

File tree

drivers/cpufreq/cpufreq-dt.c

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
222222
struct regulator *cpu_reg;
223223
struct clk *cpu_clk;
224224
struct dev_pm_opp *suspend_opp;
225-
unsigned long min_uV = ~0, max_uV = 0;
226225
unsigned int transition_latency;
227226
bool opp_v1 = false;
228227
const char *name;
@@ -316,49 +315,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
316315
priv->reg_name = name;
317316
of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance);
318317

319-
transition_latency = dev_pm_opp_get_max_clock_latency(cpu_dev);
320-
if (!transition_latency)
321-
transition_latency = CPUFREQ_ETERNAL;
322-
323-
if (!IS_ERR(cpu_reg)) {
324-
unsigned long opp_freq = 0;
325-
326-
/*
327-
* Disable any OPPs where the connected regulator isn't able to
328-
* provide the specified voltage and record minimum and maximum
329-
* voltage levels.
330-
*/
331-
while (1) {
332-
struct dev_pm_opp *opp;
333-
unsigned long opp_uV, tol_uV;
334-
335-
rcu_read_lock();
336-
opp = dev_pm_opp_find_freq_ceil(cpu_dev, &opp_freq);
337-
if (IS_ERR(opp)) {
338-
rcu_read_unlock();
339-
break;
340-
}
341-
opp_uV = dev_pm_opp_get_voltage(opp);
342-
rcu_read_unlock();
343-
344-
tol_uV = opp_uV * priv->voltage_tolerance / 100;
345-
if (regulator_is_supported_voltage(cpu_reg,
346-
opp_uV - tol_uV,
347-
opp_uV + tol_uV)) {
348-
if (opp_uV < min_uV)
349-
min_uV = opp_uV;
350-
if (opp_uV > max_uV)
351-
max_uV = opp_uV;
352-
}
353-
354-
opp_freq++;
355-
}
356-
357-
ret = regulator_set_voltage_time(cpu_reg, min_uV, max_uV);
358-
if (ret > 0)
359-
transition_latency += ret * 1000;
360-
}
361-
362318
ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
363319
if (ret) {
364320
dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret);
@@ -393,6 +349,10 @@ static int cpufreq_init(struct cpufreq_policy *policy)
393349
cpufreq_dt_attr[1] = &cpufreq_freq_attr_scaling_boost_freqs;
394350
}
395351

352+
transition_latency = dev_pm_opp_get_max_transition_latency(cpu_dev);
353+
if (!transition_latency)
354+
transition_latency = CPUFREQ_ETERNAL;
355+
396356
policy->cpuinfo.transition_latency = transition_latency;
397357

398358
of_node_put(np);

0 commit comments

Comments
 (0)