diff options
author | Zhao Yakui <yakui.zhao@intel.com> | 2007-11-15 04:03:46 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-11-16 21:40:40 -0500 |
commit | 0753f6e0a3d9568fb6b8e34753b944d9f8eed05b (patch) | |
tree | dc42d0f3e9d77f61c9b54e0dfaed9a9c2bddc18f /drivers/acpi/processor_throttling.c | |
parent | 22cc50199d0616f7b002563a0e9117ba479356e1 (diff) |
ACPI: throttle: Change internal APIs better handle _PTC
Change the function interface for throttling control via PTC.
The following functions are concerned:
acpi_read_throttling_status()
acpi_write_throttling_state()
acpi_get_throttling_value()
acpi_get_throttling_state()
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/processor_throttling.c')
-rw-r--r-- | drivers/acpi/processor_throttling.c | 60 |
1 files changed, 39 insertions, 21 deletions
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 20d82f55ce5f..5c96ef18e94c 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -376,16 +376,23 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr) | |||
376 | return 0; | 376 | return 0; |
377 | } | 377 | } |
378 | 378 | ||
379 | static int acpi_read_throttling_status(struct acpi_processor_throttling | 379 | static int acpi_read_throttling_status(struct acpi_processor *pr, |
380 | *throttling) | 380 | acpi_integer *value) |
381 | { | 381 | { |
382 | int value = -1; | 382 | u64 ptc_value; |
383 | struct acpi_processor_throttling *throttling; | ||
384 | int ret = -1; | ||
385 | |||
386 | throttling = &pr->throttling; | ||
383 | switch (throttling->status_register.space_id) { | 387 | switch (throttling->status_register.space_id) { |
384 | case ACPI_ADR_SPACE_SYSTEM_IO: | 388 | case ACPI_ADR_SPACE_SYSTEM_IO: |
389 | ptc_value = 0; | ||
385 | acpi_os_read_port((acpi_io_address) throttling->status_register. | 390 | acpi_os_read_port((acpi_io_address) throttling->status_register. |
386 | address, &value, | 391 | address, (u32 *) &ptc_value, |
387 | (u32) throttling->status_register.bit_width * | 392 | (u32) throttling->status_register.bit_width * |
388 | 8); | 393 | 8); |
394 | *value = (acpi_integer) ptc_value; | ||
395 | ret = 0; | ||
389 | break; | 396 | break; |
390 | case ACPI_ADR_SPACE_FIXED_HARDWARE: | 397 | case ACPI_ADR_SPACE_FIXED_HARDWARE: |
391 | printk(KERN_ERR PREFIX | 398 | printk(KERN_ERR PREFIX |
@@ -395,18 +402,22 @@ static int acpi_read_throttling_status(struct acpi_processor_throttling | |||
395 | printk(KERN_ERR PREFIX "Unknown addr space %d\n", | 402 | printk(KERN_ERR PREFIX "Unknown addr space %d\n", |
396 | (u32) (throttling->status_register.space_id)); | 403 | (u32) (throttling->status_register.space_id)); |
397 | } | 404 | } |
398 | return value; | 405 | return ret; |
399 | } | 406 | } |
400 | 407 | ||
401 | static int acpi_write_throttling_state(struct acpi_processor_throttling | 408 | static int acpi_write_throttling_state(struct acpi_processor *pr, |
402 | *throttling, int value) | 409 | acpi_integer value) |
403 | { | 410 | { |
411 | u64 ptc_value; | ||
412 | struct acpi_processor_throttling *throttling; | ||
404 | int ret = -1; | 413 | int ret = -1; |
405 | 414 | ||
415 | throttling = &pr->throttling; | ||
406 | switch (throttling->control_register.space_id) { | 416 | switch (throttling->control_register.space_id) { |
407 | case ACPI_ADR_SPACE_SYSTEM_IO: | 417 | case ACPI_ADR_SPACE_SYSTEM_IO: |
418 | ptc_value = value; | ||
408 | acpi_os_write_port((acpi_io_address) throttling-> | 419 | acpi_os_write_port((acpi_io_address) throttling-> |
409 | control_register.address, value, | 420 | control_register.address, (u32) ptc_value, |
410 | (u32) throttling->control_register. | 421 | (u32) throttling->control_register. |
411 | bit_width * 8); | 422 | bit_width * 8); |
412 | ret = 0; | 423 | ret = 0; |
@@ -422,7 +433,8 @@ static int acpi_write_throttling_state(struct acpi_processor_throttling | |||
422 | return ret; | 433 | return ret; |
423 | } | 434 | } |
424 | 435 | ||
425 | static int acpi_get_throttling_state(struct acpi_processor *pr, int value) | 436 | static int acpi_get_throttling_state(struct acpi_processor *pr, |
437 | acpi_integer value) | ||
426 | { | 438 | { |
427 | int i; | 439 | int i; |
428 | 440 | ||
@@ -438,22 +450,26 @@ static int acpi_get_throttling_state(struct acpi_processor *pr, int value) | |||
438 | return i; | 450 | return i; |
439 | } | 451 | } |
440 | 452 | ||
441 | static int acpi_get_throttling_value(struct acpi_processor *pr, int state) | 453 | static int acpi_get_throttling_value(struct acpi_processor *pr, |
454 | int state, acpi_integer *value) | ||
442 | { | 455 | { |
443 | int value = -1; | 456 | int ret = -1; |
457 | |||
444 | if (state >= 0 && state <= pr->throttling.state_count) { | 458 | if (state >= 0 && state <= pr->throttling.state_count) { |
445 | struct acpi_processor_tx_tss *tx = | 459 | struct acpi_processor_tx_tss *tx = |
446 | (struct acpi_processor_tx_tss *)&(pr->throttling. | 460 | (struct acpi_processor_tx_tss *)&(pr->throttling. |
447 | states_tss[state]); | 461 | states_tss[state]); |
448 | value = tx->control; | 462 | *value = tx->control; |
463 | ret = 0; | ||
449 | } | 464 | } |
450 | return value; | 465 | return ret; |
451 | } | 466 | } |
452 | 467 | ||
453 | static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) | 468 | static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) |
454 | { | 469 | { |
455 | int state = 0; | 470 | int state = 0; |
456 | u32 value = 0; | 471 | int ret; |
472 | acpi_integer value; | ||
457 | 473 | ||
458 | if (!pr) | 474 | if (!pr) |
459 | return -EINVAL; | 475 | return -EINVAL; |
@@ -463,8 +479,9 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) | |||
463 | 479 | ||
464 | pr->throttling.state = 0; | 480 | pr->throttling.state = 0; |
465 | local_irq_disable(); | 481 | local_irq_disable(); |
466 | value = acpi_read_throttling_status(&pr->throttling); | 482 | value = 0; |
467 | if (value >= 0) { | 483 | ret = acpi_read_throttling_status(pr, &value); |
484 | if (ret >= 0) { | ||
468 | state = acpi_get_throttling_state(pr, value); | 485 | state = acpi_get_throttling_state(pr, value); |
469 | pr->throttling.state = state; | 486 | pr->throttling.state = state; |
470 | } | 487 | } |
@@ -588,7 +605,8 @@ static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, | |||
588 | static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, | 605 | static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, |
589 | int state) | 606 | int state) |
590 | { | 607 | { |
591 | u32 value = 0; | 608 | int ret; |
609 | acpi_integer value; | ||
592 | 610 | ||
593 | if (!pr) | 611 | if (!pr) |
594 | return -EINVAL; | 612 | return -EINVAL; |
@@ -606,10 +624,10 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, | |||
606 | return -EPERM; | 624 | return -EPERM; |
607 | 625 | ||
608 | local_irq_disable(); | 626 | local_irq_disable(); |
609 | 627 | value = 0; | |
610 | value = acpi_get_throttling_value(pr, state); | 628 | ret = acpi_get_throttling_value(pr, state, &value); |
611 | if (value >= 0) { | 629 | if (ret >= 0) { |
612 | acpi_write_throttling_state(&pr->throttling, value); | 630 | acpi_write_throttling_state(pr, value); |
613 | pr->throttling.state = state; | 631 | pr->throttling.state = state; |
614 | } | 632 | } |
615 | local_irq_enable(); | 633 | local_irq_enable(); |