summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew McRae <amcrae@google.com>2020-07-15 11:26:13 +1000
committerCommit Bot <commit-bot@chromium.org>2020-07-15 07:23:33 +0000
commitbac525d57d08cdb74df7ab02913bbe23aa0a1e67 (patch)
treece10c9b2e2ebac65b2cb7787b37ffe7dac408260
parentd3a2090e1e0061ec664f914f10d1220395100635 (diff)
downloadchrome-ec-bac525d57d08cdb74df7ab02913bbe23aa0a1e67.tar.gz
Puff: Delay turning off LED during shutdown.
Delay turning off the power LED during suspend/shutdown. The CPU CSME-Lite processing introduced extra CPU transitions, which caused the power LED to turn on/off/on during startup. BUG=b:160282627 TEST=Ensure that powering on does not blink the LED. BRANCH=none Change-Id: I4d605f3d484159ba4e6384e85cf194873655e674 Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2297078 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Andrew McRae <amcrae@chromium.org> Commit-Queue: Andrew McRae <amcrae@chromium.org> Tested-by: Andrew McRae <amcrae@chromium.org>
-rw-r--r--board/puff/led.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/board/puff/led.c b/board/puff/led.c
index 56f0914872..fe6abf6c0e 100644
--- a/board/puff/led.c
+++ b/board/puff/led.c
@@ -19,6 +19,15 @@
#include "timer.h"
#include "util.h"
+#define CPRINTS(format, args...) cprints(CC_GPIO, format, ## args)
+
+/*
+ * Due to the CSME-Lite processing, upon startup the CPU transitions through
+ * S0->S3->S5->S3->S0, causing the LED to turn on/off/on, so
+ * delay turning off the LED during suspend/shutdown.
+ */
+#define LED_CPU_DELAY_MS (2000 * MSEC)
+
const enum ec_led_id supported_led_ids[] = {EC_LED_ID_POWER_LED};
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
@@ -135,21 +144,40 @@ static void led_suspend(void)
CONFIG_TICK(LED_PULSE_TICK_US, LED_GREEN);
led_tick();
}
-DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, led_suspend, HOOK_PRIO_DEFAULT);
+DECLARE_DEFERRED(led_suspend);
static void led_shutdown(void)
{
- hook_call_deferred(&led_tick_data, -1);
if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED))
set_color(EC_LED_ID_POWER_LED, LED_OFF, 0);
}
-DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, led_shutdown, HOOK_PRIO_DEFAULT);
+DECLARE_DEFERRED(led_shutdown);
+
+static void led_shutdown_hook(void)
+{
+ hook_call_deferred(&led_tick_data, -1);
+ hook_call_deferred(&led_suspend_data, -1);
+ hook_call_deferred(&led_shutdown_data, LED_CPU_DELAY_MS);
+}
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, led_shutdown_hook, HOOK_PRIO_DEFAULT);
+
+static void led_suspend_hook(void)
+{
+ hook_call_deferred(&led_shutdown_data, -1);
+ hook_call_deferred(&led_suspend_data, LED_CPU_DELAY_MS);
+}
+DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, led_suspend_hook, HOOK_PRIO_DEFAULT);
static void led_resume(void)
{
/* Assume there is no race condition with led_tick, which also
* runs in hook_task. */
hook_call_deferred(&led_tick_data, -1);
+ /*
+ * Avoid invoking the suspend/shutdown delayed hooks.
+ */
+ hook_call_deferred(&led_suspend_data, -1);
+ hook_call_deferred(&led_shutdown_data, -1);
if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED))
set_color(EC_LED_ID_POWER_LED, LED_GREEN, 100);
}