diff options
author | Henry Hsu <Henry.Hsu@quantatw.com> | 2013-09-09 13:11:48 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-10-01 00:57:36 +0000 |
commit | 61822f327e1245698fd6207ca3c644fe5b1aa631 (patch) | |
tree | 72f192de499b5458d72e5c29e45899e971daf17d | |
parent | 95494966db9009e59be7e263d26928bfac0a67be (diff) | |
download | chrome-ec-61822f327e1245698fd6207ca3c644fe5b1aa631.tar.gz |
Update Wolf led behavior
The SPEC is
1. When plugged in and charging, the battery charge LED illuminates
while. When the system reaches full charge, the LED extinguishes.
2. When not plugged in and in a low power state, the battery LED
illuminates Amber.
3. When not plugged in and not in a low power state, the LED behavior
is Amber.
4. When battery error, the LED behavior is RED.
5. The near full charge state, the LED extinguishes.
6. Low battery state behavior is Amber.
But item 4 should be modified because of inexistence of RED led,
Now let it blink amber quickly instead.
BUG=chrome-os-partner:22043
BRANCH=Wolf
TEST=manual
Change-Id: Ice0a2dd5e5aa5101c9f18e82e688f686d1b64dbe
Signed-off-by: Henry Hsu <Henry.Hsu@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/168424
Reviewed-by: Dave Parker <daveparker+DONTUSE@gmail.com>
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
Commit-Queue: 志偉 黃 <David.Huang@quantatw.com>
-rw-r--r-- | common/build.mk | 2 | ||||
-rw-r--r-- | common/led_wolf.c | 76 |
2 files changed, 77 insertions, 1 deletions
diff --git a/common/build.mk b/common/build.mk index 86742794f9..d2d72185aa 100644 --- a/common/build.mk +++ b/common/build.mk @@ -18,7 +18,7 @@ common-$(BOARD_peppy)+=battery_peppy.o led_common.o led_peppy.o common-$(BOARD_slippy)+=battery_slippy.o led_slippy.o common-$(BOARD_snow)+=extpower_snow.o common-$(BOARD_spring)+=battery_spring.o -common-$(BOARD_wolf)+=battery_wolf.o led_slippy.o +common-$(BOARD_wolf)+=battery_wolf.o led_wolf.o common-$(CONFIG_BACKLIGHT_X86)+=backlight_x86.o common-$(CONFIG_BATTERY_BQ20Z453)+=battery_bq20z453.o diff --git a/common/led_wolf.c b/common/led_wolf.c new file mode 100644 index 0000000000..9212d467ac --- /dev/null +++ b/common/led_wolf.c @@ -0,0 +1,76 @@ +/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Power and battery LED control for Wolf. + */ + +#include "battery.h" +#include "charge_state.h" +#include "chipset.h" +#include "gpio.h" +#include "hooks.h" + +enum led_color { + LED_OFF = 0, + LED_WHITE, + LED_AMBER, + LED_COLOR_COUNT /* Number of colors, not a color itself */ +}; + +static int bat_led_set_color(enum led_color color) +{ + switch (color) { + case LED_OFF: + gpio_set_level(GPIO_BAT_LED0_L, 1); + gpio_set_level(GPIO_BAT_LED1_L, 1); + break; + case LED_WHITE: + gpio_set_level(GPIO_BAT_LED0_L, 0); + gpio_set_level(GPIO_BAT_LED1_L, 1); + break; + case LED_AMBER: + gpio_set_level(GPIO_BAT_LED0_L, 1); + gpio_set_level(GPIO_BAT_LED1_L, 0); + break; + default: + return EC_ERROR_UNKNOWN; + } + return EC_SUCCESS; +} + +/* Called by hook task every 250mSec */ +static void led_tick(void) +{ + static int ticks; + uint32_t chflags = charge_get_flags(); + + ticks++; + + switch (charge_get_state()) { + case PWR_STATE_CHARGE: + bat_led_set_color(LED_WHITE); + break; + case PWR_STATE_CHARGE_NEAR_FULL: + bat_led_set_color(LED_OFF); + break; + case PWR_STATE_DISCHARGE: + bat_led_set_color(LED_AMBER); + break; + case PWR_STATE_ERROR: + /*FIXME Now keep blink amber till the new spec arrival */ + bat_led_set_color((ticks & 0x2) ? LED_AMBER : LED_OFF); + break; + case PWR_STATE_IDLE: + if (chflags & CHARGE_FLAG_FORCE_IDLE) + bat_led_set_color((ticks & 0x4) ? LED_WHITE : LED_OFF); + else + bat_led_set_color(LED_OFF); + break; + default: + /* Other states don't alter LED behavior */ + break; + } +} +DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT); + |