aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/speedstep-centrino.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq/speedstep-centrino.c')
-rw-r--r--drivers/cpufreq/speedstep-centrino.c84
1 files changed, 11 insertions, 73 deletions
diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
index f897d5105842..4e1daca5ce3b 100644
--- a/drivers/cpufreq/speedstep-centrino.c
+++ b/drivers/cpufreq/speedstep-centrino.c
@@ -343,9 +343,7 @@ static unsigned int get_cur_freq(unsigned int cpu)
343static int centrino_cpu_init(struct cpufreq_policy *policy) 343static int centrino_cpu_init(struct cpufreq_policy *policy)
344{ 344{
345 struct cpuinfo_x86 *cpu = &cpu_data(policy->cpu); 345 struct cpuinfo_x86 *cpu = &cpu_data(policy->cpu);
346 unsigned freq;
347 unsigned l, h; 346 unsigned l, h;
348 int ret;
349 int i; 347 int i;
350 348
351 /* Only Intel makes Enhanced Speedstep-capable CPUs */ 349 /* Only Intel makes Enhanced Speedstep-capable CPUs */
@@ -373,9 +371,8 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
373 return -ENODEV; 371 return -ENODEV;
374 } 372 }
375 373
376 if (centrino_cpu_init_table(policy)) { 374 if (centrino_cpu_init_table(policy))
377 return -ENODEV; 375 return -ENODEV;
378 }
379 376
380 /* Check to see if Enhanced SpeedStep is enabled, and try to 377 /* Check to see if Enhanced SpeedStep is enabled, and try to
381 enable it if not. */ 378 enable it if not. */
@@ -395,22 +392,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
395 } 392 }
396 } 393 }
397 394
398 freq = get_cur_freq(policy->cpu);
399 policy->cpuinfo.transition_latency = 10000; 395 policy->cpuinfo.transition_latency = 10000;
400 /* 10uS transition latency */ 396 /* 10uS transition latency */
401 policy->cur = freq;
402
403 pr_debug("centrino_cpu_init: cur=%dkHz\n", policy->cur);
404 397
405 ret = cpufreq_frequency_table_cpuinfo(policy, 398 return cpufreq_table_validate_and_show(policy,
406 per_cpu(centrino_model, policy->cpu)->op_points); 399 per_cpu(centrino_model, policy->cpu)->op_points);
407 if (ret)
408 return (ret);
409
410 cpufreq_frequency_table_get_attr(
411 per_cpu(centrino_model, policy->cpu)->op_points, policy->cpu);
412
413 return 0;
414} 400}
415 401
416static int centrino_cpu_exit(struct cpufreq_policy *policy) 402static int centrino_cpu_exit(struct cpufreq_policy *policy)
@@ -428,36 +414,18 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy)
428} 414}
429 415
430/** 416/**
431 * centrino_verify - verifies a new CPUFreq policy
432 * @policy: new policy
433 *
434 * Limit must be within this model's frequency range at least one
435 * border included.
436 */
437static int centrino_verify (struct cpufreq_policy *policy)
438{
439 return cpufreq_frequency_table_verify(policy,
440 per_cpu(centrino_model, policy->cpu)->op_points);
441}
442
443/**
444 * centrino_setpolicy - set a new CPUFreq policy 417 * centrino_setpolicy - set a new CPUFreq policy
445 * @policy: new policy 418 * @policy: new policy
446 * @target_freq: the target frequency 419 * @index: index of target frequency
447 * @relation: how that frequency relates to achieved frequency
448 * (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
449 * 420 *
450 * Sets a new CPUFreq policy. 421 * Sets a new CPUFreq policy.
451 */ 422 */
452static int centrino_target (struct cpufreq_policy *policy, 423static int centrino_target(struct cpufreq_policy *policy, unsigned int index)
453 unsigned int target_freq,
454 unsigned int relation)
455{ 424{
456 unsigned int newstate = 0;
457 unsigned int msr, oldmsr = 0, h = 0, cpu = policy->cpu; 425 unsigned int msr, oldmsr = 0, h = 0, cpu = policy->cpu;
458 struct cpufreq_freqs freqs;
459 int retval = 0; 426 int retval = 0;
460 unsigned int j, first_cpu, tmp; 427 unsigned int j, first_cpu;
428 struct cpufreq_frequency_table *op_points;
461 cpumask_var_t covered_cpus; 429 cpumask_var_t covered_cpus;
462 430
463 if (unlikely(!zalloc_cpumask_var(&covered_cpus, GFP_KERNEL))) 431 if (unlikely(!zalloc_cpumask_var(&covered_cpus, GFP_KERNEL)))
@@ -468,16 +436,8 @@ static int centrino_target (struct cpufreq_policy *policy,
468 goto out; 436 goto out;
469 } 437 }
470 438
471 if (unlikely(cpufreq_frequency_table_target(policy,
472 per_cpu(centrino_model, cpu)->op_points,
473 target_freq,
474 relation,
475 &newstate))) {
476 retval = -EINVAL;
477 goto out;
478 }
479
480 first_cpu = 1; 439 first_cpu = 1;
440 op_points = &per_cpu(centrino_model, cpu)->op_points[index];
481 for_each_cpu(j, policy->cpus) { 441 for_each_cpu(j, policy->cpus) {
482 int good_cpu; 442 int good_cpu;
483 443
@@ -501,7 +461,7 @@ static int centrino_target (struct cpufreq_policy *policy,
501 break; 461 break;
502 } 462 }
503 463
504 msr = per_cpu(centrino_model, cpu)->op_points[newstate].driver_data; 464 msr = op_points->driver_data;
505 465
506 if (first_cpu) { 466 if (first_cpu) {
507 rdmsr_on_cpu(good_cpu, MSR_IA32_PERF_CTL, &oldmsr, &h); 467 rdmsr_on_cpu(good_cpu, MSR_IA32_PERF_CTL, &oldmsr, &h);
@@ -512,15 +472,6 @@ static int centrino_target (struct cpufreq_policy *policy,
512 goto out; 472 goto out;
513 } 473 }
514 474
515 freqs.old = extract_clock(oldmsr, cpu, 0);
516 freqs.new = extract_clock(msr, cpu, 0);
517
518 pr_debug("target=%dkHz old=%d new=%d msr=%04x\n",
519 target_freq, freqs.old, freqs.new, msr);
520
521 cpufreq_notify_transition(policy, &freqs,
522 CPUFREQ_PRECHANGE);
523
524 first_cpu = 0; 475 first_cpu = 0;
525 /* all but 16 LSB are reserved, treat them with care */ 476 /* all but 16 LSB are reserved, treat them with care */
526 oldmsr &= ~0xffff; 477 oldmsr &= ~0xffff;
@@ -535,8 +486,6 @@ static int centrino_target (struct cpufreq_policy *policy,
535 cpumask_set_cpu(j, covered_cpus); 486 cpumask_set_cpu(j, covered_cpus);
536 } 487 }
537 488
538 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
539
540 if (unlikely(retval)) { 489 if (unlikely(retval)) {
541 /* 490 /*
542 * We have failed halfway through the frequency change. 491 * We have failed halfway through the frequency change.
@@ -547,12 +496,6 @@ static int centrino_target (struct cpufreq_policy *policy,
547 496
548 for_each_cpu(j, covered_cpus) 497 for_each_cpu(j, covered_cpus)
549 wrmsr_on_cpu(j, MSR_IA32_PERF_CTL, oldmsr, h); 498 wrmsr_on_cpu(j, MSR_IA32_PERF_CTL, oldmsr, h);
550
551 tmp = freqs.new;
552 freqs.new = freqs.old;
553 freqs.old = tmp;
554 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
555 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
556 } 499 }
557 retval = 0; 500 retval = 0;
558 501
@@ -561,20 +504,15 @@ out:
561 return retval; 504 return retval;
562} 505}
563 506
564static struct freq_attr* centrino_attr[] = {
565 &cpufreq_freq_attr_scaling_available_freqs,
566 NULL,
567};
568
569static struct cpufreq_driver centrino_driver = { 507static struct cpufreq_driver centrino_driver = {
570 .name = "centrino", /* should be speedstep-centrino, 508 .name = "centrino", /* should be speedstep-centrino,
571 but there's a 16 char limit */ 509 but there's a 16 char limit */
572 .init = centrino_cpu_init, 510 .init = centrino_cpu_init,
573 .exit = centrino_cpu_exit, 511 .exit = centrino_cpu_exit,
574 .verify = centrino_verify, 512 .verify = cpufreq_generic_frequency_table_verify,
575 .target = centrino_target, 513 .target_index = centrino_target,
576 .get = get_cur_freq, 514 .get = get_cur_freq,
577 .attr = centrino_attr, 515 .attr = cpufreq_generic_attr,
578}; 516};
579 517
580/* 518/*