Commit 1354760c authored by Dave Jones's avatar Dave Jones Committed by Dave Jones

[CPUFREQ] Further cleanups to longhaul driver using defines.

By defining the cpu type at startup, we can make a lot of comparisons
a lot more obvious what they are meaning.
Signed-off-by: default avatarDave Jones <davej@redhat.com>
parent 268751a4
...@@ -42,6 +42,13 @@ ...@@ -42,6 +42,13 @@
#define TYPE_LONGHAUL_V2 2 #define TYPE_LONGHAUL_V2 2
#define TYPE_POWERSAVER 3 #define TYPE_POWERSAVER 3
#define CPU_SAMUEL 1
#define CPU_SAMUEL2 2
#define CPU_EZRA 3
#define CPU_EZRA_T 4
#define CPU_NEHEMIAH 5
static int cpu_model;
static unsigned int numscales=16, numvscales; static unsigned int numscales=16, numvscales;
static unsigned int fsb; static unsigned int fsb;
static int minvid, maxvid; static int minvid, maxvid;
...@@ -121,16 +128,17 @@ static int longhaul_get_cpu_mult(void) ...@@ -121,16 +128,17 @@ static int longhaul_get_cpu_mult(void)
static void do_powersaver(union msr_longhaul *longhaul, static void do_powersaver(union msr_longhaul *longhaul,
unsigned int clock_ratio_index) unsigned int clock_ratio_index)
{ {
struct cpuinfo_x86 *c = cpu_data;
int version; int version;
switch (c->x86_model) { switch (cpu_model) {
case 8: version = 3; case CPU_EZRA_T:
break; version = 3;
case 9: version = 0xf; break;
break; case CPU_NEHEMIAH:
version = 0xf;
break;
default: default:
return; return;
} }
rdmsrl(MSR_VIA_LONGHAUL, longhaul->val); rdmsrl(MSR_VIA_LONGHAUL, longhaul->val);
...@@ -273,7 +281,6 @@ static int guess_fsb(void) ...@@ -273,7 +281,6 @@ static int guess_fsb(void)
static int __init longhaul_get_ranges(void) static int __init longhaul_get_ranges(void)
{ {
struct cpuinfo_x86 *c = cpu_data;
unsigned long invalue; unsigned long invalue;
unsigned int multipliers[32]= { unsigned int multipliers[32]= {
50,30,40,100,55,35,45,95,90,70,80,60,120,75,85,65, 50,30,40,100,55,35,45,95,90,70,80,60,120,75,85,65,
...@@ -293,7 +300,7 @@ static int __init longhaul_get_ranges(void) ...@@ -293,7 +300,7 @@ static int __init longhaul_get_ranges(void)
maxmult = longhaul_get_cpu_mult(); maxmult = longhaul_get_cpu_mult();
rdmsr (MSR_IA32_EBL_CR_POWERON, lo, hi); rdmsr (MSR_IA32_EBL_CR_POWERON, lo, hi);
invalue = (lo & (1<<18|1<<19)) >>18; invalue = (lo & (1<<18|1<<19)) >>18;
if (c->x86_model==6) if (cpu_model==CPU_SAMUEL)
fsb = eblcr_fsb_table_v1[invalue]; fsb = eblcr_fsb_table_v1[invalue];
else else
fsb = guess_fsb(); fsb = guess_fsb();
...@@ -301,7 +308,7 @@ static int __init longhaul_get_ranges(void) ...@@ -301,7 +308,7 @@ static int __init longhaul_get_ranges(void)
case TYPE_POWERSAVER: case TYPE_POWERSAVER:
/* Ezra-T */ /* Ezra-T */
if (c->x86_model == 8) { if (cpu_model==CPU_EZRA_T) {
rdmsrl (MSR_VIA_LONGHAUL, longhaul.val); rdmsrl (MSR_VIA_LONGHAUL, longhaul.val);
invalue = longhaul.bits.MaxMHzBR; invalue = longhaul.bits.MaxMHzBR;
if (longhaul.bits.MaxMHzBR4) if (longhaul.bits.MaxMHzBR4)
...@@ -318,7 +325,7 @@ static int __init longhaul_get_ranges(void) ...@@ -318,7 +325,7 @@ static int __init longhaul_get_ranges(void)
} }
/* Nehemiah */ /* Nehemiah */
if (c->x86_model == 9) { if (cpu_model==CPU_NEHEMIAH) {
rdmsrl (MSR_VIA_LONGHAUL, longhaul.val); rdmsrl (MSR_VIA_LONGHAUL, longhaul.val);
/* /*
...@@ -478,6 +485,7 @@ static unsigned int longhaul_get(unsigned int cpu) ...@@ -478,6 +485,7 @@ static unsigned int longhaul_get(unsigned int cpu)
return (calc_speed (longhaul_get_cpu_mult(), fsb)); return (calc_speed (longhaul_get_cpu_mult(), fsb));
} }
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; struct cpuinfo_x86 *c = cpu_data;
...@@ -486,6 +494,7 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy) ...@@ -486,6 +494,7 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
switch (c->x86_model) { switch (c->x86_model) {
case 6: case 6:
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 (clock_ratio, samuel1_clock_ratio, sizeof(samuel1_clock_ratio));
...@@ -496,16 +505,20 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy) ...@@ -496,16 +505,20 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
longhaul_version = TYPE_LONGHAUL_V1; longhaul_version = TYPE_LONGHAUL_V1;
switch (c->x86_mask) { switch (c->x86_mask) {
case 0: case 0:
cpu_model = CPU_SAMUEL2;
cpuname = "C3 'Samuel 2' [C5B]"; cpuname = "C3 'Samuel 2' [C5B]";
/* Note, this is not a typo, early Samuel2's had Samuel1 ratios. */ /* Note, this is not a typo, early Samuel2's had Samuel1 ratios. */
memcpy (clock_ratio, samuel1_clock_ratio, sizeof(samuel1_clock_ratio)); memcpy (clock_ratio, samuel1_clock_ratio, sizeof(samuel1_clock_ratio));
memcpy (eblcr_table, samuel2_eblcr, sizeof(samuel2_eblcr)); memcpy (eblcr_table, samuel2_eblcr, sizeof(samuel2_eblcr));
break; break;
case 1 ... 15: case 1 ... 15:
if (c->x86_mask < 8) if (c->x86_mask < 8) {
cpu_model = CPU_SAMUEL2;
cpuname = "C3 'Samuel 2' [C5B]"; cpuname = "C3 'Samuel 2' [C5B]";
else } else {
cpu_model = CPU_EZRA;
cpuname = "C3 'Ezra' [C5C]"; cpuname = "C3 'Ezra' [C5C]";
}
memcpy (clock_ratio, ezra_clock_ratio, sizeof(ezra_clock_ratio)); memcpy (clock_ratio, ezra_clock_ratio, sizeof(ezra_clock_ratio));
memcpy (eblcr_table, ezra_eblcr, sizeof(ezra_eblcr)); memcpy (eblcr_table, ezra_eblcr, sizeof(ezra_eblcr));
break; break;
...@@ -513,6 +526,7 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy) ...@@ -513,6 +526,7 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
break; break;
case 8: case 8:
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;
...@@ -521,6 +535,7 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy) ...@@ -521,6 +535,7 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
break; break;
case 9: case 9:
cpu_model = CPU_NEHEMIAH;
longhaul_version = TYPE_POWERSAVER; longhaul_version = TYPE_POWERSAVER;
numscales=32; numscales=32;
switch (c->x86_mask) { switch (c->x86_mask) {
......
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