summaryrefslogtreecommitdiff
path: root/common/led_onoff_states.c
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-04-16 12:02:12 -0600
committerCommit Bot <commit-bot@chromium.org>2021-04-22 22:30:32 +0000
commit4746791009b75da679d44d45e8487c57c9191329 (patch)
tree5401e9c35f6bae95373f5fa472680813dc69d47f /common/led_onoff_states.c
parent7fa18f56441dd596927845198ea61dbe164d7a00 (diff)
downloadchrome-ec-4746791009b75da679d44d45e8487c57c9191329.tar.gz
LED On/Off: Remove power LED config
Move the LED on/off module towards using a more flexible LED support approach. Define a weak power LED table and setter for boards to override when needed. Note that during run-time these functions will not get called since led_auto_control_is_enabled() will return false for nonexistent LEDs. This consumes an average of 165 additional bytes of flash space on boards which do not use a power LED. BRANCH=None BUG=b:185508707 TEST=make -j buildall, load on guybrush (battery LED only) and confirm no errors are seen. Load on Boten (both LEDs) and confirm behavior appears normal Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Iaa1e22a7f5d8be39eb8792ee13d358087d7f7482 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2832691 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/led_onoff_states.c')
-rw-r--r--common/led_onoff_states.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/common/led_onoff_states.c b/common/led_onoff_states.c
index 3c64882388..ef4ddbd2b5 100644
--- a/common/led_onoff_states.c
+++ b/common/led_onoff_states.c
@@ -142,7 +142,16 @@ static void led_update_battery(void)
led_set_color_battery(led_bat_state_table[led_state][phase].color);
}
-#ifdef CONFIG_LED_POWER_LED
+/*
+ * In order to support the power LED being optional, set up default power LED
+ * table and setter
+ */
+__overridable const struct led_descriptor
+ led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES];
+__overridable void led_set_color_power(enum ec_led_colors color)
+{
+}
+
static enum pwr_led_states pwr_led_get_state(void)
{
if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) {
@@ -201,7 +210,6 @@ static void led_update_power(void)
led_set_color_power(led_pwr_state_table[led_state][phase].color);
}
-#endif
static void led_init(void)
{
@@ -210,10 +218,8 @@ static void led_init(void)
led_set_color_battery(LED_OFF);
/* If power LED is enabled, set it to "off" to start with */
-#ifdef CONFIG_LED_POWER_LED
if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED))
led_set_color_power(LED_OFF);
-#endif /* CONFIG_LED_POWER_LED */
}
DECLARE_HOOK(HOOK_INIT, led_init, HOOK_PRIO_DEFAULT);
@@ -227,9 +233,7 @@ static void led_update(void)
*/
if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED))
led_update_battery();
-#ifdef CONFIG_LED_POWER_LED
if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED))
led_update_power();
-#endif
}
DECLARE_HOOK(HOOK_TICK, led_update, HOOK_PRIO_DEFAULT);