summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2020-06-25 12:50:49 -0700
committerCommit Bot <commit-bot@chromium.org>2020-06-30 01:43:13 +0000
commit06dd6614be859a9225dd6263b476d5e0025a9efa (patch)
tree1e8ff8df13ceca2b87f5f3fe01efe3b396163b85 /util
parent7b8e3250134bff29a9b4d29254a9945a37309dbb (diff)
downloadchrome-ec-06dd6614be859a9225dd6263b476d5e0025a9efa.tar.gz
ectool: Show smartdischarge thresholds by charge %
Currently, the smartdischarge command prints cutoff and stay-up thresholds by the remaining capacity. This CL makes it print the thresholds by the state of charge as well. $ ectool smartdischarge 2880 1150 65 Hours to zero capacity: 2880 h Stay-up threshold: 3312 mAh (64 %) Cutoff threshold: 187 mAh (3 %) Hibernate discharge rate: 1150 uA Cutoff discharge rate: 65 uA BUG=b:152431365, b:157602162 BRANCH=none TEST=See above Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I9aa163eab861f766a8f1120481c0e1db2608aa77 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2268280 Reviewed-by: Mengqi Guo <mqg@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
Diffstat (limited to 'util')
-rwxr-xr-xutil/ectool.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/util/ectool.c b/util/ectool.c
index ed1c932f9b..b76dc3aecd 100755
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -2604,6 +2604,7 @@ int cmd_smart_discharge(int argc, char *argv[])
{
struct ec_params_smart_discharge *p = ec_outbuf;
struct ec_response_smart_discharge *r = ec_inbuf;
+ uint32_t cap;
char *e;
int rv;
@@ -2642,9 +2643,18 @@ int cmd_smart_discharge(int argc, char *argv[])
perror("ERROR: EC_CMD_SMART_DISCHARGE failed");
return rv;
}
+
+ cap = read_mapped_mem32(EC_MEMMAP_BATT_LFCC);
+ if (!is_battery_range(cap)) {
+ perror("WARN: Failed to read battery capacity");
+ cap = 0;
+ }
+
printf("%-27s %5d h\n", "Hours to zero capacity:", r->hours_to_zero);
- printf("%-27s %5d mAh\n", "Stay-up threshold:", r->dzone.stayup);
- printf("%-27s %5d mAh\n", "Cutoff threshold:", r->dzone.cutoff);
+ printf("%-27s %5d mAh (%d %%)\n", "Stay-up threshold:",
+ r->dzone.stayup, cap > 0 ? r->dzone.stayup * 100 / cap : -1);
+ printf("%-27s %5d mAh (%d %%)\n", "Cutoff threshold:",
+ r->dzone.cutoff, cap > 0 ? r->dzone.cutoff * 100 / cap : -1);
printf("%-27s %5d uA\n", "Hibernate discharge rate:", r->drate.hibern);
printf("%-27s %5d uA\n", "Cutoff discharge rate:", r->drate.cutoff);