diff options
Diffstat (limited to 'drivers/cpufreq/pxa3xx-cpufreq.c')
-rw-r--r-- | drivers/cpufreq/pxa3xx-cpufreq.c | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c index d26306fb00d2..93840048dd11 100644 --- a/drivers/cpufreq/pxa3xx-cpufreq.c +++ b/drivers/cpufreq/pxa3xx-cpufreq.c | |||
@@ -108,7 +108,7 @@ static int setup_freqs_table(struct cpufreq_policy *policy, | |||
108 | pxa3xx_freqs_num = num; | 108 | pxa3xx_freqs_num = num; |
109 | pxa3xx_freqs_table = table; | 109 | pxa3xx_freqs_table = table; |
110 | 110 | ||
111 | return cpufreq_frequency_table_cpuinfo(policy, table); | 111 | return cpufreq_table_validate_and_show(policy, table); |
112 | } | 112 | } |
113 | 113 | ||
114 | static void __update_core_freq(struct pxa3xx_freq_info *info) | 114 | static void __update_core_freq(struct pxa3xx_freq_info *info) |
@@ -150,54 +150,26 @@ static void __update_bus_freq(struct pxa3xx_freq_info *info) | |||
150 | cpu_relax(); | 150 | cpu_relax(); |
151 | } | 151 | } |
152 | 152 | ||
153 | static int pxa3xx_cpufreq_verify(struct cpufreq_policy *policy) | ||
154 | { | ||
155 | return cpufreq_frequency_table_verify(policy, pxa3xx_freqs_table); | ||
156 | } | ||
157 | |||
158 | static unsigned int pxa3xx_cpufreq_get(unsigned int cpu) | 153 | static unsigned int pxa3xx_cpufreq_get(unsigned int cpu) |
159 | { | 154 | { |
160 | return pxa3xx_get_clk_frequency_khz(0); | 155 | return pxa3xx_get_clk_frequency_khz(0); |
161 | } | 156 | } |
162 | 157 | ||
163 | static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, | 158 | static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, unsigned int index) |
164 | unsigned int target_freq, | ||
165 | unsigned int relation) | ||
166 | { | 159 | { |
167 | struct pxa3xx_freq_info *next; | 160 | struct pxa3xx_freq_info *next; |
168 | struct cpufreq_freqs freqs; | ||
169 | unsigned long flags; | 161 | unsigned long flags; |
170 | int idx; | ||
171 | 162 | ||
172 | if (policy->cpu != 0) | 163 | if (policy->cpu != 0) |
173 | return -EINVAL; | 164 | return -EINVAL; |
174 | 165 | ||
175 | /* Lookup the next frequency */ | 166 | next = &pxa3xx_freqs[index]; |
176 | if (cpufreq_frequency_table_target(policy, pxa3xx_freqs_table, | ||
177 | target_freq, relation, &idx)) | ||
178 | return -EINVAL; | ||
179 | |||
180 | next = &pxa3xx_freqs[idx]; | ||
181 | |||
182 | freqs.old = policy->cur; | ||
183 | freqs.new = next->cpufreq_mhz * 1000; | ||
184 | |||
185 | pr_debug("CPU frequency from %d MHz to %d MHz%s\n", | ||
186 | freqs.old / 1000, freqs.new / 1000, | ||
187 | (freqs.old == freqs.new) ? " (skipped)" : ""); | ||
188 | |||
189 | if (freqs.old == target_freq) | ||
190 | return 0; | ||
191 | |||
192 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
193 | 167 | ||
194 | local_irq_save(flags); | 168 | local_irq_save(flags); |
195 | __update_core_freq(next); | 169 | __update_core_freq(next); |
196 | __update_bus_freq(next); | 170 | __update_bus_freq(next); |
197 | local_irq_restore(flags); | 171 | local_irq_restore(flags); |
198 | 172 | ||
199 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | ||
200 | |||
201 | return 0; | 173 | return 0; |
202 | } | 174 | } |
203 | 175 | ||
@@ -206,11 +178,10 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy) | |||
206 | int ret = -EINVAL; | 178 | int ret = -EINVAL; |
207 | 179 | ||
208 | /* set default policy and cpuinfo */ | 180 | /* set default policy and cpuinfo */ |
209 | policy->cpuinfo.min_freq = 104000; | 181 | policy->min = policy->cpuinfo.min_freq = 104000; |
210 | policy->cpuinfo.max_freq = (cpu_is_pxa320()) ? 806000 : 624000; | 182 | policy->max = policy->cpuinfo.max_freq = |
183 | (cpu_is_pxa320()) ? 806000 : 624000; | ||
211 | policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ | 184 | policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ |
212 | policy->max = pxa3xx_get_clk_frequency_khz(0); | ||
213 | policy->cur = policy->min = policy->max; | ||
214 | 185 | ||
215 | if (cpu_is_pxa300() || cpu_is_pxa310()) | 186 | if (cpu_is_pxa300() || cpu_is_pxa310()) |
216 | ret = setup_freqs_table(policy, pxa300_freqs, | 187 | ret = setup_freqs_table(policy, pxa300_freqs, |
@@ -230,9 +201,10 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy) | |||
230 | } | 201 | } |
231 | 202 | ||
232 | static struct cpufreq_driver pxa3xx_cpufreq_driver = { | 203 | static struct cpufreq_driver pxa3xx_cpufreq_driver = { |
233 | .verify = pxa3xx_cpufreq_verify, | 204 | .verify = cpufreq_generic_frequency_table_verify, |
234 | .target = pxa3xx_cpufreq_set, | 205 | .target_index = pxa3xx_cpufreq_set, |
235 | .init = pxa3xx_cpufreq_init, | 206 | .init = pxa3xx_cpufreq_init, |
207 | .exit = cpufreq_generic_exit, | ||
236 | .get = pxa3xx_cpufreq_get, | 208 | .get = pxa3xx_cpufreq_get, |
237 | .name = "pxa3xx-cpufreq", | 209 | .name = "pxa3xx-cpufreq", |
238 | }; | 210 | }; |