Lines Matching +full:ecx +full:- +full:1000

1 // SPDX-License-Identifier: GPL-2.0-only
3 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
23 * performance_pctg = (current_freq - low_freq)/(high_freq - low_freq)
29 * longrun_get_policy - get the current LongRun policy
40 pr_debug("longrun flags are %x - %x\n", msr_lo, msr_hi); in longrun_get_policy()
42 policy->policy = CPUFREQ_POLICY_PERFORMANCE; in longrun_get_policy()
44 policy->policy = CPUFREQ_POLICY_POWERSAVE; in longrun_get_policy()
47 pr_debug("longrun ctrl is %x - %x\n", msr_lo, msr_hi); in longrun_get_policy()
53 policy->min = policy->max = longrun_high_freq; in longrun_get_policy()
55 policy->min = longrun_low_freq + msr_lo * in longrun_get_policy()
56 ((longrun_high_freq - longrun_low_freq) / 100); in longrun_get_policy()
57 policy->max = longrun_low_freq + msr_hi * in longrun_get_policy()
58 ((longrun_high_freq - longrun_low_freq) / 100); in longrun_get_policy()
60 policy->cpu = 0; in longrun_get_policy()
65 * longrun_set_policy - sets a new CPUFreq policy
68 * Sets a new CPUFreq policy on LongRun-capable processors. This function
77 return -EINVAL; in longrun_set_policy()
83 pctg_lo = (policy->min - longrun_low_freq) / in longrun_set_policy()
84 ((longrun_high_freq - longrun_low_freq) / 100); in longrun_set_policy()
85 pctg_hi = (policy->max - longrun_low_freq) / in longrun_set_policy()
86 ((longrun_high_freq - longrun_low_freq) / 100); in longrun_set_policy()
97 switch (policy->policy) { in longrun_set_policy()
119 * longrun_verify_poliy - verifies a new CPUFreq policy
128 return -EINVAL; in longrun_verify_policy()
130 policy->cpu = 0; in longrun_verify_policy()
138 u32 eax, ebx, ecx, edx; in longrun_get() local
143 cpuid(0x80860007, &eax, &ebx, &ecx, &edx); in longrun_get()
146 return eax * 1000; in longrun_get()
150 * longrun_determine_freqs - determines the lowest and highest possible core frequency
157 * performance_pctg = (target_freq - low_freq)/(high_freq - low_freq)
164 u32 eax, ebx, ecx, edx; in longrun_determine_freqs() local
169 return -EINVAL; in longrun_determine_freqs()
183 *low_freq = msr_lo * 1000; /* to kHz */ in longrun_determine_freqs()
188 *high_freq = msr_lo * 1000; /* to kHz */ in longrun_determine_freqs()
190 pr_debug("longrun table interface told %u - %u kHz\n", in longrun_determine_freqs()
199 *high_freq = (cpu_khz / 1000); in longrun_determine_freqs()
200 *high_freq = *high_freq * 1000; in longrun_determine_freqs()
211 cpuid(0x80860007, &eax, &ebx, &ecx, &edx); in longrun_determine_freqs()
214 for (try_hi = 80; try_hi > 0 && ecx > 90; try_hi -= 10) { in longrun_determine_freqs()
222 cpuid(0x80860007, &eax, &ebx, &ecx, &edx); in longrun_determine_freqs()
227 pr_debug("percentage is %u %%, freq is %u MHz\n", ecx, eax); in longrun_determine_freqs()
229 /* performance_pctg = (current_freq - low_freq)/(high_freq - low_freq) in longrun_determine_freqs()
231 * low_freq * (1 - perf_pctg) = (cur_freq - high_freq * perf_pctg) in longrun_determine_freqs()
235 ebx = (((cpu_khz / 1000) * ecx) / 100); /* to MHz */ in longrun_determine_freqs()
237 if ((ecx > 95) || (ecx == 0) || (eax < ebx)) in longrun_determine_freqs()
238 return -EIO; in longrun_determine_freqs()
240 edx = ((eax - ebx) * 100) / (100 - ecx); in longrun_determine_freqs()
241 *low_freq = edx * 1000; /* back to kHz */ in longrun_determine_freqs()
257 if (policy->cpu != 0) in longrun_cpu_init()
258 return -ENODEV; in longrun_cpu_init()
266 policy->cpuinfo.min_freq = longrun_low_freq; in longrun_cpu_init()
267 policy->cpuinfo.max_freq = longrun_high_freq; in longrun_cpu_init()
290 * longrun_init - initializes the Transmeta Crusoe LongRun CPUFreq driver
297 return -ENODEV; in longrun_init()
303 * longrun_exit - unregisters LongRun support