diff options
Diffstat (limited to 'drivers/cpufreq/speedstep-centrino.c')
-rw-r--r-- | drivers/cpufreq/speedstep-centrino.c | 67 |
1 files changed, 12 insertions, 55 deletions
diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c index f897d5105842..c51ec8c0e3a8 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) | |||
343 | static int centrino_cpu_init(struct cpufreq_policy *policy) | 343 | static 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 | ||
416 | static int centrino_cpu_exit(struct cpufreq_policy *policy) | 402 | static int centrino_cpu_exit(struct cpufreq_policy *policy) |
@@ -428,36 +414,19 @@ 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 | */ | ||
437 | static 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 | */ |
452 | static int centrino_target (struct cpufreq_policy *policy, | 423 | static 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; | 426 | struct cpufreq_freqs freqs; |
459 | int retval = 0; | 427 | int retval = 0; |
460 | unsigned int j, first_cpu, tmp; | 428 | unsigned int j, first_cpu, tmp; |
429 | struct cpufreq_frequency_table *op_points; | ||
461 | cpumask_var_t covered_cpus; | 430 | cpumask_var_t covered_cpus; |
462 | 431 | ||
463 | if (unlikely(!zalloc_cpumask_var(&covered_cpus, GFP_KERNEL))) | 432 | if (unlikely(!zalloc_cpumask_var(&covered_cpus, GFP_KERNEL))) |
@@ -468,16 +437,8 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
468 | goto out; | 437 | goto out; |
469 | } | 438 | } |
470 | 439 | ||
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; | 440 | first_cpu = 1; |
441 | op_points = &per_cpu(centrino_model, cpu)->op_points[index]; | ||
481 | for_each_cpu(j, policy->cpus) { | 442 | for_each_cpu(j, policy->cpus) { |
482 | int good_cpu; | 443 | int good_cpu; |
483 | 444 | ||
@@ -501,7 +462,7 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
501 | break; | 462 | break; |
502 | } | 463 | } |
503 | 464 | ||
504 | msr = per_cpu(centrino_model, cpu)->op_points[newstate].driver_data; | 465 | msr = op_points->driver_data; |
505 | 466 | ||
506 | if (first_cpu) { | 467 | if (first_cpu) { |
507 | rdmsr_on_cpu(good_cpu, MSR_IA32_PERF_CTL, &oldmsr, &h); | 468 | rdmsr_on_cpu(good_cpu, MSR_IA32_PERF_CTL, &oldmsr, &h); |
@@ -516,7 +477,8 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
516 | freqs.new = extract_clock(msr, cpu, 0); | 477 | freqs.new = extract_clock(msr, cpu, 0); |
517 | 478 | ||
518 | pr_debug("target=%dkHz old=%d new=%d msr=%04x\n", | 479 | pr_debug("target=%dkHz old=%d new=%d msr=%04x\n", |
519 | target_freq, freqs.old, freqs.new, msr); | 480 | op_points->frequency, freqs.old, freqs.new, |
481 | msr); | ||
520 | 482 | ||
521 | cpufreq_notify_transition(policy, &freqs, | 483 | cpufreq_notify_transition(policy, &freqs, |
522 | CPUFREQ_PRECHANGE); | 484 | CPUFREQ_PRECHANGE); |
@@ -561,20 +523,15 @@ out: | |||
561 | return retval; | 523 | return retval; |
562 | } | 524 | } |
563 | 525 | ||
564 | static struct freq_attr* centrino_attr[] = { | ||
565 | &cpufreq_freq_attr_scaling_available_freqs, | ||
566 | NULL, | ||
567 | }; | ||
568 | |||
569 | static struct cpufreq_driver centrino_driver = { | 526 | static struct cpufreq_driver centrino_driver = { |
570 | .name = "centrino", /* should be speedstep-centrino, | 527 | .name = "centrino", /* should be speedstep-centrino, |
571 | but there's a 16 char limit */ | 528 | but there's a 16 char limit */ |
572 | .init = centrino_cpu_init, | 529 | .init = centrino_cpu_init, |
573 | .exit = centrino_cpu_exit, | 530 | .exit = centrino_cpu_exit, |
574 | .verify = centrino_verify, | 531 | .verify = cpufreq_generic_frequency_table_verify, |
575 | .target = centrino_target, | 532 | .target_index = centrino_target, |
576 | .get = get_cur_freq, | 533 | .get = get_cur_freq, |
577 | .attr = centrino_attr, | 534 | .attr = cpufreq_generic_attr, |
578 | }; | 535 | }; |
579 | 536 | ||
580 | /* | 537 | /* |