summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2017-10-12 14:09:53 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-10-13 17:22:06 -0700
commit5436afc8f67e740a49f1e6e4fae2c7f4c8dee16d (patch)
tree8c4ade214567b20d305d504c06847a1113b5789f
parent7d9bd07693ba691404831861bc219e5ec7b57b82 (diff)
downloadchrome-ec-5436afc8f67e740a49f1e6e4fae2c7f4c8dee16d.tar.gz
coral: Add support for power LED for Robo devices
Robo devices have a power button LED. For these devices the desried power button LED behavior is: S0 -> always on S3 -> charging, then 500 mSec off, 3 seconds on S3 -> not charging, always off S5 -> always off Because the hook tick runs at 200 msec, using 600 msec for the off period when blinking in S3. BUG=b:64015212 BRANCH=None TEST=Manual This LED is not connected on EVT, so added a wire on GPIO02 and used a scope. Verifed that in S0 the signal level is low, and in S3 that it control signal toggles 600 mSec high/3 sec low. Verifed than in S5 control signal is high. Change-Id: I72438a009a507fcddaae5a673bf3bc83988f2dd5 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/717183 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
-rw-r--r--board/coral/gpio.inc6
-rw-r--r--board/coral/led.c48
2 files changed, 48 insertions, 6 deletions
diff --git a/board/coral/gpio.inc b/board/coral/gpio.inc
index f0a49f387e..642e1fb8d4 100644
--- a/board/coral/gpio.inc
+++ b/board/coral/gpio.inc
@@ -75,7 +75,6 @@ GPIO(PCH_SLP_S0_L, PIN(7, 5), GPIO_INPUT) /* SLP_S0_L */
GPIO(EC_BRD_ID_EN, PIN(3, 5), GPIO_INPUT)
GPIO(CCD_MODE_ODL, PIN(6, 3), GPIO_INPUT)
-GPIO(EC_HAVEN_RESET_ODL, PIN(0, 2), GPIO_ODR_HIGH)
GPIO(ENTERING_RW, PIN(7, 6), GPIO_OUTPUT) /* EC_ENTERING_RW */
GPIO(PCH_RSMRST_L, PIN(7, 0), GPIO_OUT_LOW)
@@ -131,8 +130,9 @@ GPIO(USB_C1_PD_RST_ODL, PIN(7, 4), GPIO_ODR_LOW)
GPIO(USB_C0_5V_EN, PIN(D, 3), GPIO_OUT_LOW | GPIO_PULL_UP) /* EN_USB_C0_5V_OUT, Enable C0 */
GPIO(USB_C1_5V_EN, PIN(D, 2), GPIO_OUT_LOW | GPIO_PULL_UP) /* EN_USB_C1_5V_OUT, Enable C1 */
-GPIO(BAT_LED_BLUE, PIN(8, 0), GPIO_OUT_HIGH)
-GPIO(BAT_LED_AMBER, PIN(C, 4), GPIO_OUT_HIGH)
+GPIO(BAT_LED_BLUE, PIN(8, 0), GPIO_OUT_HIGH)
+GPIO(BAT_LED_AMBER, PIN(C, 4), GPIO_OUT_HIGH)
+GPIO(POWER_LED, PIN(0, 2), GPIO_OUT_HIGH)
/*
diff --git a/board/coral/led.c b/board/coral/led.c
index 671b02f228..6e26177522 100644
--- a/board/coral/led.c
+++ b/board/coral/led.c
@@ -23,6 +23,10 @@
#define LED_ONE_SEC (1000 / HOOK_TICK_INTERVAL_MS)
#define LED_CHARGE_LEVEL_1_DEFAULT 100
#define LED_CHARGE_LEVEL_1_ROBO 5
+#define LED_POWER_BLINK_ON_MSEC 3000
+#define LED_POWER_BLINK_OFF_MSEC 600
+#define LED_POWER_ON_TICKS (LED_POWER_BLINK_ON_MSEC / HOOK_TICK_INTERVAL_MS)
+#define LED_POWER_OFF_TICKS (LED_POWER_BLINK_OFF_MSEC / HOOK_TICK_INTERVAL_MS)
const enum ec_led_id supported_led_ids[] = {
EC_LED_ID_BATTERY_LED};
@@ -130,6 +134,11 @@ static int led_set_color_battery(enum led_color color)
return EC_SUCCESS;
}
+static void led_set_color_power(int level)
+{
+ gpio_set_level(GPIO_POWER_LED, level);
+}
+
void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
{
brightness_range[EC_LED_COLOR_BLUE] = 1;
@@ -241,12 +250,45 @@ static void led_update_battery(void)
ticks++;
}
-/* Called by hook task every 1 sec */
+static void led_robo_update_power(void)
+{
+ int level;
+ static int ticks;
+
+ if (chipset_in_state(CHIPSET_STATE_ON)) {
+ /* In S0 power LED is always on */
+ level = LED_ON_LVL;
+ ticks = 0;
+ } else if ((chipset_in_state(CHIPSET_STATE_SUSPEND) |
+ chipset_in_state(CHIPSET_STATE_STANDBY)) &&
+ led.state <= STATE_CHARGING_LVL_3) {
+ int period;
+
+ /*
+ * If in suspend/standby and the device is charging, then the
+ * power LED is off for 600 msec, on for 3 seconds.
+ */
+ period = LED_POWER_ON_TICKS + LED_POWER_OFF_TICKS;
+ level = ticks % period < LED_POWER_OFF_TICKS ?
+ LED_OFF_LVL : LED_ON_LVL;
+ ticks++;
+ } else {
+ level = LED_OFF_LVL;
+ ticks = 0;
+ }
+
+ led_set_color_power(level);
+}
+
+/* Called by hook task every hook tick (200 msec) */
static void led_update(void)
{
/* Update battery LED */
- if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED))
+ if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) {
led_update_battery();
+ if (led.update_power != NULL)
+ (*led.update_power)();
+ }
}
DECLARE_HOOK(HOOK_TICK, led_update, HOOK_PRIO_DEFAULT);
@@ -258,7 +300,7 @@ static void led_init(void)
(sku >= 144 && sku <= 145)) {
led.charge_lvl_1 = LED_CHARGE_LEVEL_1_ROBO;
led.state_table = led_robo_state_table;
- led.update_power = NULL;
+ led.update_power = led_robo_update_power;
} else {
led.charge_lvl_1 = LED_CHARGE_LEVEL_1_DEFAULT;
led.state_table = led_default_state_table;