summaryrefslogtreecommitdiff
path: root/board/drawcia
diff options
context:
space:
mode:
authorDevin Lu <Devin.Lu@quantatw.com>2020-07-31 09:45:38 +0800
committerCommit Bot <commit-bot@chromium.org>2020-08-01 06:29:28 +0000
commit571d71ff7b7b7911b8b756e22ce52dc5d9febb9b (patch)
tree4ba0da16e1d8835274c3c9017d98e1ba5fc807ab /board/drawcia
parentc5513d539a889a29cb3e1168642cc44f24148e3c (diff)
downloadchrome-ec-571d71ff7b7b7911b8b756e22ce52dc5d9febb9b.tar.gz
drawcia: Add power led support
On drawcia, we have a LED indicator with following: System S0: White. System S0ix: Blinking white (1 sec on, 1 sec off) System S5/G3: Off. BUG=none BRANCH=none TEST=make sure led is showing white on system S0. make sure led is blinking white on S0ix. make sure led is OFF on S5/G3. Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: I38f8c4c06b5da1f050b9542667a54a26923ca222 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2331436 Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'board/drawcia')
-rw-r--r--board/drawcia/led.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/board/drawcia/led.c b/board/drawcia/led.c
index 1cd435b4b0..68242180fa 100644
--- a/board/drawcia/led.c
+++ b/board/drawcia/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,10 +52,34 @@ 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:
+ gpio_set_level(GPIO_PWR_LED_WHITE_L, POWER_LED_OFF);
+ break;
+ case LED_WHITE:
+ gpio_set_level(GPIO_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;
- brightness_range[EC_LED_COLOR_AMBER] = 1;
+ switch (led_id) {
+ case EC_LED_ID_BATTERY_LED:
+ brightness_range[EC_LED_COLOR_WHITE] = 1;
+ brightness_range[EC_LED_COLOR_AMBER] = 1;
+ break;
+ case EC_LED_ID_POWER_LED:
+ brightness_range[EC_LED_COLOR_WHITE] = 1;
+ break;
+ default:
+ break;
+ }
}
static int led_set_color(enum ec_led_id led_id, enum led_color color)
@@ -60,6 +90,9 @@ static int led_set_color(enum ec_led_id led_id, enum led_color color)
case EC_LED_ID_BATTERY_LED:
rv = led_set_color_battery(color);
break;
+ case EC_LED_ID_POWER_LED:
+ rv = led_set_color_power(color);
+ break;
default:
return EC_ERROR_UNKNOWN;
}
@@ -143,9 +176,27 @@ static void led_set_battery(void)
}
}
+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);
+}
+
/* 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();
}