diff options
author | Yilun Lin <yllin@google.com> | 2018-10-01 16:39:16 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-10-02 05:19:39 -0700 |
commit | fbb47e2bc63c1b84e1509b50e2169018a2701364 (patch) | |
tree | 96e4fbbf594a329d439153202abb225594d67701 | |
parent | d2d6f36adeab90692916b378839d71a09967fc5c (diff) | |
download | chrome-ec-fbb47e2bc63c1b84e1509b50e2169018a2701364.tar.gz |
max17055: Invalidate all batt info when batt not present.
BUG=b:117061273
TEST=on kukui, remove batt, connect pd, see battery output in console
> battery
Status: 0x0000
Param flags:000007fc
Temp: 0x0000 = 0.0 K (-273.1 C)
V: 0x0000 = 0 mV
V-desired: 0x0000 = 0 mV
I: 0x0000 = 0 mA
I-desired: 0x0000 = 0 mA
Charging: Not Allowed
Charge: 0 %
Manuf: <unkn>
Device: <BATT>
Chem: <unkn>
Serial: 0xffffffff
V-design: 0x0f14 = 3860 mV
Mode: (unsupported)
Abs charge:(unsupported)
Remaining: 6334 mAh
Cap-full: 6910 mAh
Design: 6910 mAh
Time-full: 0h:0
Empty: 102h:23
TEST=on connect batt, connect pd, see battery output in console
BRANCH=None
Change-Id: Ied338266fa0f7713da408438460bc97d4db01e6f
Signed-off-by: Yilun Lin <yllin@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1253372
Commit-Ready: Yilun Lin <yllin@chromium.org>
Tested-by: Yilun Lin <yllin@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r-- | driver/battery/max17055.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/driver/battery/max17055.c b/driver/battery/max17055.c index db8b798a3b..07ecc473dd 100644 --- a/driver/battery/max17055.c +++ b/driver/battery/max17055.c @@ -264,8 +264,19 @@ void battery_get_params(struct batt_params *batt) { int reg = 0; - /* Reset flags */ - batt->flags = 0; + /* Reset params */ + memset(batt, 0, sizeof(struct batt_params)); + /* + * Assuming the battery is responsive as long as + * max17055 finds battery is present. + */ + batt->is_present = battery_is_present(); + + if (batt->is_present == BP_YES) + batt->flags |= BATT_FLAG_RESPONSIVE; + else if (batt->is_present == BP_NO) + /* Battery is not present, gauge won't report useful info. */ + return; if (max17055_read(REG_TEMPERATURE, ®)) batt->flags |= BATT_FLAG_BAD_TEMPERATURE; @@ -299,15 +310,6 @@ void battery_get_params(struct batt_params *batt) batt->flags |= BATT_FLAG_BAD_FULL_CAPACITY; /* - * Assuming the battery is responsive as long as - * max17055 finds battery is present. - */ - batt->is_present = battery_is_present(); - - if (batt->is_present == BP_YES) - batt->flags |= BATT_FLAG_RESPONSIVE; - - /* * Charging allowed if both desired voltage and current are nonzero * and battery isn't full (and we read them all correctly). */ |