[CPUFREQ] correct powernow-k8 fid/vid masks for extended parts
[deliverable/linux.git] / arch / i386 / kernel / cpu / cpufreq / speedstep-centrino.c
CommitLineData
1da177e4
LT
1/*
2 * cpufreq driver for Enhanced SpeedStep, as found in Intel's Pentium
3 * M (part of the Centrino chipset).
4 *
5 * Despite the "SpeedStep" in the name, this is almost entirely unlike
6 * traditional SpeedStep.
7 *
8 * Modelled on speedstep.c
9 *
10 * Copyright (C) 2003 Jeremy Fitzhardinge <jeremy@goop.org>
11 *
12 * WARNING WARNING WARNING
13 *
14 * This driver manipulates the PERF_CTL MSR, which is only somewhat
15 * documented. While it seems to work on my laptop, it has not been
16 * tested anywhere else, and it may not work for you, do strange
17 * things or simply crash.
18 */
19
20#include <linux/kernel.h>
21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/cpufreq.h>
24#include <linux/config.h>
4e57b681 25#include <linux/sched.h> /* current */
1da177e4
LT
26#include <linux/delay.h>
27#include <linux/compiler.h>
28
29#ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI
30#include <linux/acpi.h>
31#include <acpi/processor.h>
32#endif
33
34#include <asm/msr.h>
35#include <asm/processor.h>
36#include <asm/cpufeature.h>
37
1da177e4
LT
38#define PFX "speedstep-centrino: "
39#define MAINTAINER "Jeremy Fitzhardinge <jeremy@goop.org>"
40
41#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-centrino", msg)
42
43
44struct cpu_id
45{
46 __u8 x86; /* CPU family */
47 __u8 x86_model; /* model */
48 __u8 x86_mask; /* stepping */
49};
50
51enum {
52 CPU_BANIAS,
53 CPU_DOTHAN_A1,
54 CPU_DOTHAN_A2,
55 CPU_DOTHAN_B0,
8282864a
DJ
56 CPU_MP4HT_D0,
57 CPU_MP4HT_E0,
1da177e4
LT
58};
59
60static const struct cpu_id cpu_ids[] = {
61 [CPU_BANIAS] = { 6, 9, 5 },
62 [CPU_DOTHAN_A1] = { 6, 13, 1 },
63 [CPU_DOTHAN_A2] = { 6, 13, 2 },
64 [CPU_DOTHAN_B0] = { 6, 13, 6 },
8282864a
DJ
65 [CPU_MP4HT_D0] = {15, 3, 4 },
66 [CPU_MP4HT_E0] = {15, 4, 1 },
1da177e4 67};
38e548ee 68#define N_IDS ARRAY_SIZE(cpu_ids)
1da177e4
LT
69
70struct cpu_model
71{
72 const struct cpu_id *cpu_id;
73 const char *model_name;
74 unsigned max_freq; /* max clock in kHz */
75
76 struct cpufreq_frequency_table *op_points; /* clock/voltage pairs */
77};
78static int centrino_verify_cpu_id(const struct cpuinfo_x86 *c, const struct cpu_id *x);
79
80/* Operating points for current CPU */
81static struct cpu_model *centrino_model[NR_CPUS];
82static const struct cpu_id *centrino_cpu[NR_CPUS];
83
84static struct cpufreq_driver centrino_driver;
85
86#ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE
87
88/* Computes the correct form for IA32_PERF_CTL MSR for a particular
89 frequency/voltage operating point; frequency in MHz, volts in mV.
90 This is stored as "index" in the structure. */
91#define OP(mhz, mv) \
92 { \
93 .frequency = (mhz) * 1000, \
94 .index = (((mhz)/100) << 8) | ((mv - 700) / 16) \
95 }
96
97/*
98 * These voltage tables were derived from the Intel Pentium M
99 * datasheet, document 25261202.pdf, Table 5. I have verified they
100 * are consistent with my IBM ThinkPad X31, which has a 1.3GHz Pentium
101 * M.
102 */
103
104/* Ultra Low Voltage Intel Pentium M processor 900MHz (Banias) */
105static struct cpufreq_frequency_table banias_900[] =
106{
107 OP(600, 844),
108 OP(800, 988),
109 OP(900, 1004),
110 { .frequency = CPUFREQ_TABLE_END }
111};
112
113/* Ultra Low Voltage Intel Pentium M processor 1000MHz (Banias) */
114static struct cpufreq_frequency_table banias_1000[] =
115{
116 OP(600, 844),
117 OP(800, 972),
118 OP(900, 988),
119 OP(1000, 1004),
120 { .frequency = CPUFREQ_TABLE_END }
121};
122
123/* Low Voltage Intel Pentium M processor 1.10GHz (Banias) */
124static struct cpufreq_frequency_table banias_1100[] =
125{
126 OP( 600, 956),
127 OP( 800, 1020),
128 OP( 900, 1100),
129 OP(1000, 1164),
130 OP(1100, 1180),
131 { .frequency = CPUFREQ_TABLE_END }
132};
133
134
135/* Low Voltage Intel Pentium M processor 1.20GHz (Banias) */
136static struct cpufreq_frequency_table banias_1200[] =
137{
138 OP( 600, 956),
139 OP( 800, 1004),
140 OP( 900, 1020),
141 OP(1000, 1100),
142 OP(1100, 1164),
143 OP(1200, 1180),
144 { .frequency = CPUFREQ_TABLE_END }
145};
146
147/* Intel Pentium M processor 1.30GHz (Banias) */
148static struct cpufreq_frequency_table banias_1300[] =
149{
150 OP( 600, 956),
151 OP( 800, 1260),
152 OP(1000, 1292),
153 OP(1200, 1356),
154 OP(1300, 1388),
155 { .frequency = CPUFREQ_TABLE_END }
156};
157
158/* Intel Pentium M processor 1.40GHz (Banias) */
159static struct cpufreq_frequency_table banias_1400[] =
160{
161 OP( 600, 956),
162 OP( 800, 1180),
163 OP(1000, 1308),
164 OP(1200, 1436),
165 OP(1400, 1484),
166 { .frequency = CPUFREQ_TABLE_END }
167};
168
169/* Intel Pentium M processor 1.50GHz (Banias) */
170static struct cpufreq_frequency_table banias_1500[] =
171{
172 OP( 600, 956),
173 OP( 800, 1116),
174 OP(1000, 1228),
175 OP(1200, 1356),
176 OP(1400, 1452),
177 OP(1500, 1484),
178 { .frequency = CPUFREQ_TABLE_END }
179};
180
181/* Intel Pentium M processor 1.60GHz (Banias) */
182static struct cpufreq_frequency_table banias_1600[] =
183{
184 OP( 600, 956),
185 OP( 800, 1036),
186 OP(1000, 1164),
187 OP(1200, 1276),
188 OP(1400, 1420),
189 OP(1600, 1484),
190 { .frequency = CPUFREQ_TABLE_END }
191};
192
193/* Intel Pentium M processor 1.70GHz (Banias) */
194static struct cpufreq_frequency_table banias_1700[] =
195{
196 OP( 600, 956),
197 OP( 800, 1004),
198 OP(1000, 1116),
199 OP(1200, 1228),
200 OP(1400, 1308),
201 OP(1700, 1484),
202 { .frequency = CPUFREQ_TABLE_END }
203};
204#undef OP
205
206#define _BANIAS(cpuid, max, name) \
207{ .cpu_id = cpuid, \
208 .model_name = "Intel(R) Pentium(R) M processor " name "MHz", \
209 .max_freq = (max)*1000, \
210 .op_points = banias_##max, \
211}
212#define BANIAS(max) _BANIAS(&cpu_ids[CPU_BANIAS], max, #max)
213
214/* CPU models, their operating frequency range, and freq/voltage
215 operating points */
216static struct cpu_model models[] =
217{
218 _BANIAS(&cpu_ids[CPU_BANIAS], 900, " 900"),
219 BANIAS(1000),
220 BANIAS(1100),
221 BANIAS(1200),
222 BANIAS(1300),
223 BANIAS(1400),
224 BANIAS(1500),
225 BANIAS(1600),
226 BANIAS(1700),
227
228 /* NULL model_name is a wildcard */
229 { &cpu_ids[CPU_DOTHAN_A1], NULL, 0, NULL },
230 { &cpu_ids[CPU_DOTHAN_A2], NULL, 0, NULL },
231 { &cpu_ids[CPU_DOTHAN_B0], NULL, 0, NULL },
8282864a
DJ
232 { &cpu_ids[CPU_MP4HT_D0], NULL, 0, NULL },
233 { &cpu_ids[CPU_MP4HT_E0], NULL, 0, NULL },
1da177e4
LT
234
235 { NULL, }
236};
237#undef _BANIAS
238#undef BANIAS
239
240static int centrino_cpu_init_table(struct cpufreq_policy *policy)
241{
242 struct cpuinfo_x86 *cpu = &cpu_data[policy->cpu];
243 struct cpu_model *model;
244
245 for(model = models; model->cpu_id != NULL; model++)
246 if (centrino_verify_cpu_id(cpu, model->cpu_id) &&
247 (model->model_name == NULL ||
248 strcmp(cpu->x86_model_id, model->model_name) == 0))
249 break;
250
251 if (model->cpu_id == NULL) {
252 /* No match at all */
8c362a5d 253 dprintk("no support for CPU model \"%s\": "
1da177e4
LT
254 "send /proc/cpuinfo to " MAINTAINER "\n",
255 cpu->x86_model_id);
256 return -ENOENT;
257 }
258
259 if (model->op_points == NULL) {
260 /* Matched a non-match */
8c362a5d 261 dprintk("no table support for CPU model \"%s\"\n",
1da177e4
LT
262 cpu->x86_model_id);
263#ifndef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI
8c362a5d 264 dprintk("try compiling with CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI enabled\n");
1da177e4
LT
265#endif
266 return -ENOENT;
267 }
268
269 centrino_model[policy->cpu] = model;
270
271 dprintk("found \"%s\": max frequency: %dkHz\n",
272 model->model_name, model->max_freq);
273
274 return 0;
275}
276
277#else
278static inline int centrino_cpu_init_table(struct cpufreq_policy *policy) { return -ENODEV; }
279#endif /* CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE */
280
281static int centrino_verify_cpu_id(const struct cpuinfo_x86 *c, const struct cpu_id *x)
282{
283 if ((c->x86 == x->x86) &&
284 (c->x86_model == x->x86_model) &&
285 (c->x86_mask == x->x86_mask))
286 return 1;
287 return 0;
288}
289
290/* To be called only after centrino_model is initialized */
291static unsigned extract_clock(unsigned msr, unsigned int cpu, int failsafe)
292{
293 int i;
294
295 /*
296 * Extract clock in kHz from PERF_CTL value
297 * for centrino, as some DSDTs are buggy.
298 * Ideally, this can be done using the acpi_data structure.
299 */
300 if ((centrino_cpu[cpu] == &cpu_ids[CPU_BANIAS]) ||
301 (centrino_cpu[cpu] == &cpu_ids[CPU_DOTHAN_A1]) ||
302 (centrino_cpu[cpu] == &cpu_ids[CPU_DOTHAN_B0])) {
303 msr = (msr >> 8) & 0xff;
304 return msr * 100000;
305 }
306
307 if ((!centrino_model[cpu]) || (!centrino_model[cpu]->op_points))
308 return 0;
309
310 msr &= 0xffff;
311 for (i=0;centrino_model[cpu]->op_points[i].frequency != CPUFREQ_TABLE_END; i++) {
312 if (msr == centrino_model[cpu]->op_points[i].index)
313 return centrino_model[cpu]->op_points[i].frequency;
314 }
315 if (failsafe)
316 return centrino_model[cpu]->op_points[i-1].frequency;
317 else
318 return 0;
319}
320
321/* Return the current CPU frequency in kHz */
322static unsigned int get_cur_freq(unsigned int cpu)
323{
324 unsigned l, h;
325 unsigned clock_freq;
326 cpumask_t saved_mask;
327
328 saved_mask = current->cpus_allowed;
329 set_cpus_allowed(current, cpumask_of_cpu(cpu));
330 if (smp_processor_id() != cpu)
331 return 0;
332
333 rdmsr(MSR_IA32_PERF_STATUS, l, h);
334 clock_freq = extract_clock(l, cpu, 0);
335
336 if (unlikely(clock_freq == 0)) {
337 /*
338 * On some CPUs, we can see transient MSR values (which are
339 * not present in _PSS), while CPU is doing some automatic
340 * P-state transition (like TM2). Get the last freq set
341 * in PERF_CTL.
342 */
343 rdmsr(MSR_IA32_PERF_CTL, l, h);
344 clock_freq = extract_clock(l, cpu, 1);
345 }
346
347 set_cpus_allowed(current, saved_mask);
348 return clock_freq;
349}
350
351
352#ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI
353
354static struct acpi_processor_performance p;
355
356/*
357 * centrino_cpu_init_acpi - register with ACPI P-States library
358 *
359 * Register with the ACPI P-States library (part of drivers/acpi/processor.c)
360 * in order to determine correct frequency and voltage pairings by reading
361 * the _PSS of the ACPI DSDT or SSDT tables.
362 */
363static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
364{
1da177e4
LT
365 unsigned long cur_freq;
366 int result = 0, i;
367 unsigned int cpu = policy->cpu;
368
1da177e4
LT
369 /* register with ACPI core */
370 if (acpi_processor_register_performance(&p, cpu)) {
8c362a5d 371 dprintk("obtaining ACPI data failed\n");
1da177e4
LT
372 return -EIO;
373 }
374
375 /* verify the acpi_data */
376 if (p.state_count <= 1) {
377 dprintk("No P-States\n");
378 result = -ENODEV;
379 goto err_unreg;
380 }
381
382 if ((p.control_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) ||
383 (p.status_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) {
384 dprintk("Invalid control/status registers (%x - %x)\n",
385 p.control_register.space_id, p.status_register.space_id);
386 result = -EIO;
387 goto err_unreg;
388 }
389
390 for (i=0; i<p.state_count; i++) {
391 if (p.states[i].control != p.states[i].status) {
123411f2 392 dprintk("Different control (%llu) and status values (%llu)\n",
1da177e4
LT
393 p.states[i].control, p.states[i].status);
394 result = -EINVAL;
395 goto err_unreg;
396 }
397
398 if (!p.states[i].core_frequency) {
399 dprintk("Zero core frequency for state %u\n", i);
400 result = -EINVAL;
401 goto err_unreg;
402 }
403
404 if (p.states[i].core_frequency > p.states[0].core_frequency) {
123411f2 405 dprintk("P%u has larger frequency (%llu) than P0 (%llu), skipping\n", i,
1da177e4
LT
406 p.states[i].core_frequency, p.states[0].core_frequency);
407 p.states[i].core_frequency = 0;
408 continue;
409 }
410 }
411
bfdc708d 412 centrino_model[cpu] = kzalloc(sizeof(struct cpu_model), GFP_KERNEL);
1da177e4
LT
413 if (!centrino_model[cpu]) {
414 result = -ENOMEM;
415 goto err_unreg;
416 }
1da177e4
LT
417
418 centrino_model[cpu]->model_name=NULL;
419 centrino_model[cpu]->max_freq = p.states[0].core_frequency * 1000;
420 centrino_model[cpu]->op_points = kmalloc(sizeof(struct cpufreq_frequency_table) *
421 (p.state_count + 1), GFP_KERNEL);
422 if (!centrino_model[cpu]->op_points) {
423 result = -ENOMEM;
424 goto err_kfree;
425 }
426
427 for (i=0; i<p.state_count; i++) {
428 centrino_model[cpu]->op_points[i].index = p.states[i].control;
429 centrino_model[cpu]->op_points[i].frequency = p.states[i].core_frequency * 1000;
430 dprintk("adding state %i with frequency %u and control value %04x\n",
431 i, centrino_model[cpu]->op_points[i].frequency, centrino_model[cpu]->op_points[i].index);
432 }
433 centrino_model[cpu]->op_points[p.state_count].frequency = CPUFREQ_TABLE_END;
434
435 cur_freq = get_cur_freq(cpu);
436
437 for (i=0; i<p.state_count; i++) {
438 if (!p.states[i].core_frequency) {
439 dprintk("skipping state %u\n", i);
440 centrino_model[cpu]->op_points[i].frequency = CPUFREQ_ENTRY_INVALID;
441 continue;
442 }
443
444 if (extract_clock(centrino_model[cpu]->op_points[i].index, cpu, 0) !=
445 (centrino_model[cpu]->op_points[i].frequency)) {
446 dprintk("Invalid encoded frequency (%u vs. %u)\n",
447 extract_clock(centrino_model[cpu]->op_points[i].index, cpu, 0),
448 centrino_model[cpu]->op_points[i].frequency);
449 result = -EINVAL;
450 goto err_kfree_all;
451 }
452
453 if (cur_freq == centrino_model[cpu]->op_points[i].frequency)
454 p.state = i;
455 }
456
457 /* notify BIOS that we exist */
458 acpi_processor_notify_smm(THIS_MODULE);
459
460 return 0;
461
462 err_kfree_all:
463 kfree(centrino_model[cpu]->op_points);
464 err_kfree:
465 kfree(centrino_model[cpu]);
466 err_unreg:
467 acpi_processor_unregister_performance(&p, cpu);
8c362a5d 468 dprintk("invalid ACPI data\n");
1da177e4
LT
469 return (result);
470}
471#else
472static inline int centrino_cpu_init_acpi(struct cpufreq_policy *policy) { return -ENODEV; }
473#endif
474
475static int centrino_cpu_init(struct cpufreq_policy *policy)
476{
477 struct cpuinfo_x86 *cpu = &cpu_data[policy->cpu];
478 unsigned freq;
479 unsigned l, h;
480 int ret;
481 int i;
482
483 /* Only Intel makes Enhanced Speedstep-capable CPUs */
484 if (cpu->x86_vendor != X86_VENDOR_INTEL || !cpu_has(cpu, X86_FEATURE_EST))
485 return -ENODEV;
486
8ad5496d 487 if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
1da177e4 488 centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
1da177e4
LT
489
490 if (centrino_cpu_init_acpi(policy)) {
491 if (policy->cpu != 0)
492 return -ENODEV;
493
f914be79
VP
494 for (i = 0; i < N_IDS; i++)
495 if (centrino_verify_cpu_id(cpu, &cpu_ids[i]))
496 break;
497
498 if (i != N_IDS)
499 centrino_cpu[policy->cpu] = &cpu_ids[i];
500
1da177e4 501 if (!centrino_cpu[policy->cpu]) {
8c362a5d 502 dprintk("found unsupported CPU with "
1da177e4
LT
503 "Enhanced SpeedStep: send /proc/cpuinfo to "
504 MAINTAINER "\n");
505 return -ENODEV;
506 }
507
508 if (centrino_cpu_init_table(policy)) {
509 return -ENODEV;
510 }
511 }
512
513 /* Check to see if Enhanced SpeedStep is enabled, and try to
514 enable it if not. */
515 rdmsr(MSR_IA32_MISC_ENABLE, l, h);
516
517 if (!(l & (1<<16))) {
518 l |= (1<<16);
519 dprintk("trying to enable Enhanced SpeedStep (%x)\n", l);
520 wrmsr(MSR_IA32_MISC_ENABLE, l, h);
521
522 /* check to see if it stuck */
523 rdmsr(MSR_IA32_MISC_ENABLE, l, h);
524 if (!(l & (1<<16))) {
525 printk(KERN_INFO PFX "couldn't enable Enhanced SpeedStep\n");
526 return -ENODEV;
527 }
528 }
529
530 freq = get_cur_freq(policy->cpu);
531
532 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
533 policy->cpuinfo.transition_latency = 10000; /* 10uS transition latency */
534 policy->cur = freq;
535
536 dprintk("centrino_cpu_init: cur=%dkHz\n", policy->cur);
537
538 ret = cpufreq_frequency_table_cpuinfo(policy, centrino_model[policy->cpu]->op_points);
539 if (ret)
540 return (ret);
541
542 cpufreq_frequency_table_get_attr(centrino_model[policy->cpu]->op_points, policy->cpu);
543
544 return 0;
545}
546
547static int centrino_cpu_exit(struct cpufreq_policy *policy)
548{
549 unsigned int cpu = policy->cpu;
550
551 if (!centrino_model[cpu])
552 return -ENODEV;
553
554 cpufreq_frequency_table_put_attr(cpu);
555
556#ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI
557 if (!centrino_model[cpu]->model_name) {
558 dprintk("unregistering and freeing ACPI data\n");
559 acpi_processor_unregister_performance(&p, cpu);
560 kfree(centrino_model[cpu]->op_points);
561 kfree(centrino_model[cpu]);
562 }
563#endif
564
565 centrino_model[cpu] = NULL;
566
567 return 0;
568}
569
570/**
571 * centrino_verify - verifies a new CPUFreq policy
572 * @policy: new policy
573 *
574 * Limit must be within this model's frequency range at least one
575 * border included.
576 */
577static int centrino_verify (struct cpufreq_policy *policy)
578{
579 return cpufreq_frequency_table_verify(policy, centrino_model[policy->cpu]->op_points);
580}
581
582/**
583 * centrino_setpolicy - set a new CPUFreq policy
584 * @policy: new policy
585 * @target_freq: the target frequency
586 * @relation: how that frequency relates to achieved frequency (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
587 *
588 * Sets a new CPUFreq policy.
589 */
590static int centrino_target (struct cpufreq_policy *policy,
591 unsigned int target_freq,
592 unsigned int relation)
593{
594 unsigned int newstate = 0;
595 unsigned int msr, oldmsr, h, cpu = policy->cpu;
596 struct cpufreq_freqs freqs;
597 cpumask_t saved_mask;
598 int retval;
599
600 if (centrino_model[cpu] == NULL)
601 return -ENODEV;
602
603 /*
604 * Support for SMP systems.
605 * Make sure we are running on the CPU that wants to change frequency
606 */
607 saved_mask = current->cpus_allowed;
608 set_cpus_allowed(current, policy->cpus);
609 if (!cpu_isset(smp_processor_id(), policy->cpus)) {
610 dprintk("couldn't limit to CPUs in this domain\n");
611 return(-EAGAIN);
612 }
613
614 if (cpufreq_frequency_table_target(policy, centrino_model[cpu]->op_points, target_freq,
615 relation, &newstate)) {
616 retval = -EINVAL;
617 goto migrate_end;
618 }
619
620 msr = centrino_model[cpu]->op_points[newstate].index;
621 rdmsr(MSR_IA32_PERF_CTL, oldmsr, h);
622
623 if (msr == (oldmsr & 0xffff)) {
624 retval = 0;
625 dprintk("no change needed - msr was and needs to be %x\n", oldmsr);
626 goto migrate_end;
627 }
628
629 freqs.cpu = cpu;
630 freqs.old = extract_clock(oldmsr, cpu, 0);
631 freqs.new = extract_clock(msr, cpu, 0);
632
633 dprintk("target=%dkHz old=%d new=%d msr=%04x\n",
634 target_freq, freqs.old, freqs.new, msr);
635
636 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
637
638 /* all but 16 LSB are "reserved", so treat them with
639 care */
640 oldmsr &= ~0xffff;
641 msr &= 0xffff;
642 oldmsr |= msr;
643
644 wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
645
646 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
647
648 retval = 0;
649migrate_end:
650 set_cpus_allowed(current, saved_mask);
651 return (retval);
652}
653
654static struct freq_attr* centrino_attr[] = {
655 &cpufreq_freq_attr_scaling_available_freqs,
656 NULL,
657};
658
659static struct cpufreq_driver centrino_driver = {
660 .name = "centrino", /* should be speedstep-centrino,
661 but there's a 16 char limit */
662 .init = centrino_cpu_init,
663 .exit = centrino_cpu_exit,
664 .verify = centrino_verify,
665 .target = centrino_target,
666 .get = get_cur_freq,
667 .attr = centrino_attr,
668 .owner = THIS_MODULE,
669};
670
671
672/**
673 * centrino_init - initializes the Enhanced SpeedStep CPUFreq driver
674 *
675 * Initializes the Enhanced SpeedStep support. Returns -ENODEV on
676 * unsupported devices, -ENOENT if there's no voltage table for this
677 * particular CPU model, -EINVAL on problems during initiatization,
678 * and zero on success.
679 *
680 * This is quite picky. Not only does the CPU have to advertise the
681 * "est" flag in the cpuid capability flags, we look for a specific
682 * CPU model and stepping, and we need to have the exact model name in
683 * our voltage tables. That is, be paranoid about not releasing
684 * someone's valuable magic smoke.
685 */
686static int __init centrino_init(void)
687{
688 struct cpuinfo_x86 *cpu = cpu_data;
689
690 if (!cpu_has(cpu, X86_FEATURE_EST))
691 return -ENODEV;
692
693 return cpufreq_register_driver(&centrino_driver);
694}
695
696static void __exit centrino_exit(void)
697{
698 cpufreq_unregister_driver(&centrino_driver);
699}
700
701MODULE_AUTHOR ("Jeremy Fitzhardinge <jeremy@goop.org>");
702MODULE_DESCRIPTION ("Enhanced SpeedStep driver for Intel Pentium M processors.");
703MODULE_LICENSE ("GPL");
704
705late_initcall(centrino_init);
706module_exit(centrino_exit);
This page took 0.203604 seconds and 5 git commands to generate.