diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-09-20 15:56:56 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-09-21 00:36:19 -0700 |
commit | e97896945dc22681aaa11abadaace30d1a1396e7 (patch) | |
tree | 3ae835513043979f22113f1cfe712856db5b6956 | |
parent | ce74696f56171d43420c65030e5eeea6f06aa886 (diff) | |
download | chrome-ec-e97896945dc22681aaa11abadaace30d1a1396e7.tar.gz |
Only use trickle charging logic when battery is mostly discharged
At other times, the battery should follow the normal charging rules.
Using the trickle charging logic has 2 problems here:
1) Battery voltage is near maximum, so trickle charging logic starts
out with voltage less than the actual battery voltage, and less than
the charging spec.
2) Trickle charging only exits when battery requests more current
(which it won't if it's near full) or on 4-hour timeout, not when
battery reads 100%. So this can cause overcharging.
Note that we still limit the charging current to what the battery asks
for, but if that's less than the minimum current from the charger we
simply provide the minimum and don't fiddle with the voltage since
that may interfere with the battery's ability to determine it's fully
charged.
BUG=chrome-os-partner:14402
BRANCH=link
TEST=manual
1. charge laptop to full
2. quickly unplug and plug charger
3. look at debug log; should either not charge at all (if charge is currently
100%) or charge at 8400mV (if charge is less than 100%).
Change-Id: Ifd5a9eb2e9bb791f74196713b645d1c9211eb736
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33729
Reviewed-by: Rong Chang <rongchang@chromium.org>
-rw-r--r-- | common/charge_state.c | 11 | ||||
-rw-r--r-- | include/battery.h | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/common/charge_state.c b/common/charge_state.c index caa9caa6b6..e907d5e90a 100644 --- a/common/charge_state.c +++ b/common/charge_state.c @@ -331,14 +331,14 @@ static enum power_state state_idle(struct power_state_context *ctx) ctx->curr.charging_current) return PWR_STATE_INIT; - if (ctx->curr.batt.state_of_charge >= STOP_CHARGE_THRESHOLD) + if (batt->state_of_charge >= STOP_CHARGE_THRESHOLD) return PWR_STATE_UNCHANGE; /* Configure init charger state and switch to charge state */ - if (ctx->curr.batt.desired_voltage && - ctx->curr.batt.desired_current) { + if (batt->desired_voltage && batt->desired_current) { /* Set charger output constraints */ - if (batt->desired_current < ctx->charger->current_min) { + if (batt->desired_current < ctx->charger->current_min && + batt->state_of_charge < PRE_CHARGE_THRESHOLD) { /* Trickle charging */ if (charger_set_current(c_info->current_min) || charger_set_voltage(batt->voltage)) @@ -373,7 +373,8 @@ static enum power_state state_charge(struct power_state_context *ctx) return PWR_STATE_ERROR; if (batt->desired_current < c_info->current_min && - batt->desired_current > 0) + batt->desired_current > 0 && + batt->state_of_charge < PRE_CHARGE_THRESHOLD) return trickle_charge(ctx); /* Check charger reset */ diff --git a/include/battery.h b/include/battery.h index b5b3909abe..9f3cb4cad7 100644 --- a/include/battery.h +++ b/include/battery.h @@ -18,6 +18,8 @@ #define STOP_CHARGE_THRESHOLD 100 /* Threshold for power led to turn green */ #define POWERLED_GREEN_THRESHOLD 90 +/* Precharge only when state of charge is below this level */ +#define PRE_CHARGE_THRESHOLD 25 /* Define the lightbar color thresholds */ #define LIGHTBAR_POWER_THRESHOLD_FULL 99 |