23 #include <linux/kernel.h>
24 #include <linux/module.h>
29 #include <linux/timex.h>
31 #include <asm/processor.h>
33 #include <asm/timer.h>
38 #define PFX "p4-clockmod: "
52 static int has_N44_O17_errata[
NR_CPUS];
53 static unsigned int stock_freq;
55 static unsigned int cpufreq_p4_get(
unsigned int cpu);
57 static int cpufreq_p4_setdc(
unsigned int cpu,
unsigned int newstate)
68 pr_debug(
"CPU#%d currently thermal throttled\n", cpu);
70 if (has_N44_O17_errata[cpu] &&
76 pr_debug(
"CPU#%d disabling modulation\n", cpu);
79 pr_debug(
"CPU#%d setting duty cycle to %d%%\n",
80 cpu, ((125 * newstate) / 10));
87 l = l | (1<<4) | ((newstate & 0x7)<<1);
110 unsigned int target_freq,
111 unsigned int relation)
113 unsigned int newstate =
DC_RESV;
118 target_freq, relation, &newstate))
121 freqs.old = cpufreq_p4_get(policy->
cpu);
122 freqs.new = stock_freq * p4clockmod_table[newstate].
index / 8;
124 if (freqs.new == freqs.old)
138 cpufreq_p4_setdc(i, p4clockmod_table[newstate].
index);
156 static unsigned int cpufreq_p4_get_frequency(
struct cpuinfo_x86 *
c)
158 if (c->
x86 == 0x06) {
161 "CPU detected. The acpi-cpufreq module offers "
162 "voltage scaling in addition to frequency "
163 "scaling. You should use that instead of "
164 "p4-clockmod, if possible.\n");
189 "The speedstep-ich or acpi cpufreq modules offer "
190 "voltage scaling in addition of frequency scaling. "
191 "You should use either one instead of p4-clockmod, "
208 cpumask_copy(policy->
cpus, cpu_sibling_mask(policy->
cpu));
218 has_N44_O17_errata[policy->
cpu] = 1;
219 pr_debug(
"has errata -- disabling low frequencies\n");
229 stock_freq = cpufreq_p4_get_frequency(c);
235 if ((i < 2) && (has_N44_O17_errata[policy->
cpu]))
238 p4clockmod_table[
i].
frequency = (stock_freq *
i)/8;
246 policy->
cpuinfo.transition_latency = 10000001;
247 policy->
cur = stock_freq;
259 static unsigned int cpufreq_p4_get(
unsigned int cpu)
272 return stock_freq * l / 8;
277 static struct freq_attr *p4clockmod_attr[] = {
283 .verify = cpufreq_p4_verify,
284 .target = cpufreq_p4_target,
285 .init = cpufreq_p4_cpu_init,
286 .exit = cpufreq_p4_cpu_exit,
287 .get = cpufreq_p4_get,
288 .name =
"p4-clockmod",
290 .attr = p4clockmod_attr,
293 static const struct x86_cpu_id cpufreq_p4_id[] = {
303 static int __init cpufreq_p4_init(
void)
317 "Modulation available\n");
323 static void __exit cpufreq_p4_exit(
void)