diff options
author | ZhengShunQian <zhengsq@rock-chips.com> | 2015-03-22 14:02:35 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-03-31 06:32:14 +0000 |
commit | a4c4a2e7abf630612fa62497fdbd982cf1094a24 (patch) | |
tree | cf5ea0afb11672b69c711d6765aeaadc09aa3933 | |
parent | fe293908edbac37396d1c205dde7ba1a9adff011 (diff) | |
download | chrome-ec-a4c4a2e7abf630612fa62497fdbd982cf1094a24.tar.gz |
mighty: fix the LED bug of removed battery
Clear curr.batt_is_charging when the battery is not present.
Add a new batt_was_removed flag to track when the battery has been
removed. This causes PWR_STATE_ERROR so the LED shows error state,
and triggers re-reading the static parameters from the battery when
it's reattached.
BUG=chrome-os-partner:38235
TEST=check the LED state on mighty
BRANCH=veyron
Change-Id: I400c22eda4bc0043adf7217166bd9f80c557d991
Signed-off-by: ZhengShunQian <zhengsq@rock-chips.com>
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/262007
Commit-Queue: Gediminas Ramanauskas <gedis@chromium.org>
Tested-by: Gediminas Ramanauskas <gedis@chromium.org>
(cherry picked from commit 6727e1dba2aafa81fa9572145413545106ae9626)
Reviewed-on: https://chromium-review.googlesource.com/262140
-rw-r--r-- | common/charge_state_v2.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index f693f99482..27bdbab410 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -46,8 +46,20 @@ static int manual_mode; /* volt/curr are no longer maintained by charger */ static unsigned int user_current_limit = -1U; test_export_static timestamp_t shutdown_warning_time; static timestamp_t precharge_start_time; + +/* Is battery connected but unresponsive after precharge? */ static int battery_seems_to_be_dead; + static int battery_seems_to_be_disconnected; + +/* + * Was battery removed? Set when we see BP_NO, cleared after the battery is + * reattached and becomes responsive. Used to indicate an error state after + * removal and trigger re-reading the battery static info when battery is + * reattached and responsive. + */ +static int battery_was_removed; + static int problems_exist; static int debugging; static int fake_state_of_charge = -1; @@ -307,6 +319,7 @@ static void dump_charge_state(void) ccprintf("battery_seems_to_be_dead = %d\n", battery_seems_to_be_dead); ccprintf("battery_seems_to_be_disconnected = %d\n", battery_seems_to_be_disconnected); + ccprintf("battery_was_removed = %d\n", battery_was_removed); ccprintf("debug output = %s\n", debugging ? "on" : "off"); #undef DUMP } @@ -657,6 +670,8 @@ void charger_task(void) if (curr.batt.is_present == BP_NO) { ASSERT(curr.ac); /* How are we running? */ curr.state = ST_IDLE; + curr.batt_is_charging = 0; + battery_was_removed = 1; goto wait_for_it; } @@ -759,15 +774,16 @@ void charger_task(void) } else #endif if (curr.state == ST_PRECHARGE || - battery_seems_to_be_dead) { + battery_seems_to_be_dead || + battery_was_removed) { CPRINTS("battery woke up"); /* Update the battery-specific values */ batt_info = battery_get_info(); need_static = 1; - } + } - battery_seems_to_be_dead = 0; + battery_seems_to_be_dead = battery_was_removed = 0; curr.state = ST_CHARGE; } @@ -916,7 +932,7 @@ enum charge_state charge_get_state(void) { switch (curr.state) { case ST_IDLE: - if (battery_seems_to_be_dead) + if (battery_seems_to_be_dead || battery_was_removed) return PWR_STATE_ERROR; return PWR_STATE_IDLE; case ST_DISCHARGE: |