mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
ectool: hostcmd support to set fans auto control individually
ectool autofanctrl 1 - set auto fan control for fan 1 BUG=chrome-os-partner:23803 TEST=Tested the above EC command on Auron BRANCH=none Change-Id: Idcd3690ad98d7965420f26f7cc445207fe73704d Signed-off-by: Mohammed Habibulla <moch@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221816 Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
7cde31850d
commit
5c8da35f87
18
common/fan.c
18
common/fan.c
@@ -370,16 +370,26 @@ DECLARE_HOST_COMMAND(EC_CMD_PWM_SET_FAN_DUTY,
|
||||
static int hc_thermal_auto_fan_ctrl(struct host_cmd_handler_args *args)
|
||||
{
|
||||
int fan;
|
||||
const struct ec_params_auto_fan_ctrl_v1 *p_v1 = args->params;
|
||||
|
||||
/* TODO(crosbug.com/p/23803) */
|
||||
for (fan = 0; fan < CONFIG_FANS; fan++)
|
||||
set_thermal_control_enabled(fan, 1);
|
||||
if (args->version == 0) {
|
||||
for (fan = 0; fan < CONFIG_FANS; fan++)
|
||||
set_thermal_control_enabled(fan, 1);
|
||||
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
|
||||
fan = p_v1->fan_idx;
|
||||
if (fan >= CONFIG_FANS)
|
||||
return EC_RES_ERROR;
|
||||
|
||||
set_thermal_control_enabled(fan, 1);
|
||||
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
DECLARE_HOST_COMMAND(EC_CMD_THERMAL_AUTO_FAN_CTRL,
|
||||
hc_thermal_auto_fan_ctrl,
|
||||
EC_VER_MASK(0));
|
||||
EC_VER_MASK(0)|EC_VER_MASK(1));
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -1607,6 +1607,11 @@ struct ec_params_thermal_set_threshold_v1 {
|
||||
/* Toggle automatic fan control */
|
||||
#define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x52
|
||||
|
||||
/* Version 1 of input params */
|
||||
struct ec_params_auto_fan_ctrl_v1 {
|
||||
uint8_t fan_idx;
|
||||
} __packed;
|
||||
|
||||
/* Get TMP006 calibration data */
|
||||
#define EC_CMD_TMP006_GET_CALIBRATION 0x53
|
||||
|
||||
|
||||
@@ -1359,15 +1359,59 @@ int cmd_thermal_set_threshold(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
static int get_num_fans(void)
|
||||
{
|
||||
int idx, rv;
|
||||
|
||||
for (idx = 0; idx < EC_FAN_SPEED_ENTRIES; idx++) {
|
||||
rv = read_mapped_mem16(EC_MEMMAP_FAN + 2 * idx);
|
||||
if (rv == EC_FAN_SPEED_NOT_PRESENT)
|
||||
break;
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
int cmd_thermal_auto_fan_ctrl(int argc, char *argv[])
|
||||
{
|
||||
int rv;
|
||||
int rv, num_fans;
|
||||
struct ec_params_auto_fan_ctrl_v1 p_v1;
|
||||
char *e;
|
||||
int cmdver = 1;
|
||||
|
||||
rv = ec_command(EC_CMD_THERMAL_AUTO_FAN_CTRL, 0, NULL, 0, NULL, 0);
|
||||
if (!ec_cmd_version_supported(EC_CMD_THERMAL_AUTO_FAN_CTRL, cmdver)
|
||||
|| (argc == 1)) {
|
||||
/* If no argument is provided then enable auto fan ctrl */
|
||||
/* for all fans by using version 0 of the host command */
|
||||
|
||||
rv = ec_command(EC_CMD_THERMAL_AUTO_FAN_CTRL, 0,
|
||||
NULL, 0, NULL, 0);
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
|
||||
printf("Automatic fan control is now on for all fans.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc > 2 || !strcmp(argv[1], "help")) {
|
||||
printf("Usage: %s [idx]\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
num_fans = get_num_fans();
|
||||
p_v1.fan_idx = strtol(argv[1], &e, 0);
|
||||
if ((e && *e) || (p_v1.fan_idx >= num_fans)) {
|
||||
fprintf(stderr, "Bad fan index.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = ec_command(EC_CMD_THERMAL_AUTO_FAN_CTRL, cmdver,
|
||||
&p_v1, sizeof(p_v1), NULL, 0);
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
|
||||
printf("Automatic fan control is now on.\n");
|
||||
printf("Automatic fan control is now on for fan %d\n", p_v1.fan_idx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1389,19 +1433,6 @@ static int print_fan(int idx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_num_fans(void)
|
||||
{
|
||||
int idx, rv;
|
||||
|
||||
for (idx = 0; idx < EC_FAN_SPEED_ENTRIES; idx++) {
|
||||
rv = read_mapped_mem16(EC_MEMMAP_FAN + 2 * idx);
|
||||
if (rv == EC_FAN_SPEED_NOT_PRESENT)
|
||||
break;
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
int cmd_pwm_get_num_fans(int argc, char *argv[])
|
||||
{
|
||||
int num_fans;
|
||||
|
||||
Reference in New Issue
Block a user