Commit f3b5c894fd416bc9f0d92a1ba542869e42b53f56

Authored by Nishanth Menon
Committed by Afzal Mohammed
1 parent 43e940442c
Exists in master

cpufreq: OMAP: dont support !freq_table

OMAP2+ all have frequency tables, hence the hacks we had for older
silicon do not need to be carried forward. As part of this change,
use cpufreq_frequency_table_target to find the best match for
frequency requested.

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
[vaibhav.bedia@ti.com: Pull in for AM33xx]
Signed-off-by: Vaibhav Bedia <vaibhav.bedia@ti.com>

Showing 1 changed file with 33 additions and 34 deletions Side-by-side Diff

drivers/cpufreq/omap-cpufreq.c
... ... @@ -36,8 +36,6 @@
36 36  
37 37 #include <mach/hardware.h>
38 38  
39   -#define VERY_HI_RATE 900000000
40   -
41 39 #ifdef CONFIG_SMP
42 40 struct lpj_info {
43 41 unsigned long ref;
44 42  
... ... @@ -55,20 +53,9 @@
55 53  
56 54 static int omap_verify_speed(struct cpufreq_policy *policy)
57 55 {
58   - if (freq_table)
59   - return cpufreq_frequency_table_verify(policy, freq_table);
60   -
61   - if (policy->cpu)
  56 + if (!freq_table)
62 57 return -EINVAL;
63   -
64   - cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
65   - policy->cpuinfo.max_freq);
66   -
67   - policy->min = clk_round_rate(mpu_clk, policy->min * 1000) / 1000;
68   - policy->max = clk_round_rate(mpu_clk, policy->max * 1000) / 1000;
69   - cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
70   - policy->cpuinfo.max_freq);
71   - return 0;
  58 + return cpufreq_frequency_table_verify(policy, freq_table);
72 59 }
73 60  
74 61 static unsigned int omap_getspeed(unsigned int cpu)
75 62  
76 63  
77 64  
... ... @@ -86,18 +73,31 @@
86 73 unsigned int target_freq,
87 74 unsigned int relation)
88 75 {
89   - int i, ret = 0;
  76 + unsigned int i;
  77 + int ret = 0;
90 78 struct cpufreq_freqs freqs;
91 79  
92   - /* Ensure desired rate is within allowed range. Some govenors
93   - * (ondemand) will just pass target_freq=0 to get the minimum. */
94   - if (target_freq < policy->min)
95   - target_freq = policy->min;
96   - if (target_freq > policy->max)
97   - target_freq = policy->max;
  80 + if (!freq_table) {
  81 + dev_err(mpu_dev, "%s: cpu%d: no freq table!\n", __func__,
  82 + policy->cpu);
  83 + return -EINVAL;
  84 + }
98 85  
  86 + ret = cpufreq_frequency_table_target(policy, freq_table, target_freq,
  87 + relation, &i);
  88 + if (ret) {
  89 + dev_dbg(mpu_dev, "%s: cpu%d: no freq match for %d(ret=%d)\n",
  90 + __func__, policy->cpu, target_freq, ret);
  91 + return ret;
  92 + }
  93 + freqs.new = freq_table[i].frequency;
  94 + if (!freqs.new) {
  95 + dev_err(mpu_dev, "%s: cpu%d: no match for freq %d\n", __func__,
  96 + policy->cpu, target_freq);
  97 + return -EINVAL;
  98 + }
  99 +
99 100 freqs.old = omap_getspeed(policy->cpu);
100   - freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000;
101 101 freqs.cpu = policy->cpu;
102 102  
103 103 if (freqs.old == freqs.new && policy->cur == freqs.new)
104 104  
105 105  
... ... @@ -163,18 +163,17 @@
163 163 return -EINVAL;
164 164  
165 165 policy->cur = policy->min = policy->max = omap_getspeed(policy->cpu);
166   - opp_init_cpufreq_table(mpu_dev, &freq_table);
  166 + result = opp_init_cpufreq_table(mpu_dev, &freq_table);
167 167  
168   - if (freq_table) {
169   - result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
170   - if (!result)
171   - cpufreq_frequency_table_get_attr(freq_table,
172   - policy->cpu);
173   - } else {
174   - policy->cpuinfo.min_freq = clk_round_rate(mpu_clk, 0) / 1000;
175   - policy->cpuinfo.max_freq = clk_round_rate(mpu_clk,
176   - VERY_HI_RATE) / 1000;
  168 + if (result) {
  169 + dev_err(mpu_dev, "%s: cpu%d: failed creating freq table[%d]\n",
  170 + __func__, policy->cpu, result);
  171 + return result;
177 172 }
  173 +
  174 + result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
  175 + if (!result)
  176 + cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
178 177  
179 178 policy->min = policy->cpuinfo.min_freq;
180 179 policy->max = policy->cpuinfo.max_freq;