Avoid charging over battery's maximum voltage

When the battery doesn't report desired voltage, we should charge at the
minimum value of charger maximum voltage and battery maximum voltage.

BUG=chrome-os-partner:22055
TEST=Boot Kirby and check we are charging at 4.2V instead of 4.4V.
BRANCH=None

Change-Id: Ie520aa223d85c0690cc959522c4a46691aaa9a66
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168732
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vic Yang
2013-09-10 15:20:09 +08:00
committed by chrome-internal-fetch
parent 793b52f327
commit 057d71ae79

View File

@@ -306,7 +306,8 @@ static int state_common(struct power_state_context *ctx)
} else if (d) {
rv = battery_desired_voltage(&batt->desired_voltage);
if (rv == EC_ERROR_UNIMPLEMENTED)
batt->desired_voltage = ctx->charger->voltage_max;
batt->desired_voltage = MIN(ctx->charger->voltage_max,
ctx->battery->voltage_max);
else if (rv != EC_SUCCESS)
curr->error |= F_DESIRED_VOLTAGE;