diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-10-10 16:39:42 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-10-11 13:47:17 -0700 |
commit | d1bebbbe66f78d2dcfb9380456a80e7c2f26a662 (patch) | |
tree | d7e7e996bbebc8e70bd58a57c2b24e64683851ce /util | |
parent | bea56570f3105830a9df92cc7c9ea1185bf0dbef (diff) | |
download | chrome-ec-d1bebbbe66f78d2dcfb9380456a80e7c2f26a662.tar.gz |
Add host command to get/set TMP006 calibration data
Needed for host-based thermal control and tweaking.
BUG=chrome-os-partner:14955
BRANCH=link
TEST=manual
From a root shell,
ectool tmp006cal 0 3.5e-14 -2.8e-5 -5.5e-7 4.5e-9
ectool tmp006cal 2 3.6e-14 -2.9e-5 -5.6e-7 4.6e-9
ectool tmp006cal 0
S0: 3.500000e-14
b0: -2.800000e-05
b1: -5.500000e-07
b2: 4.500000e-09
ectool tmp006cal 2
S0: 3.600000e-14
b0: -2.900000e-05
b1: -5.600000e-07
b2: 4.600000e-09
At the ec console, "t6cal" should show the settings took effect as well.
Change-Id: If43b11e1e827483f0a20db1a2e5644f3475fd95e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35215
Diffstat (limited to 'util')
-rw-r--r-- | util/ectool.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c index 263477c951..fbfa9be214 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -128,6 +128,8 @@ const char help_str[] = " 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" + " tmp006cal <tmp006_index> [<S0> <b0> <b1> <b2>]\n" + " Get/set TMP006 calibration\n" " usbchargemode <port> <mode>\n" " Set USB charging mode\n" " version\n" @@ -2383,6 +2385,78 @@ static int cmd_keyconfig(int argc, char *argv[]) return 0; } +int cmd_tmp006cal(int argc, char *argv[]) +{ + struct ec_params_tmp006_set_calibration p; + char *e; + int idx; + int rv; + + if (argc < 2) { + fprintf(stderr, "Must specify tmp006 index.\n"); + return -1; + } + + idx = strtol(argv[1], &e, 0); + if ((e && *e) || idx < 0 || idx > 255) { + fprintf(stderr, "Bad index.\n"); + return -1; + } + + if (argc == 2) { + struct ec_params_tmp006_get_calibration pg; + struct ec_response_tmp006_get_calibration r; + + pg.index = idx; + + rv = ec_command(EC_CMD_TMP006_GET_CALIBRATION, 0, + &pg, sizeof(pg), &r, sizeof(r)); + if (rv < 0) + return rv; + + printf("S0: %e\n", r.s0); + printf("b0: %e\n", r.b0); + printf("b1: %e\n", r.b1); + printf("b2: %e\n", r.b2); + return EC_SUCCESS; + } + + if (argc != 6) { + fprintf(stderr, "Must specify all calibration params.\n"); + return -1; + } + + memset(&p, 0, sizeof(p)); + p.index = idx; + + p.s0 = strtod(argv[2], &e); + if (e && *e) { + fprintf(stderr, "Bad S0.\n"); + return -1; + } + + p.b0 = strtod(argv[3], &e); + if (e && *e) { + fprintf(stderr, "Bad b0.\n"); + return -1; + } + + p.b1 = strtod(argv[4], &e); + if (e && *e) { + fprintf(stderr, "Bad b1.\n"); + return -1; + } + + p.b2 = strtod(argv[5], &e); + if (e && *e) { + fprintf(stderr, "Bad b2.\n"); + return -1; + } + + return ec_command(EC_CMD_TMP006_SET_CALIBRATION, 0, + &p, sizeof(p), NULL, 0); +} + struct command { const char *name; int (*handler)(int argc, char *argv[]); @@ -2442,6 +2516,7 @@ const struct command commands[] = { {"tempsinfo", cmd_temp_sensor_info}, {"thermalget", cmd_thermal_get_threshold}, {"thermalset", cmd_thermal_set_threshold}, + {"tmp006cal", cmd_tmp006cal}, {"usbchargemode", cmd_usb_charge_set_mode}, {"version", cmd_version}, {"wireless", cmd_wireless}, |