diff options
Diffstat (limited to 'board/veyron/led.c')
-rw-r--r-- | board/veyron/led.c | 86 |
1 files changed, 18 insertions, 68 deletions
diff --git a/board/veyron/led.c b/board/veyron/led.c index aebc2d3251..a50a716d3e 100644 --- a/board/veyron/led.c +++ b/board/veyron/led.c @@ -14,13 +14,13 @@ #include "util.h" 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); enum led_color { LED_OFF = 0, - LED_BLUE, + LED_GREEN, LED_ORANGE, LED_COLOR_COUNT /* Number of colors, not a color itself */ }; @@ -29,37 +29,16 @@ static int bat_led_set_color(enum led_color color) { switch (color) { case LED_OFF: - gpio_set_level(GPIO_CHARGING, 0); - gpio_set_level(GPIO_BAT_LED1, 0); - break; - case LED_BLUE: - gpio_set_level(GPIO_CHARGING, 0); + gpio_set_level(GPIO_BAT_LED0, 1); gpio_set_level(GPIO_BAT_LED1, 1); break; - case LED_ORANGE: - gpio_set_level(GPIO_CHARGING, 1); + case LED_GREEN: + gpio_set_level(GPIO_BAT_LED0, 1); gpio_set_level(GPIO_BAT_LED1, 0); break; - default: - return EC_ERROR_UNKNOWN; - } - return EC_SUCCESS; -} - -static int pwr_led_set_color(enum led_color color) -{ - switch (color) { - case LED_OFF: - gpio_set_level(GPIO_LED_POWER_L, 0); - gpio_set_level(GPIO_PWR_LED0, 0); - break; - case LED_BLUE: - gpio_set_level(GPIO_LED_POWER_L, 1); - gpio_set_level(GPIO_PWR_LED0, 0); - break; case LED_ORANGE: - gpio_set_level(GPIO_LED_POWER_L, 0); - gpio_set_level(GPIO_PWR_LED0, 1); + gpio_set_level(GPIO_BAT_LED0, 0); + gpio_set_level(GPIO_BAT_LED1, 1); break; default: return EC_ERROR_UNKNOWN; @@ -67,55 +46,28 @@ static int pwr_led_set_color(enum led_color color) return EC_SUCCESS; } + void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) { /* Ignoring led_id as both leds support the same colors */ - brightness_range[EC_LED_COLOR_BLUE] = 1; + brightness_range[EC_LED_COLOR_GREEN] = 1; brightness_range[EC_LED_COLOR_YELLOW] = 1; } int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) { - switch (led_id) { - case EC_LED_ID_BATTERY_LED: - if (brightness[EC_LED_COLOR_BLUE] != 0) - bat_led_set_color(LED_BLUE); + if (EC_LED_ID_BATTERY_LED == led_id) { + if (brightness[EC_LED_COLOR_GREEN] != 0) + bat_led_set_color(LED_GREEN); else if (brightness[EC_LED_COLOR_YELLOW] != 0) bat_led_set_color(LED_ORANGE); else bat_led_set_color(LED_OFF); - break; - case EC_LED_ID_POWER_LED: - if (brightness[EC_LED_COLOR_BLUE] != 0) - pwr_led_set_color(LED_BLUE); - else if (brightness[EC_LED_COLOR_YELLOW] != 0) - pwr_led_set_color(LED_ORANGE); - else - pwr_led_set_color(LED_OFF); - break; - default: + return EC_SUCCESS; + } else { return EC_ERROR_UNKNOWN; } - return EC_SUCCESS; -} - -static void veyron_led_set_power(void) -{ - static int power_second; - - power_second++; - /* PWR LED behavior: - * Power on: Blue - * Suspend: Orange in breeze mode ( 1 sec on/ 3 sec off) - * Power off: OFF - */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - pwr_led_set_color(LED_OFF); - else if (chipset_in_state(CHIPSET_STATE_ON)) - pwr_led_set_color(LED_BLUE); - else if (chipset_in_state(CHIPSET_STATE_SUSPEND)) - pwr_led_set_color((power_second & 3) ? LED_OFF : LED_ORANGE); } static void veyron_led_set_battery(void) @@ -152,14 +104,14 @@ static void veyron_led_set_battery(void) bat_led_set_color((battery_second & 1) ? LED_OFF : LED_ORANGE); break; case PWR_STATE_CHARGE_NEAR_FULL: - bat_led_set_color(LED_BLUE); + bat_led_set_color(LED_GREEN); break; case PWR_STATE_IDLE: /* External power connected in IDLE. */ if (chflags & CHARGE_FLAG_FORCE_IDLE) - bat_led_set_color( - (battery_second & 0x2) ? LED_BLUE : LED_ORANGE); + bat_led_set_color((battery_second & 0x2) + ? LED_GREEN : LED_ORANGE); else - bat_led_set_color(LED_BLUE); + bat_led_set_color(LED_GREEN); break; default: /* Other states don't alter LED behavior */ @@ -170,8 +122,6 @@ static void veyron_led_set_battery(void) /** * Called by hook task every 1 sec */ static void led_second(void) { - if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED)) - veyron_led_set_power(); if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) veyron_led_set_battery(); } |