diff options
author | Chaya Rachel Ivgi <chaya.rachel.ivgi@intel.com> | 2016-02-24 05:19:22 -0500 |
---|---|---|
committer | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2016-03-09 13:59:11 -0500 |
commit | 00f481bd895a826058d301b3093e86e819497b51 (patch) | |
tree | 67610301751637636cae68b9c4f8564ce2cb2605 /drivers/net/wireless/intel/iwlwifi/mvm/tt.c | |
parent | 7c70fee5ae5c4fb542e432599cb85c8031b952a0 (diff) |
iwlwifi: mvm: add ctdp operations to debugfs
Add debugfs entries to get the ctdp budget average
and to stop ctdp.
Signed-off-by: Chaya Rachel Ivgi <chaya.rachel.ivgi@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Diffstat (limited to 'drivers/net/wireless/intel/iwlwifi/mvm/tt.c')
-rw-r--r-- | drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 78 |
1 files changed, 44 insertions, 34 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c index 0a02e9835d6b..ce0c6fd183bb 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c | |||
@@ -510,6 +510,50 @@ static const struct iwl_tt_params iwl_mvm_default_tt_params = { | |||
510 | .support_tx_backoff = true, | 510 | .support_tx_backoff = true, |
511 | }; | 511 | }; |
512 | 512 | ||
513 | int iwl_mvm_ctdp_command(struct iwl_mvm *mvm, u32 op, u32 budget) | ||
514 | { | ||
515 | struct iwl_mvm_ctdp_cmd cmd = { | ||
516 | .operation = cpu_to_le32(op), | ||
517 | .budget = cpu_to_le32(budget), | ||
518 | .window_size = 0, | ||
519 | }; | ||
520 | int ret; | ||
521 | u32 status; | ||
522 | |||
523 | lockdep_assert_held(&mvm->mutex); | ||
524 | |||
525 | ret = iwl_mvm_send_cmd_pdu_status(mvm, WIDE_ID(PHY_OPS_GROUP, | ||
526 | CTDP_CONFIG_CMD), | ||
527 | sizeof(cmd), &cmd, &status); | ||
528 | |||
529 | if (ret) { | ||
530 | IWL_ERR(mvm, "cTDP command failed (err=%d)\n", ret); | ||
531 | return ret; | ||
532 | } | ||
533 | |||
534 | switch (op) { | ||
535 | case CTDP_CMD_OPERATION_START: | ||
536 | #ifdef CONFIG_THERMAL | ||
537 | mvm->cooling_dev.cur_state = budget; | ||
538 | #endif /* CONFIG_THERMAL */ | ||
539 | break; | ||
540 | case CTDP_CMD_OPERATION_REPORT: | ||
541 | IWL_DEBUG_TEMP(mvm, "cTDP avg energy in mWatt = %d\n", status); | ||
542 | /* when the function is called with CTDP_CMD_OPERATION_REPORT | ||
543 | * option the function should return the average budget value | ||
544 | * that is received from the FW. | ||
545 | * The budget can't be less or equal to 0, so it's possible | ||
546 | * to distinguish between error values and budgets. | ||
547 | */ | ||
548 | return status; | ||
549 | case CTDP_CMD_OPERATION_STOP: | ||
550 | IWL_DEBUG_TEMP(mvm, "cTDP stopped successfully\n"); | ||
551 | break; | ||
552 | } | ||
553 | |||
554 | return 0; | ||
555 | } | ||
556 | |||
513 | #ifdef CONFIG_THERMAL | 557 | #ifdef CONFIG_THERMAL |
514 | static int compare_temps(const void *a, const void *b) | 558 | static int compare_temps(const void *a, const void *b) |
515 | { | 559 | { |
@@ -738,40 +782,6 @@ static const u32 iwl_mvm_cdev_budgets[] = { | |||
738 | 150, /* cooling state 19 */ | 782 | 150, /* cooling state 19 */ |
739 | }; | 783 | }; |
740 | 784 | ||
741 | int iwl_mvm_ctdp_command(struct iwl_mvm *mvm, u32 op, u32 budget) | ||
742 | { | ||
743 | struct iwl_mvm_ctdp_cmd cmd = { | ||
744 | .operation = cpu_to_le32(op), | ||
745 | .budget = cpu_to_le32(budget), | ||
746 | .window_size = 0, | ||
747 | }; | ||
748 | int ret; | ||
749 | u32 status; | ||
750 | |||
751 | lockdep_assert_held(&mvm->mutex); | ||
752 | |||
753 | ret = iwl_mvm_send_cmd_pdu_status(mvm, WIDE_ID(PHY_OPS_GROUP, | ||
754 | CTDP_CONFIG_CMD), | ||
755 | sizeof(cmd), &cmd, &status); | ||
756 | |||
757 | if (ret) { | ||
758 | IWL_ERR(mvm, "cTDP command failed (err=%d)\n", ret); | ||
759 | return ret; | ||
760 | } | ||
761 | |||
762 | /* can happen if the registration failed */ | ||
763 | if (!mvm->cooling_dev.cdev) | ||
764 | return -EINVAL; | ||
765 | |||
766 | if (op == CTDP_CMD_OPERATION_START) | ||
767 | mvm->cooling_dev.cur_state = budget; | ||
768 | |||
769 | else if (op == CTDP_CMD_OPERATION_REPORT) | ||
770 | IWL_DEBUG_TEMP(mvm, "cTDP avg energy in mWatt = %d\n", status); | ||
771 | |||
772 | return 0; | ||
773 | } | ||
774 | |||
775 | static int iwl_mvm_tcool_get_max_state(struct thermal_cooling_device *cdev, | 785 | static int iwl_mvm_tcool_get_max_state(struct thermal_cooling_device *cdev, |
776 | unsigned long *state) | 786 | unsigned long *state) |
777 | { | 787 | { |