diff options
author | Rafael J. Wysocki <rjw@rjwysocki.net> | 2013-10-25 16:36:40 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@rjwysocki.net> | 2013-10-25 16:36:40 -0400 |
commit | 6ddee424fea2d269c2f402278d93165c7b92dc58 (patch) | |
tree | c1b1d0d9058846a6da22def648dea61e16faacd0 /drivers/cpufreq/omap-cpufreq.c | |
parent | e4db1c7439b31993a4886b273bb9235a8eea82bf (diff) | |
parent | a814613b9a32d9ab9578d9dab396265c826d37f0 (diff) |
Merge back earlier 'pm-cpufreq' material.
Conflicts:
drivers/cpufreq/omap-cpufreq.c
Diffstat (limited to 'drivers/cpufreq/omap-cpufreq.c')
-rw-r--r-- | drivers/cpufreq/omap-cpufreq.c | 64 |
1 files changed, 14 insertions, 50 deletions
diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c index 20190f56594f..ac552d090463 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c | |||
@@ -40,13 +40,6 @@ static struct clk *mpu_clk; | |||
40 | static struct device *mpu_dev; | 40 | static struct device *mpu_dev; |
41 | static struct regulator *mpu_reg; | 41 | static struct regulator *mpu_reg; |
42 | 42 | ||
43 | static int omap_verify_speed(struct cpufreq_policy *policy) | ||
44 | { | ||
45 | if (!freq_table) | ||
46 | return -EINVAL; | ||
47 | return cpufreq_frequency_table_verify(policy, freq_table); | ||
48 | } | ||
49 | |||
50 | static unsigned int omap_getspeed(unsigned int cpu) | 43 | static unsigned int omap_getspeed(unsigned int cpu) |
51 | { | 44 | { |
52 | unsigned long rate; | 45 | unsigned long rate; |
@@ -167,81 +160,52 @@ static inline void freq_table_free(void) | |||
167 | 160 | ||
168 | static int omap_cpu_init(struct cpufreq_policy *policy) | 161 | static int omap_cpu_init(struct cpufreq_policy *policy) |
169 | { | 162 | { |
170 | int result = 0; | 163 | int result; |
171 | 164 | ||
172 | mpu_clk = clk_get(NULL, "cpufreq_ck"); | 165 | mpu_clk = clk_get(NULL, "cpufreq_ck"); |
173 | if (IS_ERR(mpu_clk)) | 166 | if (IS_ERR(mpu_clk)) |
174 | return PTR_ERR(mpu_clk); | 167 | return PTR_ERR(mpu_clk); |
175 | 168 | ||
176 | if (policy->cpu >= NR_CPUS) { | 169 | if (!freq_table) { |
177 | result = -EINVAL; | ||
178 | goto fail_ck; | ||
179 | } | ||
180 | |||
181 | policy->cur = omap_getspeed(policy->cpu); | ||
182 | |||
183 | if (!freq_table) | ||
184 | result = dev_pm_opp_init_cpufreq_table(mpu_dev, &freq_table); | 170 | result = dev_pm_opp_init_cpufreq_table(mpu_dev, &freq_table); |
185 | 171 | if (result) { | |
186 | if (result) { | 172 | dev_err(mpu_dev, |
187 | dev_err(mpu_dev, "%s: cpu%d: failed creating freq table[%d]\n", | 173 | "%s: cpu%d: failed creating freq table[%d]\n", |
188 | __func__, policy->cpu, result); | 174 | __func__, policy->cpu, result); |
189 | goto fail_ck; | 175 | goto fail; |
176 | } | ||
190 | } | 177 | } |
191 | 178 | ||
192 | atomic_inc_return(&freq_table_users); | 179 | atomic_inc_return(&freq_table_users); |
193 | 180 | ||
194 | result = cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
195 | if (result) | ||
196 | goto fail_table; | ||
197 | |||
198 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); | ||
199 | |||
200 | policy->cur = omap_getspeed(policy->cpu); | ||
201 | |||
202 | /* | ||
203 | * On OMAP SMP configuartion, both processors share the voltage | ||
204 | * and clock. So both CPUs needs to be scaled together and hence | ||
205 | * needs software co-ordination. Use cpufreq affected_cpus | ||
206 | * interface to handle this scenario. Additional is_smp() check | ||
207 | * is to keep SMP_ON_UP build working. | ||
208 | */ | ||
209 | if (is_smp()) | ||
210 | cpumask_setall(policy->cpus); | ||
211 | |||
212 | /* FIXME: what's the actual transition time? */ | 181 | /* FIXME: what's the actual transition time? */ |
213 | policy->cpuinfo.transition_latency = 300 * 1000; | 182 | result = cpufreq_generic_init(policy, freq_table, 300 * 1000); |
214 | 183 | if (!result) | |
215 | return 0; | 184 | return 0; |
216 | 185 | ||
217 | fail_table: | ||
218 | freq_table_free(); | 186 | freq_table_free(); |
219 | fail_ck: | 187 | fail: |
220 | clk_put(mpu_clk); | 188 | clk_put(mpu_clk); |
221 | return result; | 189 | return result; |
222 | } | 190 | } |
223 | 191 | ||
224 | static int omap_cpu_exit(struct cpufreq_policy *policy) | 192 | static int omap_cpu_exit(struct cpufreq_policy *policy) |
225 | { | 193 | { |
194 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
226 | freq_table_free(); | 195 | freq_table_free(); |
227 | clk_put(mpu_clk); | 196 | clk_put(mpu_clk); |
228 | return 0; | 197 | return 0; |
229 | } | 198 | } |
230 | 199 | ||
231 | static struct freq_attr *omap_cpufreq_attr[] = { | ||
232 | &cpufreq_freq_attr_scaling_available_freqs, | ||
233 | NULL, | ||
234 | }; | ||
235 | |||
236 | static struct cpufreq_driver omap_driver = { | 200 | static struct cpufreq_driver omap_driver = { |
237 | .flags = CPUFREQ_STICKY, | 201 | .flags = CPUFREQ_STICKY, |
238 | .verify = omap_verify_speed, | 202 | .verify = cpufreq_generic_frequency_table_verify, |
239 | .target = omap_target, | 203 | .target = omap_target, |
240 | .get = omap_getspeed, | 204 | .get = omap_getspeed, |
241 | .init = omap_cpu_init, | 205 | .init = omap_cpu_init, |
242 | .exit = omap_cpu_exit, | 206 | .exit = omap_cpu_exit, |
243 | .name = "omap", | 207 | .name = "omap", |
244 | .attr = omap_cpufreq_attr, | 208 | .attr = cpufreq_generic_attr, |
245 | }; | 209 | }; |
246 | 210 | ||
247 | static int omap_cpufreq_probe(struct platform_device *pdev) | 211 | static int omap_cpufreq_probe(struct platform_device *pdev) |