summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-10-01 15:19:29 -0700
committerGerrit <chrome-bot@google.com>2012-10-01 23:50:16 -0700
commit56ce828309b2c7a15d032bd47b3deac39c7715ab (patch)
treee6e992196e00bcb4daa29602e72b2fc5b57e8084
parentbb66bec788c9447976d1be56f69a40b6c1ea36a3 (diff)
downloadchrome-ec-56ce828309b2c7a15d032bd47b3deac39c7715ab.tar.gz
link: Don't set power LED green until second idle
Currently, the charge state machine sets the power LED green the first time it hits IDLE. This causes the LED to briefly flash green when the adapter is inserted, because the state machine goes discharging->init->idle->charging. Instead, add a new idle0 state in between init and idle which does not set the power LED. This allows the state machine to go discharging->init->idle0->charging, so the LED only goes from off->yellow. If the system is actually fully charged, it'll go init->idle0->idle and show green. BUG=chrome-os-partner:14630 BRANCH=link TEST=manual - Remove adapter and allow system to discharge a bit - Insert adapter - Should see LED go from off directly to yellow - Wait for charge - Should see LED go green Change-Id: I9b77f01fad27c8574133211c9fe250486609f3c1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34387 Reviewed-by: Rong Chang <rongchang@chromium.org>
-rw-r--r--common/charge_state.c17
-rw-r--r--include/charge_state.h2
2 files changed, 18 insertions, 1 deletions
diff --git a/common/charge_state.c b/common/charge_state.c
index e97f03290b..c1454996cb 100644
--- a/common/charge_state.c
+++ b/common/charge_state.c
@@ -305,7 +305,7 @@ static enum power_state state_init(struct power_state_context *ctx)
/* Send battery event to host */
host_set_single_event(EC_HOST_EVENT_BATTERY);
- return PWR_STATE_IDLE;
+ return PWR_STATE_IDLE0;
}
/* Idle state handler
@@ -600,6 +600,11 @@ void charge_state_machine_task(void)
case PWR_STATE_INIT:
new_state = state_init(ctx);
break;
+ case PWR_STATE_IDLE0:
+ new_state = state_idle(ctx);
+ if (new_state == PWR_STATE_UNCHANGE)
+ new_state = PWR_STATE_IDLE;
+ break;
case PWR_STATE_IDLE:
new_state = state_idle(ctx);
break;
@@ -620,6 +625,7 @@ void charge_state_machine_task(void)
}
if (state_machine_force_idle &&
+ ctx->prev.state != PWR_STATE_IDLE0 &&
ctx->prev.state != PWR_STATE_IDLE &&
ctx->prev.state != PWR_STATE_INIT)
new_state = PWR_STATE_INIT;
@@ -633,6 +639,15 @@ void charge_state_machine_task(void)
switch (new_state) {
+ case PWR_STATE_IDLE0:
+ /*
+ * First time transitioning from init -> idle. Don't
+ * set the flags or LED yet because we may transition
+ * to charging on the next call and we don't want to
+ * blink the LED green.
+ */
+ sleep_usec = POLL_PERIOD_SHORT;
+ break;
case PWR_STATE_IDLE:
batt_flags = *ctx->memmap_batt_flags;
batt_flags &= ~EC_BATT_FLAG_CHARGING;
diff --git a/include/charge_state.h b/include/charge_state.h
index 4810a01c50..9b4e6d364f 100644
--- a/include/charge_state.h
+++ b/include/charge_state.h
@@ -50,6 +50,7 @@
enum power_state {
PWR_STATE_UNCHANGE = 0,
PWR_STATE_INIT,
+ PWR_STATE_IDLE0,
PWR_STATE_IDLE,
PWR_STATE_DISCHARGE,
PWR_STATE_CHARGE,
@@ -63,6 +64,7 @@ enum power_state {
{ \
"unchange", \
"init", \
+ "idle0", \
"idle", \
"discharge", \
"charge", \