diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-06-06 09:18:45 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-06-07 01:29:53 +0000 |
commit | 49cc3902b06b10c03bb139fda864ca9b591f958a (patch) | |
tree | bb5617bce1eb3c759dee571b3acfe9a0a9d5e62d | |
parent | 57856ba2b31ca46c5f450abdcb5725939c40a529 (diff) | |
download | chrome-ec-49cc3902b06b10c03bb139fda864ca9b591f958a.tar.gz |
samus: allow charging of dead battery requesting nil
On samus battery, when the battery is dead it reports 0 for desired
voltage, current, and state of charge. In this case we should allow
charging.
Added a CONFIG option for this that should be removed as soon as
the battery side is fixed.
With this CL, when a dead samus battery is used and a charger is
connected, we attempt to charge it.
BUG=chrome-os-partner:29465
BRANCH=none
TEST=test on a samus with a dead battery. w/o this CL, the battery
never charges because the charging not allowed flag is set. With this
CL, the battery charges.
Change-Id: Ic61f27a27237166d33cb9ea5f024d3ef6360ce82
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202603
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r-- | board/samus/board.h | 2 | ||||
-rw-r--r-- | common/charge_state_v2.c | 15 | ||||
-rw-r--r-- | driver/battery/smart.c | 13 | ||||
-rw-r--r-- | include/config.h | 7 |
4 files changed, 37 insertions, 0 deletions
diff --git a/board/samus/board.h b/board/samus/board.h index 36e83f68c7..b914964e78 100644 --- a/board/samus/board.h +++ b/board/samus/board.h @@ -29,6 +29,8 @@ /* Note: not CONFIG_BACKLIGHT_LID. It's handled specially for Samus. */ #define CONFIG_BACKLIGHT_REQ_GPIO GPIO_PCH_BL_EN #define CONFIG_BATTERY_SAMUS +/* TODO(crosbug.com/p/29467): remove this workaround when possible. */ +#define CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD #define CONFIG_CHARGER_PROFILE_OVERRIDE #define CONFIG_BATTERY_SMART #define CONFIG_CHARGER diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 4a58aae54f..87ad28561b 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -570,6 +570,21 @@ void charger_task(void) goto wait_for_it; } else { /* The battery is responding. Yay. Try to use it. */ +#ifdef CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD + /* + * TODO (crosbug.com/p/29467): remove this workaround + * for dead battery that requests no voltage/current + */ + if (curr.requested_voltage == 0 && + curr.requested_current == 0 && + curr.batt.state_of_charge == 0) { + /* Battery is dead, give precharge current */ + curr.requested_voltage = + batt_info->voltage_max; + curr.requested_current = + batt_info->precharge_current; + } else +#endif if (curr.state == ST_PRECHARGE || battery_seems_to_be_dead) { CPRINTS("battery woke up"); diff --git a/driver/battery/smart.c b/driver/battery/smart.c index 52e61a8699..6dcedfd81f 100644 --- a/driver/battery/smart.c +++ b/driver/battery/smart.c @@ -300,9 +300,22 @@ void battery_get_params(struct batt_params *batt) if (!(batt_new.flags & (BATT_FLAG_BAD_DESIRED_VOLTAGE | BATT_FLAG_BAD_DESIRED_CURRENT | BATT_FLAG_BAD_STATE_OF_CHARGE)) && +#ifdef CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD + /* + * TODO (crosbug.com/p/29467): remove this workaround + * for dead battery that requests no voltage/current + */ + ((batt_new.desired_voltage && + batt_new.desired_current && + batt_new.state_of_charge < BATTERY_LEVEL_FULL) || + (batt_new.desired_voltage == 0 && + batt_new.desired_current == 0 && + batt_new.state_of_charge == 0))) +#else batt_new.desired_voltage && batt_new.desired_current && batt_new.state_of_charge < BATTERY_LEVEL_FULL) +#endif batt_new.flags |= BATT_FLAG_WANT_CHARGE; else /* Force both to zero */ diff --git a/include/config.h b/include/config.h index 86b43d2509..464ad50953 100644 --- a/include/config.h +++ b/include/config.h @@ -143,6 +143,13 @@ */ #undef CONFIG_BATTERY_VENDOR_PARAM +/* + * TODO(crosbug.com/p/29467): allows charging of a dead battery that + * requests nil for current and voltage. Remove this workaround when + * possible. + */ +#undef CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD + /*****************************************************************************/ /* |