Commit 3e7bf251 authored by Dave Jones's avatar Dave Jones

Merge hardwired.(none):/mnt/stuff/backups/src/kernel/2.6/trees/bk-linus

into hardwired.(none):/mnt/stuff/backups/src/kernel/2.6/trees/cpufreq
parents 7140df08 d5d0de56
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "speedstep-lib.h" #include "speedstep-lib.h"
#define PFX "speedstep-smi: "
/* speedstep system management interface port/command. /* speedstep system management interface port/command.
* *
* These parameters are got from IST-SMI BIOS call. * These parameters are got from IST-SMI BIOS call.
...@@ -65,43 +67,45 @@ static struct cpufreq_frequency_table speedstep_freqs[] = { ...@@ -65,43 +67,45 @@ static struct cpufreq_frequency_table speedstep_freqs[] = {
*/ */
static int speedstep_smi_ownership (void) static int speedstep_smi_ownership (void)
{ {
u32 command, result, magic; u32 command, result, magic;
u32 function = GET_SPEEDSTEP_OWNER; u32 function = GET_SPEEDSTEP_OWNER;
unsigned char magic_data[] = "Copyright (c) 1999 Intel Corporation"; unsigned char magic_data[] = "Copyright (c) 1999 Intel Corporation";
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);
__asm__ __volatile__( __asm__ __volatile__(
"out %%al, (%%dx)\n" "out %%al, (%%dx)\n"
: "=D" (result) : "=D" (result)
: "a" (command), "b" (function), "c" (0), "d" (smi_port), "D" (0), "S" (magic) : "a" (command), "b" (function), "c" (0), "d" (smi_port), "D" (0), "S" (magic)
); );
return result; return result;
} }
/** /**
* speedstep_smi_get_freqs - get SpeedStep preferred & current freq. * speedstep_smi_get_freqs - get SpeedStep preferred & current freq.
* *
*/ */
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, edi, high_mhz, low_mhz; u32 command, result, edi, high_mhz, low_mhz;
u32 state=0; u32 state=0;
u32 function = GET_SPEEDSTEP_FREQS; u32 function = GET_SPEEDSTEP_FREQS;
command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff); command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
__asm__ __volatile__("movl $0, %%edi\n" __asm__ __volatile__("movl $0, %%edi\n"
"out %%al, (%%dx)\n" "out %%al, (%%dx)\n"
: "=a" (result), "=b" (high_mhz), "=c" (low_mhz), "=d" (state), "=D" (edi) : "=a" (result), "=b" (high_mhz), "=c" (low_mhz), "=d" (state), "=D" (edi)
: "a" (command), "b" (function), "c" (state), "d" (smi_port), "S" (0) : "a" (command), "b" (function), "c" (state), "d" (smi_port), "S" (0)
); );
*high = high_mhz * 1000; *high = high_mhz * 1000;
*low = low_mhz * 1000; *low = low_mhz * 1000;
return result; return result;
} }
/** /**
* speedstep_get_state - set the SpeedStep state * speedstep_get_state - set the SpeedStep state
* @state: processor frequency state (SPEEDSTEP_LOW or SPEEDSTEP_HIGH) * @state: processor frequency state (SPEEDSTEP_LOW or SPEEDSTEP_HIGH)
...@@ -109,17 +113,17 @@ static int speedstep_smi_get_freqs (unsigned int *low, unsigned int *high) ...@@ -109,17 +113,17 @@ static int speedstep_smi_get_freqs (unsigned int *low, unsigned int *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; u32 result, state, edi, command;
command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff); __asm__ __volatile__("movl $0, %%edi\n"
"out %%al, (%%dx)\n"
: "=a" (result), "=b" (state), "=D" (edi)
: "a" (command), "b" (function), "c" (0), "d" (smi_port), "S" (0)
);
__asm__ __volatile__("movl $0, %%edi\n"
"out %%al, (%%dx)\n"
: "=a" (result), "=b" (state), "=D" (edi)
: "a" (command), "b" (function), "c" (0), "d" (smi_port), "S" (0)
);
return state; return state;
} }
...@@ -130,10 +134,10 @@ static int speedstep_get_state (void) ...@@ -130,10 +134,10 @@ static int speedstep_get_state (void)
*/ */
static void speedstep_set_state (unsigned int state, unsigned int notify) static void speedstep_set_state (unsigned int state, unsigned int notify)
{ {
unsigned int old_state, result, command, new_state; unsigned int old_state, result, command, new_state;
unsigned long flags; unsigned long flags;
struct cpufreq_freqs freqs; struct cpufreq_freqs freqs;
unsigned int function=SET_SPEEDSTEP_STATE; unsigned int function=SET_SPEEDSTEP_STATE;
if (state > 0x1) if (state > 0x1)
return; return;
...@@ -142,7 +146,7 @@ static void speedstep_set_state (unsigned int state, unsigned int notify) ...@@ -142,7 +146,7 @@ static void speedstep_set_state (unsigned int state, unsigned int notify)
freqs.old = speedstep_freqs[old_state].frequency; freqs.old = speedstep_freqs[old_state].frequency;
freqs.new = speedstep_freqs[state].frequency; freqs.new = speedstep_freqs[state].frequency;
freqs.cpu = 0; /* speedstep.c is UP only driver */ freqs.cpu = 0; /* speedstep.c is UP only driver */
if (old_state == state) if (old_state == state)
return; return;
...@@ -152,13 +156,13 @@ static void speedstep_set_state (unsigned int state, unsigned int notify) ...@@ -152,13 +156,13 @@ static void speedstep_set_state (unsigned int state, unsigned int notify)
/* Disable IRQs */ /* Disable IRQs */
local_irq_save(flags); local_irq_save(flags);
command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff); command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
__asm__ __volatile__( __asm__ __volatile__(
"movl $0, %%edi\n" "movl $0, %%edi\n"
"out %%al, (%%dx)\n" "out %%al, (%%dx)\n"
: "=b" (new_state), "=D" (result) : "=b" (new_state), "=D" (result)
: "a" (command), "b" (function), "c" (state), "d" (smi_port), "S" (0) : "a" (command), "b" (function), "c" (state), "d" (smi_port), "S" (0)
); );
/* enable IRQs */ /* enable IRQs */
local_irq_restore(flags); local_irq_restore(flags);
...@@ -185,10 +189,9 @@ static void speedstep_set_state (unsigned int state, unsigned int notify) ...@@ -185,10 +189,9 @@ static void speedstep_set_state (unsigned int state, unsigned int notify)
* 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 target_freq, unsigned int relation)
unsigned int relation)
{ {
unsigned int newstate = 0; unsigned int newstate = 0;
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;
...@@ -214,8 +217,8 @@ static int speedstep_verify (struct cpufreq_policy *policy) ...@@ -214,8 +217,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;
/* capability check */ /* capability check */
if (policy->cpu != 0) if (policy->cpu != 0)
...@@ -228,25 +231,25 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) ...@@ -228,25 +231,25 @@ 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, result = speedstep_smi_get_freqs(&speedstep_freqs[SPEEDSTEP_LOW].frequency,
&speedstep_freqs[SPEEDSTEP_HIGH].frequency); &speedstep_freqs[SPEEDSTEP_HIGH].frequency);
if (result) { if (result) {
/* fall back to speedstep_lib.c dection mechanism: try both states out */ /* fall back to speedstep_lib.c dection mechanism: try both states out */
unsigned int speedstep_processor = speedstep_detect_processor(); unsigned int speedstep_processor = speedstep_detect_processor();
dprintk(KERN_INFO "speedstep-smi: could not detect low and high frequencies by SMI call.\n"); dprintk(KERN_INFO PFX "could not detect low and high frequencies by SMI call.\n");
if (!speedstep_processor) if (!speedstep_processor)
return -ENODEV; return -ENODEV;
result = speedstep_get_freqs(speedstep_processor, result = speedstep_get_freqs(speedstep_processor,
&speedstep_freqs[SPEEDSTEP_LOW].frequency, &speedstep_freqs[SPEEDSTEP_LOW].frequency,
&speedstep_freqs[SPEEDSTEP_HIGH].frequency, &speedstep_freqs[SPEEDSTEP_HIGH].frequency,
&speedstep_set_state); &speedstep_set_state);
if (result) { if (result) {
dprintk(KERN_INFO "speedstep-smi: could not detect two different speeds -- aborting.\n"); dprintk(KERN_INFO PFX "could not detect two different speeds -- aborting.\n");
return result; return result;
} else } else
dprintk(KERN_INFO "speedstep-smi: workaround worked.\n"); dprintk(KERN_INFO PFX "workaround worked.\n");
} }
/* get current speed setting */ /* get current speed setting */
...@@ -294,8 +297,14 @@ static struct cpufreq_driver speedstep_driver = { ...@@ -294,8 +297,14 @@ static struct cpufreq_driver speedstep_driver = {
*/ */
static int __init speedstep_init(void) static int __init speedstep_init(void)
{ {
struct cpuinfo_x86 *c = cpu_data;
if (c->x86_vendor != X86_VENDOR_INTEL) {
printk (KERN_INFO PFX "No Intel CPU detected.\n");
return -ENODEV;
}
dprintk("speedstep-smi: signature:0%.8lx, command:0lx%.8lx, event:0x%.8lx, perf_level:0x%.8lx.\n", dprintk(KERN_DEBUG PFX "signature:0x%.8lx, command:0x%.8lx, event:0x%.8lx, perf_level:0x%.8lx.\n",
ist_info.signature, ist_info.command, ist_info.event, ist_info.perf_level); ist_info.signature, ist_info.command, ist_info.event, ist_info.perf_level);
......
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