aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/pmac32-cpufreq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq/pmac32-cpufreq.c')
-rw-r--r--drivers/cpufreq/pmac32-cpufreq.c53
1 files changed, 9 insertions, 44 deletions
diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
index a096cd3fa23d..cf55d202f332 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -86,11 +86,6 @@ static struct cpufreq_frequency_table pmac_cpu_freqs[] = {
86 {0, CPUFREQ_TABLE_END}, 86 {0, CPUFREQ_TABLE_END},
87}; 87};
88 88
89static struct freq_attr* pmac_cpu_freqs_attr[] = {
90 &cpufreq_freq_attr_scaling_available_freqs,
91 NULL,
92};
93
94static inline void local_delay(unsigned long ms) 89static inline void local_delay(unsigned long ms)
95{ 90{
96 if (no_schedule) 91 if (no_schedule)
@@ -336,21 +331,11 @@ static int pmu_set_cpu_speed(int low_speed)
336 return 0; 331 return 0;
337} 332}
338 333
339static int do_set_cpu_speed(struct cpufreq_policy *policy, int speed_mode, 334static int do_set_cpu_speed(struct cpufreq_policy *policy, int speed_mode)
340 int notify)
341{ 335{
342 struct cpufreq_freqs freqs;
343 unsigned long l3cr; 336 unsigned long l3cr;
344 static unsigned long prev_l3cr; 337 static unsigned long prev_l3cr;
345 338
346 freqs.old = cur_freq;
347 freqs.new = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq;
348
349 if (freqs.old == freqs.new)
350 return 0;
351
352 if (notify)
353 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
354 if (speed_mode == CPUFREQ_LOW && 339 if (speed_mode == CPUFREQ_LOW &&
355 cpu_has_feature(CPU_FTR_L3CR)) { 340 cpu_has_feature(CPU_FTR_L3CR)) {
356 l3cr = _get_L3CR(); 341 l3cr = _get_L3CR();
@@ -366,8 +351,6 @@ static int do_set_cpu_speed(struct cpufreq_policy *policy, int speed_mode,
366 if ((prev_l3cr & L3CR_L3E) && l3cr != prev_l3cr) 351 if ((prev_l3cr & L3CR_L3E) && l3cr != prev_l3cr)
367 _set_L3CR(prev_l3cr); 352 _set_L3CR(prev_l3cr);
368 } 353 }
369 if (notify)
370 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
371 cur_freq = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq; 354 cur_freq = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq;
372 355
373 return 0; 356 return 0;
@@ -378,23 +361,12 @@ static unsigned int pmac_cpufreq_get_speed(unsigned int cpu)
378 return cur_freq; 361 return cur_freq;
379} 362}
380 363
381static int pmac_cpufreq_verify(struct cpufreq_policy *policy)
382{
383 return cpufreq_frequency_table_verify(policy, pmac_cpu_freqs);
384}
385
386static int pmac_cpufreq_target( struct cpufreq_policy *policy, 364static int pmac_cpufreq_target( struct cpufreq_policy *policy,
387 unsigned int target_freq, 365 unsigned int index)
388 unsigned int relation)
389{ 366{
390 unsigned int newstate = 0;
391 int rc; 367 int rc;
392 368
393 if (cpufreq_frequency_table_target(policy, pmac_cpu_freqs, 369 rc = do_set_cpu_speed(policy, index);
394 target_freq, relation, &newstate))
395 return -EINVAL;
396
397 rc = do_set_cpu_speed(policy, newstate, 1);
398 370
399 ppc_proc_freq = cur_freq * 1000ul; 371 ppc_proc_freq = cur_freq * 1000ul;
400 return rc; 372 return rc;
@@ -402,14 +374,7 @@ static int pmac_cpufreq_target( struct cpufreq_policy *policy,
402 374
403static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy) 375static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy)
404{ 376{
405 if (policy->cpu != 0) 377 return cpufreq_generic_init(policy, pmac_cpu_freqs, transition_latency);
406 return -ENODEV;
407
408 policy->cpuinfo.transition_latency = transition_latency;
409 policy->cur = cur_freq;
410
411 cpufreq_frequency_table_get_attr(pmac_cpu_freqs, policy->cpu);
412 return cpufreq_frequency_table_cpuinfo(policy, pmac_cpu_freqs);
413} 378}
414 379
415static u32 read_gpio(struct device_node *np) 380static u32 read_gpio(struct device_node *np)
@@ -443,7 +408,7 @@ static int pmac_cpufreq_suspend(struct cpufreq_policy *policy)
443 no_schedule = 1; 408 no_schedule = 1;
444 sleep_freq = cur_freq; 409 sleep_freq = cur_freq;
445 if (cur_freq == low_freq && !is_pmu_based) 410 if (cur_freq == low_freq && !is_pmu_based)
446 do_set_cpu_speed(policy, CPUFREQ_HIGH, 0); 411 do_set_cpu_speed(policy, CPUFREQ_HIGH);
447 return 0; 412 return 0;
448} 413}
449 414
@@ -460,7 +425,7 @@ static int pmac_cpufreq_resume(struct cpufreq_policy *policy)
460 * probably high speed due to our suspend() routine 425 * probably high speed due to our suspend() routine
461 */ 426 */
462 do_set_cpu_speed(policy, sleep_freq == low_freq ? 427 do_set_cpu_speed(policy, sleep_freq == low_freq ?
463 CPUFREQ_LOW : CPUFREQ_HIGH, 0); 428 CPUFREQ_LOW : CPUFREQ_HIGH);
464 429
465 ppc_proc_freq = cur_freq * 1000ul; 430 ppc_proc_freq = cur_freq * 1000ul;
466 431
@@ -469,14 +434,14 @@ static int pmac_cpufreq_resume(struct cpufreq_policy *policy)
469} 434}
470 435
471static struct cpufreq_driver pmac_cpufreq_driver = { 436static struct cpufreq_driver pmac_cpufreq_driver = {
472 .verify = pmac_cpufreq_verify, 437 .verify = cpufreq_generic_frequency_table_verify,
473 .target = pmac_cpufreq_target, 438 .target_index = pmac_cpufreq_target,
474 .get = pmac_cpufreq_get_speed, 439 .get = pmac_cpufreq_get_speed,
475 .init = pmac_cpufreq_cpu_init, 440 .init = pmac_cpufreq_cpu_init,
476 .suspend = pmac_cpufreq_suspend, 441 .suspend = pmac_cpufreq_suspend,
477 .resume = pmac_cpufreq_resume, 442 .resume = pmac_cpufreq_resume,
478 .flags = CPUFREQ_PM_NO_WARN, 443 .flags = CPUFREQ_PM_NO_WARN,
479 .attr = pmac_cpu_freqs_attr, 444 .attr = cpufreq_generic_attr,
480 .name = "powermac", 445 .name = "powermac",
481}; 446};
482 447