11 #include <linux/kernel.h>
12 #include <linux/module.h>
21 #define PFX "speedstep-lib: "
23 #ifdef CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK
26 #define relaxed_check 0
40 } msr_decode_mult[] = {
63 } msr_decode_fsb[] = {
75 pr_debug(
"P3 - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp);
81 while (msr_tmp != msr_decode_fsb[i].
bitmap) {
82 if (msr_decode_fsb[i].bitmap == 0xff)
89 pr_debug(
"workaround for early PIIIs\n");
94 while (msr_lo != msr_decode_mult[
j].bitmap) {
95 if (msr_decode_mult[
j].bitmap == 0xff)
101 (msr_decode_mult[
j].
ratio * msr_decode_fsb[i].
value * 100));
103 return msr_decode_mult[
j].ratio * msr_decode_fsb[
i].value * 100;
107 static unsigned int pentiumM_get_frequency(
void)
112 pr_debug(
"PM - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp);
115 if (msr_lo & 0x00040000) {
121 msr_tmp = (msr_lo >> 22) & 0x1f;
122 pr_debug(
"bits 22-26 are 0x%x, speed is %u\n",
123 msr_tmp, (msr_tmp * 100 * 1000));
125 return msr_tmp * 100 * 1000;
128 static unsigned int pentium_core_get_frequency(
void)
136 switch (msr_lo & 0x07) {
160 pr_debug(
"PCORE - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n",
163 msr_tmp = (msr_lo >> 22) & 0x1f;
164 pr_debug(
"bits 22-26 are 0x%x, speed is %u\n",
165 msr_tmp, (msr_tmp * fsb));
167 ret = (msr_tmp * fsb);
172 static unsigned int pentium4_get_frequency(
void)
176 unsigned int fsb = 0;
188 rdmsr(0x2c, msr_lo, msr_hi);
190 pr_debug(
"P4 - MSR_EBC_FREQUENCY_ID: 0x%x 0x%x\n", msr_lo, msr_hi);
197 fsb_code = (msr_lo >> 16) & 0x7;
217 pr_debug(
"P4 - FSB %u kHz; Multiplier %u; Speed %u kHz\n",
218 fsb, mult, (fsb * mult));
230 return pentium_core_get_frequency();
232 return pentiumM_get_frequency();
235 return pentium4_get_frequency();
239 return pentium3_get_frequency(processor);
261 ((c->
x86 != 6) && (c->
x86 != 0xF)))
270 ebx = cpuid_ebx(0x00000001);
281 if ((ebx == 0x0e) || (ebx == 0x0f))
314 "Mobile Intel(R) Pentium(R) 4") !=
NULL))
327 ebx = cpuid_ebx(0x00000001);
345 pr_debug(
"Coppermine: MSR_IA32_EBL_CR_POWERON is 0x%x, 0x%x\n",
348 if (msr_lo != 0x0080000)
358 pr_debug(
"Coppermine: MSR_IA32_PLATFORM ID is 0x%x, 0x%x\n",
360 if ((msr_hi & (1<<18)) &&
381 unsigned int *low_speed,
382 unsigned int *high_speed,
383 unsigned int *transition_latency,
384 void (*set_state) (
unsigned int state))
386 unsigned int prev_speed;
387 unsigned int ret = 0;
391 if ((!processor) || (!low_speed) || (!high_speed) || (!set_state))
394 pr_debug(
"trying to determine both speeds\n");
401 pr_debug(
"previous speed is %u\n", prev_speed);
413 pr_debug(
"low speed is %u\n", *low_speed);
416 if (transition_latency)
423 if (transition_latency)
432 pr_debug(
"high speed is %u\n", *high_speed);
434 if (*low_speed == *high_speed) {
440 if (*high_speed != prev_speed)
443 if (transition_latency) {
446 pr_debug(
"transition latency is %u uSec\n", *transition_latency);
449 *transition_latency *= 1200;
454 if (*transition_latency > 10000000 ||
455 *transition_latency < 50000) {
457 "measured seems out of range (%u "
458 "nSec), falling back to a safe one of"
460 *transition_latency, 500000);
461 *transition_latency = 500000;
471 #ifdef CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK
474 "Don't do all checks for speedstep capability.");