summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommy Chung <tommy.chung@quanta.corp-partner.google.com>2021-10-04 11:29:02 +0800
committerCommit Bot <commit-bot@chromium.org>2021-10-27 09:14:47 +0000
commitf35f5e36581b3ec630a2e6f19dc68e5ff8573bc3 (patch)
tree1a37384ac383e14942d6f327819dd8336a2c565a
parent25bc0d1cc657960ee6a92cebdecd7439ba5744d5 (diff)
downloadchrome-ec-f35f5e36581b3ec630a2e6f19dc68e5ff8573bc3.tar.gz
kingoftown: Update led config
LED policies for kingoftown are defined in the following BUG tracker. This CL is updated to meet the policies. BUG=b:202464175 BRANCH=trogdor TEST=make sure that C0/C1 LED behaviors correct when 1. DC mode 2. DC mode when system suspend 3. AC mode when charging 4. AC mode when fully charging 5. AC mode when fully charging and system suspend 6. AC mode when battery is not present 7. AC mode and force idle. Signed-off-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com> Change-Id: I8e0eb03ba209194f2b47d6d32f64b44d1be1af1b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3199437 Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Devin Lu <Devin.Lu@quantatw.com>
-rw-r--r--board/kingoftown/led.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/board/kingoftown/led.c b/board/kingoftown/led.c
index 295c8effeb..fc578684f9 100644
--- a/board/kingoftown/led.c
+++ b/board/kingoftown/led.c
@@ -17,6 +17,11 @@
#include "system.h"
#include "util.h"
+/* Times of tick per 1 second */
+#define TIMES_TICK_ONE_SEC (1000 / HOOK_TICK_INTERVAL_MS)
+/* Times of tick per half second */
+#define TIMES_TICK_HALF_SEC (500 / HOOK_TICK_INTERVAL_MS)
+
#define BAT_LED_ON 1
#define BAT_LED_OFF 0
@@ -90,10 +95,32 @@ static void set_active_port_color(enum led_color color)
static void board_led_set_battery(void)
{
static int battery_ticks;
+ static int power_ticks;
+ int led_blink_cycle;
uint32_t chflags = charge_get_flags();
battery_ticks++;
+ /*
+ * Override battery LED for kingoftown which doesn't have power LED,
+ * blinking battery white LED to indicate system suspend without
+ * charging.
+ */
+ if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) &&
+ charge_get_state() != PWR_STATE_CHARGE) {
+
+ power_ticks++;
+ led_blink_cycle = power_ticks % (2 * TIMES_TICK_ONE_SEC);
+
+ side_led_set_color(0, (led_blink_cycle < TIMES_TICK_ONE_SEC) ?
+ LED_WHITE : LED_OFF);
+ side_led_set_color(1, (led_blink_cycle < TIMES_TICK_ONE_SEC) ?
+ LED_WHITE : LED_OFF);
+ return;
+ }
+
+ power_ticks = 0;
+
switch (charge_get_state()) {
case PWR_STATE_CHARGE:
/* Always indicate when charging, even in suspend. */
@@ -101,9 +128,13 @@ static void board_led_set_battery(void)
break;
case PWR_STATE_DISCHARGE:
if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) {
- if (charge_get_percent() <= 10)
+ if (charge_get_percent() <= 10) {
+ led_blink_cycle =
+ battery_ticks % (2 * TIMES_TICK_ONE_SEC);
side_led_set_color(0,
- (battery_ticks & 0x4) ? LED_WHITE : LED_OFF);
+ (led_blink_cycle < TIMES_TICK_ONE_SEC) ?
+ LED_WHITE : LED_OFF);
+ }
else
side_led_set_color(0, LED_OFF);
}
@@ -112,17 +143,20 @@ static void board_led_set_battery(void)
side_led_set_color(1, LED_OFF);
break;
case PWR_STATE_ERROR:
- set_active_port_color((battery_ticks & 0x2) ?
- LED_WHITE : LED_OFF);
+ led_blink_cycle = battery_ticks % TIMES_TICK_ONE_SEC;
+ set_active_port_color((led_blink_cycle < TIMES_TICK_HALF_SEC) ?
+ LED_WHITE : LED_OFF);
break;
case PWR_STATE_CHARGE_NEAR_FULL:
set_active_port_color(LED_WHITE);
break;
case PWR_STATE_IDLE: /* External power connected in IDLE */
- if (chflags & CHARGE_FLAG_FORCE_IDLE)
- set_active_port_color((battery_ticks & 0x4) ?
+ if (chflags & CHARGE_FLAG_FORCE_IDLE) {
+ led_blink_cycle = battery_ticks % (2 * TIMES_TICK_ONE_SEC);
+ set_active_port_color(
+ (led_blink_cycle < TIMES_TICK_ONE_SEC) ?
LED_AMBER : LED_OFF);
- else
+ } else
set_active_port_color(LED_WHITE);
break;
default: