9 #include <linux/kernel.h>
10 #include <linux/module.h>
13 #include <linux/timex.h>
16 #include <asm/processor.h>
26 static unsigned int longrun_low_freq, longrun_high_freq;
41 pr_debug(
"longrun flags are %x - %x\n", msr_lo, msr_hi);
48 pr_debug(
"longrun ctrl is %x - %x\n", msr_lo, msr_hi);
52 if (longrun_high_freq <= longrun_low_freq) {
54 policy->
min = policy->
max = longrun_high_freq;
56 policy->
min = longrun_low_freq + msr_lo *
57 ((longrun_high_freq - longrun_low_freq) / 100);
58 policy->
max = longrun_low_freq + msr_hi *
59 ((longrun_high_freq - longrun_low_freq) / 100);
80 if (longrun_high_freq <= longrun_low_freq) {
82 pctg_lo = pctg_hi = 100;
84 pctg_lo = (policy->
min - longrun_low_freq) /
85 ((longrun_high_freq - longrun_low_freq) / 100);
86 pctg_hi = (policy->
max - longrun_low_freq) /
87 ((longrun_high_freq - longrun_low_freq) / 100);
92 if (pctg_lo > pctg_hi)
100 msr_lo |= 0x00000001;
109 msr_lo &= 0xFFFFFF80;
110 msr_hi &= 0xFFFFFF80;
132 cpufreq_verify_within_limits(policy,
143 static unsigned int longrun_get(
unsigned int cpu)
150 cpuid(0x80860007, &eax, &ebx, &ecx, &edx);
166 static int __cpuinit longrun_determine_freqs(
unsigned int *low_freq,
167 unsigned int *high_freq)
170 u32 save_lo, save_hi;
175 if (!low_freq || !high_freq)
190 *low_freq = msr_lo * 1000;
195 *high_freq = msr_lo * 1000;
197 pr_debug(
"longrun table interface told %u - %u kHz\n",
198 *low_freq, *high_freq);
200 if (*low_freq > *high_freq)
201 *low_freq = *high_freq;
207 *high_freq = *high_freq * 1000;
208 pr_debug(
"high frequency is %u kHz\n", *high_freq);
212 save_lo = msr_lo & 0x0000007F;
213 save_hi = msr_hi & 0x0000007F;
218 cpuid(0x80860007, &eax, &ebx, &ecx, &edx);
221 for (try_hi = 80; try_hi > 0 && ecx > 90; try_hi -= 10) {
223 msr_lo &= 0xFFFFFF80;
224 msr_hi &= 0xFFFFFF80;
229 cpuid(0x80860007, &eax, &ebx, &ecx, &edx);
234 pr_debug(
"percentage is %u %%, freq is %u MHz\n", ecx, eax);
242 ebx = (((
cpu_khz / 1000) * ecx) / 100);
244 if ((ecx > 95) || (ecx == 0) || (eax < ebx))
247 edx = ((eax -
ebx) * 100) / (100 -
ecx);
248 *low_freq = edx * 1000;
250 pr_debug(
"low frequency is %u kHz\n", *low_freq);
252 if (*low_freq > *high_freq)
253 *low_freq = *high_freq;
264 if (policy->
cpu != 0)
268 result = longrun_determine_freqs(&longrun_low_freq, &longrun_high_freq);
273 policy->
cpuinfo.min_freq = longrun_low_freq;
274 policy->
cpuinfo.max_freq = longrun_high_freq;
276 longrun_get_policy(policy);
284 .verify = longrun_verify_policy,
285 .setpolicy = longrun_set_policy,
287 .init = longrun_cpu_init,
292 static const struct x86_cpu_id longrun_ids[] = {
304 static int __init longrun_init(
void)
315 static void __exit longrun_exit(
void)
323 "Efficeon processors.");