Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 1 | /* |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 2 | * This file provides the ACPI based P-state support. This |
| 3 | * module works with generic cpufreq infrastructure. Most of |
| 4 | * the code is based on i386 version |
| 5 | * (arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c) |
| 6 | * |
| 7 | * Copyright (C) 2005 Intel Corp |
| 8 | * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> |
| 9 | */ |
| 10 | |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 11 | #include <linux/kernel.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | #include <linux/slab.h> |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 13 | #include <linux/module.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/cpufreq.h> |
| 16 | #include <linux/proc_fs.h> |
| 17 | #include <linux/seq_file.h> |
| 18 | #include <asm/io.h> |
| 19 | #include <asm/uaccess.h> |
| 20 | #include <asm/pal.h> |
| 21 | |
| 22 | #include <linux/acpi.h> |
| 23 | #include <acpi/processor.h> |
| 24 | |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 25 | MODULE_AUTHOR("Venkatesh Pallipadi"); |
| 26 | MODULE_DESCRIPTION("ACPI Processor P-States Driver"); |
| 27 | MODULE_LICENSE("GPL"); |
| 28 | |
| 29 | |
| 30 | struct cpufreq_acpi_io { |
| 31 | struct acpi_processor_performance acpi_data; |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 32 | unsigned int resume; |
| 33 | }; |
| 34 | |
| 35 | static struct cpufreq_acpi_io *acpi_io_data[NR_CPUS]; |
| 36 | |
| 37 | static struct cpufreq_driver acpi_cpufreq_driver; |
| 38 | |
| 39 | |
| 40 | static int |
| 41 | processor_set_pstate ( |
| 42 | u32 value) |
| 43 | { |
| 44 | s64 retval; |
| 45 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 46 | pr_debug("processor_set_pstate\n"); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 47 | |
| 48 | retval = ia64_pal_set_pstate((u64)value); |
| 49 | |
| 50 | if (retval) { |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 51 | pr_debug("Failed to set freq to 0x%x, with error 0x%lx\n", |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 52 | value, retval); |
| 53 | return -ENODEV; |
| 54 | } |
| 55 | return (int)retval; |
| 56 | } |
| 57 | |
| 58 | |
| 59 | static int |
| 60 | processor_get_pstate ( |
| 61 | u32 *value) |
| 62 | { |
| 63 | u64 pstate_index = 0; |
| 64 | s64 retval; |
| 65 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 66 | pr_debug("processor_get_pstate\n"); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 67 | |
Venkatesh Pallipadi | 17e77b1 | 2006-12-01 15:28:14 -0800 | [diff] [blame] | 68 | retval = ia64_pal_get_pstate(&pstate_index, |
| 69 | PAL_GET_PSTATE_TYPE_INSTANT); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 70 | *value = (u32) pstate_index; |
| 71 | |
| 72 | if (retval) |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 73 | pr_debug("Failed to get current freq with " |
Denis V. Lunev | 60192db | 2008-07-17 11:11:17 -0700 | [diff] [blame] | 74 | "error 0x%lx, idx 0x%x\n", retval, *value); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 75 | |
| 76 | return (int)retval; |
| 77 | } |
| 78 | |
| 79 | |
| 80 | /* To be used only after data->acpi_data is initialized */ |
| 81 | static unsigned |
| 82 | extract_clock ( |
| 83 | struct cpufreq_acpi_io *data, |
| 84 | unsigned value, |
| 85 | unsigned int cpu) |
| 86 | { |
| 87 | unsigned long i; |
| 88 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 89 | pr_debug("extract_clock\n"); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 90 | |
| 91 | for (i = 0; i < data->acpi_data.state_count; i++) { |
Venkatesh Pallipadi | 17e77b1 | 2006-12-01 15:28:14 -0800 | [diff] [blame] | 92 | if (value == data->acpi_data.states[i].status) |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 93 | return data->acpi_data.states[i].core_frequency; |
| 94 | } |
| 95 | return data->acpi_data.states[i-1].core_frequency; |
| 96 | } |
| 97 | |
| 98 | |
| 99 | static unsigned int |
| 100 | processor_get_freq ( |
| 101 | struct cpufreq_acpi_io *data, |
| 102 | unsigned int cpu) |
| 103 | { |
| 104 | int ret = 0; |
| 105 | u32 value = 0; |
| 106 | cpumask_t saved_mask; |
| 107 | unsigned long clock_freq; |
| 108 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 109 | pr_debug("processor_get_freq\n"); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 110 | |
| 111 | saved_mask = current->cpus_allowed; |
Julia Lawall | 552dce3 | 2010-03-26 23:02:23 +0100 | [diff] [blame] | 112 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); |
Alex Williamson | 182fdd2 | 2007-08-13 15:49:46 -0600 | [diff] [blame] | 113 | if (smp_processor_id() != cpu) |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 114 | goto migrate_end; |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 115 | |
Venkatesh Pallipadi | 17e77b1 | 2006-12-01 15:28:14 -0800 | [diff] [blame] | 116 | /* processor_get_pstate gets the instantaneous frequency */ |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 117 | ret = processor_get_pstate(&value); |
| 118 | |
| 119 | if (ret) { |
Julia Lawall | 552dce3 | 2010-03-26 23:02:23 +0100 | [diff] [blame] | 120 | set_cpus_allowed_ptr(current, &saved_mask); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 121 | printk(KERN_WARNING "get performance failed with error %d\n", |
| 122 | ret); |
Alex Williamson | 182fdd2 | 2007-08-13 15:49:46 -0600 | [diff] [blame] | 123 | ret = 0; |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 124 | goto migrate_end; |
| 125 | } |
| 126 | clock_freq = extract_clock(data, value, cpu); |
| 127 | ret = (clock_freq*1000); |
| 128 | |
| 129 | migrate_end: |
Julia Lawall | 552dce3 | 2010-03-26 23:02:23 +0100 | [diff] [blame] | 130 | set_cpus_allowed_ptr(current, &saved_mask); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 131 | return ret; |
| 132 | } |
| 133 | |
| 134 | |
| 135 | static int |
| 136 | processor_set_freq ( |
| 137 | struct cpufreq_acpi_io *data, |
Viresh Kumar | b43a7ff | 2013-03-24 11:56:43 +0530 | [diff] [blame] | 138 | struct cpufreq_policy *policy, |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 139 | int state) |
| 140 | { |
| 141 | int ret = 0; |
| 142 | u32 value = 0; |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 143 | cpumask_t saved_mask; |
| 144 | int retval; |
| 145 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 146 | pr_debug("processor_set_freq\n"); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 147 | |
| 148 | saved_mask = current->cpus_allowed; |
Viresh Kumar | b43a7ff | 2013-03-24 11:56:43 +0530 | [diff] [blame] | 149 | set_cpus_allowed_ptr(current, cpumask_of(policy->cpu)); |
| 150 | if (smp_processor_id() != policy->cpu) { |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 151 | retval = -EAGAIN; |
| 152 | goto migrate_end; |
| 153 | } |
| 154 | |
| 155 | if (state == data->acpi_data.state) { |
| 156 | if (unlikely(data->resume)) { |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 157 | pr_debug("Called after resume, resetting to P%d\n", state); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 158 | data->resume = 0; |
| 159 | } else { |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 160 | pr_debug("Already at target state (P%d)\n", state); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 161 | retval = 0; |
| 162 | goto migrate_end; |
| 163 | } |
| 164 | } |
| 165 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 166 | pr_debug("Transitioning from P%d to P%d\n", |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 167 | data->acpi_data.state, state); |
| 168 | |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 169 | /* |
| 170 | * First we write the target state's 'control' value to the |
| 171 | * control_register. |
| 172 | */ |
| 173 | |
| 174 | value = (u32) data->acpi_data.states[state].control; |
| 175 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 176 | pr_debug("Transitioning to state: 0x%08x\n", value); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 177 | |
| 178 | ret = processor_set_pstate(value); |
| 179 | if (ret) { |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 180 | printk(KERN_WARNING "Transition failed with error %d\n", ret); |
| 181 | retval = -ENODEV; |
| 182 | goto migrate_end; |
| 183 | } |
| 184 | |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 185 | data->acpi_data.state = state; |
| 186 | |
| 187 | retval = 0; |
| 188 | |
| 189 | migrate_end: |
Julia Lawall | 552dce3 | 2010-03-26 23:02:23 +0100 | [diff] [blame] | 190 | set_cpus_allowed_ptr(current, &saved_mask); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 191 | return (retval); |
| 192 | } |
| 193 | |
| 194 | |
| 195 | static unsigned int |
| 196 | acpi_cpufreq_get ( |
| 197 | unsigned int cpu) |
| 198 | { |
| 199 | struct cpufreq_acpi_io *data = acpi_io_data[cpu]; |
| 200 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 201 | pr_debug("acpi_cpufreq_get\n"); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 202 | |
| 203 | return processor_get_freq(data, cpu); |
| 204 | } |
| 205 | |
| 206 | |
| 207 | static int |
| 208 | acpi_cpufreq_target ( |
| 209 | struct cpufreq_policy *policy, |
Viresh Kumar | 9c0ebcf | 2013-10-25 19:45:48 +0530 | [diff] [blame] | 210 | unsigned int index) |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 211 | { |
Viresh Kumar | 9c0ebcf | 2013-10-25 19:45:48 +0530 | [diff] [blame] | 212 | return processor_set_freq(acpi_io_data[policy->cpu], policy, index); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 215 | static int |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 216 | acpi_cpufreq_cpu_init ( |
| 217 | struct cpufreq_policy *policy) |
| 218 | { |
| 219 | unsigned int i; |
| 220 | unsigned int cpu = policy->cpu; |
| 221 | struct cpufreq_acpi_io *data; |
| 222 | unsigned int result = 0; |
Pan Xinhui | 946c14f | 2015-07-20 14:22:46 +0800 | [diff] [blame] | 223 | struct cpufreq_frequency_table *freq_table; |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 224 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 225 | pr_debug("acpi_cpufreq_cpu_init\n"); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 226 | |
Viresh Kumar | d5b73cd | 2013-08-06 22:53:06 +0530 | [diff] [blame] | 227 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 228 | if (!data) |
| 229 | return (-ENOMEM); |
| 230 | |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 231 | acpi_io_data[cpu] = data; |
| 232 | |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 233 | result = acpi_processor_register_performance(&data->acpi_data, cpu); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 234 | |
| 235 | if (result) |
| 236 | goto err_free; |
| 237 | |
| 238 | /* capability check */ |
| 239 | if (data->acpi_data.state_count <= 1) { |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 240 | pr_debug("No P-States\n"); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 241 | result = -ENODEV; |
| 242 | goto err_unreg; |
| 243 | } |
| 244 | |
| 245 | if ((data->acpi_data.control_register.space_id != |
| 246 | ACPI_ADR_SPACE_FIXED_HARDWARE) || |
| 247 | (data->acpi_data.status_register.space_id != |
| 248 | ACPI_ADR_SPACE_FIXED_HARDWARE)) { |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 249 | pr_debug("Unsupported address space [%d, %d]\n", |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 250 | (u32) (data->acpi_data.control_register.space_id), |
| 251 | (u32) (data->acpi_data.status_register.space_id)); |
| 252 | result = -ENODEV; |
| 253 | goto err_unreg; |
| 254 | } |
| 255 | |
| 256 | /* alloc freq_table */ |
Pan Xinhui | 946c14f | 2015-07-20 14:22:46 +0800 | [diff] [blame] | 257 | freq_table = kzalloc(sizeof(*freq_table) * |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 258 | (data->acpi_data.state_count + 1), |
| 259 | GFP_KERNEL); |
Pan Xinhui | 946c14f | 2015-07-20 14:22:46 +0800 | [diff] [blame] | 260 | if (!freq_table) { |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 261 | result = -ENOMEM; |
| 262 | goto err_unreg; |
| 263 | } |
| 264 | |
| 265 | /* detect transition latency */ |
| 266 | policy->cpuinfo.transition_latency = 0; |
| 267 | for (i=0; i<data->acpi_data.state_count; i++) { |
| 268 | if ((data->acpi_data.states[i].transition_latency * 1000) > |
| 269 | policy->cpuinfo.transition_latency) { |
| 270 | policy->cpuinfo.transition_latency = |
| 271 | data->acpi_data.states[i].transition_latency * 1000; |
| 272 | } |
| 273 | } |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 274 | |
| 275 | /* table init */ |
| 276 | for (i = 0; i <= data->acpi_data.state_count; i++) |
| 277 | { |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 278 | if (i < data->acpi_data.state_count) { |
Pan Xinhui | 946c14f | 2015-07-20 14:22:46 +0800 | [diff] [blame] | 279 | freq_table[i].frequency = |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 280 | data->acpi_data.states[i].core_frequency * 1000; |
| 281 | } else { |
Pan Xinhui | 946c14f | 2015-07-20 14:22:46 +0800 | [diff] [blame] | 282 | freq_table[i].frequency = CPUFREQ_TABLE_END; |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 283 | } |
| 284 | } |
| 285 | |
Pan Xinhui | 946c14f | 2015-07-20 14:22:46 +0800 | [diff] [blame] | 286 | result = cpufreq_table_validate_and_show(policy, freq_table); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 287 | if (result) { |
| 288 | goto err_freqfree; |
| 289 | } |
| 290 | |
| 291 | /* notify BIOS that we exist */ |
| 292 | acpi_processor_notify_smm(THIS_MODULE); |
| 293 | |
| 294 | printk(KERN_INFO "acpi-cpufreq: CPU%u - ACPI performance management " |
| 295 | "activated.\n", cpu); |
| 296 | |
| 297 | for (i = 0; i < data->acpi_data.state_count; i++) |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 298 | pr_debug(" %cP%d: %d MHz, %d mW, %d uS, %d uS, 0x%x 0x%x\n", |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 299 | (i == data->acpi_data.state?'*':' '), i, |
| 300 | (u32) data->acpi_data.states[i].core_frequency, |
| 301 | (u32) data->acpi_data.states[i].power, |
| 302 | (u32) data->acpi_data.states[i].transition_latency, |
| 303 | (u32) data->acpi_data.states[i].bus_master_latency, |
| 304 | (u32) data->acpi_data.states[i].status, |
| 305 | (u32) data->acpi_data.states[i].control); |
| 306 | |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 307 | /* the first call to ->target() should result in us actually |
| 308 | * writing something to the appropriate registers. */ |
| 309 | data->resume = 1; |
| 310 | |
| 311 | return (result); |
| 312 | |
| 313 | err_freqfree: |
Pan Xinhui | 946c14f | 2015-07-20 14:22:46 +0800 | [diff] [blame] | 314 | kfree(freq_table); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 315 | err_unreg: |
Rafael J. Wysocki | b2f8dc4 | 2015-07-22 22:11:16 +0200 | [diff] [blame] | 316 | acpi_processor_unregister_performance(cpu); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 317 | err_free: |
| 318 | kfree(data); |
| 319 | acpi_io_data[cpu] = NULL; |
| 320 | |
| 321 | return (result); |
| 322 | } |
| 323 | |
| 324 | |
| 325 | static int |
| 326 | acpi_cpufreq_cpu_exit ( |
| 327 | struct cpufreq_policy *policy) |
| 328 | { |
| 329 | struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu]; |
| 330 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 331 | pr_debug("acpi_cpufreq_cpu_exit\n"); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 332 | |
| 333 | if (data) { |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 334 | acpi_io_data[policy->cpu] = NULL; |
Rafael J. Wysocki | b2f8dc4 | 2015-07-22 22:11:16 +0200 | [diff] [blame] | 335 | acpi_processor_unregister_performance(policy->cpu); |
Pan Xinhui | 555f3fe | 2015-07-20 14:24:36 +0800 | [diff] [blame] | 336 | kfree(policy->freq_table); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 337 | kfree(data); |
| 338 | } |
| 339 | |
| 340 | return (0); |
| 341 | } |
| 342 | |
| 343 | |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 344 | static struct cpufreq_driver acpi_cpufreq_driver = { |
Viresh Kumar | 59b2413 | 2013-10-03 20:28:07 +0530 | [diff] [blame] | 345 | .verify = cpufreq_generic_frequency_table_verify, |
Viresh Kumar | 9c0ebcf | 2013-10-25 19:45:48 +0530 | [diff] [blame] | 346 | .target_index = acpi_cpufreq_target, |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 347 | .get = acpi_cpufreq_get, |
| 348 | .init = acpi_cpufreq_cpu_init, |
| 349 | .exit = acpi_cpufreq_cpu_exit, |
| 350 | .name = "acpi-cpufreq", |
Viresh Kumar | 59b2413 | 2013-10-03 20:28:07 +0530 | [diff] [blame] | 351 | .attr = cpufreq_generic_attr, |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 352 | }; |
| 353 | |
| 354 | |
| 355 | static int __init |
| 356 | acpi_cpufreq_init (void) |
| 357 | { |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 358 | pr_debug("acpi_cpufreq_init\n"); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 359 | |
| 360 | return cpufreq_register_driver(&acpi_cpufreq_driver); |
| 361 | } |
| 362 | |
| 363 | |
| 364 | static void __exit |
| 365 | acpi_cpufreq_exit (void) |
| 366 | { |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 367 | pr_debug("acpi_cpufreq_exit\n"); |
Venkatesh Pallipadi | 4db8699 | 2005-07-29 16:15:00 -0700 | [diff] [blame] | 368 | |
| 369 | cpufreq_unregister_driver(&acpi_cpufreq_driver); |
| 370 | return; |
| 371 | } |
| 372 | |
| 373 | |
| 374 | late_initcall(acpi_cpufreq_init); |
| 375 | module_exit(acpi_cpufreq_exit); |
| 376 | |