12 #include <linux/kernel.h>
13 #include <linux/slab.h>
14 #include <linux/module.h>
20 #include <asm/uaccess.h>
43 processor_set_pstate (
50 retval = ia64_pal_set_pstate((
u64)value);
53 pr_debug(
"Failed to set freq to 0x%x, with error 0x%lx\n",
62 processor_get_pstate (
70 retval = ia64_pal_get_pstate(&pstate_index,
72 *value = (
u32) pstate_index;
75 pr_debug(
"Failed to get current freq with "
76 "error 0x%lx, idx 0x%x\n", retval, *value);
93 for (i = 0; i < data->
acpi_data.state_count; i++) {
94 if (value == data->
acpi_data.states[i].status)
95 return data->
acpi_data.states[
i].core_frequency;
97 return data->
acpi_data.states[i-1].core_frequency;
109 unsigned long clock_freq;
113 saved_mask =
current->cpus_allowed;
119 ret = processor_get_pstate(&value);
122 set_cpus_allowed_ptr(
current, &saved_mask);
128 clock_freq = extract_clock(data, value, cpu);
129 ret = (clock_freq*1000);
132 set_cpus_allowed_ptr(
current, &saved_mask);
151 saved_mask =
current->cpus_allowed;
160 pr_debug(
"Called after resume, resetting to P%d\n", state);
163 pr_debug(
"Already at target state (P%d)\n", state);
169 pr_debug(
"Transitioning from P%d to P%d\n",
187 pr_debug(
"Transitioning to state: 0x%08x\n", value);
189 ret = processor_set_pstate(value);
209 set_cpus_allowed_ptr(
current, &saved_mask);
222 return processor_get_freq(data, cpu);
227 acpi_cpufreq_target (
229 unsigned int target_freq,
230 unsigned int relation)
236 pr_debug(
"acpi_cpufreq_setpolicy\n");
239 data->
freq_table, target_freq, relation, &next_state);
243 result = processor_set_freq(data, policy->
cpu, next_state);
250 acpi_cpufreq_verify (
253 unsigned int result = 0;
266 acpi_cpufreq_cpu_init (
270 unsigned int cpu = policy->
cpu;
272 unsigned int result = 0;
274 pr_debug(
"acpi_cpufreq_cpu_init\n");
294 if ((data->
acpi_data.control_register.space_id !=
296 (data->
acpi_data.status_register.space_id !=
298 pr_debug(
"Unsupported address space [%d, %d]\n",
315 policy->
cpuinfo.transition_latency = 0;
316 for (i=0; i<data->
acpi_data.state_count; i++) {
317 if ((data->
acpi_data.states[i].transition_latency * 1000) >
318 policy->
cpuinfo.transition_latency) {
319 policy->
cpuinfo.transition_latency =
320 data->
acpi_data.states[
i].transition_latency * 1000;
323 policy->
cur = processor_get_freq(data, policy->
cpu);
326 for (i = 0; i <= data->
acpi_data.state_count; i++)
331 data->
acpi_data.states[
i].core_frequency * 1000;
346 "activated.\n", cpu);
348 for (i = 0; i < data->
acpi_data.state_count; i++)
349 pr_debug(
" %cP%d: %d MHz, %d mW, %d uS, %d uS, 0x%x 0x%x\n",
379 acpi_cpufreq_cpu_exit (
384 pr_debug(
"acpi_cpufreq_cpu_exit\n");
388 acpi_io_data[policy->
cpu] =
NULL;
398 static struct freq_attr* acpi_cpufreq_attr[] = {
405 .verify = acpi_cpufreq_verify,
406 .target = acpi_cpufreq_target,
407 .get = acpi_cpufreq_get,
408 .init = acpi_cpufreq_cpu_init,
409 .exit = acpi_cpufreq_cpu_exit,
410 .name =
"acpi-cpufreq",
412 .attr = acpi_cpufreq_attr,
417 acpi_cpufreq_init (
void)
426 acpi_cpufreq_exit (
void)