2 * (C) 2001-2004 Dave Jones. <davej@codemonkey.org.uk>
3 * (C) 2002 Padraig Brady. <padraig@antefacto.com>
5 * Licensed under the terms of the GNU GPL License version 2.
6 * Based upon datasheets & sample CPUs kindly provided by VIA.
8 * VIA have currently 3 different versions of Longhaul.
9 * Version 1 (Longhaul) uses the BCR2 MSR at 0x1147.
10 * It is present only in Samuel 1 (C5A), Samuel 2 (C5B) stepping 0.
11 * Version 2 of longhaul is the same as v1, but adds voltage scaling.
12 * Present in Samuel 2 (steppings 1-7 only) (C5B), and Ezra (C5C)
13 * voltage scaling support has currently been disabled in this driver
14 * until we have code that gets it right.
15 * Version 3 of longhaul got renamed to Powersaver and redesigned
16 * to use the POWERSAVER MSR at 0x110a.
17 * It is present in Ezra-T (C5M), Nehemiah (C5X) and above.
18 * It's pretty much the same feature wise to longhaul v2, though
19 * there is provision for scaling FSB too, but this doesn't work
20 * too well in practice so we don't even try to use this.
22 * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous*
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/moduleparam.h>
28 #include <linux/init.h>
29 #include <linux/cpufreq.h>
30 #include <linux/pci.h>
31 #include <linux/slab.h>
32 #include <linux/string.h>
35 #include <asm/timex.h>
38 #include <linux/acpi.h>
39 #include <acpi/processor.h>
43 #define PFX "longhaul: "
45 #define TYPE_LONGHAUL_V1 1
46 #define TYPE_LONGHAUL_V2 2
47 #define TYPE_POWERSAVER 3
53 #define CPU_NEHEMIAH 5
54 #define CPU_NEHEMIAH_C 6
57 #define USE_ACPI_C3 (1 << 1)
58 #define USE_NORTHBRIDGE (1 << 2)
59 #define USE_VT8235 (1 << 3)
62 static unsigned int numscales=16;
63 static unsigned int fsb;
65 static struct mV_pos *vrm_mV_table;
66 static unsigned char *mV_vrm_table;
71 static struct f_msr f_msr_table[32];
73 static unsigned int highest_speed, lowest_speed; /* kHz */
74 static unsigned int minmult, maxmult;
75 static int can_scale_voltage;
76 static struct acpi_processor *pr = NULL;
77 static struct acpi_processor_cx *cx = NULL;
78 static u8 longhaul_flags;
79 static u8 longhaul_pos;
81 /* Module parameters */
82 static int scale_voltage;
84 #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "longhaul", msg)
87 /* Clock ratios multiplied by 10 */
88 static int clock_ratio[32];
89 static int eblcr_table[32];
90 static int longhaul_version;
91 static struct cpufreq_frequency_table *longhaul_table;
93 #ifdef CONFIG_CPU_FREQ_DEBUG
94 static char speedbuffer[8];
96 static char *print_speed(int speed)
99 snprintf(speedbuffer, sizeof(speedbuffer),"%dMHz", speed);
104 snprintf(speedbuffer, sizeof(speedbuffer),
105 "%dGHz", speed/1000);
107 snprintf(speedbuffer, sizeof(speedbuffer),
108 "%d.%dGHz", speed/1000, (speed%1000)/100);
115 static unsigned int calc_speed(int mult)
126 static int longhaul_get_cpu_mult(void)
128 unsigned long invalue=0,lo, hi;
130 rdmsr (MSR_IA32_EBL_CR_POWERON, lo, hi);
131 invalue = (lo & (1<<22|1<<23|1<<24|1<<25)) >>22;
132 if (longhaul_version==TYPE_LONGHAUL_V2 || longhaul_version==TYPE_POWERSAVER) {
136 return eblcr_table[invalue];
139 /* For processor with BCR2 MSR */
141 static void do_longhaul1(unsigned int clock_ratio_index)
145 rdmsrl(MSR_VIA_BCR2, bcr2.val);
146 /* Enable software clock multiplier */
147 bcr2.bits.ESOFTBF = 1;
148 bcr2.bits.CLOCKMUL = clock_ratio_index;
150 /* Sync to timer tick */
152 /* Change frequency on next halt or sleep */
153 wrmsrl(MSR_VIA_BCR2, bcr2.val);
154 /* Invoke transition */
155 ACPI_FLUSH_CPU_CACHE();
158 /* Disable software clock multiplier */
160 rdmsrl(MSR_VIA_BCR2, bcr2.val);
161 bcr2.bits.ESOFTBF = 0;
162 wrmsrl(MSR_VIA_BCR2, bcr2.val);
165 /* For processor with Longhaul MSR */
167 static void do_powersaver(int cx_address, unsigned int clock_ratio_index)
169 union msr_longhaul longhaul;
173 dest_pos = f_msr_table[clock_ratio_index].pos;
175 rdmsrl(MSR_VIA_LONGHAUL, longhaul.val);
176 /* Setup new frequency */
177 longhaul.bits.RevisionKey = longhaul.bits.RevisionID;
178 longhaul.bits.SoftBusRatio = clock_ratio_index & 0xf;
179 longhaul.bits.SoftBusRatio4 = (clock_ratio_index & 0x10) >> 4;
180 /* Setup new voltage */
181 if (can_scale_voltage)
182 longhaul.bits.SoftVID = f_msr_table[clock_ratio_index].vrm;
183 /* Sync to timer tick */
185 /* Raise voltage if necessary */
186 if (can_scale_voltage && longhaul_pos < dest_pos) {
187 longhaul.bits.EnableSoftVID = 1;
188 wrmsrl(MSR_VIA_LONGHAUL, longhaul.val);
191 ACPI_FLUSH_CPU_CACHE();
194 ACPI_FLUSH_CPU_CACHE();
197 /* Dummy op - must do something useless after P_LVL3
199 t = inl(acpi_gbl_FADT.xpm_timer_block.address);
201 longhaul.bits.EnableSoftVID = 0;
202 wrmsrl(MSR_VIA_LONGHAUL, longhaul.val);
203 longhaul_pos = dest_pos;
206 /* Change frequency on next halt or sleep */
207 longhaul.bits.EnableSoftBusRatio = 1;
208 wrmsrl(MSR_VIA_LONGHAUL, longhaul.val);
210 ACPI_FLUSH_CPU_CACHE();
213 ACPI_FLUSH_CPU_CACHE();
216 /* Dummy op - must do something useless after P_LVL3 read */
217 t = inl(acpi_gbl_FADT.xpm_timer_block.address);
219 /* Disable bus ratio bit */
220 longhaul.bits.EnableSoftBusRatio = 0;
221 wrmsrl(MSR_VIA_LONGHAUL, longhaul.val);
223 /* Reduce voltage if necessary */
224 if (can_scale_voltage && longhaul_pos > dest_pos) {
225 longhaul.bits.EnableSoftVID = 1;
226 wrmsrl(MSR_VIA_LONGHAUL, longhaul.val);
229 ACPI_FLUSH_CPU_CACHE();
232 ACPI_FLUSH_CPU_CACHE();
235 /* Dummy op - must do something useless after P_LVL3
237 t = inl(acpi_gbl_FADT.xpm_timer_block.address);
239 longhaul.bits.EnableSoftVID = 0;
240 wrmsrl(MSR_VIA_LONGHAUL, longhaul.val);
241 longhaul_pos = dest_pos;
246 * longhaul_set_cpu_frequency()
247 * @clock_ratio_index : bitpattern of the new multiplier.
249 * Sets a new clock ratio.
252 static void longhaul_setstate(unsigned int clock_ratio_index)
255 struct cpufreq_freqs freqs;
256 static unsigned int old_ratio=-1;
258 unsigned int pic1_mask, pic2_mask;
260 if (old_ratio == clock_ratio_index)
262 old_ratio = clock_ratio_index;
264 mult = clock_ratio[clock_ratio_index];
268 speed = calc_speed(mult);
269 if ((speed > highest_speed) || (speed < lowest_speed))
272 freqs.old = calc_speed(longhaul_get_cpu_mult());
274 freqs.cpu = 0; /* longhaul.c is UP only driver */
276 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
278 dprintk ("Setting to FSB:%dMHz Mult:%d.%dx (%s)\n",
279 fsb, mult/10, mult%10, print_speed(speed/1000));
282 local_irq_save(flags);
284 pic2_mask = inb(0xA1);
285 pic1_mask = inb(0x21); /* works on C3. save mask. */
286 outb(0xFF,0xA1); /* Overkill */
287 outb(0xFE,0x21); /* TMR0 only */
289 if (longhaul_flags & USE_NORTHBRIDGE) {
290 /* Disable AGP and PCI arbiters */
292 } else if ((pr != NULL) && pr->flags.bm_control) {
293 /* Disable bus master arbitration */
294 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1);
296 switch (longhaul_version) {
299 * Longhaul v1. (Samuel[C5A] and Samuel2 stepping 0[C5B])
300 * Software controlled multipliers only.
302 * *NB* Until we get voltage scaling working v1 & v2 are the same code.
303 * Longhaul v2 appears in Samuel2 Steppings 1->7 [C5b] and Ezra [C5C]
305 case TYPE_LONGHAUL_V1:
306 case TYPE_LONGHAUL_V2:
307 do_longhaul1(clock_ratio_index);
311 * Longhaul v3 (aka Powersaver). (Ezra-T [C5M] & Nehemiah [C5N])
312 * We can scale voltage with this too, but that's currently
313 * disabled until we come up with a decent 'match freq to voltage'
315 * When we add voltage scaling, we will also need to do the
316 * voltage/freq setting in order depending on the direction
317 * of scaling (like we do in powernow-k7.c)
318 * Nehemiah can do FSB scaling too, but this has never been proven
319 * to work in practice.
321 case TYPE_POWERSAVER:
322 if (longhaul_flags & USE_ACPI_C3) {
323 /* Don't allow wakeup */
324 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0);
325 do_powersaver(cx->address, clock_ratio_index);
327 do_powersaver(0, clock_ratio_index);
332 if (longhaul_flags & USE_NORTHBRIDGE) {
333 /* Enable arbiters */
335 } else if ((pr != NULL) && pr->flags.bm_control) {
336 /* Enable bus master arbitration */
337 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
339 outb(pic2_mask,0xA1); /* restore mask */
340 outb(pic1_mask,0x21);
342 local_irq_restore(flags);
345 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
349 * Centaur decided to make life a little more tricky.
350 * Only longhaul v1 is allowed to read EBLCR BSEL[0:1].
351 * Samuel2 and above have to try and guess what the FSB is.
352 * We do this by assuming we booted at maximum multiplier, and interpolate
353 * between that value multiplied by possible FSBs and cpu_mhz which
354 * was calculated at boot time. Really ugly, but no other way to do this.
359 static int guess_fsb(int mult)
361 int speed = cpu_khz / 1000;
363 int speeds[] = { 666, 1000, 1333, 2000 };
366 for (i = 0; i < 4; i++) {
367 f_max = ((speeds[i] * mult) + 50) / 100;
368 f_max += (ROUNDING / 2);
369 f_min = f_max - ROUNDING;
370 if ((speed <= f_max) && (speed >= f_min))
371 return speeds[i] / 10;
377 static int __init longhaul_get_ranges(void)
379 unsigned int j, k = 0;
382 /* Get current frequency */
383 mult = longhaul_get_cpu_mult();
385 printk(KERN_INFO PFX "Invalid (reserved) multiplier!\n");
388 fsb = guess_fsb(mult);
390 printk(KERN_INFO PFX "Invalid (reserved) FSB!\n");
393 /* Get max multiplier - as we always did.
394 * Longhaul MSR is usefull only when voltage scaling is enabled.
395 * C3 is booting at max anyway. */
397 /* Get min multiplier */
410 dprintk ("MinMult:%d.%dx MaxMult:%d.%dx\n",
411 minmult/10, minmult%10, maxmult/10, maxmult%10);
413 highest_speed = calc_speed(maxmult);
414 lowest_speed = calc_speed(minmult);
415 dprintk ("FSB:%dMHz Lowest speed: %s Highest speed:%s\n", fsb,
416 print_speed(lowest_speed/1000),
417 print_speed(highest_speed/1000));
419 if (lowest_speed == highest_speed) {
420 printk (KERN_INFO PFX "highestspeed == lowest, aborting.\n");
423 if (lowest_speed > highest_speed) {
424 printk (KERN_INFO PFX "nonsense! lowest (%d > %d) !\n",
425 lowest_speed, highest_speed);
429 longhaul_table = kmalloc((numscales + 1) * sizeof(struct cpufreq_frequency_table), GFP_KERNEL);
433 for (j=0; j < numscales; j++) {
435 ratio = clock_ratio[j];
438 if (ratio > maxmult || ratio < minmult)
440 longhaul_table[k].frequency = calc_speed(ratio);
441 longhaul_table[k].index = j;
445 longhaul_table[k].frequency = CPUFREQ_TABLE_END;
447 kfree (longhaul_table);
455 static void __init longhaul_setup_voltagescaling(void)
457 union msr_longhaul longhaul;
458 struct mV_pos minvid, maxvid;
459 unsigned int j, speed, pos, kHz_step, numvscales;
462 rdmsrl(MSR_VIA_LONGHAUL, longhaul.val);
463 if (!(longhaul.bits.RevisionID & 1)) {
464 printk(KERN_INFO PFX "Voltage scaling not supported by CPU.\n");
468 if (!longhaul.bits.VRMRev) {
469 printk (KERN_INFO PFX "VRM 8.5\n");
470 vrm_mV_table = &vrm85_mV[0];
471 mV_vrm_table = &mV_vrm85[0];
473 printk (KERN_INFO PFX "Mobile VRM\n");
474 vrm_mV_table = &mobilevrm_mV[0];
475 mV_vrm_table = &mV_mobilevrm[0];
478 minvid = vrm_mV_table[longhaul.bits.MinimumVID];
479 maxvid = vrm_mV_table[longhaul.bits.MaximumVID];
481 if (minvid.mV == 0 || maxvid.mV == 0 || minvid.mV > maxvid.mV) {
482 printk (KERN_INFO PFX "Bogus values Min:%d.%03d Max:%d.%03d. "
483 "Voltage scaling disabled.\n",
484 minvid.mV/1000, minvid.mV%1000, maxvid.mV/1000, maxvid.mV%1000);
488 if (minvid.mV == maxvid.mV) {
489 printk (KERN_INFO PFX "Claims to support voltage scaling but min & max are "
490 "both %d.%03d. Voltage scaling disabled\n",
491 maxvid.mV/1000, maxvid.mV%1000);
495 /* How many voltage steps */
496 numvscales = maxvid.pos - minvid.pos + 1;
500 "%d possible voltage scales\n",
501 maxvid.mV/1000, maxvid.mV%1000,
502 minvid.mV/1000, minvid.mV%1000,
505 /* Calculate max frequency at min voltage */
506 j = longhaul.bits.MinMHzBR;
507 if (longhaul.bits.MinMHzBR4)
509 min_vid_speed = eblcr_table[j];
510 if (min_vid_speed == -1)
512 switch (longhaul.bits.MinMHzFSB) {
514 min_vid_speed *= 13333;
517 min_vid_speed *= 10000;
520 min_vid_speed *= 6666;
526 if (min_vid_speed >= highest_speed)
528 /* Calculate kHz for one voltage step */
529 kHz_step = (highest_speed - min_vid_speed) / numvscales;
533 while (longhaul_table[j].frequency != CPUFREQ_TABLE_END) {
534 speed = longhaul_table[j].frequency;
535 if (speed > min_vid_speed)
536 pos = (speed - min_vid_speed) / kHz_step + minvid.pos;
539 f_msr_table[longhaul_table[j].index].vrm = mV_vrm_table[pos];
540 f_msr_table[longhaul_table[j].index].pos = pos;
544 longhaul_pos = maxvid.pos;
545 can_scale_voltage = 1;
546 printk(KERN_INFO PFX "Voltage scaling enabled. "
547 "Use of \"conservative\" governor is highly recommended.\n");
551 static int longhaul_verify(struct cpufreq_policy *policy)
553 return cpufreq_frequency_table_verify(policy, longhaul_table);
557 static int longhaul_target(struct cpufreq_policy *policy,
558 unsigned int target_freq, unsigned int relation)
560 unsigned int table_index = 0;
561 unsigned int new_clock_ratio = 0;
563 if (cpufreq_frequency_table_target(policy, longhaul_table, target_freq, relation, &table_index))
566 new_clock_ratio = longhaul_table[table_index].index & 0xFF;
568 longhaul_setstate(new_clock_ratio);
574 static unsigned int longhaul_get(unsigned int cpu)
578 return calc_speed(longhaul_get_cpu_mult());
581 static acpi_status longhaul_walk_callback(acpi_handle obj_handle,
583 void *context, void **return_value)
585 struct acpi_device *d;
587 if ( acpi_bus_get_device(obj_handle, &d) ) {
590 *return_value = (void *)acpi_driver_data(d);
594 /* VIA don't support PM2 reg, but have something similar */
595 static int enable_arbiter_disable(void)
601 /* Find PLE133 host bridge */
603 dev = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8601_0, NULL);
604 /* Find CLE266 host bridge */
607 dev = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_862X_0, NULL);
608 /* Find CN400 V-Link host bridge */
610 dev = pci_find_device(PCI_VENDOR_ID_VIA, 0x7259, NULL);
614 /* Enable access to port 0x22 */
615 pci_read_config_byte(dev, reg, &pci_cmd);
616 if (!(pci_cmd & 1<<7)) {
618 pci_write_config_byte(dev, reg, pci_cmd);
619 pci_read_config_byte(dev, reg, &pci_cmd);
620 if (!(pci_cmd & 1<<7)) {
622 "Can't enable access to port 0x22.\n");
631 static int longhaul_setup_vt8235(void)
636 /* Find VT8235 southbridge */
637 dev = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, NULL);
639 /* Set transition time to max */
640 pci_read_config_byte(dev, 0xec, &pci_cmd);
641 pci_cmd &= ~(1 << 2);
642 pci_write_config_byte(dev, 0xec, pci_cmd);
643 pci_read_config_byte(dev, 0xe4, &pci_cmd);
644 pci_cmd &= ~(1 << 7);
645 pci_write_config_byte(dev, 0xe4, pci_cmd);
646 pci_read_config_byte(dev, 0xe5, &pci_cmd);
648 pci_write_config_byte(dev, 0xe5, pci_cmd);
654 static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
656 struct cpuinfo_x86 *c = cpu_data;
661 /* Check what we have on this motherboard */
662 switch (c->x86_model) {
664 cpu_model = CPU_SAMUEL;
665 cpuname = "C3 'Samuel' [C5A]";
666 longhaul_version = TYPE_LONGHAUL_V1;
667 memcpy (clock_ratio, samuel1_clock_ratio, sizeof(samuel1_clock_ratio));
668 memcpy (eblcr_table, samuel1_eblcr, sizeof(samuel1_eblcr));
672 longhaul_version = TYPE_LONGHAUL_V1;
673 switch (c->x86_mask) {
675 cpu_model = CPU_SAMUEL2;
676 cpuname = "C3 'Samuel 2' [C5B]";
677 /* Note, this is not a typo, early Samuel2's had Samuel1 ratios. */
678 memcpy (clock_ratio, samuel1_clock_ratio, sizeof(samuel1_clock_ratio));
679 memcpy (eblcr_table, samuel2_eblcr, sizeof(samuel2_eblcr));
682 if (c->x86_mask < 8) {
683 cpu_model = CPU_SAMUEL2;
684 cpuname = "C3 'Samuel 2' [C5B]";
686 cpu_model = CPU_EZRA;
687 cpuname = "C3 'Ezra' [C5C]";
689 memcpy (clock_ratio, ezra_clock_ratio, sizeof(ezra_clock_ratio));
690 memcpy (eblcr_table, ezra_eblcr, sizeof(ezra_eblcr));
696 cpu_model = CPU_EZRA_T;
697 cpuname = "C3 'Ezra-T' [C5M]";
698 longhaul_version = TYPE_POWERSAVER;
700 memcpy (clock_ratio, ezrat_clock_ratio, sizeof(ezrat_clock_ratio));
701 memcpy (eblcr_table, ezrat_eblcr, sizeof(ezrat_eblcr));
705 longhaul_version = TYPE_POWERSAVER;
708 nehemiah_clock_ratio,
709 sizeof(nehemiah_clock_ratio));
710 memcpy(eblcr_table, nehemiah_eblcr, sizeof(nehemiah_eblcr));
711 switch (c->x86_mask) {
713 cpu_model = CPU_NEHEMIAH;
714 cpuname = "C3 'Nehemiah A' [C5XLOE]";
717 cpu_model = CPU_NEHEMIAH;
718 cpuname = "C3 'Nehemiah B' [C5XLOH]";
721 cpu_model = CPU_NEHEMIAH_C;
722 cpuname = "C3 'Nehemiah C' [C5P]";
732 printk (KERN_INFO PFX "VIA %s CPU detected. ", cpuname);
733 switch (longhaul_version) {
734 case TYPE_LONGHAUL_V1:
735 case TYPE_LONGHAUL_V2:
736 printk ("Longhaul v%d supported.\n", longhaul_version);
738 case TYPE_POWERSAVER:
739 printk ("Powersaver supported.\n");
744 vt8235_present = longhaul_setup_vt8235();
746 /* Find ACPI data for processor */
747 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
748 ACPI_UINT32_MAX, &longhaul_walk_callback,
751 /* Check ACPI support for C3 state */
752 if (pr != NULL && longhaul_version == TYPE_POWERSAVER) {
753 cx = &pr->power.states[ACPI_STATE_C3];
754 if (cx->address > 0 && cx->latency <= 1000) {
755 longhaul_flags |= USE_ACPI_C3;
756 goto print_support_type;
759 /* Check if northbridge is friendly */
760 if (enable_arbiter_disable()) {
761 longhaul_flags |= USE_NORTHBRIDGE;
762 goto print_support_type;
764 /* Use VT8235 southbridge if present */
765 if (longhaul_version == TYPE_POWERSAVER && vt8235_present) {
766 longhaul_flags |= USE_VT8235;
767 goto print_support_type;
769 /* Check ACPI support for bus master arbiter disable */
770 if ((pr == NULL) || !(pr->flags.bm_control)) {
772 "No ACPI support. Unsupported northbridge.\n");
777 if (longhaul_flags & USE_NORTHBRIDGE)
778 printk (KERN_INFO PFX "Using northbridge support.\n");
779 else if (longhaul_flags & USE_VT8235)
780 printk (KERN_INFO PFX "Using VT8235 support.\n");
782 printk (KERN_INFO PFX "Using ACPI support.\n");
784 ret = longhaul_get_ranges();
788 if ((longhaul_version != TYPE_LONGHAUL_V1) && (scale_voltage != 0))
789 longhaul_setup_voltagescaling();
791 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
792 policy->cpuinfo.transition_latency = 200000; /* nsec */
793 policy->cur = calc_speed(longhaul_get_cpu_mult());
795 ret = cpufreq_frequency_table_cpuinfo(policy, longhaul_table);
799 cpufreq_frequency_table_get_attr(longhaul_table, policy->cpu);
804 static int __devexit longhaul_cpu_exit(struct cpufreq_policy *policy)
806 cpufreq_frequency_table_put_attr(policy->cpu);
810 static struct freq_attr* longhaul_attr[] = {
811 &cpufreq_freq_attr_scaling_available_freqs,
815 static struct cpufreq_driver longhaul_driver = {
816 .verify = longhaul_verify,
817 .target = longhaul_target,
819 .init = longhaul_cpu_init,
820 .exit = __devexit_p(longhaul_cpu_exit),
822 .owner = THIS_MODULE,
823 .attr = longhaul_attr,
827 static int __init longhaul_init(void)
829 struct cpuinfo_x86 *c = cpu_data;
831 if (c->x86_vendor != X86_VENDOR_CENTAUR || c->x86 != 6)
835 if (num_online_cpus() > 1) {
836 printk(KERN_ERR PFX "More than 1 CPU detected, longhaul disabled.\n");
840 #ifdef CONFIG_X86_IO_APIC
842 printk(KERN_ERR PFX "APIC detected. Longhaul is currently broken in this configuration.\n");
846 switch (c->x86_model) {
848 return cpufreq_register_driver(&longhaul_driver);
850 printk(KERN_ERR PFX "Use acpi-cpufreq driver for VIA C7\n");
859 static void __exit longhaul_exit(void)
863 for (i=0; i < numscales; i++) {
864 if (clock_ratio[i] == maxmult) {
865 longhaul_setstate(i);
870 cpufreq_unregister_driver(&longhaul_driver);
871 kfree(longhaul_table);
874 module_param (scale_voltage, int, 0644);
875 MODULE_PARM_DESC(scale_voltage, "Scale voltage of processor");
877 MODULE_AUTHOR ("Dave Jones <davej@codemonkey.org.uk>");
878 MODULE_DESCRIPTION ("Longhaul driver for VIA Cyrix processors.");
879 MODULE_LICENSE ("GPL");
881 late_initcall(longhaul_init);
882 module_exit(longhaul_exit);