summaryrefslogtreecommitdiff
path: root/common/led_onoff_states.c
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-04-16 15:18:28 -0600
committerCommit Bot <commit-bot@chromium.org>2021-04-23 15:49:38 +0000
commit33fa1073fd5d944f5199bfcccc5a6fc9a782739a (patch)
treedf276ededdaa6f9febe2455533d217bd7882d716 /common/led_onoff_states.c
parent964b2d90ffc87a2366a0d2e436bef65ed2dcc84f (diff)
downloadchrome-ec-33fa1073fd5d944f5199bfcccc5a6fc9a782739a.tar.gz
LED On/Off: Add state for off with insufficient power
Add a common state to communicate that we're off due to insufficient power. If not defined, allow this state to fall back to OFF since many systems with batteries will be using the battery LED to communicate this information. BRANCH=None BUG=b:185508707 TEST=on boten, confirm no regressions with fake low battery in S5 Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ie8b37785a43fdfdd6619fe72c8bd7e2be6776e43 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2832694 Reviewed-by: Rob Barnes <robbarnes@google.com> Commit-Queue: Rob Barnes <robbarnes@google.com>
Diffstat (limited to 'common/led_onoff_states.c')
-rw-r--r--common/led_onoff_states.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/common/led_onoff_states.c b/common/led_onoff_states.c
index eea527373d..7b699b4fea 100644
--- a/common/led_onoff_states.c
+++ b/common/led_onoff_states.c
@@ -14,6 +14,7 @@
#include "hooks.h"
#include "led_common.h"
#include "led_onoff_states.h"
+#include "system.h"
#define CPRINTS(format, args...) cprints(CC_GPIO, format, ## args)
@@ -180,7 +181,10 @@ static enum pwr_led_states pwr_led_get_state(void)
else
return PWR_LED_STATE_SUSPEND_NO_AC;
} else if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
- return PWR_LED_STATE_OFF;
+ if (system_can_boot_ap())
+ return PWR_LED_STATE_OFF;
+ else
+ return PWR_LED_STATE_OFF_LOW_POWER;
} else if (chipset_in_state(CHIPSET_STATE_ON)) {
return PWR_LED_STATE_ON;
}
@@ -200,6 +204,14 @@ static void led_update_power(void)
* Otherwise, continue to use old state
*/
if (desired_state != led_state && desired_state < PWR_LED_NUM_STATES) {
+ /*
+ * Allow optional OFF_LOW_POWER state to fall back to
+ * OFF not defined, as indicated by no specified phase 0 time.
+ */
+ if (desired_state == PWR_LED_STATE_OFF_LOW_POWER &&
+ led_bat_state_table[desired_state][LED_PHASE_0].time == 0)
+ desired_state = PWR_LED_STATE_OFF;
+
/* State is changing */
led_state = desired_state;
/* Reset ticks and period when state changes */