summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-09-10 15:20:09 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-09-11 03:45:04 +0000
commit057d71ae798b42613fc6bf61e17f8f6c83247ec0 (patch)
tree19322ca497ab38100ca6e9a646c918f99a80e963 /common
parent793b52f327b20ee5897dc04093ac30a5d000d6e9 (diff)
downloadchrome-ec-057d71ae798b42613fc6bf61e17f8f6c83247ec0.tar.gz
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>
Diffstat (limited to 'common')
-rw-r--r--common/charge_state.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/common/charge_state.c b/common/charge_state.c
index 02d670a7ed..e959c8cc57 100644
--- a/common/charge_state.c
+++ b/common/charge_state.c
@@ -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;