Commit f9dfb7b5 authored by Dave Jones's avatar Dave Jones Committed by Dave Jones

[CPUFREQ] A reduce-Jeremy's-mail patch:

- Only Intel makes EST CPUs.  (Some Cyrix M IIs have the EST bit set -
  I don't know what it means, but it isn't Enhanced Speedstep.)

- If it's a known Dothan, but we're looking in the tables, give a
   useful message about using ACPI rather than mailing me.

- Code cleanups:
  - Make the CPU ID stuff table driven
  - Turn centrino_verify_cpu_id into a proper boolean predicate

 - Diddle some whitespace
Signed-off-by: default avatarDave Jones <davej@redhat.com>
parent 5bdfb4be
...@@ -40,32 +40,24 @@ ...@@ -40,32 +40,24 @@
struct cpu_id struct cpu_id
{ {
__u8 x86; /* CPU family */
__u8 x86_vendor; /* CPU vendor */ __u8 x86_vendor; /* CPU vendor */
__u8 x86; /* CPU family */
__u8 x86_model; /* model */ __u8 x86_model; /* model */
__u8 x86_mask; /* stepping */ __u8 x86_mask; /* stepping */
}; };
static const struct cpu_id cpu_id_banias = { enum {
.x86_vendor = X86_VENDOR_INTEL, CPU_BANIAS,
.x86 = 6, CPU_DOTHAN_A1,
.x86_model = 9, CPU_DOTHAN_B0,
.x86_mask = 5,
}; };
static const struct cpu_id cpu_id_dothan_a1 = { static const struct cpu_id cpu_ids[] = {
.x86_vendor = X86_VENDOR_INTEL, [CPU_BANIAS] = { X86_VENDOR_INTEL, 6, 9, 5 },
.x86 = 6, [CPU_DOTHAN_A1] = { X86_VENDOR_INTEL, 6, 13, 1 },
.x86_model = 13, [CPU_DOTHAN_B0] = { X86_VENDOR_INTEL, 6, 13, 6 },
.x86_mask = 1,
};
static const struct cpu_id cpu_id_dothan_b0 = {
.x86_vendor = X86_VENDOR_INTEL,
.x86 = 6,
.x86_model = 13,
.x86_mask = 6,
}; };
#define N_IDS (sizeof(cpu_ids)/sizeof(cpu_ids[0]))
struct cpu_model struct cpu_model
{ {
...@@ -75,7 +67,7 @@ struct cpu_model ...@@ -75,7 +67,7 @@ struct cpu_model
struct cpufreq_frequency_table *op_points; /* clock/voltage pairs */ struct cpufreq_frequency_table *op_points; /* clock/voltage pairs */
}; };
static int centrino_verify_cpu_id(struct cpuinfo_x86 *c, const struct cpu_id *x); static int centrino_verify_cpu_id(const struct cpuinfo_x86 *c, const struct cpu_id *x);
/* Operating points for current CPU */ /* Operating points for current CPU */
static struct cpu_model *centrino_model; static struct cpu_model *centrino_model;
...@@ -110,9 +102,9 @@ static struct cpufreq_frequency_table banias_900[] = ...@@ -110,9 +102,9 @@ static struct cpufreq_frequency_table banias_900[] =
/* Ultra Low Voltage Intel Pentium M processor 1000MHz (Banias) */ /* Ultra Low Voltage Intel Pentium M processor 1000MHz (Banias) */
static struct cpufreq_frequency_table banias_1000[] = static struct cpufreq_frequency_table banias_1000[] =
{ {
OP(600, 844), OP(600, 844),
OP(800, 972), OP(800, 972),
OP(900, 988), OP(900, 988),
OP(1000, 1004), OP(1000, 1004),
{ .frequency = CPUFREQ_TABLE_END } { .frequency = CPUFREQ_TABLE_END }
}; };
...@@ -206,13 +198,13 @@ static struct cpufreq_frequency_table banias_1700[] = ...@@ -206,13 +198,13 @@ static struct cpufreq_frequency_table banias_1700[] =
.max_freq = (max)*1000, \ .max_freq = (max)*1000, \
.op_points = banias_##max, \ .op_points = banias_##max, \
} }
#define BANIAS(max) _BANIAS(&cpu_id_banias, max, #max) #define BANIAS(max) _BANIAS(&cpu_ids[CPU_BANIAS], max, #max)
/* CPU models, their operating frequency range, and freq/voltage /* CPU models, their operating frequency range, and freq/voltage
operating points */ operating points */
static struct cpu_model models[] = static struct cpu_model models[] =
{ {
_BANIAS(&cpu_id_banias, 900, " 900"), _BANIAS(&cpu_ids[CPU_BANIAS], 900, " 900"),
BANIAS(1000), BANIAS(1000),
BANIAS(1100), BANIAS(1100),
BANIAS(1200), BANIAS(1200),
...@@ -221,6 +213,11 @@ static struct cpu_model models[] = ...@@ -221,6 +213,11 @@ static struct cpu_model models[] =
BANIAS(1500), BANIAS(1500),
BANIAS(1600), BANIAS(1600),
BANIAS(1700), BANIAS(1700),
/* NULL model_name is a wildcard */
{ &cpu_ids[CPU_DOTHAN_A1], NULL, 0, NULL },
{ &cpu_ids[CPU_DOTHAN_B0], NULL, 0, NULL },
{ NULL, } { NULL, }
}; };
#undef _BANIAS #undef _BANIAS
...@@ -231,17 +228,28 @@ static int centrino_cpu_init_table(struct cpufreq_policy *policy) ...@@ -231,17 +228,28 @@ static int centrino_cpu_init_table(struct cpufreq_policy *policy)
struct cpuinfo_x86 *cpu = &cpu_data[policy->cpu]; struct cpuinfo_x86 *cpu = &cpu_data[policy->cpu];
struct cpu_model *model; struct cpu_model *model;
for(model = models; model->model_name != NULL; model++) for(model = models; model->cpu_id != NULL; model++)
if ((strcmp(cpu->x86_model_id, model->model_name) == 0) && if (centrino_verify_cpu_id(cpu, model->cpu_id) &&
(!centrino_verify_cpu_id(cpu, model->cpu_id))) (model->model_name == NULL ||
strcmp(cpu->x86_model_id, model->model_name) == 0))
break; break;
if (model->model_name == NULL) {
if (model->cpu_id == NULL) {
/* No match at all */
printk(KERN_INFO PFX "no support for CPU model \"%s\": " printk(KERN_INFO PFX "no support for CPU model \"%s\": "
"send /proc/cpuinfo to " MAINTAINER "\n", "send /proc/cpuinfo to " MAINTAINER "\n",
cpu->x86_model_id); cpu->x86_model_id);
return -ENOENT; return -ENOENT;
} }
if (model->op_points == NULL) {
/* Matched a non-match */
printk(KERN_INFO PFX "no table support for CPU model \"%s\": \n",
cpu->x86_model_id);
printk(KERN_INFO PFX "try compiling with CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI enabled\n");
return -ENOENT;
}
centrino_model = model; centrino_model = model;
printk(KERN_INFO PFX "found \"%s\": max frequency: %dkHz\n", printk(KERN_INFO PFX "found \"%s\": max frequency: %dkHz\n",
...@@ -254,14 +262,14 @@ static int centrino_cpu_init_table(struct cpufreq_policy *policy) ...@@ -254,14 +262,14 @@ static int centrino_cpu_init_table(struct cpufreq_policy *policy)
static inline int centrino_cpu_init_table(struct cpufreq_policy *policy) { return -ENODEV; } static inline int centrino_cpu_init_table(struct cpufreq_policy *policy) { return -ENODEV; }
#endif /* CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE */ #endif /* CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE */
static int centrino_verify_cpu_id(struct cpuinfo_x86 *c, const struct cpu_id *x) static int centrino_verify_cpu_id(const struct cpuinfo_x86 *c, const struct cpu_id *x)
{ {
if ((c->x86 == x->x86) && if ((c->x86 == x->x86) &&
(c->x86_vendor == x->x86_vendor) && (c->x86_vendor == x->x86_vendor) &&
(c->x86_model == x->x86_model) && (c->x86_model == x->x86_model) &&
(c->x86_mask == x->x86_mask)) (c->x86_mask == x->x86_mask))
return 0; return 1;
return -ENODEV; return 0;
} }
/* Extract clock in kHz from PERF_CTL value */ /* Extract clock in kHz from PERF_CTL value */
...@@ -407,16 +415,20 @@ static int centrino_cpu_init(struct cpufreq_policy *policy) ...@@ -407,16 +415,20 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
unsigned freq; unsigned freq;
unsigned l, h; unsigned l, h;
int ret; int ret;
int i;
if (policy->cpu != 0) if (policy->cpu != 0)
return -ENODEV; return -ENODEV;
if (!cpu_has(cpu, X86_FEATURE_EST)) /* Only Intel makes Enhanced Speedstep-capable CPUs */
if (cpu->x86_vendor != X86_VENDOR_INTEL || !cpu_has(cpu, X86_FEATURE_EST))
return -ENODEV; return -ENODEV;
if ((centrino_verify_cpu_id(cpu, &cpu_id_banias)) && for (i = 0; i < N_IDS; i++)
(centrino_verify_cpu_id(cpu, &cpu_id_dothan_a1)) && if (centrino_verify_cpu_id(cpu, &cpu_ids[i]))
(centrino_verify_cpu_id(cpu, &cpu_id_dothan_b0))) { break;
if (i == N_IDS) {
printk(KERN_INFO PFX "found unsupported CPU with Enhanced SpeedStep: " printk(KERN_INFO PFX "found unsupported CPU with Enhanced SpeedStep: "
"send /proc/cpuinfo to " MAINTAINER "\n"); "send /proc/cpuinfo to " MAINTAINER "\n");
return -ENODEV; return -ENODEV;
......
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