summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2019-01-17 16:01:29 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-01-28 14:17:07 -0800
commit2223f8723d0bb25e9637802b22232664e0d974af (patch)
tree75e39e4d858875b42ef77ddbff29a88b68e62aa8
parent10033d0f9dddc4863cbc2cc49aada8d356def28a (diff)
downloadchrome-ec-2223f8723d0bb25e9637802b22232664e0d974af.tar.gz
Fleex: Add new LED state for fully charged in S5
This change adds another battery LED state to represent a fully charged system in S5, so that fleex systems can have their LED off when this occurs. This state will be optional, and the state machine will fall back to using the previously defined FULL_CHARGE state if this new state is not defined. BUG=b:122636016 BRANCH=octopus TEST=flashed orbatrix and ensured LED went off in S5 after EC reported it was charged, flashed another octopus board to ensure it didn't regress Change-Id: I0265b268818e7f1ec20339afe5cf3544c882926b Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1419477 Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--baseboard/octopus/led_states.c23
-rw-r--r--baseboard/octopus/led_states.h4
-rw-r--r--board/fleex/led.c1
3 files changed, 25 insertions, 3 deletions
diff --git a/baseboard/octopus/led_states.c b/baseboard/octopus/led_states.c
index 8df4758d31..4836a1c18a 100644
--- a/baseboard/octopus/led_states.c
+++ b/baseboard/octopus/led_states.c
@@ -32,11 +32,17 @@ static enum led_states led_get_state(void)
else if (charge_lvl < led_charge_lvl_2)
new_state = STATE_CHARGING_LVL_2;
else
- new_state = STATE_CHARGING_FULL_CHARGE;
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ new_state = STATE_CHARGING_FULL_S5;
+ else
+ new_state = STATE_CHARGING_FULL_CHARGE;
break;
case PWR_STATE_DISCHARGE_FULL:
if (extpower_is_present()) {
- new_state = STATE_CHARGING_FULL_CHARGE;
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ new_state = STATE_CHARGING_FULL_S5;
+ else
+ new_state = STATE_CHARGING_FULL_CHARGE;
break;
}
/* Intentional fall-through */
@@ -59,7 +65,10 @@ static enum led_states led_get_state(void)
new_state = STATE_BATTERY_ERROR;
break;
case PWR_STATE_CHARGE_NEAR_FULL:
- new_state = STATE_CHARGING_FULL_CHARGE;
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ new_state = STATE_CHARGING_FULL_S5;
+ else
+ new_state = STATE_CHARGING_FULL_CHARGE;
break;
case PWR_STATE_IDLE: /* External power connected in IDLE */
if (charge_get_flags() & CHARGE_FLAG_FORCE_IDLE)
@@ -89,6 +98,14 @@ static void led_update_battery(void)
* continue using the previous one.
*/
if (desired_state != led_state && desired_state < LED_NUM_STATES) {
+ /*
+ * Allow optional CHARGING_FULL_S5 state to fall back to
+ * FULL_CHARGE if not defined.
+ */
+ if (desired_state == STATE_CHARGING_FULL_S5 &&
+ led_bat_state_table[desired_state][LED_PHASE_0].time == 0)
+ desired_state = STATE_CHARGING_FULL_CHARGE;
+
/* State is changing */
led_state = desired_state;
/* Reset ticks and period when state changes */
diff --git a/baseboard/octopus/led_states.h b/baseboard/octopus/led_states.h
index d9d9c8c235..72e8b37f73 100644
--- a/baseboard/octopus/led_states.h
+++ b/baseboard/octopus/led_states.h
@@ -28,11 +28,15 @@ enum led_phase {
* STATE_CHARGING_LVL_1 is when 0 <= charge_percentage < led_charge_level_1
* STATE_CHARGING_LVL_2 is when led_charge_level_1 <= charge_percentage < led_charge_level_2
* STATE_CHARGING_FULL_CHARGE is when led_charge_level_2 <= charge_percentage < 100
+ *
+ * STATE_CHARGING_FULL_S5 is optional and state machine will fall back to
+ * FULL_CHARGE if not defined
*/
enum led_states {
STATE_CHARGING_LVL_1,
STATE_CHARGING_LVL_2,
STATE_CHARGING_FULL_CHARGE,
+ STATE_CHARGING_FULL_S5,
STATE_DISCHARGE_S0,
STATE_DISCHARGE_S0_BAT_LOW,
STATE_DISCHARGE_S3,
diff --git a/board/fleex/led.c b/board/fleex/led.c
index 32a3855bd2..c658dc369e 100644
--- a/board/fleex/led.c
+++ b/board/fleex/led.c
@@ -23,6 +23,7 @@ struct led_descriptor led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = {
{LED_OFF, 1 * LED_ONE_SEC} },
[STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} },
[STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} },
+ [STATE_CHARGING_FULL_S5] = {{LED_OFF, LED_INDEFINITE} },
[STATE_DISCHARGE_S0] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} },
[STATE_DISCHARGE_S0_BAT_LOW] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC},
{LED_OFF, 1 * LED_ONE_SEC} },