From 2b4b55f6f2d27f7009c4faf4eb5f2e153e6ffe6e Mon Sep 17 00:00:00 2001 From: Aaron Weng Date: Tue, 1 Jul 2014 16:46:35 +0800 Subject: 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 Change-Id: I3a7a6d6e7e9cd11d2ecd352945c5f0f64bdbb048 Reviewed-on: https://chromium-review.googlesource.com/206084 Commit-Queue: Aaron Weng Tested-by: Aaron Weng Reviewed-by: Dave Parker --- board/swanky/led.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'board/swanky/led.c') 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); } -- cgit v1.2.1