diff options
author | Vic Yang <victoryang@chromium.org> | 2012-02-29 10:04:46 -0800 |
---|---|---|
committer | Vic Yang <victoryang@chromium.org> | 2012-02-29 14:42:45 -0800 |
commit | 747b1f752007d6563288f7be41c20b8cc43ca3f6 (patch) | |
tree | a2137b57819b3eb368c95a3ed2956ff6485d10c7 /util | |
parent | 13b5c41951c2da3e90ac115a3dbe8aaddb959782 (diff) | |
download | chrome-ec-747b1f752007d6563288f7be41c20b8cc43ca3f6.tar.gz |
Thermal Engine: LPC commands.
Implement LPC commands and ectool commands to
1. Set/get threshold temperature values.
2. Toggle on/off automatic fan speed control.
Signed-off-by: Vic Yang <victoryang@chromium.org>
BUG=chrome-os-partner:8251
TEST=Manual test
Change-Id: Ia4282a6fa47a838aed26540f33c1eb7acc92ef0e
Diffstat (limited to 'util')
-rw-r--r-- | util/ectool.c | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c index 676bcc4fe8..a7ebee84a3 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -42,6 +42,12 @@ const char help_str[] = " Prints EC version\n" " temps <sensorid>\n" " Print temperature.\n" + " thermalget <sensor_id> <threshold_id>\n" + " Get the threshold temperature value from thermal engine.\n" + " thermalset <sensor_id> <threshold_id> <value>\n" + " Set the threshold temperature value for thermal engine.\n" + " autofanctrl <on>\n" + " Turn on automatic fan speed control.\n" " pwmgetfanrpm\n" " Prints current fan RPM\n" " pwmsetfanrpm <targetrpm>\n" @@ -531,6 +537,101 @@ int cmd_temperature(int argc, char *argv[]) } +int cmd_thermal_get_threshold(int argc, char *argv[]) +{ + struct lpc_params_thermal_get_threshold p; + struct lpc_response_thermal_get_threshold r; + char *e; + int rv; + + if (argc != 2) { + fprintf(stderr, "Usage: thermalget <sensorid> <thresholdid>\n"); + return -1; + } + + p.sensor_id = strtol(argv[0], &e, 0); + if (e && *e) { + fprintf(stderr, "Bad sensor ID.\n"); + return -1; + } + + p.threshold_id = strtol(argv[1], &e, 0); + if (e && *e) { + fprintf(stderr, "Bad threshold ID.\n"); + return -1; + } + + rv = ec_command(EC_LPC_COMMAND_THERMAL_GET_THRESHOLD, + &p, sizeof(p), &r, sizeof(r)); + if (rv) + return rv; + + if (r.value < 0) + return -1; + + printf("Threshold %d for sensor %d is %d K.\n", + p.threshold_id, p.sensor_id, r.value); + + return 0; +} + + +int cmd_thermal_set_threshold(int argc, char *argv[]) +{ + struct lpc_params_thermal_set_threshold p; + char *e; + int rv; + + if (argc != 3) { + fprintf(stderr, + "Usage: thermalset <sensorid> <thresholdid> <value>\n"); + return -1; + } + + p.sensor_id = strtol(argv[0], &e, 0); + if (e && *e) { + fprintf(stderr, "Bad sensor ID.\n"); + return -1; + } + + p.threshold_id = strtol(argv[1], &e, 0); + if (e && *e) { + fprintf(stderr, "Bad threshold ID.\n"); + return -1; + } + + p.value = strtol(argv[2], &e, 0); + if (e && *e) { + fprintf(stderr, "Bad threshold value.\n"); + return -1; + } + + rv = ec_command(EC_LPC_COMMAND_THERMAL_SET_THRESHOLD, + &p, sizeof(p), NULL, 0); + if (rv) + return rv; + + printf("Threshold %d for sensor %d set to %d.\n", + p.threshold_id, p.sensor_id, p.value); + + return 0; +} + + +int cmd_thermal_auto_fan_ctrl(int argc, char *argv[]) +{ + int rv; + + rv = ec_command(EC_LPC_COMMAND_THERMAL_AUTO_FAN_CTRL, + NULL, 0, NULL, 0); + if (rv) + return rv; + + printf("Automatic fan control is now on.\n"); + return 0; +} + + int cmd_pwm_get_fan_rpm(void) { int rv; @@ -802,6 +903,12 @@ int main(int argc, char *argv[]) return cmd_version(); if (!strcasecmp(argv[1], "temps")) return cmd_temperature(argc - 2, argv + 2); + if (!strcasecmp(argv[1], "thermalget")) + return cmd_thermal_get_threshold(argc - 2, argv + 2); + if (!strcasecmp(argv[1], "thermalset")) + return cmd_thermal_set_threshold(argc - 2, argv + 2); + if (!strcasecmp(argv[1], "autofanctrl")) + return cmd_thermal_auto_fan_ctrl(argc - 2, argv + 2); if (!strcasecmp(argv[1], "pwmgetfanrpm")) return cmd_pwm_get_fan_rpm(); if (!strcasecmp(argv[1], "pwmsetfanrpm")) |