diff options
author | Mohammed Habibulla <moch@chromium.org> | 2014-10-02 14:36:16 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-03 22:27:03 +0000 |
commit | 7b1e58cc4361ea0369b0326dba82e3b513ac3232 (patch) | |
tree | c6adc96da4a155a1dd5b452504f2834e91efabad /common/fan.c | |
parent | f93c3e83e469b63c79407b2b8dc14f250b4e1950 (diff) | |
download | chrome-ec-7b1e58cc4361ea0369b0326dba82e3b513ac3232.tar.gz |
ectool: Add host command support to set fan RPM for each fan separately
First case is for legacy support
ectool pwmsetfanrpm <targetrpm> - set all fans to <targetrpm>
ectool pwmsetfanrpm <fan> <targetrpm> - set <fan> to <targetrpm>
BUG=chrome-os-partner:23803
TEST=Tested the above EC commands on Auron
BRANCH=none
CQ-DEPEND=CL:220960
Change-Id: I8f447f53289abaa9c5cc1285f9f0921328fbf32c
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221291
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/fan.c')
-rw-r--r-- | common/fan.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/common/fan.c b/common/fan.c index 7543d1e4d5..550a4cf305 100644 --- a/common/fan.c +++ b/common/fan.c @@ -308,24 +308,39 @@ DECLARE_HOST_COMMAND(EC_CMD_PWM_GET_FAN_TARGET_RPM, static int hc_pwm_set_fan_target_rpm(struct host_cmd_handler_args *args) { - const struct ec_params_pwm_set_fan_target_rpm *p = args->params; + const struct ec_params_pwm_set_fan_target_rpm_v1 *p_v1 = args->params; + const struct ec_params_pwm_set_fan_target_rpm_v0 *p_v0 = args->params; int fan; - /* TODO(crosbug.com/p/23803) */ - for (fan = 0; fan < CONFIG_FANS; fan++) { - /* Always enable the fan */ - set_enabled(fan, 1); + if (args->version == 0) { + for (fan = 0; fan < CONFIG_FANS; fan++) { + /* Always enable the fan */ + set_enabled(fan, 1); - set_thermal_control_enabled(fan, 0); - fan_set_rpm_mode(fans[fan].ch, 1); - fan_set_rpm_target(fans[fan].ch, p->rpm); + set_thermal_control_enabled(fan, 0); + fan_set_rpm_mode(fans[fan].ch, 1); + fan_set_rpm_target(fans[fan].ch, p_v0->rpm); + } + + return EC_RES_SUCCESS; } + fan = p_v1->fan_idx; + if (fan >= CONFIG_FANS) + return EC_RES_ERROR; + + /* Always enable the fan */ + set_enabled(fan, 1); + + set_thermal_control_enabled(fan, 0); + fan_set_rpm_mode(fans[fan].ch, 1); + fan_set_rpm_target(fans[fan].ch, p_v1->rpm); + return EC_RES_SUCCESS; } DECLARE_HOST_COMMAND(EC_CMD_PWM_SET_FAN_TARGET_RPM, hc_pwm_set_fan_target_rpm, - EC_VER_MASK(0)); + EC_VER_MASK(0) | EC_VER_MASK(1)); static int hc_pwm_set_fan_duty(struct host_cmd_handler_args *args) { |