summaryrefslogtreecommitdiff
path: root/common/fan.c
diff options
context:
space:
mode:
authorMohammed Habibulla <moch@chromium.org>2014-10-03 16:45:33 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-07 01:29:36 +0000
commit876b0f0bdc503dfb4f564dfcd1bb9e721f9ddc98 (patch)
tree7e33c3c0951051242205d46f50b4ccd758a3351a /common/fan.c
parente541eeb2945ad81c8d89b343e2a70f8bce373fb5 (diff)
downloadchrome-ec-876b0f0bdc503dfb4f564dfcd1bb9e721f9ddc98.tar.gz
ectool: Add hostcmd support to set fan duty cycle for each fan separately
ectool fanduty <percent> - set all fans to <percent> duty cycle ectool fanduty <fan> <percent> - set <fan> to <percent> duty cycle BUG=chrome-os-partner:23803 TEST=Tested the above EC commands on Auron BRANCH=none Change-Id: I06ca1552bd8f3412f6e90245da302c9f86ab6103 Signed-off-by: Mohammed Habibulla <moch@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221505 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/fan.c')
-rw-r--r--common/fan.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/common/fan.c b/common/fan.c
index 550a4cf305..96eb373ca0 100644
--- a/common/fan.c
+++ b/common/fan.c
@@ -344,18 +344,28 @@ DECLARE_HOST_COMMAND(EC_CMD_PWM_SET_FAN_TARGET_RPM,
static int hc_pwm_set_fan_duty(struct host_cmd_handler_args *args)
{
- const struct ec_params_pwm_set_fan_duty *p = args->params;
+ const struct ec_params_pwm_set_fan_duty_v1 *p_v1 = args->params;
+ const struct ec_params_pwm_set_fan_duty_v0 *p_v0 = args->params;
int fan;
- /* TODO(crosbug.com/p/23803) */
- for (fan = 0; fan < CONFIG_FANS; fan++)
- set_duty_cycle(fan, p->percent);
+ if (args->version == 0) {
+ for (fan = 0; fan < CONFIG_FANS; fan++)
+ set_duty_cycle(fan, p_v0->percent);
+
+ return EC_RES_SUCCESS;
+ }
+
+ fan = p_v1->fan_idx;
+ if (fan >= CONFIG_FANS)
+ return EC_RES_ERROR;
+
+ set_duty_cycle(fan, p_v1->percent);
return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_PWM_SET_FAN_DUTY,
hc_pwm_set_fan_duty,
- EC_VER_MASK(0));
+ EC_VER_MASK(0) | EC_VER_MASK(1));
static int hc_thermal_auto_fan_ctrl(struct host_cmd_handler_args *args)
{