summaryrefslogtreecommitdiff
path: root/board/burnet/led.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/burnet/led.c')
-rw-r--r--board/burnet/led.c53
1 files changed, 40 insertions, 13 deletions
diff --git a/board/burnet/led.c b/board/burnet/led.c
index 5b65d7b948..46dab20697 100644
--- a/board/burnet/led.c
+++ b/board/burnet/led.c
@@ -14,7 +14,13 @@
#define BAT_LED_ON 0
#define BAT_LED_OFF 1
-const enum ec_led_id supported_led_ids[] = {EC_LED_ID_BATTERY_LED};
+#define POWER_LED_ON 0
+#define POWER_LED_OFF 1
+
+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);
@@ -46,6 +52,21 @@ static int led_set_color_battery(enum led_color color)
return EC_SUCCESS;
}
+static int led_set_color_power(enum ec_led_colors color)
+{
+ switch (color) {
+ case LED_OFF:
+ ioex_set_level(IOEX_PWR_LED_WHITE_L, POWER_LED_OFF);
+ break;
+ case LED_WHITE:
+ ioex_set_level(IOEX_PWR_LED_WHITE_L, POWER_LED_ON);
+ break;
+ default:
+ return EC_ERROR_UNKNOWN;
+ }
+ return EC_SUCCESS;
+}
+
void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
{
brightness_range[EC_LED_COLOR_WHITE] = 1;
@@ -78,25 +99,28 @@ 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_tick;
+
+ power_tick++;
+
+ if (chipset_in_state(CHIPSET_STATE_ON))
+ led_set_color_power(LED_WHITE);
+ else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND))
+ led_set_color_power(
+ (power_tick & 0x2) ? LED_WHITE : LED_OFF);
+ else
+ led_set_color_power(LED_OFF);
+}
+
static void led_set_battery(void)
{
static int battery_ticks;
- static int power_ticks;
uint32_t chflags = charge_get_flags();
battery_ticks++;
- /* override battery led for system suspend */
- if (chipset_in_state(CHIPSET_STATE_SUSPEND |
- CHIPSET_STATE_STANDBY) &&
- charge_get_state() != PWR_STATE_CHARGE) {
- led_set_color_battery(power_ticks++ & 0x2 ?
- LED_WHITE : LED_OFF);
- return;
- }
-
- power_ticks = 0;
-
switch (charge_get_state()) {
case PWR_STATE_CHARGE:
led_set_color_battery(LED_AMBER);
@@ -141,6 +165,9 @@ static void led_set_battery(void)
/* Called by hook task every TICK */
static void led_tick(void)
{
+ if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED))
+ led_set_power();
+
if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED))
led_set_battery();
}