diff options
author | li feng <li1.feng@intel.com> | 2016-09-08 17:11:53 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-09-20 21:55:53 -0700 |
commit | ddb620ce4755caf456527f1933b83d54be41371e (patch) | |
tree | 906bde74e5d6022ad02ba8f6ad6dbcd5ca9bb343 | |
parent | cca986c9b4a3d078cfc8cfffd3201b32216a298d (diff) | |
download | chrome-ec-ddb620ce4755caf456527f1933b83d54be41371e.tar.gz |
reef led: correct battery LED behavior
Removed power LED support.
In case of discharging, if below critical level, LED should blink;
otherwise, will show power state;
In case of charging, will show charging/battery state.
BUG=chrome-os-partner:56932,chrome-os-partner:57025
BRANCH=none
TEST=Verified on EVT with <10% and <3% battery, LED is blinking
amber at proper duty cycle.
Also verified ectool led command works as expected.
Change-Id: I903396a9a1dc5e08618683f7124b09678678e233
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/383880
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | board/reef/led.c | 83 |
1 files changed, 26 insertions, 57 deletions
diff --git a/board/reef/led.c b/board/reef/led.c index ad1a16b073..17a63a9562 100644 --- a/board/reef/led.c +++ b/board/reef/led.c @@ -28,8 +28,7 @@ #define LED_ON_2SECS_TICKS 2 const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_BATTERY_LED, - EC_LED_ID_POWER_LED}; + EC_LED_ID_BATTERY_LED}; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); @@ -40,7 +39,7 @@ enum led_color { LED_COLOR_COUNT /* Number of colors, not a color itself */ }; -static int set_color(enum led_color color) +static int led_set_color_battery(enum led_color color) { switch (color) { case LED_OFF: @@ -67,27 +66,13 @@ void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) brightness_range[EC_LED_COLOR_AMBER] = 1; } -static inline int led_set_color_battery(enum led_color color) -{ - return set_color(color); -} - -static inline int led_set_color_power(enum led_color color) -{ - return set_color(color); -} - static int led_set_color(enum ec_led_id led_id, enum led_color color) { int rv; - led_auto_control(led_id, 0); switch (led_id) { case EC_LED_ID_BATTERY_LED: rv = led_set_color_battery(color); break; - case EC_LED_ID_POWER_LED: - rv = led_set_color_power(color); - break; default: return EC_ERROR_UNKNOWN; } @@ -106,44 +91,15 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) return EC_SUCCESS; } -static void led_set_power(void) -{ - static int power_ticks; - static int previous_state_suspend; - - power_ticks++; - if (chipset_in_state(CHIPSET_STATE_SUSPEND)) { - /* - * Reset ticks if entering suspend so LED turns amber - * as soon as possible. - */ - - if (!previous_state_suspend) - power_ticks = 0; - - /* Blink once every four seconds. */ - led_set_color_power( - (power_ticks % LED_TOTAL_4SECS_TICKS) - < LED_ON_1SEC_TICKS ? LED_AMBER : LED_OFF); - - previous_state_suspend = 1; - return; - } - - previous_state_suspend = 0; - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - led_set_color_power(LED_OFF); - else if (chipset_in_state(CHIPSET_STATE_ON)) - led_set_color_power(LED_BLUE); -} - static void led_set_battery(void) { static int battery_ticks; + static int suspend_ticks; + static int previous_state_suspend; uint32_t chflags = charge_get_flags(); battery_ticks++; - + suspend_ticks++; switch (charge_get_state()) { case PWR_STATE_CHARGE: led_set_color_battery(LED_AMBER); @@ -161,8 +117,25 @@ static void led_set_battery(void) led_set_color_battery( (battery_ticks % LED_TOTAL_4SECS_TICKS < LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); - else - led_set_color_battery(LED_OFF); + else { + if (chipset_in_state(CHIPSET_STATE_SUSPEND + | CHIPSET_STATE_STANDBY)) { + if (!previous_state_suspend) + suspend_ticks = 0; + /* Blink once every four seconds. */ + led_set_color_battery( + (suspend_ticks % LED_TOTAL_4SECS_TICKS) + < LED_ON_1SEC_TICKS ? + LED_AMBER : LED_OFF); + previous_state_suspend = 1; + return; + } + + if (chipset_in_state(CHIPSET_STATE_ON)) + led_set_color_battery(LED_BLUE); + else + led_set_color_battery(LED_OFF); + } break; case PWR_STATE_ERROR: led_set_color_battery( @@ -184,6 +157,7 @@ static void led_set_battery(void) /* Other states don't alter LED behavior */ break; } + previous_state_suspend = 0; } /* Called by hook task every 1 sec */ @@ -193,12 +167,7 @@ static void led_second(void) * Reference board only has one LED, so overload it to act as both * power LED and battery LED. */ - if (extpower_is_present() && - led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) + if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) led_set_battery(); - else if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED)) - led_set_power(); - else - set_color(LED_OFF); } DECLARE_HOOK(HOOK_SECOND, led_second, HOOK_PRIO_DEFAULT); |