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 backward compatible with v1, but adds
12 * LONGHAUL MSR for purpose of both frequency and voltage scaling.
13 * Present in Samuel 2 (steppings 1-7 only) (C5B), and Ezra (C5C).
14 * Version 3 of longhaul got renamed to Powersaver and redesigned
15 * to use only the POWERSAVER MSR at 0x110a.
16 * It is present in Ezra-T (C5M), Nehemiah (C5X) and above.
17 * It's pretty much the same feature wise to longhaul v2, though
18 * there is provision for scaling FSB too, but this doesn't work
19 * too well in practice so we don't even try to use this.
21 * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous*
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/moduleparam.h>
27 #include <linux/init.h>
28 #include <linux/cpufreq.h>
29 #include <linux/pci.h>
30 #include <linux/slab.h>
31 #include <linux/string.h>
34 #include <asm/timex.h>
37 #include <linux/acpi.h>
38 #include <acpi/processor.h>
42 #define PFX "longhaul: "
44 #define TYPE_LONGHAUL_V1 1
45 #define TYPE_LONGHAUL_V2 2
46 #define TYPE_POWERSAVER 3
52 #define CPU_NEHEMIAH 5
53 #define CPU_NEHEMIAH_C 6
56 #define USE_ACPI_C3 (1 << 1)
57 #define USE_NORTHBRIDGE (1 << 2)
60 static unsigned int numscales
=16;
61 static unsigned int fsb
;
63 static const struct mV_pos
*vrm_mV_table
;
64 static const unsigned char *mV_vrm_table
;
69 static struct f_msr f_msr_table
[32];
71 static unsigned int highest_speed
, lowest_speed
; /* kHz */
72 static unsigned int minmult
, maxmult
;
73 static int can_scale_voltage
;
74 static struct acpi_processor
*pr
= NULL
;
75 static struct acpi_processor_cx
*cx
= NULL
;
76 static u8 longhaul_flags
;
77 static u8 longhaul_pos
;
79 /* Module parameters */
80 static int scale_voltage
;
82 #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "longhaul", msg)
85 /* Clock ratios multiplied by 10 */
86 static int clock_ratio
[32];
87 static int eblcr_table
[32];
88 static int longhaul_version
;
89 static struct cpufreq_frequency_table
*longhaul_table
;
90 static unsigned int old_ratio
= -1;
92 #ifdef CONFIG_CPU_FREQ_DEBUG
93 static char speedbuffer
[8];
95 static char *print_speed(int speed
)
98 snprintf(speedbuffer
, sizeof(speedbuffer
),"%dMHz", speed
);
103 snprintf(speedbuffer
, sizeof(speedbuffer
),
104 "%dGHz", speed
/1000);
106 snprintf(speedbuffer
, sizeof(speedbuffer
),
107 "%d.%dGHz", speed
/1000, (speed
%1000)/100);
114 static unsigned int calc_speed(int mult
)
125 static int longhaul_get_cpu_mult(void)
127 unsigned long invalue
=0,lo
, hi
;
129 rdmsr (MSR_IA32_EBL_CR_POWERON
, lo
, hi
);
130 invalue
= (lo
& (1<<22|1<<23|1<<24|1<<25)) >>22;
131 if (longhaul_version
==TYPE_LONGHAUL_V2
|| longhaul_version
==TYPE_POWERSAVER
) {
135 return eblcr_table
[invalue
];
138 /* For processor with BCR2 MSR */
140 static void do_longhaul1(unsigned int clock_ratio_index
)
144 rdmsrl(MSR_VIA_BCR2
, bcr2
.val
);
145 /* Enable software clock multiplier */
146 bcr2
.bits
.ESOFTBF
= 1;
147 bcr2
.bits
.CLOCKMUL
= clock_ratio_index
;
149 /* Sync to timer tick */
151 /* Change frequency on next halt or sleep */
152 wrmsrl(MSR_VIA_BCR2
, bcr2
.val
);
153 /* Invoke transition */
154 ACPI_FLUSH_CPU_CACHE();
157 /* Disable software clock multiplier */
159 rdmsrl(MSR_VIA_BCR2
, bcr2
.val
);
160 bcr2
.bits
.ESOFTBF
= 0;
161 wrmsrl(MSR_VIA_BCR2
, bcr2
.val
);
164 /* For processor with Longhaul MSR */
166 static void do_powersaver(int cx_address
, unsigned int clock_ratio_index
)
168 union msr_longhaul longhaul
;
172 dest_pos
= f_msr_table
[clock_ratio_index
].pos
;
174 rdmsrl(MSR_VIA_LONGHAUL
, longhaul
.val
);
175 /* Setup new frequency */
176 longhaul
.bits
.RevisionKey
= longhaul
.bits
.RevisionID
;
177 longhaul
.bits
.SoftBusRatio
= clock_ratio_index
& 0xf;
178 longhaul
.bits
.SoftBusRatio4
= (clock_ratio_index
& 0x10) >> 4;
179 /* Setup new voltage */
180 if (can_scale_voltage
)
181 longhaul
.bits
.SoftVID
= f_msr_table
[clock_ratio_index
].vrm
;
182 /* Sync to timer tick */
184 /* Raise voltage if necessary */
185 if (can_scale_voltage
&& longhaul_pos
< dest_pos
) {
186 longhaul
.bits
.EnableSoftVID
= 1;
187 wrmsrl(MSR_VIA_LONGHAUL
, longhaul
.val
);
190 ACPI_FLUSH_CPU_CACHE();
193 ACPI_FLUSH_CPU_CACHE();
196 /* Dummy op - must do something useless after P_LVL3
198 t
= inl(acpi_gbl_FADT
.xpm_timer_block
.address
);
200 longhaul
.bits
.EnableSoftVID
= 0;
201 wrmsrl(MSR_VIA_LONGHAUL
, longhaul
.val
);
202 longhaul_pos
= dest_pos
;
205 /* Change frequency on next halt or sleep */
206 longhaul
.bits
.EnableSoftBusRatio
= 1;
207 wrmsrl(MSR_VIA_LONGHAUL
, longhaul
.val
);
209 ACPI_FLUSH_CPU_CACHE();
212 ACPI_FLUSH_CPU_CACHE();
215 /* Dummy op - must do something useless after P_LVL3 read */
216 t
= inl(acpi_gbl_FADT
.xpm_timer_block
.address
);
218 /* Disable bus ratio bit */
219 longhaul
.bits
.EnableSoftBusRatio
= 0;
220 wrmsrl(MSR_VIA_LONGHAUL
, longhaul
.val
);
222 /* Reduce voltage if necessary */
223 if (can_scale_voltage
&& longhaul_pos
> dest_pos
) {
224 longhaul
.bits
.EnableSoftVID
= 1;
225 wrmsrl(MSR_VIA_LONGHAUL
, longhaul
.val
);
228 ACPI_FLUSH_CPU_CACHE();
231 ACPI_FLUSH_CPU_CACHE();
234 /* Dummy op - must do something useless after P_LVL3
236 t
= inl(acpi_gbl_FADT
.xpm_timer_block
.address
);
238 longhaul
.bits
.EnableSoftVID
= 0;
239 wrmsrl(MSR_VIA_LONGHAUL
, longhaul
.val
);
240 longhaul_pos
= dest_pos
;
245 * longhaul_set_cpu_frequency()
246 * @clock_ratio_index : bitpattern of the new multiplier.
248 * Sets a new clock ratio.
251 static void longhaul_setstate(unsigned int clock_ratio_index
)
254 struct cpufreq_freqs freqs
;
256 unsigned int pic1_mask
, pic2_mask
;
258 u32 bm_timeout
= 100000;
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 /* Wait while PCI bus is busy. */
290 if (longhaul_flags
& USE_NORTHBRIDGE
291 || ((pr
!= NULL
) && pr
->flags
.bm_control
)) {
292 acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS
, &bm_status
);
293 while (bm_status
&& bm_timeout
) {
294 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS
, 1);
296 acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS
,
301 if (longhaul_flags
& USE_NORTHBRIDGE
) {
302 /* Disable AGP and PCI arbiters */
304 } else if ((pr
!= NULL
) && pr
->flags
.bm_control
) {
305 /* Disable bus master arbitration */
306 acpi_set_register(ACPI_BITREG_ARB_DISABLE
, 1);
308 switch (longhaul_version
) {
311 * Longhaul v1. (Samuel[C5A] and Samuel2 stepping 0[C5B])
312 * Software controlled multipliers only.
314 case TYPE_LONGHAUL_V1
:
315 do_longhaul1(clock_ratio_index
);
319 * Longhaul v2 appears in Samuel2 Steppings 1->7 [C5B] and Ezra [C5C]
321 * Longhaul v3 (aka Powersaver). (Ezra-T [C5M] & Nehemiah [C5N])
322 * Nehemiah can do FSB scaling too, but this has never been proven
323 * to work in practice.
325 case TYPE_LONGHAUL_V2
:
326 case TYPE_POWERSAVER
:
327 if (longhaul_flags
& USE_ACPI_C3
) {
328 /* Don't allow wakeup */
329 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD
, 0);
330 do_powersaver(cx
->address
, clock_ratio_index
);
332 do_powersaver(0, clock_ratio_index
);
337 if (longhaul_flags
& USE_NORTHBRIDGE
) {
338 /* Enable arbiters */
340 } else if ((pr
!= NULL
) && pr
->flags
.bm_control
) {
341 /* Enable bus master arbitration */
342 acpi_set_register(ACPI_BITREG_ARB_DISABLE
, 0);
344 outb(pic2_mask
,0xA1); /* restore mask */
345 outb(pic1_mask
,0x21);
347 local_irq_restore(flags
);
350 freqs
.new = calc_speed(longhaul_get_cpu_mult());
351 cpufreq_notify_transition(&freqs
, CPUFREQ_POSTCHANGE
);
354 printk(KERN_INFO PFX
"Warning: Timeout while waiting for "
359 * Centaur decided to make life a little more tricky.
360 * Only longhaul v1 is allowed to read EBLCR BSEL[0:1].
361 * Samuel2 and above have to try and guess what the FSB is.
362 * We do this by assuming we booted at maximum multiplier, and interpolate
363 * between that value multiplied by possible FSBs and cpu_mhz which
364 * was calculated at boot time. Really ugly, but no other way to do this.
369 static int guess_fsb(int mult
)
371 int speed
= cpu_khz
/ 1000;
373 int speeds
[] = { 666, 1000, 1333, 2000 };
376 for (i
= 0; i
< 4; i
++) {
377 f_max
= ((speeds
[i
] * mult
) + 50) / 100;
378 f_max
+= (ROUNDING
/ 2);
379 f_min
= f_max
- ROUNDING
;
380 if ((speed
<= f_max
) && (speed
>= f_min
))
381 return speeds
[i
] / 10;
387 static int __init
longhaul_get_ranges(void)
389 unsigned int j
, k
= 0;
392 /* Get current frequency */
393 mult
= longhaul_get_cpu_mult();
395 printk(KERN_INFO PFX
"Invalid (reserved) multiplier!\n");
398 fsb
= guess_fsb(mult
);
400 printk(KERN_INFO PFX
"Invalid (reserved) FSB!\n");
403 /* Get max multiplier - as we always did.
404 * Longhaul MSR is usefull only when voltage scaling is enabled.
405 * C3 is booting at max anyway. */
407 /* Get min multiplier */
420 dprintk ("MinMult:%d.%dx MaxMult:%d.%dx\n",
421 minmult
/10, minmult
%10, maxmult
/10, maxmult
%10);
423 highest_speed
= calc_speed(maxmult
);
424 lowest_speed
= calc_speed(minmult
);
425 dprintk ("FSB:%dMHz Lowest speed: %s Highest speed:%s\n", fsb
,
426 print_speed(lowest_speed
/1000),
427 print_speed(highest_speed
/1000));
429 if (lowest_speed
== highest_speed
) {
430 printk (KERN_INFO PFX
"highestspeed == lowest, aborting.\n");
433 if (lowest_speed
> highest_speed
) {
434 printk (KERN_INFO PFX
"nonsense! lowest (%d > %d) !\n",
435 lowest_speed
, highest_speed
);
439 longhaul_table
= kmalloc((numscales
+ 1) * sizeof(struct cpufreq_frequency_table
), GFP_KERNEL
);
443 for (j
=0; j
< numscales
; j
++) {
445 ratio
= clock_ratio
[j
];
448 if (ratio
> maxmult
|| ratio
< minmult
)
450 longhaul_table
[k
].frequency
= calc_speed(ratio
);
451 longhaul_table
[k
].index
= j
;
455 longhaul_table
[k
].frequency
= CPUFREQ_TABLE_END
;
457 kfree (longhaul_table
);
465 static void __init
longhaul_setup_voltagescaling(void)
467 union msr_longhaul longhaul
;
468 struct mV_pos minvid
, maxvid
;
469 unsigned int j
, speed
, pos
, kHz_step
, numvscales
;
472 rdmsrl(MSR_VIA_LONGHAUL
, longhaul
.val
);
473 if (!(longhaul
.bits
.RevisionID
& 1)) {
474 printk(KERN_INFO PFX
"Voltage scaling not supported by CPU.\n");
478 if (!longhaul
.bits
.VRMRev
) {
479 printk (KERN_INFO PFX
"VRM 8.5\n");
480 vrm_mV_table
= &vrm85_mV
[0];
481 mV_vrm_table
= &mV_vrm85
[0];
483 printk (KERN_INFO PFX
"Mobile VRM\n");
484 if (cpu_model
< CPU_NEHEMIAH
)
486 vrm_mV_table
= &mobilevrm_mV
[0];
487 mV_vrm_table
= &mV_mobilevrm
[0];
490 minvid
= vrm_mV_table
[longhaul
.bits
.MinimumVID
];
491 maxvid
= vrm_mV_table
[longhaul
.bits
.MaximumVID
];
493 if (minvid
.mV
== 0 || maxvid
.mV
== 0 || minvid
.mV
> maxvid
.mV
) {
494 printk (KERN_INFO PFX
"Bogus values Min:%d.%03d Max:%d.%03d. "
495 "Voltage scaling disabled.\n",
496 minvid
.mV
/1000, minvid
.mV
%1000, maxvid
.mV
/1000, maxvid
.mV
%1000);
500 if (minvid
.mV
== maxvid
.mV
) {
501 printk (KERN_INFO PFX
"Claims to support voltage scaling but min & max are "
502 "both %d.%03d. Voltage scaling disabled\n",
503 maxvid
.mV
/1000, maxvid
.mV
%1000);
507 /* How many voltage steps */
508 numvscales
= maxvid
.pos
- minvid
.pos
+ 1;
512 "%d possible voltage scales\n",
513 maxvid
.mV
/1000, maxvid
.mV
%1000,
514 minvid
.mV
/1000, minvid
.mV
%1000,
517 /* Calculate max frequency at min voltage */
518 j
= longhaul
.bits
.MinMHzBR
;
519 if (longhaul
.bits
.MinMHzBR4
)
521 min_vid_speed
= eblcr_table
[j
];
522 if (min_vid_speed
== -1)
524 switch (longhaul
.bits
.MinMHzFSB
) {
526 min_vid_speed
*= 13333;
529 min_vid_speed
*= 10000;
532 min_vid_speed
*= 6666;
538 if (min_vid_speed
>= highest_speed
)
540 /* Calculate kHz for one voltage step */
541 kHz_step
= (highest_speed
- min_vid_speed
) / numvscales
;
545 while (longhaul_table
[j
].frequency
!= CPUFREQ_TABLE_END
) {
546 speed
= longhaul_table
[j
].frequency
;
547 if (speed
> min_vid_speed
)
548 pos
= (speed
- min_vid_speed
) / kHz_step
+ minvid
.pos
;
551 f_msr_table
[longhaul_table
[j
].index
].vrm
= mV_vrm_table
[pos
];
552 f_msr_table
[longhaul_table
[j
].index
].pos
= pos
;
556 longhaul_pos
= maxvid
.pos
;
557 can_scale_voltage
= 1;
558 printk(KERN_INFO PFX
"Voltage scaling enabled. "
559 "Use of \"conservative\" governor is highly recommended.\n");
563 static int longhaul_verify(struct cpufreq_policy
*policy
)
565 return cpufreq_frequency_table_verify(policy
, longhaul_table
);
569 static int longhaul_target(struct cpufreq_policy
*policy
,
570 unsigned int target_freq
, unsigned int relation
)
572 unsigned int table_index
= 0;
573 unsigned int new_clock_ratio
= 0;
575 if (cpufreq_frequency_table_target(policy
, longhaul_table
, target_freq
, relation
, &table_index
))
578 new_clock_ratio
= longhaul_table
[table_index
].index
& 0xFF;
580 longhaul_setstate(new_clock_ratio
);
586 static unsigned int longhaul_get(unsigned int cpu
)
590 return calc_speed(longhaul_get_cpu_mult());
593 static acpi_status
longhaul_walk_callback(acpi_handle obj_handle
,
595 void *context
, void **return_value
)
597 struct acpi_device
*d
;
599 if ( acpi_bus_get_device(obj_handle
, &d
) ) {
602 *return_value
= (void *)acpi_driver_data(d
);
606 /* VIA don't support PM2 reg, but have something similar */
607 static int enable_arbiter_disable(void)
615 /* Find PLE133 host bridge */
617 dev
= pci_get_device(PCI_VENDOR_ID_VIA
, PCI_DEVICE_ID_VIA_8601_0
,
619 /* Find CLE266 host bridge */
622 dev
= pci_get_device(PCI_VENDOR_ID_VIA
,
623 PCI_DEVICE_ID_VIA_862X_0
, NULL
);
624 /* Find CN400 V-Link host bridge */
626 dev
= pci_get_device(PCI_VENDOR_ID_VIA
, 0x7259, NULL
);
629 /* Enable access to port 0x22 */
630 pci_read_config_byte(dev
, reg
, &pci_cmd
);
631 if (!(pci_cmd
& 1<<7)) {
633 pci_write_config_byte(dev
, reg
, pci_cmd
);
634 pci_read_config_byte(dev
, reg
, &pci_cmd
);
635 if (!(pci_cmd
& 1<<7)) {
637 "Can't enable access to port 0x22.\n");
647 static int longhaul_setup_southbridge(void)
652 /* Find VT8235 southbridge */
653 dev
= pci_get_device(PCI_VENDOR_ID_VIA
, PCI_DEVICE_ID_VIA_8235
, NULL
);
655 /* Find VT8237 southbridge */
656 dev
= pci_get_device(PCI_VENDOR_ID_VIA
,
657 PCI_DEVICE_ID_VIA_8237
, NULL
);
659 /* Set transition time to max */
660 pci_read_config_byte(dev
, 0xec, &pci_cmd
);
661 pci_cmd
&= ~(1 << 2);
662 pci_write_config_byte(dev
, 0xec, pci_cmd
);
663 pci_read_config_byte(dev
, 0xe4, &pci_cmd
);
664 pci_cmd
&= ~(1 << 7);
665 pci_write_config_byte(dev
, 0xe4, pci_cmd
);
666 pci_read_config_byte(dev
, 0xe5, &pci_cmd
);
668 pci_write_config_byte(dev
, 0xe5, pci_cmd
);
675 static int __init
longhaul_cpu_init(struct cpufreq_policy
*policy
)
677 struct cpuinfo_x86
*c
= cpu_data
;
682 /* Check what we have on this motherboard */
683 switch (c
->x86_model
) {
685 cpu_model
= CPU_SAMUEL
;
686 cpuname
= "C3 'Samuel' [C5A]";
687 longhaul_version
= TYPE_LONGHAUL_V1
;
688 memcpy (clock_ratio
, samuel1_clock_ratio
, sizeof(samuel1_clock_ratio
));
689 memcpy (eblcr_table
, samuel1_eblcr
, sizeof(samuel1_eblcr
));
693 switch (c
->x86_mask
) {
695 longhaul_version
= TYPE_LONGHAUL_V1
;
696 cpu_model
= CPU_SAMUEL2
;
697 cpuname
= "C3 'Samuel 2' [C5B]";
698 /* Note, this is not a typo, early Samuel2's had
700 memcpy(clock_ratio
, samuel1_clock_ratio
,
701 sizeof(samuel1_clock_ratio
));
702 memcpy(eblcr_table
, samuel2_eblcr
,
703 sizeof(samuel2_eblcr
));
706 longhaul_version
= TYPE_LONGHAUL_V1
;
707 if (c
->x86_mask
< 8) {
708 cpu_model
= CPU_SAMUEL2
;
709 cpuname
= "C3 'Samuel 2' [C5B]";
711 cpu_model
= CPU_EZRA
;
712 cpuname
= "C3 'Ezra' [C5C]";
714 memcpy(clock_ratio
, ezra_clock_ratio
,
715 sizeof(ezra_clock_ratio
));
716 memcpy(eblcr_table
, ezra_eblcr
,
723 cpu_model
= CPU_EZRA_T
;
724 cpuname
= "C3 'Ezra-T' [C5M]";
725 longhaul_version
= TYPE_POWERSAVER
;
727 memcpy (clock_ratio
, ezrat_clock_ratio
, sizeof(ezrat_clock_ratio
));
728 memcpy (eblcr_table
, ezrat_eblcr
, sizeof(ezrat_eblcr
));
732 longhaul_version
= TYPE_POWERSAVER
;
735 nehemiah_clock_ratio
,
736 sizeof(nehemiah_clock_ratio
));
737 memcpy(eblcr_table
, nehemiah_eblcr
, sizeof(nehemiah_eblcr
));
738 switch (c
->x86_mask
) {
740 cpu_model
= CPU_NEHEMIAH
;
741 cpuname
= "C3 'Nehemiah A' [C5XLOE]";
744 cpu_model
= CPU_NEHEMIAH
;
745 cpuname
= "C3 'Nehemiah B' [C5XLOH]";
748 cpu_model
= CPU_NEHEMIAH_C
;
749 cpuname
= "C3 'Nehemiah C' [C5P]";
758 /* Check Longhaul ver. 2 */
759 if (longhaul_version
== TYPE_LONGHAUL_V2
) {
760 rdmsr(MSR_VIA_LONGHAUL
, lo
, hi
);
761 if (lo
== 0 && hi
== 0)
762 /* Looks like MSR isn't present */
763 longhaul_version
= TYPE_LONGHAUL_V1
;
766 printk (KERN_INFO PFX
"VIA %s CPU detected. ", cpuname
);
767 switch (longhaul_version
) {
768 case TYPE_LONGHAUL_V1
:
769 case TYPE_LONGHAUL_V2
:
770 printk ("Longhaul v%d supported.\n", longhaul_version
);
772 case TYPE_POWERSAVER
:
773 printk ("Powersaver supported.\n");
778 longhaul_setup_southbridge();
780 /* Find ACPI data for processor */
781 acpi_walk_namespace(ACPI_TYPE_PROCESSOR
, ACPI_ROOT_OBJECT
,
782 ACPI_UINT32_MAX
, &longhaul_walk_callback
,
785 /* Check ACPI support for C3 state */
786 if (pr
!= NULL
&& longhaul_version
== TYPE_POWERSAVER
) {
787 cx
= &pr
->power
.states
[ACPI_STATE_C3
];
788 if (cx
->address
> 0 && cx
->latency
<= 1000)
789 longhaul_flags
|= USE_ACPI_C3
;
791 /* Check if northbridge is friendly */
792 if (enable_arbiter_disable())
793 longhaul_flags
|= USE_NORTHBRIDGE
;
795 /* Check ACPI support for bus master arbiter disable */
796 if (!(longhaul_flags
& USE_ACPI_C3
797 || longhaul_flags
& USE_NORTHBRIDGE
)
798 && ((pr
== NULL
) || !(pr
->flags
.bm_control
))) {
800 "No ACPI support. Unsupported northbridge.\n");
804 if (longhaul_flags
& USE_NORTHBRIDGE
)
805 printk(KERN_INFO PFX
"Using northbridge support.\n");
806 if (longhaul_flags
& USE_ACPI_C3
)
807 printk(KERN_INFO PFX
"Using ACPI support.\n");
809 ret
= longhaul_get_ranges();
813 if ((longhaul_version
!= TYPE_LONGHAUL_V1
) && (scale_voltage
!= 0))
814 longhaul_setup_voltagescaling();
816 policy
->governor
= CPUFREQ_DEFAULT_GOVERNOR
;
817 policy
->cpuinfo
.transition_latency
= 200000; /* nsec */
818 policy
->cur
= calc_speed(longhaul_get_cpu_mult());
820 ret
= cpufreq_frequency_table_cpuinfo(policy
, longhaul_table
);
824 cpufreq_frequency_table_get_attr(longhaul_table
, policy
->cpu
);
829 static int __devexit
longhaul_cpu_exit(struct cpufreq_policy
*policy
)
831 cpufreq_frequency_table_put_attr(policy
->cpu
);
835 static struct freq_attr
* longhaul_attr
[] = {
836 &cpufreq_freq_attr_scaling_available_freqs
,
840 static struct cpufreq_driver longhaul_driver
= {
841 .verify
= longhaul_verify
,
842 .target
= longhaul_target
,
844 .init
= longhaul_cpu_init
,
845 .exit
= __devexit_p(longhaul_cpu_exit
),
847 .owner
= THIS_MODULE
,
848 .attr
= longhaul_attr
,
852 static int __init
longhaul_init(void)
854 struct cpuinfo_x86
*c
= cpu_data
;
856 if (c
->x86_vendor
!= X86_VENDOR_CENTAUR
|| c
->x86
!= 6)
860 if (num_online_cpus() > 1) {
861 printk(KERN_ERR PFX
"More than 1 CPU detected, longhaul disabled.\n");
865 #ifdef CONFIG_X86_IO_APIC
867 printk(KERN_ERR PFX
"APIC detected. Longhaul is currently broken in this configuration.\n");
871 switch (c
->x86_model
) {
873 return cpufreq_register_driver(&longhaul_driver
);
875 printk(KERN_ERR PFX
"Use acpi-cpufreq driver for VIA C7\n");
884 static void __exit
longhaul_exit(void)
888 for (i
=0; i
< numscales
; i
++) {
889 if (clock_ratio
[i
] == maxmult
) {
890 longhaul_setstate(i
);
895 cpufreq_unregister_driver(&longhaul_driver
);
896 kfree(longhaul_table
);
899 module_param (scale_voltage
, int, 0644);
900 MODULE_PARM_DESC(scale_voltage
, "Scale voltage of processor");
902 MODULE_AUTHOR ("Dave Jones <davej@codemonkey.org.uk>");
903 MODULE_DESCRIPTION ("Longhaul driver for VIA Cyrix processors.");
904 MODULE_LICENSE ("GPL");
906 late_initcall(longhaul_init
);
907 module_exit(longhaul_exit
);