diff options
author | Aaron Weng <aaron.weng@quantatw.com> | 2014-07-01 16:46:35 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-07-08 18:36:58 +0000 |
commit | 2b4b55f6f2d27f7009c4faf4eb5f2e153e6ffe6e (patch) | |
tree | 0f88f1e84ecb9d6635d343a9bb55404d9eb3085f | |
parent | 4ddc97da66797e8d8d66017fd9126b819b934f70 (diff) | |
download | chrome-ec-2b4b55f6f2d27f7009c4faf4eb5f2e153e6ffe6e.tar.gz |
Swanky: Supports Power LED blinking in S3 mode.
To implement the power led blinks in S3 mode when
lid is open.
BUG=chrome-os-partner:30107
BRANCH=rambi
TEST=make buildall -j and check the power led behavior is
correct on S3 and S0/S5 mode.
Signed-off-by: Aaron Weng <aaron.weng@quantatw.com>
Change-Id: I3a7a6d6e7e9cd11d2ecd352945c5f0f64bdbb048
Reviewed-on: https://chromium-review.googlesource.com/206084
Commit-Queue: Aaron Weng <aaron.weng@quantatw.com>
Tested-by: Aaron Weng <aaron.weng@quantatw.com>
Reviewed-by: Dave Parker <dparker@chromium.org>
-rw-r--r-- | board/swanky/led.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/board/swanky/led.c b/board/swanky/led.c index ebaa88bdf6..792ab6eacd 100644 --- a/board/swanky/led.c +++ b/board/swanky/led.c @@ -10,9 +10,13 @@ #include "gpio.h" #include "hooks.h" #include "led_common.h" +#include "lid_switch.h" #include "pwm.h" #include "util.h" +#define LED_TOTAL_TICKS 16 +#define LED_ON_TICKS 4 + const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED, EC_LED_ID_POWER_LED}; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); @@ -140,16 +144,44 @@ static void battery_led_tick(void) static void power_led_tick(void) { + static int power_ticks; + static int previous_state_suspend; + + /* If we don't control the LED, nothing to do */ if (!led_auto_control_is_enabled(EC_LED_ID_POWER_LED)) return; - if (chipset_in_state(CHIPSET_STATE_ON)) { - set_power_led_color(LED_WHITE); + power_ticks++; + + /* If lid close, LED turn off */ + if (!lid_is_open()) { + set_power_led_color(LED_OFF); return; } - set_power_led_color(LED_OFF); + 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. */ + set_power_led_color( + (power_ticks % LED_TOTAL_TICKS < LED_ON_TICKS) ? + LED_WHITE : LED_OFF); + + previous_state_suspend = 1; + return; + } + + previous_state_suspend = 0; + + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + set_power_led_color(LED_OFF); + else if (chipset_in_state(CHIPSET_STATE_ON)) + set_power_led_color(LED_WHITE); } |