diff options
author | Vic Yang <victoryang@chromium.org> | 2013-03-16 06:14:04 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-03-19 14:59:47 -0700 |
commit | 6e07f94c908aaaf0e490e48073878c6cfb4b3ba7 (patch) | |
tree | b6b48de659c98f288e63d63f3e935a105e259395 /common/pmu_tps65090_charger.c | |
parent | 24f0d888dd8110f7f0448b9dbeb47c13f5b1e298 (diff) | |
download | chrome-ec-6e07f94c908aaaf0e490e48073878c6cfb4b3ba7.tar.gz |
spring: More stable battery LED controlstabilize-3881.0.B
This includes:
- Discharging with AC present now recognized as battery assist mode
- Trigger LED update every second instead of from PMU task
- Minor breathing effect optimization
- Control LED power and color from the same task to prevent
simultaneous access to LED driver
BUG=chrome-os-partner:18244
TEST=Manual
BRANCH=spring
Change-Id: I9b34934f46cd4f04aaa7ca30cbe90316aec3e61e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45632
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/pmu_tps65090_charger.c')
-rw-r--r-- | common/pmu_tps65090_charger.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c index 9d3fea4630..732a5b6d98 100644 --- a/common/pmu_tps65090_charger.c +++ b/common/pmu_tps65090_charger.c @@ -54,6 +54,8 @@ static const char * const state_list[] = { static timestamp_t last_waken; /* Initialized to 0 */ static int has_pending_event; +static enum charging_state current_state = ST_IDLE; + static void enable_charging(int enable) { enable = enable ? 1 : 0; @@ -365,17 +367,14 @@ static int calc_next_state(int state) return ST_IDLE; } -int __board_battery_led(enum charging_state state) +/* TODO: Merge charge_state.h and unify charge interface */ +enum charging_state charge_get_state(void) { - return EC_SUCCESS; + return current_state; } -int board_battery_led(enum charging_state state) - __attribute__((weak, alias("__board_battery_led"))); - void pmu_charger_task(void) { - int state = ST_IDLE; int next_state; int wait_time = T1_USEC; unsigned int pre_charging_count = 0; @@ -421,20 +420,20 @@ void pmu_charger_task(void) * failed. */ next_state = pre_charging_count > PRE_CHARGING_RETRY ? - ST_CHARGING_ERROR : calc_next_state(state); + ST_CHARGING_ERROR : calc_next_state(current_state); - if (next_state != state) { + if (next_state != current_state) { /* Reset state of charge moving average window */ rsoc_moving_average(-1); pre_charging_count = 0; CPRINTF("[batt] state %s -> %s\n", - state_list[state], + state_list[current_state], state_list[next_state]); - state = next_state; + current_state = next_state; - switch (state) { + switch (current_state) { case ST_PRE_CHARGING: case ST_CHARGING: if (pmu_blink_led(0)) @@ -461,9 +460,7 @@ void pmu_charger_task(void) } } - board_battery_led(state); - - switch (state) { + switch (current_state) { case ST_CHARGING: case ST_CHARGING_ERROR: wait_time = T2_USEC; |