[PATCH V4 38/62] SPEAr CPU freq: Adding support for CPU Freq framework
From: Russell King - ARM Linux <hidden>
Date: 2011-01-19 09:53:58
On Wed, Jan 19, 2011 at 03:09:42PM +0530, Shiraz Hashim wrote:
On second thought it should always be there irrespective of failures
as in our case it may happen that eventually CPU sets to a clock <=
desired clock. So we would do following
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
ret = clk_set_rate(cpu_clk, freqs.new * 1000);
if (ret)
pr_err("Could not change cpu clk rate\n");
freqs.new = clk_get_rate(cpu_clk);
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
It probably makes more sense to do:
newfreq = clk_round_rate(cpu_clk, freqs.new * 1000);
if (newfreq < 0) {
pr_err("Invalid frequency blah blah\n");
return newfreq;
}
freqs.new = newfreq / 1000;
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
ret = clk_set_rate(cpu_clk, newfreq);
if (ret) {
pr_err("Could not change cpu clk rate\n");
freqs.new = clk_get_rate(cpu_clk) / 1000;
}
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
so that the prechange notifier gets the actual frequency to be switched
to too. In theory clk_set_rate() should only fail if the new frequency
couldn't be set for some reason.