Commit ac617bd0 authored by Dave Jones's avatar Dave Jones

[CPUFREQ] checkpatch cleanups for longhaul

Signed-off-by: default avatarDave Jones <davej@redhat.com>
parent 00f6a235
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/timex.h>
#include <linux/io.h>
#include <linux/acpi.h>
#include <linux/kernel.h>
#include <asm/msr.h> #include <asm/msr.h>
#include <asm/timex.h>
#include <asm/io.h>
#include <asm/acpi.h>
#include <linux/acpi.h>
#include <acpi/processor.h> #include <acpi/processor.h>
#include "longhaul.h" #include "longhaul.h"
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
#define USE_NORTHBRIDGE (1 << 2) #define USE_NORTHBRIDGE (1 << 2)
static int cpu_model; static int cpu_model;
static unsigned int numscales=16; static unsigned int numscales = 16;
static unsigned int fsb; static unsigned int fsb;
static const struct mV_pos *vrm_mV_table; static const struct mV_pos *vrm_mV_table;
...@@ -67,8 +67,8 @@ static const unsigned char *mV_vrm_table; ...@@ -67,8 +67,8 @@ static const unsigned char *mV_vrm_table;
static unsigned int highest_speed, lowest_speed; /* kHz */ static unsigned int highest_speed, lowest_speed; /* kHz */
static unsigned int minmult, maxmult; static unsigned int minmult, maxmult;
static int can_scale_voltage; static int can_scale_voltage;
static struct acpi_processor *pr = NULL; static struct acpi_processor *pr;
static struct acpi_processor_cx *cx = NULL; static struct acpi_processor_cx *cx;
static u32 acpi_regs_addr; static u32 acpi_regs_addr;
static u8 longhaul_flags; static u8 longhaul_flags;
static unsigned int longhaul_index; static unsigned int longhaul_index;
...@@ -78,12 +78,13 @@ static int scale_voltage; ...@@ -78,12 +78,13 @@ static int scale_voltage;
static int disable_acpi_c3; static int disable_acpi_c3;
static int revid_errata; static int revid_errata;
#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "longhaul", msg) #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, \
"longhaul", msg)
/* Clock ratios multiplied by 10 */ /* Clock ratios multiplied by 10 */
static int clock_ratio[32]; static int mults[32];
static int eblcr_table[32]; static int eblcr[32];
static int longhaul_version; static int longhaul_version;
static struct cpufreq_frequency_table *longhaul_table; static struct cpufreq_frequency_table *longhaul_table;
...@@ -93,7 +94,7 @@ static char speedbuffer[8]; ...@@ -93,7 +94,7 @@ static char speedbuffer[8];
static char *print_speed(int speed) static char *print_speed(int speed)
{ {
if (speed < 1000) { if (speed < 1000) {
snprintf(speedbuffer, sizeof(speedbuffer),"%dMHz", speed); snprintf(speedbuffer, sizeof(speedbuffer), "%dMHz", speed);
return speedbuffer; return speedbuffer;
} }
...@@ -122,27 +123,28 @@ static unsigned int calc_speed(int mult) ...@@ -122,27 +123,28 @@ static unsigned int calc_speed(int mult)
static int longhaul_get_cpu_mult(void) static int longhaul_get_cpu_mult(void)
{ {
unsigned long invalue=0,lo, hi; unsigned long invalue = 0, lo, hi;
rdmsr (MSR_IA32_EBL_CR_POWERON, lo, hi); rdmsr(MSR_IA32_EBL_CR_POWERON, lo, hi);
invalue = (lo & (1<<22|1<<23|1<<24|1<<25)) >>22; invalue = (lo & (1<<22|1<<23|1<<24|1<<25))>>22;
if (longhaul_version==TYPE_LONGHAUL_V2 || longhaul_version==TYPE_POWERSAVER) { if (longhaul_version == TYPE_LONGHAUL_V2 ||
longhaul_version == TYPE_POWERSAVER) {
if (lo & (1<<27)) if (lo & (1<<27))
invalue+=16; invalue += 16;
} }
return eblcr_table[invalue]; return eblcr[invalue];
} }
/* For processor with BCR2 MSR */ /* For processor with BCR2 MSR */
static void do_longhaul1(unsigned int clock_ratio_index) static void do_longhaul1(unsigned int mults_index)
{ {
union msr_bcr2 bcr2; union msr_bcr2 bcr2;
rdmsrl(MSR_VIA_BCR2, bcr2.val); rdmsrl(MSR_VIA_BCR2, bcr2.val);
/* Enable software clock multiplier */ /* Enable software clock multiplier */
bcr2.bits.ESOFTBF = 1; bcr2.bits.ESOFTBF = 1;
bcr2.bits.CLOCKMUL = clock_ratio_index & 0xff; bcr2.bits.CLOCKMUL = mults_index & 0xff;
/* Sync to timer tick */ /* Sync to timer tick */
safe_halt(); safe_halt();
...@@ -161,7 +163,7 @@ static void do_longhaul1(unsigned int clock_ratio_index) ...@@ -161,7 +163,7 @@ static void do_longhaul1(unsigned int clock_ratio_index)
/* For processor with Longhaul MSR */ /* For processor with Longhaul MSR */
static void do_powersaver(int cx_address, unsigned int clock_ratio_index, static void do_powersaver(int cx_address, unsigned int mults_index,
unsigned int dir) unsigned int dir)
{ {
union msr_longhaul longhaul; union msr_longhaul longhaul;
...@@ -173,11 +175,11 @@ static void do_powersaver(int cx_address, unsigned int clock_ratio_index, ...@@ -173,11 +175,11 @@ static void do_powersaver(int cx_address, unsigned int clock_ratio_index,
longhaul.bits.RevisionKey = longhaul.bits.RevisionID; longhaul.bits.RevisionKey = longhaul.bits.RevisionID;
else else
longhaul.bits.RevisionKey = 0; longhaul.bits.RevisionKey = 0;
longhaul.bits.SoftBusRatio = clock_ratio_index & 0xf; longhaul.bits.SoftBusRatio = mults_index & 0xf;
longhaul.bits.SoftBusRatio4 = (clock_ratio_index & 0x10) >> 4; longhaul.bits.SoftBusRatio4 = (mults_index & 0x10) >> 4;
/* Setup new voltage */ /* Setup new voltage */
if (can_scale_voltage) if (can_scale_voltage)
longhaul.bits.SoftVID = (clock_ratio_index >> 8) & 0x1f; longhaul.bits.SoftVID = (mults_index >> 8) & 0x1f;
/* Sync to timer tick */ /* Sync to timer tick */
safe_halt(); safe_halt();
/* Raise voltage if necessary */ /* Raise voltage if necessary */
...@@ -240,14 +242,14 @@ static void do_powersaver(int cx_address, unsigned int clock_ratio_index, ...@@ -240,14 +242,14 @@ static void do_powersaver(int cx_address, unsigned int clock_ratio_index,
/** /**
* longhaul_set_cpu_frequency() * longhaul_set_cpu_frequency()
* @clock_ratio_index : bitpattern of the new multiplier. * @mults_index : bitpattern of the new multiplier.
* *
* Sets a new clock ratio. * Sets a new clock ratio.
*/ */
static void longhaul_setstate(unsigned int table_index) static void longhaul_setstate(unsigned int table_index)
{ {
unsigned int clock_ratio_index; unsigned int mults_index;
int speed, mult; int speed, mult;
struct cpufreq_freqs freqs; struct cpufreq_freqs freqs;
unsigned long flags; unsigned long flags;
...@@ -256,9 +258,9 @@ static void longhaul_setstate(unsigned int table_index) ...@@ -256,9 +258,9 @@ static void longhaul_setstate(unsigned int table_index)
u32 bm_timeout = 1000; u32 bm_timeout = 1000;
unsigned int dir = 0; unsigned int dir = 0;
clock_ratio_index = longhaul_table[table_index].index; mults_index = longhaul_table[table_index].index;
/* Safety precautions */ /* Safety precautions */
mult = clock_ratio[clock_ratio_index & 0x1f]; mult = mults[mults_index & 0x1f];
if (mult == -1) if (mult == -1)
return; return;
speed = calc_speed(mult); speed = calc_speed(mult);
...@@ -274,7 +276,7 @@ static void longhaul_setstate(unsigned int table_index) ...@@ -274,7 +276,7 @@ static void longhaul_setstate(unsigned int table_index)
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
dprintk ("Setting to FSB:%dMHz Mult:%d.%dx (%s)\n", dprintk("Setting to FSB:%dMHz Mult:%d.%dx (%s)\n",
fsb, mult/10, mult%10, print_speed(speed/1000)); fsb, mult/10, mult%10, print_speed(speed/1000));
retry_loop: retry_loop:
preempt_disable(); preempt_disable();
...@@ -282,8 +284,8 @@ static void longhaul_setstate(unsigned int table_index) ...@@ -282,8 +284,8 @@ static void longhaul_setstate(unsigned int table_index)
pic2_mask = inb(0xA1); pic2_mask = inb(0xA1);
pic1_mask = inb(0x21); /* works on C3. save mask. */ pic1_mask = inb(0x21); /* works on C3. save mask. */
outb(0xFF,0xA1); /* Overkill */ outb(0xFF, 0xA1); /* Overkill */
outb(0xFE,0x21); /* TMR0 only */ outb(0xFE, 0x21); /* TMR0 only */
/* Wait while PCI bus is busy. */ /* Wait while PCI bus is busy. */
if (acpi_regs_addr && (longhaul_flags & USE_NORTHBRIDGE if (acpi_regs_addr && (longhaul_flags & USE_NORTHBRIDGE
...@@ -312,7 +314,7 @@ static void longhaul_setstate(unsigned int table_index) ...@@ -312,7 +314,7 @@ static void longhaul_setstate(unsigned int table_index)
* Software controlled multipliers only. * Software controlled multipliers only.
*/ */
case TYPE_LONGHAUL_V1: case TYPE_LONGHAUL_V1:
do_longhaul1(clock_ratio_index); do_longhaul1(mults_index);
break; break;
/* /*
...@@ -327,9 +329,9 @@ static void longhaul_setstate(unsigned int table_index) ...@@ -327,9 +329,9 @@ static void longhaul_setstate(unsigned int table_index)
if (longhaul_flags & USE_ACPI_C3) { if (longhaul_flags & USE_ACPI_C3) {
/* Don't allow wakeup */ /* Don't allow wakeup */
acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0); acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0);
do_powersaver(cx->address, clock_ratio_index, dir); do_powersaver(cx->address, mults_index, dir);
} else { } else {
do_powersaver(0, clock_ratio_index, dir); do_powersaver(0, mults_index, dir);
} }
break; break;
} }
...@@ -341,8 +343,8 @@ static void longhaul_setstate(unsigned int table_index) ...@@ -341,8 +343,8 @@ static void longhaul_setstate(unsigned int table_index)
/* Enable bus master arbitration */ /* Enable bus master arbitration */
acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0); acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
} }
outb(pic2_mask,0xA1); /* restore mask */ outb(pic2_mask, 0xA1); /* restore mask */
outb(pic1_mask,0x21); outb(pic1_mask, 0x21);
local_irq_restore(flags); local_irq_restore(flags);
preempt_enable(); preempt_enable();
...@@ -392,7 +394,8 @@ static void longhaul_setstate(unsigned int table_index) ...@@ -392,7 +394,8 @@ static void longhaul_setstate(unsigned int table_index)
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
if (!bm_timeout) if (!bm_timeout)
printk(KERN_INFO PFX "Warning: Timeout while waiting for idle PCI bus.\n"); printk(KERN_INFO PFX "Warning: Timeout while waiting for "
"idle PCI bus.\n");
} }
/* /*
...@@ -458,31 +461,32 @@ static int __init longhaul_get_ranges(void) ...@@ -458,31 +461,32 @@ static int __init longhaul_get_ranges(void)
break; break;
} }
dprintk ("MinMult:%d.%dx MaxMult:%d.%dx\n", dprintk("MinMult:%d.%dx MaxMult:%d.%dx\n",
minmult/10, minmult%10, maxmult/10, maxmult%10); minmult/10, minmult%10, maxmult/10, maxmult%10);
highest_speed = calc_speed(maxmult); highest_speed = calc_speed(maxmult);
lowest_speed = calc_speed(minmult); lowest_speed = calc_speed(minmult);
dprintk ("FSB:%dMHz Lowest speed: %s Highest speed:%s\n", fsb, dprintk("FSB:%dMHz Lowest speed: %s Highest speed:%s\n", fsb,
print_speed(lowest_speed/1000), print_speed(lowest_speed/1000),
print_speed(highest_speed/1000)); print_speed(highest_speed/1000));
if (lowest_speed == highest_speed) { if (lowest_speed == highest_speed) {
printk (KERN_INFO PFX "highestspeed == lowest, aborting.\n"); printk(KERN_INFO PFX "highestspeed == lowest, aborting.\n");
return -EINVAL; return -EINVAL;
} }
if (lowest_speed > highest_speed) { if (lowest_speed > highest_speed) {
printk (KERN_INFO PFX "nonsense! lowest (%d > %d) !\n", printk(KERN_INFO PFX "nonsense! lowest (%d > %d) !\n",
lowest_speed, highest_speed); lowest_speed, highest_speed);
return -EINVAL; return -EINVAL;
} }
longhaul_table = kmalloc((numscales + 1) * sizeof(struct cpufreq_frequency_table), GFP_KERNEL); longhaul_table = kmalloc((numscales + 1) * sizeof(*longhaul_table),
if(!longhaul_table) GFP_KERNEL);
if (!longhaul_table)
return -ENOMEM; return -ENOMEM;
for (j = 0; j < numscales; j++) { for (j = 0; j < numscales; j++) {
ratio = clock_ratio[j]; ratio = mults[j];
if (ratio == -1) if (ratio == -1)
continue; continue;
if (ratio > maxmult || ratio < minmult) if (ratio > maxmult || ratio < minmult)
...@@ -521,7 +525,7 @@ static int __init longhaul_get_ranges(void) ...@@ -521,7 +525,7 @@ static int __init longhaul_get_ranges(void)
/* Find index we are running on */ /* Find index we are running on */
for (j = 0; j < k; j++) { for (j = 0; j < k; j++) {
if (clock_ratio[longhaul_table[j].index & 0x1f] == mult) { if (mults[longhaul_table[j].index & 0x1f] == mult) {
longhaul_index = j; longhaul_index = j;
break; break;
} }
...@@ -559,20 +563,22 @@ static void __init longhaul_setup_voltagescaling(void) ...@@ -559,20 +563,22 @@ static void __init longhaul_setup_voltagescaling(void)
maxvid = vrm_mV_table[longhaul.bits.MaximumVID]; maxvid = vrm_mV_table[longhaul.bits.MaximumVID];
if (minvid.mV == 0 || maxvid.mV == 0 || minvid.mV > maxvid.mV) { if (minvid.mV == 0 || maxvid.mV == 0 || minvid.mV > maxvid.mV) {
printk (KERN_INFO PFX "Bogus values Min:%d.%03d Max:%d.%03d. " printk(KERN_INFO PFX "Bogus values Min:%d.%03d Max:%d.%03d. "
"Voltage scaling disabled.\n", "Voltage scaling disabled.\n",
minvid.mV/1000, minvid.mV%1000, maxvid.mV/1000, maxvid.mV%1000); minvid.mV/1000, minvid.mV%1000,
maxvid.mV/1000, maxvid.mV%1000);
return; return;
} }
if (minvid.mV == maxvid.mV) { if (minvid.mV == maxvid.mV) {
printk (KERN_INFO PFX "Claims to support voltage scaling but min & max are " printk(KERN_INFO PFX "Claims to support voltage scaling but "
"both %d.%03d. Voltage scaling disabled\n", "min & max are both %d.%03d. "
"Voltage scaling disabled\n",
maxvid.mV/1000, maxvid.mV%1000); maxvid.mV/1000, maxvid.mV%1000);
return; return;
} }
/* How many voltage steps */ /* How many voltage steps*/
numvscales = maxvid.pos - minvid.pos + 1; numvscales = maxvid.pos - minvid.pos + 1;
printk(KERN_INFO PFX printk(KERN_INFO PFX
"Max VID=%d.%03d " "Max VID=%d.%03d "
...@@ -586,7 +592,7 @@ static void __init longhaul_setup_voltagescaling(void) ...@@ -586,7 +592,7 @@ static void __init longhaul_setup_voltagescaling(void)
j = longhaul.bits.MinMHzBR; j = longhaul.bits.MinMHzBR;
if (longhaul.bits.MinMHzBR4) if (longhaul.bits.MinMHzBR4)
j += 16; j += 16;
min_vid_speed = eblcr_table[j]; min_vid_speed = eblcr[j];
if (min_vid_speed == -1) if (min_vid_speed == -1)
return; return;
switch (longhaul.bits.MinMHzFSB) { switch (longhaul.bits.MinMHzFSB) {
...@@ -617,7 +623,8 @@ static void __init longhaul_setup_voltagescaling(void) ...@@ -617,7 +623,8 @@ static void __init longhaul_setup_voltagescaling(void)
pos = minvid.pos; pos = minvid.pos;
longhaul_table[j].index |= mV_vrm_table[pos] << 8; longhaul_table[j].index |= mV_vrm_table[pos] << 8;
vid = vrm_mV_table[mV_vrm_table[pos]]; vid = vrm_mV_table[mV_vrm_table[pos]];
printk(KERN_INFO PFX "f: %d kHz, index: %d, vid: %d mV\n", speed, j, vid.mV); printk(KERN_INFO PFX "f: %d kHz, index: %d, vid: %d mV\n",
speed, j, vid.mV);
j++; j++;
} }
...@@ -640,7 +647,8 @@ static int longhaul_target(struct cpufreq_policy *policy, ...@@ -640,7 +647,8 @@ static int longhaul_target(struct cpufreq_policy *policy,
unsigned int dir = 0; unsigned int dir = 0;
u8 vid, current_vid; u8 vid, current_vid;
if (cpufreq_frequency_table_target(policy, longhaul_table, target_freq, relation, &table_index)) if (cpufreq_frequency_table_target(policy, longhaul_table, target_freq,
relation, &table_index))
return -EINVAL; return -EINVAL;
/* Don't set same frequency again */ /* Don't set same frequency again */
...@@ -656,7 +664,8 @@ static int longhaul_target(struct cpufreq_policy *policy, ...@@ -656,7 +664,8 @@ static int longhaul_target(struct cpufreq_policy *policy,
* this in hardware, C3 is old and we need to do this * this in hardware, C3 is old and we need to do this
* in software. */ * in software. */
i = longhaul_index; i = longhaul_index;
current_vid = (longhaul_table[longhaul_index].index >> 8) & 0x1f; current_vid = (longhaul_table[longhaul_index].index >> 8);
current_vid &= 0x1f;
if (table_index > longhaul_index) if (table_index > longhaul_index)
dir = 1; dir = 1;
while (i != table_index) { while (i != table_index) {
...@@ -691,9 +700,9 @@ static acpi_status longhaul_walk_callback(acpi_handle obj_handle, ...@@ -691,9 +700,9 @@ static acpi_status longhaul_walk_callback(acpi_handle obj_handle,
{ {
struct acpi_device *d; struct acpi_device *d;
if ( acpi_bus_get_device(obj_handle, &d) ) { if (acpi_bus_get_device(obj_handle, &d))
return 0; return 0;
}
*return_value = acpi_driver_data(d); *return_value = acpi_driver_data(d);
return 1; return 1;
} }
...@@ -750,7 +759,7 @@ static int longhaul_setup_southbridge(void) ...@@ -750,7 +759,7 @@ static int longhaul_setup_southbridge(void)
/* Find VT8235 southbridge */ /* Find VT8235 southbridge */
dev = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, NULL); dev = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, NULL);
if (dev == NULL) if (dev == NULL)
/* Find VT8237 southbridge */ /* Find VT8237 southbridge */
dev = pci_get_device(PCI_VENDOR_ID_VIA, dev = pci_get_device(PCI_VENDOR_ID_VIA,
PCI_DEVICE_ID_VIA_8237, NULL); PCI_DEVICE_ID_VIA_8237, NULL);
if (dev != NULL) { if (dev != NULL) {
...@@ -769,7 +778,8 @@ static int longhaul_setup_southbridge(void) ...@@ -769,7 +778,8 @@ static int longhaul_setup_southbridge(void)
if (pci_cmd & 1 << 7) { if (pci_cmd & 1 << 7) {
pci_read_config_dword(dev, 0x88, &acpi_regs_addr); pci_read_config_dword(dev, 0x88, &acpi_regs_addr);
acpi_regs_addr &= 0xff00; acpi_regs_addr &= 0xff00;
printk(KERN_INFO PFX "ACPI I/O at 0x%x\n", acpi_regs_addr); printk(KERN_INFO PFX "ACPI I/O at 0x%x\n",
acpi_regs_addr);
} }
pci_dev_put(dev); pci_dev_put(dev);
...@@ -781,7 +791,7 @@ static int longhaul_setup_southbridge(void) ...@@ -781,7 +791,7 @@ static int longhaul_setup_southbridge(void)
static int __init longhaul_cpu_init(struct cpufreq_policy *policy) static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
{ {
struct cpuinfo_x86 *c = &cpu_data(0); struct cpuinfo_x86 *c = &cpu_data(0);
char *cpuname=NULL; char *cpuname = NULL;
int ret; int ret;
u32 lo, hi; u32 lo, hi;
...@@ -791,8 +801,8 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy) ...@@ -791,8 +801,8 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
cpu_model = CPU_SAMUEL; cpu_model = CPU_SAMUEL;
cpuname = "C3 'Samuel' [C5A]"; cpuname = "C3 'Samuel' [C5A]";
longhaul_version = TYPE_LONGHAUL_V1; longhaul_version = TYPE_LONGHAUL_V1;
memcpy (clock_ratio, samuel1_clock_ratio, sizeof(samuel1_clock_ratio)); memcpy(mults, samuel1_mults, sizeof(samuel1_mults));
memcpy (eblcr_table, samuel1_eblcr, sizeof(samuel1_eblcr)); memcpy(eblcr, samuel1_eblcr, sizeof(samuel1_eblcr));
break; break;
case 7: case 7:
...@@ -803,10 +813,8 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy) ...@@ -803,10 +813,8 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
cpuname = "C3 'Samuel 2' [C5B]"; cpuname = "C3 'Samuel 2' [C5B]";
/* Note, this is not a typo, early Samuel2's had /* Note, this is not a typo, early Samuel2's had
* Samuel1 ratios. */ * Samuel1 ratios. */
memcpy(clock_ratio, samuel1_clock_ratio, memcpy(mults, samuel1_mults, sizeof(samuel1_mults));
sizeof(samuel1_clock_ratio)); memcpy(eblcr, samuel2_eblcr, sizeof(samuel2_eblcr));
memcpy(eblcr_table, samuel2_eblcr,
sizeof(samuel2_eblcr));
break; break;
case 1 ... 15: case 1 ... 15:
longhaul_version = TYPE_LONGHAUL_V1; longhaul_version = TYPE_LONGHAUL_V1;
...@@ -817,10 +825,8 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy) ...@@ -817,10 +825,8 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
cpu_model = CPU_EZRA; cpu_model = CPU_EZRA;
cpuname = "C3 'Ezra' [C5C]"; cpuname = "C3 'Ezra' [C5C]";
} }
memcpy(clock_ratio, ezra_clock_ratio, memcpy(mults, ezra_mults, sizeof(ezra_mults));
sizeof(ezra_clock_ratio)); memcpy(eblcr, ezra_eblcr, sizeof(ezra_eblcr));
memcpy(eblcr_table, ezra_eblcr,
sizeof(ezra_eblcr));
break; break;
} }
break; break;
...@@ -829,18 +835,16 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy) ...@@ -829,18 +835,16 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
cpu_model = CPU_EZRA_T; cpu_model = CPU_EZRA_T;
cpuname = "C3 'Ezra-T' [C5M]"; cpuname = "C3 'Ezra-T' [C5M]";
longhaul_version = TYPE_POWERSAVER; longhaul_version = TYPE_POWERSAVER;
numscales=32; numscales = 32;
memcpy (clock_ratio, ezrat_clock_ratio, sizeof(ezrat_clock_ratio)); memcpy(mults, ezrat_mults, sizeof(ezrat_mults));
memcpy (eblcr_table, ezrat_eblcr, sizeof(ezrat_eblcr)); memcpy(eblcr, ezrat_eblcr, sizeof(ezrat_eblcr));
break; break;
case 9: case 9:
longhaul_version = TYPE_POWERSAVER; longhaul_version = TYPE_POWERSAVER;
numscales = 32; numscales = 32;
memcpy(clock_ratio, memcpy(mults, nehemiah_mults, sizeof(nehemiah_mults));
nehemiah_clock_ratio, memcpy(eblcr, nehemiah_eblcr, sizeof(nehemiah_eblcr));
sizeof(nehemiah_clock_ratio));
memcpy(eblcr_table, nehemiah_eblcr, sizeof(nehemiah_eblcr));
switch (c->x86_mask) { switch (c->x86_mask) {
case 0 ... 1: case 0 ... 1:
cpu_model = CPU_NEHEMIAH; cpu_model = CPU_NEHEMIAH;
...@@ -869,14 +873,14 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy) ...@@ -869,14 +873,14 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
longhaul_version = TYPE_LONGHAUL_V1; longhaul_version = TYPE_LONGHAUL_V1;
} }
printk (KERN_INFO PFX "VIA %s CPU detected. ", cpuname); printk(KERN_INFO PFX "VIA %s CPU detected. ", cpuname);
switch (longhaul_version) { switch (longhaul_version) {
case TYPE_LONGHAUL_V1: case TYPE_LONGHAUL_V1:
case TYPE_LONGHAUL_V2: case TYPE_LONGHAUL_V2:
printk ("Longhaul v%d supported.\n", longhaul_version); printk(KERN_CONT "Longhaul v%d supported.\n", longhaul_version);
break; break;
case TYPE_POWERSAVER: case TYPE_POWERSAVER:
printk ("Powersaver supported.\n"); printk(KERN_CONT "Powersaver supported.\n");
break; break;
}; };
...@@ -940,7 +944,7 @@ static int __devexit longhaul_cpu_exit(struct cpufreq_policy *policy) ...@@ -940,7 +944,7 @@ static int __devexit longhaul_cpu_exit(struct cpufreq_policy *policy)
return 0; return 0;
} }
static struct freq_attr* longhaul_attr[] = { static struct freq_attr *longhaul_attr[] = {
&cpufreq_freq_attr_scaling_available_freqs, &cpufreq_freq_attr_scaling_available_freqs,
NULL, NULL,
}; };
...@@ -966,13 +970,15 @@ static int __init longhaul_init(void) ...@@ -966,13 +970,15 @@ static int __init longhaul_init(void)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
if (num_online_cpus() > 1) { if (num_online_cpus() > 1) {
printk(KERN_ERR PFX "More than 1 CPU detected, longhaul disabled.\n"); printk(KERN_ERR PFX "More than 1 CPU detected, "
"longhaul disabled.\n");
return -ENODEV; return -ENODEV;
} }
#endif #endif
#ifdef CONFIG_X86_IO_APIC #ifdef CONFIG_X86_IO_APIC
if (cpu_has_apic) { if (cpu_has_apic) {
printk(KERN_ERR PFX "APIC detected. Longhaul is currently broken in this configuration.\n"); printk(KERN_ERR PFX "APIC detected. Longhaul is currently "
"broken in this configuration.\n");
return -ENODEV; return -ENODEV;
} }
#endif #endif
...@@ -993,8 +999,8 @@ static void __exit longhaul_exit(void) ...@@ -993,8 +999,8 @@ static void __exit longhaul_exit(void)
{ {
int i; int i;
for (i=0; i < numscales; i++) { for (i = 0; i < numscales; i++) {
if (clock_ratio[i] == maxmult) { if (mults[i] == maxmult) {
longhaul_setstate(i); longhaul_setstate(i);
break; break;
} }
...@@ -1007,11 +1013,11 @@ static void __exit longhaul_exit(void) ...@@ -1007,11 +1013,11 @@ static void __exit longhaul_exit(void)
/* Even if BIOS is exporting ACPI C3 state, and it is used /* Even if BIOS is exporting ACPI C3 state, and it is used
* with success when CPU is idle, this state doesn't * with success when CPU is idle, this state doesn't
* trigger frequency transition in some cases. */ * trigger frequency transition in some cases. */
module_param (disable_acpi_c3, int, 0644); module_param(disable_acpi_c3, int, 0644);
MODULE_PARM_DESC(disable_acpi_c3, "Don't use ACPI C3 support"); MODULE_PARM_DESC(disable_acpi_c3, "Don't use ACPI C3 support");
/* Change CPU voltage with frequency. Very usefull to save /* Change CPU voltage with frequency. Very usefull to save
* power, but most VIA C3 processors aren't supporting it. */ * power, but most VIA C3 processors aren't supporting it. */
module_param (scale_voltage, int, 0644); module_param(scale_voltage, int, 0644);
MODULE_PARM_DESC(scale_voltage, "Scale voltage of processor"); MODULE_PARM_DESC(scale_voltage, "Scale voltage of processor");
/* Force revision key to 0 for processors which doesn't /* Force revision key to 0 for processors which doesn't
* support voltage scaling, but are introducing itself as * support voltage scaling, but are introducing itself as
...@@ -1019,9 +1025,9 @@ MODULE_PARM_DESC(scale_voltage, "Scale voltage of processor"); ...@@ -1019,9 +1025,9 @@ MODULE_PARM_DESC(scale_voltage, "Scale voltage of processor");
module_param(revid_errata, int, 0644); module_param(revid_errata, int, 0644);
MODULE_PARM_DESC(revid_errata, "Ignore CPU Revision ID"); MODULE_PARM_DESC(revid_errata, "Ignore CPU Revision ID");
MODULE_AUTHOR ("Dave Jones <davej@redhat.com>"); MODULE_AUTHOR("Dave Jones <davej@redhat.com>");
MODULE_DESCRIPTION ("Longhaul driver for VIA Cyrix processors."); MODULE_DESCRIPTION("Longhaul driver for VIA Cyrix processors.");
MODULE_LICENSE ("GPL"); MODULE_LICENSE("GPL");
late_initcall(longhaul_init); late_initcall(longhaul_init);
module_exit(longhaul_exit); module_exit(longhaul_exit);
...@@ -49,14 +49,14 @@ union msr_longhaul { ...@@ -49,14 +49,14 @@ union msr_longhaul {
/* /*
* Clock ratio tables. Div/Mod by 10 to get ratio. * Clock ratio tables. Div/Mod by 10 to get ratio.
* The eblcr ones specify the ratio read from the CPU. * The eblcr values specify the ratio read from the CPU.
* The clock_ratio ones specify what to write to the CPU. * The mults values specify what to write to the CPU.
*/ */
/* /*
* VIA C3 Samuel 1 & Samuel 2 (stepping 0) * VIA C3 Samuel 1 & Samuel 2 (stepping 0)
*/ */
static const int __initdata samuel1_clock_ratio[16] = { static const int __initdata samuel1_mults[16] = {
-1, /* 0000 -> RESERVED */ -1, /* 0000 -> RESERVED */
30, /* 0001 -> 3.0x */ 30, /* 0001 -> 3.0x */
40, /* 0010 -> 4.0x */ 40, /* 0010 -> 4.0x */
...@@ -119,7 +119,7 @@ static const int __initdata samuel2_eblcr[16] = { ...@@ -119,7 +119,7 @@ static const int __initdata samuel2_eblcr[16] = {
/* /*
* VIA C3 Ezra * VIA C3 Ezra
*/ */
static const int __initdata ezra_clock_ratio[16] = { static const int __initdata ezra_mults[16] = {
100, /* 0000 -> 10.0x */ 100, /* 0000 -> 10.0x */
30, /* 0001 -> 3.0x */ 30, /* 0001 -> 3.0x */
40, /* 0010 -> 4.0x */ 40, /* 0010 -> 4.0x */
...@@ -160,7 +160,7 @@ static const int __initdata ezra_eblcr[16] = { ...@@ -160,7 +160,7 @@ static const int __initdata ezra_eblcr[16] = {
/* /*
* VIA C3 (Ezra-T) [C5M]. * VIA C3 (Ezra-T) [C5M].
*/ */
static const int __initdata ezrat_clock_ratio[32] = { static const int __initdata ezrat_mults[32] = {
100, /* 0000 -> 10.0x */ 100, /* 0000 -> 10.0x */
30, /* 0001 -> 3.0x */ 30, /* 0001 -> 3.0x */
40, /* 0010 -> 4.0x */ 40, /* 0010 -> 4.0x */
...@@ -235,7 +235,7 @@ static const int __initdata ezrat_eblcr[32] = { ...@@ -235,7 +235,7 @@ static const int __initdata ezrat_eblcr[32] = {
/* /*
* VIA C3 Nehemiah */ * VIA C3 Nehemiah */
static const int __initdata nehemiah_clock_ratio[32] = { static const int __initdata nehemiah_mults[32] = {
100, /* 0000 -> 10.0x */ 100, /* 0000 -> 10.0x */
-1, /* 0001 -> 16.0x */ -1, /* 0001 -> 16.0x */
40, /* 0010 -> 4.0x */ 40, /* 0010 -> 4.0x */
......
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