ARM: tegra: clock: Clip CPU boot rate to cpufreq table
Alex Frid [Fri, 26 Oct 2012 02:19:25 +0000 (19:19 -0700)]
Clipped CPU boot rate to cpufreq table during cpufreq driver
initialization. This would help avoid futile attempts by cpufreq
governor to adjust the rate while dvfs regulators are not ready.

Bug 1060647

Change-Id: I8984c0c53798413887f866f03704b9097f40a361
Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-on: http://git-master/r/147792
(cherry picked from commit d9325e0bd3cdd1b8d8e4989a0018718dfddb84d0)
Reviewed-on: http://git-master/r/159644
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

arch/arm/mach-tegra/cpu-tegra.c

index d1dc214..96c3425 100644 (file)
@@ -726,6 +726,9 @@ static struct notifier_block tegra_cpu_pm_notifier = {
 
 static int tegra_cpu_init(struct cpufreq_policy *policy)
 {
+       int idx, ret;
+       unsigned int freq;
+
        if (policy->cpu >= CONFIG_NR_CPUS)
                return -EINVAL;
 
@@ -744,7 +747,17 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
 
        cpufreq_frequency_table_cpuinfo(policy, freq_table);
        cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
-       policy->cur = tegra_getspeed(policy->cpu);
+
+       /* clip boot frequency to table entry */
+       freq = tegra_getspeed(policy->cpu);
+       ret = cpufreq_frequency_table_target(policy, freq_table, freq,
+               CPUFREQ_RELATION_H, &idx);
+       if (!ret && (freq != freq_table[idx].frequency)) {
+               ret = tegra_update_cpu_speed(freq_table[idx].frequency);
+               if (!ret)
+                       freq = freq_table[idx].frequency;
+       }
+       policy->cur = freq;
        target_cpu_speed[policy->cpu] = policy->cur;
 
        /* FIXME: what's the actual transition time? */