diff options
author | Nishanth Menon <nm@ti.com> | 2011-05-26 22:39:17 -0400 |
---|---|---|
committer | Kevin Hilman <khilman@ti.com> | 2011-11-08 14:42:17 -0500 |
commit | bf2a359d504bca3ef71a65e8759d51af4b17055a (patch) | |
tree | e54b7c9855df5714482fa99b20f71cd0e9c555b5 /drivers/cpufreq | |
parent | a820ffa8fdbcaa4f5fe32e88db58acca27abbc76 (diff) |
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>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/omap-cpufreq.c | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c index dda32fd0343..eecb0961c6b 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c | |||
@@ -35,8 +35,6 @@ | |||
35 | 35 | ||
36 | #include <mach/hardware.h> | 36 | #include <mach/hardware.h> |
37 | 37 | ||
38 | #define VERY_HI_RATE 900000000 | ||
39 | |||
40 | #ifdef CONFIG_SMP | 38 | #ifdef CONFIG_SMP |
41 | struct lpj_info { | 39 | struct lpj_info { |
42 | unsigned long ref; | 40 | unsigned long ref; |
@@ -54,20 +52,9 @@ static struct device *mpu_dev; | |||
54 | 52 | ||
55 | static int omap_verify_speed(struct cpufreq_policy *policy) | 53 | static int omap_verify_speed(struct cpufreq_policy *policy) |
56 | { | 54 | { |
57 | if (freq_table) | 55 | if (!freq_table) |
58 | return cpufreq_frequency_table_verify(policy, freq_table); | ||
59 | |||
60 | if (policy->cpu) | ||
61 | return -EINVAL; | 56 | return -EINVAL; |
62 | 57 | return cpufreq_frequency_table_verify(policy, freq_table); | |
63 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | ||
64 | policy->cpuinfo.max_freq); | ||
65 | |||
66 | policy->min = clk_round_rate(mpu_clk, policy->min * 1000) / 1000; | ||
67 | policy->max = clk_round_rate(mpu_clk, policy->max * 1000) / 1000; | ||
68 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | ||
69 | policy->cpuinfo.max_freq); | ||
70 | return 0; | ||
71 | } | 58 | } |
72 | 59 | ||
73 | static unsigned int omap_getspeed(unsigned int cpu) | 60 | static unsigned int omap_getspeed(unsigned int cpu) |
@@ -85,18 +72,31 @@ static int omap_target(struct cpufreq_policy *policy, | |||
85 | unsigned int target_freq, | 72 | unsigned int target_freq, |
86 | unsigned int relation) | 73 | unsigned int relation) |
87 | { | 74 | { |
88 | int i, ret = 0; | 75 | unsigned int i; |
76 | int ret = 0; | ||
89 | struct cpufreq_freqs freqs; | 77 | struct cpufreq_freqs freqs; |
90 | 78 | ||
91 | /* Ensure desired rate is within allowed range. Some govenors | 79 | if (!freq_table) { |
92 | * (ondemand) will just pass target_freq=0 to get the minimum. */ | 80 | dev_err(mpu_dev, "%s: cpu%d: no freq table!\n", __func__, |
93 | if (target_freq < policy->min) | 81 | policy->cpu); |
94 | target_freq = policy->min; | 82 | return -EINVAL; |
95 | if (target_freq > policy->max) | 83 | } |
96 | target_freq = policy->max; | 84 | |
85 | ret = cpufreq_frequency_table_target(policy, freq_table, target_freq, | ||
86 | relation, &i); | ||
87 | if (ret) { | ||
88 | dev_dbg(mpu_dev, "%s: cpu%d: no freq match for %d(ret=%d)\n", | ||
89 | __func__, policy->cpu, target_freq, ret); | ||
90 | return ret; | ||
91 | } | ||
92 | freqs.new = freq_table[i].frequency; | ||
93 | if (!freqs.new) { | ||
94 | dev_err(mpu_dev, "%s: cpu%d: no match for freq %d\n", __func__, | ||
95 | policy->cpu, target_freq); | ||
96 | return -EINVAL; | ||
97 | } | ||
97 | 98 | ||
98 | freqs.old = omap_getspeed(policy->cpu); | 99 | freqs.old = omap_getspeed(policy->cpu); |
99 | freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000; | ||
100 | freqs.cpu = policy->cpu; | 100 | freqs.cpu = policy->cpu; |
101 | 101 | ||
102 | if (freqs.old == freqs.new && policy->cur == freqs.new) | 102 | if (freqs.old == freqs.new && policy->cur == freqs.new) |
@@ -162,19 +162,18 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) | |||
162 | return -EINVAL; | 162 | return -EINVAL; |
163 | 163 | ||
164 | policy->cur = policy->min = policy->max = omap_getspeed(policy->cpu); | 164 | policy->cur = policy->min = policy->max = omap_getspeed(policy->cpu); |
165 | opp_init_cpufreq_table(mpu_dev, &freq_table); | 165 | result = opp_init_cpufreq_table(mpu_dev, &freq_table); |
166 | 166 | ||
167 | if (freq_table) { | 167 | if (result) { |
168 | result = cpufreq_frequency_table_cpuinfo(policy, freq_table); | 168 | dev_err(mpu_dev, "%s: cpu%d: failed creating freq table[%d]\n", |
169 | if (!result) | 169 | __func__, policy->cpu, result); |
170 | cpufreq_frequency_table_get_attr(freq_table, | 170 | return result; |
171 | policy->cpu); | ||
172 | } else { | ||
173 | policy->cpuinfo.min_freq = clk_round_rate(mpu_clk, 0) / 1000; | ||
174 | policy->cpuinfo.max_freq = clk_round_rate(mpu_clk, | ||
175 | VERY_HI_RATE) / 1000; | ||
176 | } | 171 | } |
177 | 172 | ||
173 | result = cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
174 | if (!result) | ||
175 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); | ||
176 | |||
178 | policy->min = policy->cpuinfo.min_freq; | 177 | policy->min = policy->cpuinfo.min_freq; |
179 | policy->max = policy->cpuinfo.max_freq; | 178 | policy->max = policy->cpuinfo.max_freq; |
180 | policy->cur = omap_getspeed(policy->cpu); | 179 | policy->cur = omap_getspeed(policy->cpu); |