mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 10:00:51 +00:00
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>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user