diff options
author | Bruce <Bruce.Wan@quantatw.com> | 2017-03-14 18:42:57 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-03-16 22:28:21 -0700 |
commit | 80cb93f45d396d797a47ab478dd62f9d29be7b3b (patch) | |
tree | 39fa495bd44e8df7ab24db0be90882e495f239a0 /util | |
parent | c4fe1efc2cfca39cc679b5b9f3f5d6d6c4f503e7 (diff) | |
download | chrome-ec-80cb93f45d396d797a47ab478dd62f9d29be7b3b.tar.gz |
pyro: battery FW update tool modify for learning mode
Let unit can't update battery FW when battery state in learning mode.
BUG=b:36372859
BRANCH=reef
TEST=check unit can't update battery FW in learning mode.
Change-Id: I9d69811d84fc386cda6adb51be51f1cfb4fcdf55
Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/454656
Commit-Ready: Keith Tzeng <keith.tzeng@quantatw.com>
Tested-by: Keith Tzeng <keith.tzeng@quantatw.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/ec_sb_firmware_update.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/util/ec_sb_firmware_update.c b/util/ec_sb_firmware_update.c index 538d575f07..54b7ff1567 100644 --- a/util/ec_sb_firmware_update.c +++ b/util/ec_sb_firmware_update.c @@ -72,7 +72,8 @@ enum { F_UPDATE = 0x4, /* do firmware update */ F_NEED_UPDATE = 0x8, /* need firmware update */ F_POWERD_DISABLED = 0x10, /* powerd is disabled */ - F_LFCC_ZERO = 0x20 /* last full charge is zero */ + F_LFCC_ZERO = 0x20, /* last full charge is zero */ + F_BATT_DISCHARGE = 0x40 /* battery discharging */ }; struct fw_update_ctrl { @@ -471,6 +472,20 @@ static enum fw_update_state s1_read_battery_info( "Require AC Adapter Counnected."); return S10_TERMINAL; } + + if ((fw_update->flags & F_BATT_DISCHARGE) && + (fw_update->flags & F_AC_PRESENT)) { + /* + * If battery discharge due to battery learning mode, + * we can't update battery FW, because device will shutdown + * during FW update. + */ + fw_update->rv = 0; + log_msg(fw_update, S1_READ_INFO, + "battery can't update in learning mode"); + return S10_TERMINAL; + } + return S2_WRITE_PREPARE; } @@ -790,6 +805,11 @@ int main(int argc, char *argv[]) printf("AC_PRESENT\n"); } } + + if (val & EC_BATT_FLAG_DISCHARGING) { + fw_update.flags |= F_BATT_DISCHARGE; + printf("Battery is in discharge state\n"); + } rv = ec_readmem(EC_MEMMAP_BATT_LFCC, sizeof(val), &val); if (rv <= 0) { printf("EC Memmap read error:%d\n", rv); |