diff options
author | Duncan Laurie <dlaurie@chromium.org> | 2013-08-09 13:45:36 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-08-09 13:51:59 -0700 |
commit | 3cd5e4cf7d6a5f5ffe55700e0d0fc6895c91bb5c (patch) | |
tree | b1d60fc435e7b7667d51a987bdf156c8b54119d2 | |
parent | e71ba403c4f1893b7f52b1d6b06b124d913833b4 (diff) | |
download | chrome-ec-3cd5e4cf7d6a5f5ffe55700e0d0fc6895c91bb5c.tar.gz |
Falco: Stop charging after a timeout of 10 hours
BUG=chrome-os-partner:20145
BRANCH=falco
TEST=Hack it. Add (uint64_t)599 * MINUTE to ctx->curr.ts.val
in the timeout comparison. This makes the 10 hour timeout only
take 1 minute. Testing this directly is tricky as a healthy battery
will charge quickly. If you force it to trickle charge it will
give up before 10 hours pass.
Original-Change-Id: I69094a07e58c2d65e322ddc6a1b2ced828da0e26
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64309
(cherry picked from commit 0d3bdc690e7ab3ed0ab190b0529e95c2bbba4e7e)
Change-Id: Ieaa310f67c0813a40ae71a81d9b42f4e01a68c2b
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65366
-rw-r--r-- | board/falco/board.h | 1 | ||||
-rw-r--r-- | common/charge_state.c | 10 | ||||
-rw-r--r-- | include/config.h | 9 |
3 files changed, 20 insertions, 0 deletions
diff --git a/board/falco/board.h b/board/falco/board.h index cb5190f8b3..8abf578cb7 100644 --- a/board/falco/board.h +++ b/board/falco/board.h @@ -157,6 +157,7 @@ enum x86_signal { #define CONFIG_CHARGER_SENSE_RESISTOR 10 /* Charge sense resistor, mOhm */ #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 /* Input sensor resistor, mOhm */ #define CONFIG_CHARGER_INPUT_CURRENT 4032 /* mA, about half max */ +#define CONFIG_CHARGER_TIMEOUT_HOURS 10 /* Max time to charge battery, hours */ enum adc_channel { /* EC internal die temperature in degrees K. */ diff --git a/common/charge_state.c b/common/charge_state.c index f7a644bfe3..f425bb6509 100644 --- a/common/charge_state.c +++ b/common/charge_state.c @@ -631,6 +631,16 @@ void charger_task(void) while (1) { state_common(ctx); +#ifdef CONFIG_CHARGER_TIMEOUT_HOURS + if (ctx->curr.state == PWR_STATE_CHARGE && + ctx->power_state_updated_time.val + + CONFIG_CHARGER_TIMEOUT_HOURS * HOUR < ctx->curr.ts.val) { + CPRINTF("[%T Charge timed out after %d hours]\n", + CONFIG_CHARGER_TIMEOUT_HOURS); + charge_force_idle(1); + } +#endif /* CONFIG_CHARGER_TIMEOUT_HOURS */ + switch (ctx->prev.state) { case PWR_STATE_INIT: case PWR_STATE_REINIT: diff --git a/include/config.h b/include/config.h index 635c47f9b3..4bfe375510 100644 --- a/include/config.h +++ b/include/config.h @@ -125,6 +125,15 @@ /* Value of the input current sense resistor, in mOhms */ #undef CONFIG_CHARGER_SENSE_RESISTOR_AC +/* + * Maximum time to charge the battery, in hours. + * + * If this timeout is reached, the charger will enter force-idle state. + * If not defined, charger will provide current until the battery asks it to + * stop. + */ +#undef CONFIG_CHARGER_TIMEOUT_HOURS + /*****************************************************************************/ /* Chipset config */ |