Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * processor_throttling.c - Throttling submodule of the ACPI processor driver |
| 3 | * |
| 4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> |
| 5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> |
| 6 | * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de> |
| 7 | * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> |
| 8 | * - Added processor hotplug support |
| 9 | * |
| 10 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or (at |
| 15 | * your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, but |
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 | * General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along |
| 23 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 24 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
| 25 | * |
| 26 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 27 | */ |
| 28 | |
| 29 | #include <linux/kernel.h> |
| 30 | #include <linux/module.h> |
| 31 | #include <linux/init.h> |
| 32 | #include <linux/cpufreq.h> |
| 33 | #include <linux/proc_fs.h> |
| 34 | #include <linux/seq_file.h> |
| 35 | |
| 36 | #include <asm/io.h> |
| 37 | #include <asm/uaccess.h> |
| 38 | |
| 39 | #include <acpi/acpi_bus.h> |
| 40 | #include <acpi/processor.h> |
| 41 | |
| 42 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 |
| 43 | #define ACPI_PROCESSOR_CLASS "processor" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
Len Brown | f52fd66 | 2007-02-12 22:42:12 -0500 | [diff] [blame] | 45 | ACPI_MODULE_NAME("processor_throttling"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 47 | static int acpi_processor_get_throttling(struct acpi_processor *pr); |
| 48 | int acpi_processor_set_throttling(struct acpi_processor *pr, int state); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 49 | |
| 50 | static int acpi_processor_get_platform_limit(struct acpi_processor *pr) |
| 51 | { |
| 52 | acpi_status status = 0; |
| 53 | unsigned long tpc = 0; |
| 54 | |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 55 | if (!pr) |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 56 | return -EINVAL; |
| 57 | status = acpi_evaluate_integer(pr->handle, "_TPC", NULL, &tpc); |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 58 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 59 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TPC")); |
| 60 | return -ENODEV; |
| 61 | } |
| 62 | pr->throttling_platform_limit = (int)tpc; |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | int acpi_processor_tstate_has_changed(struct acpi_processor *pr) |
| 67 | { |
| 68 | return acpi_processor_get_platform_limit(pr); |
| 69 | } |
| 70 | |
| 71 | /* -------------------------------------------------------------------------- |
| 72 | _PTC, _TSS, _TSD support |
| 73 | -------------------------------------------------------------------------- */ |
| 74 | static int acpi_processor_get_throttling_control(struct acpi_processor *pr) |
| 75 | { |
| 76 | int result = 0; |
| 77 | acpi_status status = 0; |
| 78 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 79 | union acpi_object *ptc = NULL; |
| 80 | union acpi_object obj = { 0 }; |
| 81 | |
| 82 | status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer); |
| 83 | if (ACPI_FAILURE(status)) { |
| 84 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PTC")); |
| 85 | return -ENODEV; |
| 86 | } |
| 87 | |
| 88 | ptc = (union acpi_object *)buffer.pointer; |
| 89 | if (!ptc || (ptc->type != ACPI_TYPE_PACKAGE) |
| 90 | || (ptc->package.count != 2)) { |
| 91 | printk(KERN_ERR PREFIX "Invalid _PTC data\n"); |
| 92 | result = -EFAULT; |
| 93 | goto end; |
| 94 | } |
| 95 | |
| 96 | /* |
| 97 | * control_register |
| 98 | */ |
| 99 | |
| 100 | obj = ptc->package.elements[0]; |
| 101 | |
| 102 | if ((obj.type != ACPI_TYPE_BUFFER) |
| 103 | || (obj.buffer.length < sizeof(struct acpi_ptc_register)) |
| 104 | || (obj.buffer.pointer == NULL)) { |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 105 | printk(KERN_ERR PREFIX |
| 106 | "Invalid _PTC data (control_register)\n"); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 107 | result = -EFAULT; |
| 108 | goto end; |
| 109 | } |
| 110 | memcpy(&pr->throttling.control_register, obj.buffer.pointer, |
| 111 | sizeof(struct acpi_ptc_register)); |
| 112 | |
| 113 | /* |
| 114 | * status_register |
| 115 | */ |
| 116 | |
| 117 | obj = ptc->package.elements[1]; |
| 118 | |
| 119 | if ((obj.type != ACPI_TYPE_BUFFER) |
| 120 | || (obj.buffer.length < sizeof(struct acpi_ptc_register)) |
| 121 | || (obj.buffer.pointer == NULL)) { |
| 122 | printk(KERN_ERR PREFIX "Invalid _PTC data (status_register)\n"); |
| 123 | result = -EFAULT; |
| 124 | goto end; |
| 125 | } |
| 126 | |
| 127 | memcpy(&pr->throttling.status_register, obj.buffer.pointer, |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 128 | sizeof(struct acpi_ptc_register)); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 129 | |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 130 | end: |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 131 | kfree(buffer.pointer); |
| 132 | |
| 133 | return result; |
| 134 | } |
| 135 | static int acpi_processor_get_throttling_states(struct acpi_processor *pr) |
| 136 | { |
| 137 | int result = 0; |
| 138 | acpi_status status = AE_OK; |
| 139 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 140 | struct acpi_buffer format = { sizeof("NNNNN"), "NNNNN" }; |
| 141 | struct acpi_buffer state = { 0, NULL }; |
| 142 | union acpi_object *tss = NULL; |
| 143 | int i; |
| 144 | |
| 145 | status = acpi_evaluate_object(pr->handle, "_TSS", NULL, &buffer); |
| 146 | if (ACPI_FAILURE(status)) { |
| 147 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TSS")); |
| 148 | return -ENODEV; |
| 149 | } |
| 150 | |
| 151 | tss = buffer.pointer; |
| 152 | if (!tss || (tss->type != ACPI_TYPE_PACKAGE)) { |
| 153 | printk(KERN_ERR PREFIX "Invalid _TSS data\n"); |
| 154 | result = -EFAULT; |
| 155 | goto end; |
| 156 | } |
| 157 | |
| 158 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n", |
| 159 | tss->package.count)); |
| 160 | |
| 161 | pr->throttling.state_count = tss->package.count; |
| 162 | pr->throttling.states_tss = |
| 163 | kmalloc(sizeof(struct acpi_processor_tx_tss) * tss->package.count, |
| 164 | GFP_KERNEL); |
| 165 | if (!pr->throttling.states_tss) { |
| 166 | result = -ENOMEM; |
| 167 | goto end; |
| 168 | } |
| 169 | |
| 170 | for (i = 0; i < pr->throttling.state_count; i++) { |
| 171 | |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 172 | struct acpi_processor_tx_tss *tx = |
| 173 | (struct acpi_processor_tx_tss *)&(pr->throttling. |
| 174 | states_tss[i]); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 175 | |
| 176 | state.length = sizeof(struct acpi_processor_tx_tss); |
| 177 | state.pointer = tx; |
| 178 | |
| 179 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i)); |
| 180 | |
| 181 | status = acpi_extract_package(&(tss->package.elements[i]), |
| 182 | &format, &state); |
| 183 | if (ACPI_FAILURE(status)) { |
| 184 | ACPI_EXCEPTION((AE_INFO, status, "Invalid _TSS data")); |
| 185 | result = -EFAULT; |
| 186 | kfree(pr->throttling.states_tss); |
| 187 | goto end; |
| 188 | } |
| 189 | |
| 190 | if (!tx->freqpercentage) { |
| 191 | printk(KERN_ERR PREFIX |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 192 | "Invalid _TSS data: freq is zero\n"); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 193 | result = -EFAULT; |
| 194 | kfree(pr->throttling.states_tss); |
| 195 | goto end; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | end: |
| 200 | kfree(buffer.pointer); |
| 201 | |
| 202 | return result; |
| 203 | } |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 204 | static int acpi_processor_get_tsd(struct acpi_processor *pr) |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 205 | { |
| 206 | int result = 0; |
| 207 | acpi_status status = AE_OK; |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 208 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 209 | struct acpi_buffer format = { sizeof("NNNNN"), "NNNNN" }; |
| 210 | struct acpi_buffer state = { 0, NULL }; |
| 211 | union acpi_object *tsd = NULL; |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 212 | struct acpi_tsd_package *pdomain; |
| 213 | |
| 214 | status = acpi_evaluate_object(pr->handle, "_TSD", NULL, &buffer); |
| 215 | if (ACPI_FAILURE(status)) { |
| 216 | return -ENODEV; |
| 217 | } |
| 218 | |
| 219 | tsd = buffer.pointer; |
| 220 | if (!tsd || (tsd->type != ACPI_TYPE_PACKAGE)) { |
| 221 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n")); |
| 222 | result = -EFAULT; |
| 223 | goto end; |
| 224 | } |
| 225 | |
| 226 | if (tsd->package.count != 1) { |
| 227 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n")); |
| 228 | result = -EFAULT; |
| 229 | goto end; |
| 230 | } |
| 231 | |
| 232 | pdomain = &(pr->throttling.domain_info); |
| 233 | |
| 234 | state.length = sizeof(struct acpi_tsd_package); |
| 235 | state.pointer = pdomain; |
| 236 | |
| 237 | status = acpi_extract_package(&(tsd->package.elements[0]), |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 238 | &format, &state); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 239 | if (ACPI_FAILURE(status)) { |
| 240 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n")); |
| 241 | result = -EFAULT; |
| 242 | goto end; |
| 243 | } |
| 244 | |
| 245 | if (pdomain->num_entries != ACPI_TSD_REV0_ENTRIES) { |
| 246 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _TSD:num_entries\n")); |
| 247 | result = -EFAULT; |
| 248 | goto end; |
| 249 | } |
| 250 | |
| 251 | if (pdomain->revision != ACPI_TSD_REV0_REVISION) { |
| 252 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _TSD:revision\n")); |
| 253 | result = -EFAULT; |
| 254 | goto end; |
| 255 | } |
| 256 | |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 257 | end: |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 258 | kfree(buffer.pointer); |
| 259 | return result; |
| 260 | } |
| 261 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | /* -------------------------------------------------------------------------- |
| 263 | Throttling Control |
| 264 | -------------------------------------------------------------------------- */ |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 265 | static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 267 | int state = 0; |
| 268 | u32 value = 0; |
| 269 | u32 duty_mask = 0; |
| 270 | u32 duty_value = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | if (!pr) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 273 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | |
| 275 | if (!pr->flags.throttling) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 276 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
| 278 | pr->throttling.state = 0; |
| 279 | |
| 280 | duty_mask = pr->throttling.state_count - 1; |
| 281 | |
| 282 | duty_mask <<= pr->throttling.duty_offset; |
| 283 | |
| 284 | local_irq_disable(); |
| 285 | |
| 286 | value = inl(pr->throttling.address); |
| 287 | |
| 288 | /* |
| 289 | * Compute the current throttling state when throttling is enabled |
| 290 | * (bit 4 is on). |
| 291 | */ |
| 292 | if (value & 0x10) { |
| 293 | duty_value = value & duty_mask; |
| 294 | duty_value >>= pr->throttling.duty_offset; |
| 295 | |
| 296 | if (duty_value) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 297 | state = pr->throttling.state_count - duty_value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | pr->throttling.state = state; |
| 301 | |
| 302 | local_irq_enable(); |
| 303 | |
| 304 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 305 | "Throttling state is T%d (%d%% throttling applied)\n", |
| 306 | state, pr->throttling.states[state].performance)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 308 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | } |
| 310 | |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 311 | static int acpi_read_throttling_status(struct acpi_processor_throttling |
| 312 | *throttling) |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 313 | { |
| 314 | int value = -1; |
| 315 | switch (throttling->status_register.space_id) { |
| 316 | case ACPI_ADR_SPACE_SYSTEM_IO: |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 317 | acpi_os_read_port((acpi_io_address) throttling->status_register. |
| 318 | address, &value, |
| 319 | (u32) throttling->status_register.bit_width * |
| 320 | 8); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 321 | break; |
| 322 | case ACPI_ADR_SPACE_FIXED_HARDWARE: |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 323 | printk(KERN_ERR PREFIX |
| 324 | "HARDWARE addr space,NOT supported yet\n"); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 325 | break; |
| 326 | default: |
| 327 | printk(KERN_ERR PREFIX "Unknown addr space %d\n", |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 328 | (u32) (throttling->status_register.space_id)); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 329 | } |
| 330 | return value; |
| 331 | } |
| 332 | |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 333 | static int acpi_write_throttling_state(struct acpi_processor_throttling |
| 334 | *throttling, int value) |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 335 | { |
| 336 | int ret = -1; |
| 337 | |
| 338 | switch (throttling->control_register.space_id) { |
| 339 | case ACPI_ADR_SPACE_SYSTEM_IO: |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 340 | acpi_os_write_port((acpi_io_address) throttling-> |
| 341 | control_register.address, value, |
| 342 | (u32) throttling->control_register. |
| 343 | bit_width * 8); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 344 | ret = 0; |
| 345 | break; |
| 346 | case ACPI_ADR_SPACE_FIXED_HARDWARE: |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 347 | printk(KERN_ERR PREFIX |
| 348 | "HARDWARE addr space,NOT supported yet\n"); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 349 | break; |
| 350 | default: |
| 351 | printk(KERN_ERR PREFIX "Unknown addr space %d\n", |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 352 | (u32) (throttling->control_register.space_id)); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 353 | } |
| 354 | return ret; |
| 355 | } |
| 356 | |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 357 | static int acpi_get_throttling_state(struct acpi_processor *pr, int value) |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 358 | { |
| 359 | int i; |
| 360 | |
| 361 | for (i = 0; i < pr->throttling.state_count; i++) { |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 362 | struct acpi_processor_tx_tss *tx = |
| 363 | (struct acpi_processor_tx_tss *)&(pr->throttling. |
| 364 | states_tss[i]); |
| 365 | if (tx->control == value) |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 366 | break; |
| 367 | } |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 368 | if (i > pr->throttling.state_count) |
| 369 | i = -1; |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 370 | return i; |
| 371 | } |
| 372 | |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 373 | static int acpi_get_throttling_value(struct acpi_processor *pr, int state) |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 374 | { |
| 375 | int value = -1; |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 376 | if (state >= 0 && state <= pr->throttling.state_count) { |
| 377 | struct acpi_processor_tx_tss *tx = |
| 378 | (struct acpi_processor_tx_tss *)&(pr->throttling. |
| 379 | states_tss[state]); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 380 | value = tx->control; |
| 381 | } |
| 382 | return value; |
| 383 | } |
| 384 | |
| 385 | static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) |
| 386 | { |
| 387 | int state = 0; |
| 388 | u32 value = 0; |
| 389 | |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 390 | if (!pr) |
| 391 | return -EINVAL; |
| 392 | |
| 393 | if (!pr->flags.throttling) |
| 394 | return -ENODEV; |
| 395 | |
| 396 | pr->throttling.state = 0; |
| 397 | local_irq_disable(); |
| 398 | value = acpi_read_throttling_status(&pr->throttling); |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 399 | if (value >= 0) { |
| 400 | state = acpi_get_throttling_state(pr, value); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 401 | pr->throttling.state = state; |
| 402 | } |
| 403 | local_irq_enable(); |
| 404 | |
| 405 | return 0; |
| 406 | } |
| 407 | |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 408 | static int acpi_processor_get_throttling(struct acpi_processor *pr) |
| 409 | { |
| 410 | return pr->throttling.acpi_processor_get_throttling(pr); |
| 411 | } |
| 412 | |
Adrian Bunk | 6c5cf8a | 2007-07-03 00:53:12 -0400 | [diff] [blame] | 413 | static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, |
| 414 | int state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 416 | u32 value = 0; |
| 417 | u32 duty_mask = 0; |
| 418 | u32 duty_value = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | if (!pr) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 421 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | |
| 423 | if ((state < 0) || (state > (pr->throttling.state_count - 1))) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 424 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | |
| 426 | if (!pr->flags.throttling) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 427 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | |
| 429 | if (state == pr->throttling.state) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 430 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 432 | if (state < pr->throttling_platform_limit) |
| 433 | return -EPERM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | /* |
| 435 | * Calculate the duty_value and duty_mask. |
| 436 | */ |
| 437 | if (state) { |
| 438 | duty_value = pr->throttling.state_count - state; |
| 439 | |
| 440 | duty_value <<= pr->throttling.duty_offset; |
| 441 | |
| 442 | /* Used to clear all duty_value bits */ |
| 443 | duty_mask = pr->throttling.state_count - 1; |
| 444 | |
Alexey Starikovskiy | cee324b | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 445 | duty_mask <<= acpi_gbl_FADT.duty_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | duty_mask = ~duty_mask; |
| 447 | } |
| 448 | |
| 449 | local_irq_disable(); |
| 450 | |
| 451 | /* |
| 452 | * Disable throttling by writing a 0 to bit 4. Note that we must |
| 453 | * turn it off before you can change the duty_value. |
| 454 | */ |
| 455 | value = inl(pr->throttling.address); |
| 456 | if (value & 0x10) { |
| 457 | value &= 0xFFFFFFEF; |
| 458 | outl(value, pr->throttling.address); |
| 459 | } |
| 460 | |
| 461 | /* |
| 462 | * Write the new duty_value and then enable throttling. Note |
| 463 | * that a state value of 0 leaves throttling disabled. |
| 464 | */ |
| 465 | if (state) { |
| 466 | value &= duty_mask; |
| 467 | value |= duty_value; |
| 468 | outl(value, pr->throttling.address); |
| 469 | |
| 470 | value |= 0x00000010; |
| 471 | outl(value, pr->throttling.address); |
| 472 | } |
| 473 | |
| 474 | pr->throttling.state = state; |
| 475 | |
| 476 | local_irq_enable(); |
| 477 | |
| 478 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 479 | "Throttling state set to T%d (%d%%)\n", state, |
| 480 | (pr->throttling.states[state].performance ? pr-> |
| 481 | throttling.states[state].performance / 10 : 0))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 483 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | } |
| 485 | |
Adrian Bunk | 6c5cf8a | 2007-07-03 00:53:12 -0400 | [diff] [blame] | 486 | static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, |
| 487 | int state) |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 488 | { |
| 489 | u32 value = 0; |
| 490 | |
| 491 | if (!pr) |
| 492 | return -EINVAL; |
| 493 | |
| 494 | if ((state < 0) || (state > (pr->throttling.state_count - 1))) |
| 495 | return -EINVAL; |
| 496 | |
| 497 | if (!pr->flags.throttling) |
| 498 | return -ENODEV; |
| 499 | |
| 500 | if (state == pr->throttling.state) |
| 501 | return 0; |
| 502 | |
| 503 | if (state < pr->throttling_platform_limit) |
| 504 | return -EPERM; |
| 505 | |
| 506 | local_irq_disable(); |
| 507 | |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 508 | value = acpi_get_throttling_value(pr, state); |
| 509 | if (value >= 0) { |
| 510 | acpi_write_throttling_state(&pr->throttling, value); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 511 | pr->throttling.state = state; |
| 512 | } |
| 513 | local_irq_enable(); |
| 514 | |
| 515 | return 0; |
| 516 | } |
| 517 | |
| 518 | int acpi_processor_set_throttling(struct acpi_processor *pr, int state) |
| 519 | { |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 520 | return pr->throttling.acpi_processor_set_throttling(pr, state); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 521 | } |
| 522 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 523 | int acpi_processor_get_throttling_info(struct acpi_processor *pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 525 | int result = 0; |
| 526 | int step = 0; |
| 527 | int i = 0; |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 528 | int no_ptc = 0; |
| 529 | int no_tss = 0; |
| 530 | int no_tsd = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 533 | "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", |
| 534 | pr->throttling.address, |
| 535 | pr->throttling.duty_offset, |
| 536 | pr->throttling.duty_width)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | |
| 538 | if (!pr) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 539 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | |
| 541 | /* TBD: Support ACPI 2.0 objects */ |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 542 | no_ptc = acpi_processor_get_throttling_control(pr); |
| 543 | no_tss = acpi_processor_get_throttling_states(pr); |
| 544 | no_tsd = acpi_processor_get_tsd(pr); |
| 545 | |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 546 | if (no_ptc || no_tss) { |
| 547 | pr->throttling.acpi_processor_get_throttling = |
| 548 | &acpi_processor_get_throttling_fadt; |
| 549 | pr->throttling.acpi_processor_set_throttling = |
| 550 | &acpi_processor_set_throttling_fadt; |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 551 | } else { |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 552 | pr->throttling.acpi_processor_get_throttling = |
| 553 | &acpi_processor_get_throttling_ptc; |
| 554 | pr->throttling.acpi_processor_set_throttling = |
| 555 | &acpi_processor_set_throttling_ptc; |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 556 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | |
| 558 | if (!pr->throttling.address) { |
| 559 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 560 | return 0; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 561 | } else if (!pr->throttling.duty_width) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 563 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | } |
| 565 | /* TBD: Support duty_cycle values that span bit 4. */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 566 | else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) { |
Len Brown | cece929 | 2006-06-26 23:04:31 -0400 | [diff] [blame] | 567 | printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n"); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 568 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | /* |
| 572 | * PIIX4 Errata: We don't support throttling on the original PIIX4. |
| 573 | * This shouldn't be an issue as few (if any) mobile systems ever |
| 574 | * used this part. |
| 575 | */ |
| 576 | if (errata.piix4.throttle) { |
| 577 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 578 | "Throttling not supported on PIIX4 A- or B-step\n")); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 579 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | } |
| 581 | |
Alexey Starikovskiy | cee324b | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 582 | pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | |
| 584 | /* |
| 585 | * Compute state values. Note that throttling displays a linear power/ |
| 586 | * performance relationship (at 50% performance the CPU will consume |
| 587 | * 50% power). Values are in 1/10th of a percent to preserve accuracy. |
| 588 | */ |
| 589 | |
| 590 | step = (1000 / pr->throttling.state_count); |
| 591 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 592 | for (i = 0; i < pr->throttling.state_count; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | pr->throttling.states[i].performance = step * i; |
| 594 | pr->throttling.states[i].power = step * i; |
| 595 | } |
| 596 | |
| 597 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 598 | pr->throttling.state_count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | |
| 600 | pr->flags.throttling = 1; |
| 601 | |
| 602 | /* |
| 603 | * Disable throttling (if enabled). We'll let subsequent policy (e.g. |
| 604 | * thermal) decide to lower performance if it so chooses, but for now |
| 605 | * we'll crank up the speed. |
| 606 | */ |
| 607 | |
| 608 | result = acpi_processor_get_throttling(pr); |
| 609 | if (result) |
| 610 | goto end; |
| 611 | |
| 612 | if (pr->throttling.state) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 613 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 614 | "Disabling throttling (was T%d)\n", |
| 615 | pr->throttling.state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | result = acpi_processor_set_throttling(pr, 0); |
| 617 | if (result) |
| 618 | goto end; |
| 619 | } |
| 620 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 621 | end: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | if (result) |
| 623 | pr->flags.throttling = 0; |
| 624 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 625 | return result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | } |
| 627 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | /* proc interface */ |
| 629 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 630 | static int acpi_processor_throttling_seq_show(struct seq_file *seq, |
| 631 | void *offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | { |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 633 | struct acpi_processor *pr = seq->private; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 634 | int i = 0; |
| 635 | int result = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | if (!pr) |
| 638 | goto end; |
| 639 | |
| 640 | if (!(pr->throttling.state_count > 0)) { |
| 641 | seq_puts(seq, "<not supported>\n"); |
| 642 | goto end; |
| 643 | } |
| 644 | |
| 645 | result = acpi_processor_get_throttling(pr); |
| 646 | |
| 647 | if (result) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 648 | seq_puts(seq, |
| 649 | "Could not determine current throttling state.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | goto end; |
| 651 | } |
| 652 | |
| 653 | seq_printf(seq, "state count: %d\n" |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 654 | "active state: T%d\n" |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 655 | "state available: T%d to T%d\n", |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 656 | pr->throttling.state_count, pr->throttling.state, |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 657 | pr->throttling_platform_limit, |
| 658 | pr->throttling.state_count - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | |
| 660 | seq_puts(seq, "states:\n"); |
Luming Yu | 3cc2649 | 2007-07-23 12:39:28 -0400 | [diff] [blame] | 661 | if (pr->throttling.acpi_processor_get_throttling == |
| 662 | acpi_processor_get_throttling_fadt) { |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 663 | for (i = 0; i < pr->throttling.state_count; i++) |
| 664 | seq_printf(seq, " %cT%d: %02d%%\n", |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 665 | (i == pr->throttling.state ? '*' : ' '), i, |
| 666 | (pr->throttling.states[i].performance ? pr-> |
| 667 | throttling.states[i].performance / 10 : 0)); |
Luming Yu | 3cc2649 | 2007-07-23 12:39:28 -0400 | [diff] [blame] | 668 | } else { |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 669 | for (i = 0; i < pr->throttling.state_count; i++) |
| 670 | seq_printf(seq, " %cT%d: %02d%%\n", |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 671 | (i == pr->throttling.state ? '*' : ' '), i, |
| 672 | (int)pr->throttling.states_tss[i]. |
| 673 | freqpercentage); |
Luming Yu | 3cc2649 | 2007-07-23 12:39:28 -0400 | [diff] [blame] | 674 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 676 | end: |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 677 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | } |
| 679 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 680 | static int acpi_processor_throttling_open_fs(struct inode *inode, |
| 681 | struct file *file) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | { |
| 683 | return single_open(file, acpi_processor_throttling_seq_show, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 684 | PDE(inode)->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | } |
| 686 | |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 687 | static ssize_t acpi_processor_write_throttling(struct file *file, |
Adrian Bunk | 757b186 | 2006-01-07 13:19:00 -0500 | [diff] [blame] | 688 | const char __user * buffer, |
| 689 | size_t count, loff_t * data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 691 | int result = 0; |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 692 | struct seq_file *m = file->private_data; |
| 693 | struct acpi_processor *pr = m->private; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 694 | char state_string[12] = { '\0' }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | if (!pr || (count > sizeof(state_string) - 1)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 697 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | |
| 699 | if (copy_from_user(state_string, buffer, count)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 700 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | |
| 702 | state_string[count] = '\0'; |
| 703 | |
| 704 | result = acpi_processor_set_throttling(pr, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 705 | simple_strtoul(state_string, |
| 706 | NULL, 0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | if (result) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 708 | return result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 710 | return count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | struct file_operations acpi_processor_throttling_fops = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 714 | .open = acpi_processor_throttling_open_fs, |
| 715 | .read = seq_read, |
Arjan van de Ven | d479e90 | 2006-01-06 16:47:00 -0500 | [diff] [blame] | 716 | .write = acpi_processor_write_throttling, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 717 | .llseek = seq_lseek, |
| 718 | .release = single_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | }; |