scarlet: Clamp reported battery SOC when charge terminates

After we set TE (CL:958295), rt946x terminates charging when
the charge current is below IEOC in constant-voltage mode.

When AC is plugged and rt946x terminates, we see cases that
battery SOC falls below BATTERY_LEVEL_NEAR_FULL but rt946x doesn't
re-enable charging yet, which leads to amber LED. The Chrome OS UI
might also show battery is not full in this case.

Let's clamp the reported battery SOC in this scenario to
avoid user confusion.

BUG=b:77870927
BRANCH=scarlet
TEST=When AC is on, charge terminates, and BATTERY_LEVEL_NEAR_FULL
is hit, confirm battery SOC is overwritten.

Change-Id: I4575e562873d149d6f349ddb578334d107e21776
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1055194
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
This commit is contained in:
Philip Chen
2018-05-10 23:38:04 -07:00
committed by chrome-bot
parent 492b1aceeb
commit 163263c9a3

View File

@@ -242,6 +242,16 @@ int charger_profile_override(struct charge_state_data *curr)
break;
}
/*
* When the charger says it's done charging, even if fuel gauge says
* SOC < BATTERY_LEVEL_NEAR_FULL, we'll overwrite SOC with
* BATTERY_LEVEL_NEAR_FULL. So we can ensure both Chrome OS UI
* and battery LED indicate full charge.
*/
if (rt946x_is_charge_done())
curr->batt.state_of_charge = MAX(BATTERY_LEVEL_NEAR_FULL,
curr->batt.state_of_charge);
return 0;
}