Commit bbfebd66 authored by Dave Jones's avatar Dave Jones

[CPUFREQ] checkpatch cleanups for speedstep related drivers.

Signed-off-by: default avatarDave Jones <davej@redhat.com>
parent 97acec55
...@@ -27,15 +27,16 @@ ...@@ -27,15 +27,16 @@
#include <linux/cpufreq.h> #include <linux/cpufreq.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <linux/timex.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/msr.h> #include <asm/msr.h>
#include <asm/timex.h>
#include "speedstep-lib.h" #include "speedstep-lib.h"
#define PFX "p4-clockmod: " #define PFX "p4-clockmod: "
#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "p4-clockmod", msg) #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, \
"p4-clockmod", msg)
/* /*
* Duty Cycle (3bits), note DC_DISABLE is not specified in * Duty Cycle (3bits), note DC_DISABLE is not specified in
...@@ -58,7 +59,8 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate) ...@@ -58,7 +59,8 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)
{ {
u32 l, h; u32 l, h;
if (!cpu_online(cpu) || (newstate > DC_DISABLE) || (newstate == DC_RESV)) if (!cpu_online(cpu) ||
(newstate > DC_DISABLE) || (newstate == DC_RESV))
return -EINVAL; return -EINVAL;
rdmsr_on_cpu(cpu, MSR_IA32_THERM_STATUS, &l, &h); rdmsr_on_cpu(cpu, MSR_IA32_THERM_STATUS, &l, &h);
...@@ -66,7 +68,8 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate) ...@@ -66,7 +68,8 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)
if (l & 0x01) if (l & 0x01)
dprintk("CPU#%d currently thermal throttled\n", cpu); dprintk("CPU#%d currently thermal throttled\n", cpu);
if (has_N44_O17_errata[cpu] && (newstate == DC_25PT || newstate == DC_DFLT)) if (has_N44_O17_errata[cpu] &&
(newstate == DC_25PT || newstate == DC_DFLT))
newstate = DC_38PT; newstate = DC_38PT;
rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, &l, &h); rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, &l, &h);
...@@ -112,7 +115,8 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, ...@@ -112,7 +115,8 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
struct cpufreq_freqs freqs; struct cpufreq_freqs freqs;
int i; int i;
if (cpufreq_frequency_table_target(policy, &p4clockmod_table[0], target_freq, relation, &newstate)) if (cpufreq_frequency_table_target(policy, &p4clockmod_table[0],
target_freq, relation, &newstate))
return -EINVAL; return -EINVAL;
freqs.old = cpufreq_p4_get(policy->cpu); freqs.old = cpufreq_p4_get(policy->cpu);
...@@ -127,7 +131,8 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, ...@@ -127,7 +131,8 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
} }
/* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software /* run on each logical CPU,
* see section 13.15.3 of IA32 Intel Architecture Software
* Developer's Manual, Volume 3 * Developer's Manual, Volume 3
*/ */
for_each_cpu(i, policy->cpus) for_each_cpu(i, policy->cpus)
...@@ -153,28 +158,30 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c) ...@@ -153,28 +158,30 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
{ {
if (c->x86 == 0x06) { if (c->x86 == 0x06) {
if (cpu_has(c, X86_FEATURE_EST)) if (cpu_has(c, X86_FEATURE_EST))
printk(KERN_WARNING PFX "Warning: EST-capable CPU detected. " printk(KERN_WARNING PFX "Warning: EST-capable CPU "
"The acpi-cpufreq module offers voltage scaling" "detected. The acpi-cpufreq module offers "
" in addition of frequency scaling. You should use " "voltage scaling in addition of frequency "
"that instead of p4-clockmod, if possible.\n"); "scaling. You should use that instead of "
"p4-clockmod, if possible.\n");
switch (c->x86_model) { switch (c->x86_model) {
case 0x0E: /* Core */ case 0x0E: /* Core */
case 0x0F: /* Core Duo */ case 0x0F: /* Core Duo */
case 0x16: /* Celeron Core */ case 0x16: /* Celeron Core */
p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS; p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_PCORE); return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
case 0x0D: /* Pentium M (Dothan) */ case 0x0D: /* Pentium M (Dothan) */
p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS; p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
/* fall through */ /* fall through */
case 0x09: /* Pentium M (Banias) */ case 0x09: /* Pentium M (Banias) */
return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_PM); return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
} }
} }
if (c->x86 != 0xF) { if (c->x86 != 0xF) {
if (!cpu_has(c, X86_FEATURE_EST)) if (!cpu_has(c, X86_FEATURE_EST))
printk(KERN_WARNING PFX "Unknown p4-clockmod-capable CPU. " printk(KERN_WARNING PFX "Unknown CPU. "
"Please send an e-mail to <cpufreq@vger.kernel.org>\n"); "Please send an e-mail to "
"<cpufreq@vger.kernel.org>\n");
return 0; return 0;
} }
...@@ -182,16 +189,16 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c) ...@@ -182,16 +189,16 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
* throttling is active or not. */ * throttling is active or not. */
p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS; p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
if (speedstep_detect_processor() == SPEEDSTEP_PROCESSOR_P4M) { if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. " printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
"The speedstep-ich or acpi cpufreq modules offer " "The speedstep-ich or acpi cpufreq modules offer "
"voltage scaling in addition of frequency scaling. " "voltage scaling in addition of frequency scaling. "
"You should use either one instead of p4-clockmod, " "You should use either one instead of p4-clockmod, "
"if possible.\n"); "if possible.\n");
return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_P4M); return speedstep_get_frequency(SPEEDSTEP_CPU_P4M);
} }
return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_P4D); return speedstep_get_frequency(SPEEDSTEP_CPU_P4D);
} }
...@@ -223,8 +230,8 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy) ...@@ -223,8 +230,8 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
return -EINVAL; return -EINVAL;
/* table init */ /* table init */
for (i=1; (p4clockmod_table[i].frequency != CPUFREQ_TABLE_END); i++) { for (i = 1; (p4clockmod_table[i].frequency != CPUFREQ_TABLE_END); i++) {
if ((i<2) && (has_N44_O17_errata[policy->cpu])) if ((i < 2) && (has_N44_O17_errata[policy->cpu]))
p4clockmod_table[i].frequency = CPUFREQ_ENTRY_INVALID; p4clockmod_table[i].frequency = CPUFREQ_ENTRY_INVALID;
else else
p4clockmod_table[i].frequency = (stock_freq * i)/8; p4clockmod_table[i].frequency = (stock_freq * i)/8;
...@@ -258,12 +265,12 @@ static unsigned int cpufreq_p4_get(unsigned int cpu) ...@@ -258,12 +265,12 @@ static unsigned int cpufreq_p4_get(unsigned int cpu)
l = DC_DISABLE; l = DC_DISABLE;
if (l != DC_DISABLE) if (l != DC_DISABLE)
return (stock_freq * l / 8); return stock_freq * l / 8;
return stock_freq; return stock_freq;
} }
static struct freq_attr* p4clockmod_attr[] = { static struct freq_attr *p4clockmod_attr[] = {
&cpufreq_freq_attr_scaling_available_freqs, &cpufreq_freq_attr_scaling_available_freqs,
NULL, NULL,
}; };
...@@ -299,9 +306,10 @@ static int __init cpufreq_p4_init(void) ...@@ -299,9 +306,10 @@ static int __init cpufreq_p4_init(void)
ret = cpufreq_register_driver(&p4clockmod_driver); ret = cpufreq_register_driver(&p4clockmod_driver);
if (!ret) if (!ret)
printk(KERN_INFO PFX "P4/Xeon(TM) CPU On-Demand Clock Modulation available\n"); printk(KERN_INFO PFX "P4/Xeon(TM) CPU On-Demand Clock "
"Modulation available\n");
return (ret); return ret;
} }
...@@ -311,9 +319,9 @@ static void __exit cpufreq_p4_exit(void) ...@@ -311,9 +319,9 @@ static void __exit cpufreq_p4_exit(void)
} }
MODULE_AUTHOR ("Zwane Mwaikambo <zwane@commfireservices.com>"); MODULE_AUTHOR("Zwane Mwaikambo <zwane@commfireservices.com>");
MODULE_DESCRIPTION ("cpufreq driver for Pentium(TM) 4/Xeon(TM)"); MODULE_DESCRIPTION("cpufreq driver for Pentium(TM) 4/Xeon(TM)");
MODULE_LICENSE ("GPL"); MODULE_LICENSE("GPL");
late_initcall(cpufreq_p4_init); late_initcall(cpufreq_p4_init);
module_exit(cpufreq_p4_exit); module_exit(cpufreq_p4_exit);
...@@ -39,7 +39,7 @@ static struct pci_dev *speedstep_chipset_dev; ...@@ -39,7 +39,7 @@ static struct pci_dev *speedstep_chipset_dev;
/* speedstep_processor /* speedstep_processor
*/ */
static unsigned int speedstep_processor = 0; static unsigned int speedstep_processor;
static u32 pmbase; static u32 pmbase;
...@@ -54,7 +54,8 @@ static struct cpufreq_frequency_table speedstep_freqs[] = { ...@@ -54,7 +54,8 @@ static struct cpufreq_frequency_table speedstep_freqs[] = {
}; };
#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-ich", msg) #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, \
"speedstep-ich", msg)
/** /**
...@@ -62,7 +63,7 @@ static struct cpufreq_frequency_table speedstep_freqs[] = { ...@@ -62,7 +63,7 @@ static struct cpufreq_frequency_table speedstep_freqs[] = {
* *
* Returns: -ENODEV if no register could be found * Returns: -ENODEV if no register could be found
*/ */
static int speedstep_find_register (void) static int speedstep_find_register(void)
{ {
if (!speedstep_chipset_dev) if (!speedstep_chipset_dev)
return -ENODEV; return -ENODEV;
...@@ -90,7 +91,7 @@ static int speedstep_find_register (void) ...@@ -90,7 +91,7 @@ static int speedstep_find_register (void)
* *
* Tries to change the SpeedStep state. * Tries to change the SpeedStep state.
*/ */
static void speedstep_set_state (unsigned int state) static void speedstep_set_state(unsigned int state)
{ {
u8 pm2_blk; u8 pm2_blk;
u8 value; u8 value;
...@@ -133,11 +134,11 @@ static void speedstep_set_state (unsigned int state) ...@@ -133,11 +134,11 @@ static void speedstep_set_state (unsigned int state)
dprintk("read at pmbase 0x%x + 0x50 returned 0x%x\n", pmbase, value); dprintk("read at pmbase 0x%x + 0x50 returned 0x%x\n", pmbase, value);
if (state == (value & 0x1)) { if (state == (value & 0x1))
dprintk("change to %u MHz succeeded\n", (speedstep_get_processor_frequency(speedstep_processor) / 1000)); dprintk("change to %u MHz succeeded\n",
} else { speedstep_get_frequency(speedstep_processor) / 1000);
printk (KERN_ERR "cpufreq: change failed - I/O error\n"); else
} printk(KERN_ERR "cpufreq: change failed - I/O error\n");
return; return;
} }
...@@ -149,7 +150,7 @@ static void speedstep_set_state (unsigned int state) ...@@ -149,7 +150,7 @@ static void speedstep_set_state (unsigned int state)
* Tries to activate the SpeedStep status and control registers. * Tries to activate the SpeedStep status and control registers.
* Returns -EINVAL on an unsupported chipset, and zero on success. * Returns -EINVAL on an unsupported chipset, and zero on success.
*/ */
static int speedstep_activate (void) static int speedstep_activate(void)
{ {
u16 value = 0; u16 value = 0;
...@@ -175,20 +176,18 @@ static int speedstep_activate (void) ...@@ -175,20 +176,18 @@ static int speedstep_activate (void)
* functions. Returns the SPEEDSTEP_CHIPSET_-number for the detected * functions. Returns the SPEEDSTEP_CHIPSET_-number for the detected
* chipset, or zero on failure. * chipset, or zero on failure.
*/ */
static unsigned int speedstep_detect_chipset (void) static unsigned int speedstep_detect_chipset(void)
{ {
speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82801DB_12, PCI_DEVICE_ID_INTEL_82801DB_12,
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
PCI_ANY_ID,
NULL); NULL);
if (speedstep_chipset_dev) if (speedstep_chipset_dev)
return 4; /* 4-M */ return 4; /* 4-M */
speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82801CA_12, PCI_DEVICE_ID_INTEL_82801CA_12,
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
PCI_ANY_ID,
NULL); NULL);
if (speedstep_chipset_dev) if (speedstep_chipset_dev)
return 3; /* 3-M */ return 3; /* 3-M */
...@@ -196,8 +195,7 @@ static unsigned int speedstep_detect_chipset (void) ...@@ -196,8 +195,7 @@ static unsigned int speedstep_detect_chipset (void)
speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82801BA_10, PCI_DEVICE_ID_INTEL_82801BA_10,
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
PCI_ANY_ID,
NULL); NULL);
if (speedstep_chipset_dev) { if (speedstep_chipset_dev) {
/* speedstep.c causes lockups on Dell Inspirons 8000 and /* speedstep.c causes lockups on Dell Inspirons 8000 and
...@@ -208,8 +206,7 @@ static unsigned int speedstep_detect_chipset (void) ...@@ -208,8 +206,7 @@ static unsigned int speedstep_detect_chipset (void)
hostbridge = pci_get_subsys(PCI_VENDOR_ID_INTEL, hostbridge = pci_get_subsys(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82815_MC, PCI_DEVICE_ID_INTEL_82815_MC,
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
PCI_ANY_ID,
NULL); NULL);
if (!hostbridge) if (!hostbridge)
...@@ -236,7 +233,7 @@ static unsigned int _speedstep_get(const struct cpumask *cpus) ...@@ -236,7 +233,7 @@ static unsigned int _speedstep_get(const struct cpumask *cpus)
cpus_allowed = current->cpus_allowed; cpus_allowed = current->cpus_allowed;
set_cpus_allowed_ptr(current, cpus); set_cpus_allowed_ptr(current, cpus);
speed = speedstep_get_processor_frequency(speedstep_processor); speed = speedstep_get_frequency(speedstep_processor);
set_cpus_allowed_ptr(current, &cpus_allowed); set_cpus_allowed_ptr(current, &cpus_allowed);
dprintk("detected %u kHz as current frequency\n", speed); dprintk("detected %u kHz as current frequency\n", speed);
return speed; return speed;
...@@ -251,11 +248,12 @@ static unsigned int speedstep_get(unsigned int cpu) ...@@ -251,11 +248,12 @@ static unsigned int speedstep_get(unsigned int cpu)
* speedstep_target - set a new CPUFreq policy * speedstep_target - set a new CPUFreq policy
* @policy: new policy * @policy: new policy
* @target_freq: the target frequency * @target_freq: the target frequency
* @relation: how that frequency relates to achieved frequency (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H) * @relation: how that frequency relates to achieved frequency
* (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
* *
* Sets a new CPUFreq policy. * Sets a new CPUFreq policy.
*/ */
static int speedstep_target (struct cpufreq_policy *policy, static int speedstep_target(struct cpufreq_policy *policy,
unsigned int target_freq, unsigned int target_freq,
unsigned int relation) unsigned int relation)
{ {
...@@ -264,7 +262,8 @@ static int speedstep_target (struct cpufreq_policy *policy, ...@@ -264,7 +262,8 @@ static int speedstep_target (struct cpufreq_policy *policy,
cpumask_t cpus_allowed; cpumask_t cpus_allowed;
int i; int i;
if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], target_freq, relation, &newstate)) if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0],
target_freq, relation, &newstate))
return -EINVAL; return -EINVAL;
freqs.old = _speedstep_get(policy->cpus); freqs.old = _speedstep_get(policy->cpus);
...@@ -308,7 +307,7 @@ static int speedstep_target (struct cpufreq_policy *policy, ...@@ -308,7 +307,7 @@ static int speedstep_target (struct cpufreq_policy *policy,
* Limit must be within speedstep_low_freq and speedstep_high_freq, with * Limit must be within speedstep_low_freq and speedstep_high_freq, with
* at least one border included. * at least one border included.
*/ */
static int speedstep_verify (struct cpufreq_policy *policy) static int speedstep_verify(struct cpufreq_policy *policy)
{ {
return cpufreq_frequency_table_verify(policy, &speedstep_freqs[0]); return cpufreq_frequency_table_verify(policy, &speedstep_freqs[0]);
} }
...@@ -344,7 +343,8 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) ...@@ -344,7 +343,8 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
return -EIO; return -EIO;
dprintk("currently at %s speed setting - %i MHz\n", dprintk("currently at %s speed setting - %i MHz\n",
(speed == speedstep_freqs[SPEEDSTEP_LOW].frequency) ? "low" : "high", (speed == speedstep_freqs[SPEEDSTEP_LOW].frequency)
? "low" : "high",
(speed / 1000)); (speed / 1000));
/* cpuinfo and default policy values */ /* cpuinfo and default policy values */
...@@ -352,7 +352,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) ...@@ -352,7 +352,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
result = cpufreq_frequency_table_cpuinfo(policy, speedstep_freqs); result = cpufreq_frequency_table_cpuinfo(policy, speedstep_freqs);
if (result) if (result)
return (result); return result;
cpufreq_frequency_table_get_attr(speedstep_freqs, policy->cpu); cpufreq_frequency_table_get_attr(speedstep_freqs, policy->cpu);
...@@ -366,7 +366,7 @@ static int speedstep_cpu_exit(struct cpufreq_policy *policy) ...@@ -366,7 +366,7 @@ static int speedstep_cpu_exit(struct cpufreq_policy *policy)
return 0; return 0;
} }
static struct freq_attr* speedstep_attr[] = { static struct freq_attr *speedstep_attr[] = {
&cpufreq_freq_attr_scaling_available_freqs, &cpufreq_freq_attr_scaling_available_freqs,
NULL, NULL,
}; };
...@@ -396,13 +396,15 @@ static int __init speedstep_init(void) ...@@ -396,13 +396,15 @@ static int __init speedstep_init(void)
/* detect processor */ /* detect processor */
speedstep_processor = speedstep_detect_processor(); speedstep_processor = speedstep_detect_processor();
if (!speedstep_processor) { if (!speedstep_processor) {
dprintk("Intel(R) SpeedStep(TM) capable processor not found\n"); dprintk("Intel(R) SpeedStep(TM) capable processor "
"not found\n");
return -ENODEV; return -ENODEV;
} }
/* detect chipset */ /* detect chipset */
if (!speedstep_detect_chipset()) { if (!speedstep_detect_chipset()) {
dprintk("Intel(R) SpeedStep(TM) for this chipset not (yet) available.\n"); dprintk("Intel(R) SpeedStep(TM) for this chipset not "
"(yet) available.\n");
return -ENODEV; return -ENODEV;
} }
...@@ -431,9 +433,11 @@ static void __exit speedstep_exit(void) ...@@ -431,9 +433,11 @@ static void __exit speedstep_exit(void)
} }
MODULE_AUTHOR ("Dave Jones <davej@redhat.com>, Dominik Brodowski <linux@brodo.de>"); MODULE_AUTHOR("Dave Jones <davej@redhat.com>, "
MODULE_DESCRIPTION ("Speedstep driver for Intel mobile processors on chipsets with ICH-M southbridges."); "Dominik Brodowski <linux@brodo.de>");
MODULE_LICENSE ("GPL"); MODULE_DESCRIPTION("Speedstep driver for Intel mobile processors on chipsets "
"with ICH-M southbridges.");
MODULE_LICENSE("GPL");
module_init(speedstep_init); module_init(speedstep_init);
module_exit(speedstep_exit); module_exit(speedstep_exit);
...@@ -18,10 +18,13 @@ ...@@ -18,10 +18,13 @@
#include <asm/msr.h> #include <asm/msr.h>
#include "speedstep-lib.h" #include "speedstep-lib.h"
#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-lib", msg) #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, \
"speedstep-lib", msg)
#define PFX "speedstep-lib: "
#ifdef CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK #ifdef CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK
static int relaxed_check = 0; static int relaxed_check;
#else #else
#define relaxed_check 0 #define relaxed_check 0
#endif #endif
...@@ -30,14 +33,14 @@ static int relaxed_check = 0; ...@@ -30,14 +33,14 @@ static int relaxed_check = 0;
* GET PROCESSOR CORE SPEED IN KHZ * * GET PROCESSOR CORE SPEED IN KHZ *
*********************************************************************/ *********************************************************************/
static unsigned int pentium3_get_frequency (unsigned int processor) static unsigned int pentium3_get_frequency(unsigned int processor)
{ {
/* See table 14 of p3_ds.pdf and table 22 of 29834003.pdf */ /* See table 14 of p3_ds.pdf and table 22 of 29834003.pdf */
struct { struct {
unsigned int ratio; /* Frequency Multiplier (x10) */ unsigned int ratio; /* Frequency Multiplier (x10) */
u8 bitmap; /* power on configuration bits u8 bitmap; /* power on configuration bits
[27, 25:22] (in MSR 0x2a) */ [27, 25:22] (in MSR 0x2a) */
} msr_decode_mult [] = { } msr_decode_mult[] = {
{ 30, 0x01 }, { 30, 0x01 },
{ 35, 0x05 }, { 35, 0x05 },
{ 40, 0x02 }, { 40, 0x02 },
...@@ -60,7 +63,7 @@ static unsigned int pentium3_get_frequency (unsigned int processor) ...@@ -60,7 +63,7 @@ static unsigned int pentium3_get_frequency (unsigned int processor)
unsigned int value; /* Front Side Bus speed in MHz */ unsigned int value; /* Front Side Bus speed in MHz */
u8 bitmap; /* power on configuration bits [18: 19] u8 bitmap; /* power on configuration bits [18: 19]
(in MSR 0x2a) */ (in MSR 0x2a) */
} msr_decode_fsb [] = { } msr_decode_fsb[] = {
{ 66, 0x0 }, { 66, 0x0 },
{ 100, 0x2 }, { 100, 0x2 },
{ 133, 0x1 }, { 133, 0x1 },
...@@ -85,7 +88,7 @@ static unsigned int pentium3_get_frequency (unsigned int processor) ...@@ -85,7 +88,7 @@ static unsigned int pentium3_get_frequency (unsigned int processor)
} }
/* decode the multiplier */ /* decode the multiplier */
if (processor == SPEEDSTEP_PROCESSOR_PIII_C_EARLY) { if (processor == SPEEDSTEP_CPU_PIII_C_EARLY) {
dprintk("workaround for early PIIIs\n"); dprintk("workaround for early PIIIs\n");
msr_lo &= 0x03c00000; msr_lo &= 0x03c00000;
} else } else
...@@ -97,9 +100,10 @@ static unsigned int pentium3_get_frequency (unsigned int processor) ...@@ -97,9 +100,10 @@ static unsigned int pentium3_get_frequency (unsigned int processor)
j++; j++;
} }
dprintk("speed is %u\n", (msr_decode_mult[j].ratio * msr_decode_fsb[i].value * 100)); dprintk("speed is %u\n",
(msr_decode_mult[j].ratio * msr_decode_fsb[i].value * 100));
return (msr_decode_mult[j].ratio * msr_decode_fsb[i].value * 100); return msr_decode_mult[j].ratio * msr_decode_fsb[i].value * 100;
} }
...@@ -112,20 +116,23 @@ static unsigned int pentiumM_get_frequency(void) ...@@ -112,20 +116,23 @@ static unsigned int pentiumM_get_frequency(void)
/* see table B-2 of 24547212.pdf */ /* see table B-2 of 24547212.pdf */
if (msr_lo & 0x00040000) { if (msr_lo & 0x00040000) {
printk(KERN_DEBUG "speedstep-lib: PM - invalid FSB: 0x%x 0x%x\n", msr_lo, msr_tmp); printk(KERN_DEBUG PFX "PM - invalid FSB: 0x%x 0x%x\n",
msr_lo, msr_tmp);
return 0; return 0;
} }
msr_tmp = (msr_lo >> 22) & 0x1f; msr_tmp = (msr_lo >> 22) & 0x1f;
dprintk("bits 22-26 are 0x%x, speed is %u\n", msr_tmp, (msr_tmp * 100 * 1000)); dprintk("bits 22-26 are 0x%x, speed is %u\n",
msr_tmp, (msr_tmp * 100 * 1000));
return (msr_tmp * 100 * 1000); return msr_tmp * 100 * 1000;
} }
static unsigned int pentium_core_get_frequency(void) static unsigned int pentium_core_get_frequency(void)
{ {
u32 fsb = 0; u32 fsb = 0;
u32 msr_lo, msr_tmp; u32 msr_lo, msr_tmp;
int ret;
rdmsr(MSR_FSB_FREQ, msr_lo, msr_tmp); rdmsr(MSR_FSB_FREQ, msr_lo, msr_tmp);
/* see table B-2 of 25366920.pdf */ /* see table B-2 of 25366920.pdf */
...@@ -153,12 +160,15 @@ static unsigned int pentium_core_get_frequency(void) ...@@ -153,12 +160,15 @@ static unsigned int pentium_core_get_frequency(void)
} }
rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp); rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp);
dprintk("PCORE - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp); dprintk("PCORE - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n",
msr_lo, msr_tmp);
msr_tmp = (msr_lo >> 22) & 0x1f; msr_tmp = (msr_lo >> 22) & 0x1f;
dprintk("bits 22-26 are 0x%x, speed is %u\n", msr_tmp, (msr_tmp * fsb)); dprintk("bits 22-26 are 0x%x, speed is %u\n",
msr_tmp, (msr_tmp * fsb));
return (msr_tmp * fsb); ret = (msr_tmp * fsb);
return ret;
} }
...@@ -167,6 +177,7 @@ static unsigned int pentium4_get_frequency(void) ...@@ -167,6 +177,7 @@ static unsigned int pentium4_get_frequency(void)
struct cpuinfo_x86 *c = &boot_cpu_data; struct cpuinfo_x86 *c = &boot_cpu_data;
u32 msr_lo, msr_hi, mult; u32 msr_lo, msr_hi, mult;
unsigned int fsb = 0; unsigned int fsb = 0;
unsigned int ret;
rdmsr(0x2c, msr_lo, msr_hi); rdmsr(0x2c, msr_lo, msr_hi);
...@@ -195,44 +206,47 @@ static unsigned int pentium4_get_frequency(void) ...@@ -195,44 +206,47 @@ static unsigned int pentium4_get_frequency(void)
} }
if (!fsb) if (!fsb)
printk(KERN_DEBUG "speedstep-lib: couldn't detect FSB speed. Please send an e-mail to <linux@brodo.de>\n"); printk(KERN_DEBUG PFX "couldn't detect FSB speed. "
"Please send an e-mail to <linux@brodo.de>\n");
/* Multiplier. */ /* Multiplier. */
mult = msr_lo >> 24; mult = msr_lo >> 24;
dprintk("P4 - FSB %u kHz; Multiplier %u; Speed %u kHz\n", fsb, mult, (fsb * mult)); dprintk("P4 - FSB %u kHz; Multiplier %u; Speed %u kHz\n",
fsb, mult, (fsb * mult));
return (fsb * mult); ret = (fsb * mult);
return ret;
} }
unsigned int speedstep_get_processor_frequency(unsigned int processor) unsigned int speedstep_get_frequency(unsigned int processor)
{ {
switch (processor) { switch (processor) {
case SPEEDSTEP_PROCESSOR_PCORE: case SPEEDSTEP_CPU_PCORE:
return pentium_core_get_frequency(); return pentium_core_get_frequency();
case SPEEDSTEP_PROCESSOR_PM: case SPEEDSTEP_CPU_PM:
return pentiumM_get_frequency(); return pentiumM_get_frequency();
case SPEEDSTEP_PROCESSOR_P4D: case SPEEDSTEP_CPU_P4D:
case SPEEDSTEP_PROCESSOR_P4M: case SPEEDSTEP_CPU_P4M:
return pentium4_get_frequency(); return pentium4_get_frequency();
case SPEEDSTEP_PROCESSOR_PIII_T: case SPEEDSTEP_CPU_PIII_T:
case SPEEDSTEP_PROCESSOR_PIII_C: case SPEEDSTEP_CPU_PIII_C:
case SPEEDSTEP_PROCESSOR_PIII_C_EARLY: case SPEEDSTEP_CPU_PIII_C_EARLY:
return pentium3_get_frequency(processor); return pentium3_get_frequency(processor);
default: default:
return 0; return 0;
}; };
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(speedstep_get_processor_frequency); EXPORT_SYMBOL_GPL(speedstep_get_frequency);
/********************************************************************* /*********************************************************************
* DETECT SPEEDSTEP-CAPABLE PROCESSOR * * DETECT SPEEDSTEP-CAPABLE PROCESSOR *
*********************************************************************/ *********************************************************************/
unsigned int speedstep_detect_processor (void) unsigned int speedstep_detect_processor(void)
{ {
struct cpuinfo_x86 *c = &cpu_data(0); struct cpuinfo_x86 *c = &cpu_data(0);
u32 ebx, msr_lo, msr_hi; u32 ebx, msr_lo, msr_hi;
...@@ -261,7 +275,7 @@ unsigned int speedstep_detect_processor (void) ...@@ -261,7 +275,7 @@ unsigned int speedstep_detect_processor (void)
* sample has ebx = 0x0f, production has 0x0e. * sample has ebx = 0x0f, production has 0x0e.
*/ */
if ((ebx == 0x0e) || (ebx == 0x0f)) if ((ebx == 0x0e) || (ebx == 0x0f))
return SPEEDSTEP_PROCESSOR_P4M; return SPEEDSTEP_CPU_P4M;
break; break;
case 7: case 7:
/* /*
...@@ -272,7 +286,7 @@ unsigned int speedstep_detect_processor (void) ...@@ -272,7 +286,7 @@ unsigned int speedstep_detect_processor (void)
* samples are only of B-stepping... * samples are only of B-stepping...
*/ */
if (ebx == 0x0e) if (ebx == 0x0e)
return SPEEDSTEP_PROCESSOR_P4M; return SPEEDSTEP_CPU_P4M;
break; break;
case 9: case 9:
/* /*
...@@ -288,10 +302,13 @@ unsigned int speedstep_detect_processor (void) ...@@ -288,10 +302,13 @@ unsigned int speedstep_detect_processor (void)
* M-P4-Ms may have either ebx=0xe or 0xf [see above] * M-P4-Ms may have either ebx=0xe or 0xf [see above]
* M-P4/533 have either ebx=0xe or 0xf. [25317607.pdf] * M-P4/533 have either ebx=0xe or 0xf. [25317607.pdf]
* also, M-P4M HTs have ebx=0x8, too * also, M-P4M HTs have ebx=0x8, too
* For now, they are distinguished by the model_id string * For now, they are distinguished by the model_id
* string
*/ */
if ((ebx == 0x0e) || (strstr(c->x86_model_id,"Mobile Intel(R) Pentium(R) 4") != NULL)) if ((ebx == 0x0e) ||
return SPEEDSTEP_PROCESSOR_P4M; (strstr(c->x86_model_id,
"Mobile Intel(R) Pentium(R) 4") != NULL))
return SPEEDSTEP_CPU_P4M;
break; break;
default: default:
break; break;
...@@ -301,7 +318,8 @@ unsigned int speedstep_detect_processor (void) ...@@ -301,7 +318,8 @@ unsigned int speedstep_detect_processor (void)
switch (c->x86_model) { switch (c->x86_model) {
case 0x0B: /* Intel PIII [Tualatin] */ case 0x0B: /* Intel PIII [Tualatin] */
/* cpuid_ebx(1) is 0x04 for desktop PIII, 0x06 for mobile PIII-M */ /* cpuid_ebx(1) is 0x04 for desktop PIII,
* 0x06 for mobile PIII-M */
ebx = cpuid_ebx(0x00000001); ebx = cpuid_ebx(0x00000001);
dprintk("ebx is %x\n", ebx); dprintk("ebx is %x\n", ebx);
...@@ -313,14 +331,15 @@ unsigned int speedstep_detect_processor (void) ...@@ -313,14 +331,15 @@ unsigned int speedstep_detect_processor (void)
/* So far all PIII-M processors support SpeedStep. See /* So far all PIII-M processors support SpeedStep. See
* Intel's 24540640.pdf of June 2003 * Intel's 24540640.pdf of June 2003
*/ */
return SPEEDSTEP_PROCESSOR_PIII_T; return SPEEDSTEP_CPU_PIII_T;
case 0x08: /* Intel PIII [Coppermine] */ case 0x08: /* Intel PIII [Coppermine] */
/* all mobile PIII Coppermines have FSB 100 MHz /* all mobile PIII Coppermines have FSB 100 MHz
* ==> sort out a few desktop PIIIs. */ * ==> sort out a few desktop PIIIs. */
rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_hi); rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_hi);
dprintk("Coppermine: MSR_IA32_EBL_CR_POWERON is 0x%x, 0x%x\n", msr_lo, msr_hi); dprintk("Coppermine: MSR_IA32_EBL_CR_POWERON is 0x%x, 0x%x\n",
msr_lo, msr_hi);
msr_lo &= 0x00c0000; msr_lo &= 0x00c0000;
if (msr_lo != 0x0080000) if (msr_lo != 0x0080000)
return 0; return 0;
...@@ -332,13 +351,15 @@ unsigned int speedstep_detect_processor (void) ...@@ -332,13 +351,15 @@ unsigned int speedstep_detect_processor (void)
* bit 56 or 57 is set * bit 56 or 57 is set
*/ */
rdmsr(MSR_IA32_PLATFORM_ID, msr_lo, msr_hi); rdmsr(MSR_IA32_PLATFORM_ID, msr_lo, msr_hi);
dprintk("Coppermine: MSR_IA32_PLATFORM ID is 0x%x, 0x%x\n", msr_lo, msr_hi); dprintk("Coppermine: MSR_IA32_PLATFORM ID is 0x%x, 0x%x\n",
if ((msr_hi & (1<<18)) && (relaxed_check ? 1 : (msr_hi & (3<<24)))) { msr_lo, msr_hi);
if ((msr_hi & (1<<18)) &&
(relaxed_check ? 1 : (msr_hi & (3<<24)))) {
if (c->x86_mask == 0x01) { if (c->x86_mask == 0x01) {
dprintk("early PIII version\n"); dprintk("early PIII version\n");
return SPEEDSTEP_PROCESSOR_PIII_C_EARLY; return SPEEDSTEP_CPU_PIII_C_EARLY;
} else } else
return SPEEDSTEP_PROCESSOR_PIII_C; return SPEEDSTEP_CPU_PIII_C;
} }
default: default:
...@@ -369,7 +390,7 @@ unsigned int speedstep_get_freqs(unsigned int processor, ...@@ -369,7 +390,7 @@ unsigned int speedstep_get_freqs(unsigned int processor,
dprintk("trying to determine both speeds\n"); dprintk("trying to determine both speeds\n");
/* get current speed */ /* get current speed */
prev_speed = speedstep_get_processor_frequency(processor); prev_speed = speedstep_get_frequency(processor);
if (!prev_speed) if (!prev_speed)
return -EIO; return -EIO;
...@@ -379,7 +400,7 @@ unsigned int speedstep_get_freqs(unsigned int processor, ...@@ -379,7 +400,7 @@ unsigned int speedstep_get_freqs(unsigned int processor,
/* switch to low state */ /* switch to low state */
set_state(SPEEDSTEP_LOW); set_state(SPEEDSTEP_LOW);
*low_speed = speedstep_get_processor_frequency(processor); *low_speed = speedstep_get_frequency(processor);
if (!*low_speed) { if (!*low_speed) {
ret = -EIO; ret = -EIO;
goto out; goto out;
...@@ -398,7 +419,7 @@ unsigned int speedstep_get_freqs(unsigned int processor, ...@@ -398,7 +419,7 @@ unsigned int speedstep_get_freqs(unsigned int processor,
if (transition_latency) if (transition_latency)
do_gettimeofday(&tv2); do_gettimeofday(&tv2);
*high_speed = speedstep_get_processor_frequency(processor); *high_speed = speedstep_get_frequency(processor);
if (!*high_speed) { if (!*high_speed) {
ret = -EIO; ret = -EIO;
goto out; goto out;
...@@ -426,9 +447,12 @@ unsigned int speedstep_get_freqs(unsigned int processor, ...@@ -426,9 +447,12 @@ unsigned int speedstep_get_freqs(unsigned int processor,
/* check if the latency measurement is too high or too low /* check if the latency measurement is too high or too low
* and set it to a safe value (500uSec) in that case * and set it to a safe value (500uSec) in that case
*/ */
if (*transition_latency > 10000000 || *transition_latency < 50000) { if (*transition_latency > 10000000 ||
printk (KERN_WARNING "speedstep: frequency transition measured seems out of " *transition_latency < 50000) {
"range (%u nSec), falling back to a safe one of %u nSec.\n", printk(KERN_WARNING PFX "frequency transition "
"measured seems out of range (%u "
"nSec), falling back to a safe one of"
"%u nSec.\n",
*transition_latency, 500000); *transition_latency, 500000);
*transition_latency = 500000; *transition_latency = 500000;
} }
...@@ -436,15 +460,16 @@ unsigned int speedstep_get_freqs(unsigned int processor, ...@@ -436,15 +460,16 @@ unsigned int speedstep_get_freqs(unsigned int processor,
out: out:
local_irq_restore(flags); local_irq_restore(flags);
return (ret); return ret;
} }
EXPORT_SYMBOL_GPL(speedstep_get_freqs); EXPORT_SYMBOL_GPL(speedstep_get_freqs);
#ifdef CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK #ifdef CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK
module_param(relaxed_check, int, 0444); module_param(relaxed_check, int, 0444);
MODULE_PARM_DESC(relaxed_check, "Don't do all checks for speedstep capability."); MODULE_PARM_DESC(relaxed_check,
"Don't do all checks for speedstep capability.");
#endif #endif
MODULE_AUTHOR ("Dominik Brodowski <linux@brodo.de>"); MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>");
MODULE_DESCRIPTION ("Library for Intel SpeedStep 1 or 2 cpufreq drivers."); MODULE_DESCRIPTION("Library for Intel SpeedStep 1 or 2 cpufreq drivers.");
MODULE_LICENSE ("GPL"); MODULE_LICENSE("GPL");
...@@ -12,17 +12,17 @@ ...@@ -12,17 +12,17 @@
/* processors */ /* processors */
#define SPEEDSTEP_PROCESSOR_PIII_C_EARLY 0x00000001 /* Coppermine core */ #define SPEEDSTEP_CPU_PIII_C_EARLY 0x00000001 /* Coppermine core */
#define SPEEDSTEP_PROCESSOR_PIII_C 0x00000002 /* Coppermine core */ #define SPEEDSTEP_CPU_PIII_C 0x00000002 /* Coppermine core */
#define SPEEDSTEP_PROCESSOR_PIII_T 0x00000003 /* Tualatin core */ #define SPEEDSTEP_CPU_PIII_T 0x00000003 /* Tualatin core */
#define SPEEDSTEP_PROCESSOR_P4M 0x00000004 /* P4-M */ #define SPEEDSTEP_CPU_P4M 0x00000004 /* P4-M */
/* the following processors are not speedstep-capable and are not auto-detected /* the following processors are not speedstep-capable and are not auto-detected
* in speedstep_detect_processor(). However, their speed can be detected using * in speedstep_detect_processor(). However, their speed can be detected using
* the speedstep_get_processor_frequency() call. */ * the speedstep_get_frequency() call. */
#define SPEEDSTEP_PROCESSOR_PM 0xFFFFFF03 /* Pentium M */ #define SPEEDSTEP_CPU_PM 0xFFFFFF03 /* Pentium M */
#define SPEEDSTEP_PROCESSOR_P4D 0xFFFFFF04 /* desktop P4 */ #define SPEEDSTEP_CPU_P4D 0xFFFFFF04 /* desktop P4 */
#define SPEEDSTEP_PROCESSOR_PCORE 0xFFFFFF05 /* Core */ #define SPEEDSTEP_CPU_PCORE 0xFFFFFF05 /* Core */
/* speedstep states -- only two of them */ /* speedstep states -- only two of them */
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
extern unsigned int speedstep_detect_processor (void); extern unsigned int speedstep_detect_processor (void);
/* detect the current speed (in khz) of the processor */ /* detect the current speed (in khz) of the processor */
extern unsigned int speedstep_get_processor_frequency(unsigned int processor); extern unsigned int speedstep_get_frequency(unsigned int processor);
/* detect the low and high speeds of the processor. The callback /* detect the low and high speeds of the processor. The callback
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
#include <linux/cpufreq.h> #include <linux/cpufreq.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/io.h>
#include <asm/ist.h> #include <asm/ist.h>
#include <asm/io.h>
#include "speedstep-lib.h" #include "speedstep-lib.h"
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
* If user gives it, these are used. * If user gives it, these are used.
* *
*/ */
static int smi_port = 0; static int smi_port;
static int smi_cmd = 0; static int smi_cmd;
static unsigned int smi_sig = 0; static unsigned int smi_sig;
/* info about the processor */ /* info about the processor */
static unsigned int speedstep_processor = 0; static unsigned int speedstep_processor;
/* /*
* There are only two frequency states for each processor. Values * There are only two frequency states for each processor. Values
...@@ -56,12 +56,13 @@ static struct cpufreq_frequency_table speedstep_freqs[] = { ...@@ -56,12 +56,13 @@ static struct cpufreq_frequency_table speedstep_freqs[] = {
* of DMA activity going on? */ * of DMA activity going on? */
#define SMI_TRIES 5 #define SMI_TRIES 5
#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-smi", msg) #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, \
"speedstep-smi", msg)
/** /**
* speedstep_smi_ownership * speedstep_smi_ownership
*/ */
static int speedstep_smi_ownership (void) static int speedstep_smi_ownership(void)
{ {
u32 command, result, magic, dummy; u32 command, result, magic, dummy;
u32 function = GET_SPEEDSTEP_OWNER; u32 function = GET_SPEEDSTEP_OWNER;
...@@ -70,13 +71,15 @@ static int speedstep_smi_ownership (void) ...@@ -70,13 +71,15 @@ static int speedstep_smi_ownership (void)
command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff); command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
magic = virt_to_phys(magic_data); magic = virt_to_phys(magic_data);
dprintk("trying to obtain ownership with command %x at port %x\n", command, smi_port); dprintk("trying to obtain ownership with command %x at port %x\n",
command, smi_port);
__asm__ __volatile__( __asm__ __volatile__(
"push %%ebp\n" "push %%ebp\n"
"out %%al, (%%dx)\n" "out %%al, (%%dx)\n"
"pop %%ebp\n" "pop %%ebp\n"
: "=D" (result), "=a" (dummy), "=b" (dummy), "=c" (dummy), "=d" (dummy), : "=D" (result),
"=a" (dummy), "=b" (dummy), "=c" (dummy), "=d" (dummy),
"=S" (dummy) "=S" (dummy)
: "a" (command), "b" (function), "c" (0), "d" (smi_port), : "a" (command), "b" (function), "c" (0), "d" (smi_port),
"D" (0), "S" (magic) "D" (0), "S" (magic)
...@@ -97,10 +100,10 @@ static int speedstep_smi_ownership (void) ...@@ -97,10 +100,10 @@ static int speedstep_smi_ownership (void)
* even hangs [cf. bugme.osdl.org # 1422] on earlier systems. Empirical testing * even hangs [cf. bugme.osdl.org # 1422] on earlier systems. Empirical testing
* shows that the latter occurs if !(ist_info.event & 0xFFFF). * shows that the latter occurs if !(ist_info.event & 0xFFFF).
*/ */
static int speedstep_smi_get_freqs (unsigned int *low, unsigned int *high) static int speedstep_smi_get_freqs(unsigned int *low, unsigned int *high)
{ {
u32 command, result = 0, edi, high_mhz, low_mhz, dummy; u32 command, result = 0, edi, high_mhz, low_mhz, dummy;
u32 state=0; u32 state = 0;
u32 function = GET_SPEEDSTEP_FREQS; u32 function = GET_SPEEDSTEP_FREQS;
if (!(ist_info.event & 0xFFFF)) { if (!(ist_info.event & 0xFFFF)) {
...@@ -110,17 +113,25 @@ static int speedstep_smi_get_freqs (unsigned int *low, unsigned int *high) ...@@ -110,17 +113,25 @@ static int speedstep_smi_get_freqs (unsigned int *low, unsigned int *high)
command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff); command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
dprintk("trying to determine frequencies with command %x at port %x\n", command, smi_port); dprintk("trying to determine frequencies with command %x at port %x\n",
command, smi_port);
__asm__ __volatile__( __asm__ __volatile__(
"push %%ebp\n" "push %%ebp\n"
"out %%al, (%%dx)\n" "out %%al, (%%dx)\n"
"pop %%ebp" "pop %%ebp"
: "=a" (result), "=b" (high_mhz), "=c" (low_mhz), "=d" (state), "=D" (edi), "=S" (dummy) : "=a" (result),
: "a" (command), "b" (function), "c" (state), "d" (smi_port), "S" (0), "D" (0) "=b" (high_mhz),
"=c" (low_mhz),
"=d" (state), "=D" (edi), "=S" (dummy)
: "a" (command),
"b" (function),
"c" (state),
"d" (smi_port), "S" (0), "D" (0)
); );
dprintk("result %x, low_freq %u, high_freq %u\n", result, low_mhz, high_mhz); dprintk("result %x, low_freq %u, high_freq %u\n",
result, low_mhz, high_mhz);
/* abort if results are obviously incorrect... */ /* abort if results are obviously incorrect... */
if ((high_mhz + low_mhz) < 600) if ((high_mhz + low_mhz) < 600)
...@@ -137,26 +148,30 @@ static int speedstep_smi_get_freqs (unsigned int *low, unsigned int *high) ...@@ -137,26 +148,30 @@ static int speedstep_smi_get_freqs (unsigned int *low, unsigned int *high)
* @state: processor frequency state (SPEEDSTEP_LOW or SPEEDSTEP_HIGH) * @state: processor frequency state (SPEEDSTEP_LOW or SPEEDSTEP_HIGH)
* *
*/ */
static int speedstep_get_state (void) static int speedstep_get_state(void)
{ {
u32 function=GET_SPEEDSTEP_STATE; u32 function = GET_SPEEDSTEP_STATE;
u32 result, state, edi, command, dummy; u32 result, state, edi, command, dummy;
command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff); command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
dprintk("trying to determine current setting with command %x at port %x\n", command, smi_port); dprintk("trying to determine current setting with command %x "
"at port %x\n", command, smi_port);
__asm__ __volatile__( __asm__ __volatile__(
"push %%ebp\n" "push %%ebp\n"
"out %%al, (%%dx)\n" "out %%al, (%%dx)\n"
"pop %%ebp\n" "pop %%ebp\n"
: "=a" (result), "=b" (state), "=D" (edi), "=c" (dummy), "=d" (dummy), "=S" (dummy) : "=a" (result),
: "a" (command), "b" (function), "c" (0), "d" (smi_port), "S" (0), "D" (0) "=b" (state), "=D" (edi),
"=c" (dummy), "=d" (dummy), "=S" (dummy)
: "a" (command), "b" (function), "c" (0),
"d" (smi_port), "S" (0), "D" (0)
); );
dprintk("state is %x, result is %x\n", state, result); dprintk("state is %x, result is %x\n", state, result);
return (state & 1); return state & 1;
} }
...@@ -165,11 +180,11 @@ static int speedstep_get_state (void) ...@@ -165,11 +180,11 @@ static int speedstep_get_state (void)
* @state: new processor frequency state (SPEEDSTEP_LOW or SPEEDSTEP_HIGH) * @state: new processor frequency state (SPEEDSTEP_LOW or SPEEDSTEP_HIGH)
* *
*/ */
static void speedstep_set_state (unsigned int state) static void speedstep_set_state(unsigned int state)
{ {
unsigned int result = 0, command, new_state, dummy; unsigned int result = 0, command, new_state, dummy;
unsigned long flags; unsigned long flags;
unsigned int function=SET_SPEEDSTEP_STATE; unsigned int function = SET_SPEEDSTEP_STATE;
unsigned int retry = 0; unsigned int retry = 0;
if (state > 0x1) if (state > 0x1)
...@@ -180,11 +195,14 @@ static void speedstep_set_state (unsigned int state) ...@@ -180,11 +195,14 @@ static void speedstep_set_state (unsigned int state)
command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff); command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
dprintk("trying to set frequency to state %u with command %x at port %x\n", state, command, smi_port); dprintk("trying to set frequency to state %u "
"with command %x at port %x\n",
state, command, smi_port);
do { do {
if (retry) { if (retry) {
dprintk("retry %u, previous result %u, waiting...\n", retry, result); dprintk("retry %u, previous result %u, waiting...\n",
retry, result);
mdelay(retry * 50); mdelay(retry * 50);
} }
retry++; retry++;
...@@ -192,20 +210,26 @@ static void speedstep_set_state (unsigned int state) ...@@ -192,20 +210,26 @@ static void speedstep_set_state (unsigned int state)
"push %%ebp\n" "push %%ebp\n"
"out %%al, (%%dx)\n" "out %%al, (%%dx)\n"
"pop %%ebp" "pop %%ebp"
: "=b" (new_state), "=D" (result), "=c" (dummy), "=a" (dummy), : "=b" (new_state), "=D" (result),
"=c" (dummy), "=a" (dummy),
"=d" (dummy), "=S" (dummy) "=d" (dummy), "=S" (dummy)
: "a" (command), "b" (function), "c" (state), "d" (smi_port), "S" (0), "D" (0) : "a" (command), "b" (function), "c" (state),
"d" (smi_port), "S" (0), "D" (0)
); );
} while ((new_state != state) && (retry <= SMI_TRIES)); } while ((new_state != state) && (retry <= SMI_TRIES));
/* enable IRQs */ /* enable IRQs */
local_irq_restore(flags); local_irq_restore(flags);
if (new_state == state) { if (new_state == state)
dprintk("change to %u MHz succeeded after %u tries with result %u\n", (speedstep_freqs[new_state].frequency / 1000), retry, result); dprintk("change to %u MHz succeeded after %u tries "
} else { "with result %u\n",
printk(KERN_ERR "cpufreq: change to state %u failed with new_state %u and result %u\n", state, new_state, result); (speedstep_freqs[new_state].frequency / 1000),
} retry, result);
else
printk(KERN_ERR "cpufreq: change to state %u "
"failed with new_state %u and result %u\n",
state, new_state, result);
return; return;
} }
...@@ -219,13 +243,14 @@ static void speedstep_set_state (unsigned int state) ...@@ -219,13 +243,14 @@ static void speedstep_set_state (unsigned int state)
* *
* Sets a new CPUFreq policy/freq. * Sets a new CPUFreq policy/freq.
*/ */
static int speedstep_target (struct cpufreq_policy *policy, static int speedstep_target(struct cpufreq_policy *policy,
unsigned int target_freq, unsigned int relation) unsigned int target_freq, unsigned int relation)
{ {
unsigned int newstate = 0; unsigned int newstate = 0;
struct cpufreq_freqs freqs; struct cpufreq_freqs freqs;
if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], target_freq, relation, &newstate)) if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0],
target_freq, relation, &newstate))
return -EINVAL; return -EINVAL;
freqs.old = speedstep_freqs[speedstep_get_state()].frequency; freqs.old = speedstep_freqs[speedstep_get_state()].frequency;
...@@ -250,7 +275,7 @@ static int speedstep_target (struct cpufreq_policy *policy, ...@@ -250,7 +275,7 @@ static int speedstep_target (struct cpufreq_policy *policy,
* Limit must be within speedstep_low_freq and speedstep_high_freq, with * Limit must be within speedstep_low_freq and speedstep_high_freq, with
* at least one border included. * at least one border included.
*/ */
static int speedstep_verify (struct cpufreq_policy *policy) static int speedstep_verify(struct cpufreq_policy *policy)
{ {
return cpufreq_frequency_table_verify(policy, &speedstep_freqs[0]); return cpufreq_frequency_table_verify(policy, &speedstep_freqs[0]);
} }
...@@ -259,7 +284,8 @@ static int speedstep_verify (struct cpufreq_policy *policy) ...@@ -259,7 +284,8 @@ static int speedstep_verify (struct cpufreq_policy *policy)
static int speedstep_cpu_init(struct cpufreq_policy *policy) static int speedstep_cpu_init(struct cpufreq_policy *policy)
{ {
int result; int result;
unsigned int speed,state; unsigned int speed, state;
unsigned int *low, *high;
/* capability check */ /* capability check */
if (policy->cpu != 0) if (policy->cpu != 0)
...@@ -272,19 +298,23 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) ...@@ -272,19 +298,23 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
} }
/* detect low and high frequency */ /* detect low and high frequency */
result = speedstep_smi_get_freqs(&speedstep_freqs[SPEEDSTEP_LOW].frequency, low = &speedstep_freqs[SPEEDSTEP_LOW].frequency;
&speedstep_freqs[SPEEDSTEP_HIGH].frequency); high = &speedstep_freqs[SPEEDSTEP_HIGH].frequency;
result = speedstep_smi_get_freqs(low, high);
if (result) { if (result) {
/* fall back to speedstep_lib.c dection mechanism: try both states out */ /* fall back to speedstep_lib.c dection mechanism:
dprintk("could not detect low and high frequencies by SMI call.\n"); * try both states out */
dprintk("could not detect low and high frequencies "
"by SMI call.\n");
result = speedstep_get_freqs(speedstep_processor, result = speedstep_get_freqs(speedstep_processor,
&speedstep_freqs[SPEEDSTEP_LOW].frequency, low, high,
&speedstep_freqs[SPEEDSTEP_HIGH].frequency,
NULL, NULL,
&speedstep_set_state); &speedstep_set_state);
if (result) { if (result) {
dprintk("could not detect two different speeds -- aborting.\n"); dprintk("could not detect two different speeds"
" -- aborting.\n");
return result; return result;
} else } else
dprintk("workaround worked.\n"); dprintk("workaround worked.\n");
...@@ -295,7 +325,8 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) ...@@ -295,7 +325,8 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
speed = speedstep_freqs[state].frequency; speed = speedstep_freqs[state].frequency;
dprintk("currently at %s speed setting - %i MHz\n", dprintk("currently at %s speed setting - %i MHz\n",
(speed == speedstep_freqs[SPEEDSTEP_LOW].frequency) ? "low" : "high", (speed == speedstep_freqs[SPEEDSTEP_LOW].frequency)
? "low" : "high",
(speed / 1000)); (speed / 1000));
/* cpuinfo and default policy values */ /* cpuinfo and default policy values */
...@@ -304,7 +335,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) ...@@ -304,7 +335,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
result = cpufreq_frequency_table_cpuinfo(policy, speedstep_freqs); result = cpufreq_frequency_table_cpuinfo(policy, speedstep_freqs);
if (result) if (result)
return (result); return result;
cpufreq_frequency_table_get_attr(speedstep_freqs, policy->cpu); cpufreq_frequency_table_get_attr(speedstep_freqs, policy->cpu);
...@@ -321,7 +352,7 @@ static unsigned int speedstep_get(unsigned int cpu) ...@@ -321,7 +352,7 @@ static unsigned int speedstep_get(unsigned int cpu)
{ {
if (cpu) if (cpu)
return -ENODEV; return -ENODEV;
return speedstep_get_processor_frequency(speedstep_processor); return speedstep_get_frequency(speedstep_processor);
} }
...@@ -335,7 +366,7 @@ static int speedstep_resume(struct cpufreq_policy *policy) ...@@ -335,7 +366,7 @@ static int speedstep_resume(struct cpufreq_policy *policy)
return result; return result;
} }
static struct freq_attr* speedstep_attr[] = { static struct freq_attr *speedstep_attr[] = {
&cpufreq_freq_attr_scaling_available_freqs, &cpufreq_freq_attr_scaling_available_freqs,
NULL, NULL,
}; };
...@@ -364,21 +395,23 @@ static int __init speedstep_init(void) ...@@ -364,21 +395,23 @@ static int __init speedstep_init(void)
speedstep_processor = speedstep_detect_processor(); speedstep_processor = speedstep_detect_processor();
switch (speedstep_processor) { switch (speedstep_processor) {
case SPEEDSTEP_PROCESSOR_PIII_T: case SPEEDSTEP_CPU_PIII_T:
case SPEEDSTEP_PROCESSOR_PIII_C: case SPEEDSTEP_CPU_PIII_C:
case SPEEDSTEP_PROCESSOR_PIII_C_EARLY: case SPEEDSTEP_CPU_PIII_C_EARLY:
break; break;
default: default:
speedstep_processor = 0; speedstep_processor = 0;
} }
if (!speedstep_processor) { if (!speedstep_processor) {
dprintk ("No supported Intel CPU detected.\n"); dprintk("No supported Intel CPU detected.\n");
return -ENODEV; return -ENODEV;
} }
dprintk("signature:0x%.8lx, command:0x%.8lx, event:0x%.8lx, perf_level:0x%.8lx.\n", dprintk("signature:0x%.8lx, command:0x%.8lx, "
ist_info.signature, ist_info.command, ist_info.event, ist_info.perf_level); "event:0x%.8lx, perf_level:0x%.8lx.\n",
ist_info.signature, ist_info.command,
ist_info.event, ist_info.perf_level);
/* Error if no IST-SMI BIOS or no PARM /* Error if no IST-SMI BIOS or no PARM
sig= 'ISGE' aka 'Intel Speedstep Gate E' */ sig= 'ISGE' aka 'Intel Speedstep Gate E' */
...@@ -420,13 +453,16 @@ module_param(smi_port, int, 0444); ...@@ -420,13 +453,16 @@ module_param(smi_port, int, 0444);
module_param(smi_cmd, int, 0444); module_param(smi_cmd, int, 0444);
module_param(smi_sig, uint, 0444); module_param(smi_sig, uint, 0444);
MODULE_PARM_DESC(smi_port, "Override the BIOS-given IST port with this value -- Intel's default setting is 0xb2"); MODULE_PARM_DESC(smi_port, "Override the BIOS-given IST port with this value "
MODULE_PARM_DESC(smi_cmd, "Override the BIOS-given IST command with this value -- Intel's default setting is 0x82"); "-- Intel's default setting is 0xb2");
MODULE_PARM_DESC(smi_sig, "Set to 1 to fake the IST signature when using the SMI interface."); MODULE_PARM_DESC(smi_cmd, "Override the BIOS-given IST command with this value "
"-- Intel's default setting is 0x82");
MODULE_PARM_DESC(smi_sig, "Set to 1 to fake the IST signature when using the "
"SMI interface.");
MODULE_AUTHOR ("Hiroshi Miura"); MODULE_AUTHOR("Hiroshi Miura");
MODULE_DESCRIPTION ("Speedstep driver for IST applet SMI interface."); MODULE_DESCRIPTION("Speedstep driver for IST applet SMI interface.");
MODULE_LICENSE ("GPL"); MODULE_LICENSE("GPL");
module_init(speedstep_init); module_init(speedstep_init);
module_exit(speedstep_exit); module_exit(speedstep_exit);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment