summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2018-10-22 15:07:45 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-10-25 04:26:39 -0700
commit1044e1a5b50dbb0edf35aa178b7422715c0c458d (patch)
tree2a0f3871e1903eb25cddc0ff451e4523473d1261 /power
parenta56ab7d4a3c7e05477f7e489db08de00c30da662 (diff)
downloadchrome-ec-1044e1a5b50dbb0edf35aa178b7422715c0c458d.tar.gz
power/mt8183: Implement watchdog-initiated reset
AP watchdog line can fall in either of 2 cases: - AP asserts watchdog while the AP is on: this is a real AP-initiated reset. - EC asserted GPIO_AP_SYS_RST_L, so the AP is in reset and AP watchdog falls as well. This is _not_ a watchdog reset. We mask these cases by disabling the interrupt just before shutting down the AP, and re-enabling it before starting the AP. Also, take the opportunity to move warm reset code out of board file into generic MT8183 power code, as well as code to enable interrupts. BRANCH=none BUG=b:109900671 TEST=apshutdown => EC understand this is an EC-initiated shutdown TEST=Use test-wd from bug, see that EC detects it is a watchdog. Change-Id: I02037e5be0254fef991ae2459be35e4561e0994c Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1293132 Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'power')
-rw-r--r--power/mt8183.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/power/mt8183.c b/power/mt8183.c
index 48886a488c..631f2f3c7f 100644
--- a/power/mt8183.c
+++ b/power/mt8183.c
@@ -99,6 +99,25 @@ static const struct power_seq_op s3s5_power_seq[] = {
static int forcing_shutdown;
+void chipset_reset_request_interrupt(enum gpio_signal signal)
+{
+ chipset_reset(CHIPSET_RESET_AP_REQ);
+}
+
+/*
+ * Triggers on falling edge of AP watchdog line only. The falling edge can
+ * happen in these 2 cases:
+ * - AP asserts watchdog while the AP is on: this is a real AP-initiated reset.
+ * - EC asserted GPIO_AP_SYS_RST_L, so the AP is in reset and AP watchdog falls
+ * as well. This is _not_ a watchdog reset. We mask these cases by disabling
+ * the interrupt just before shutting down the AP, and re-enabling it just
+ * after starting the AP.
+ */
+void chipset_watchdog_interrupt(enum gpio_signal signal)
+{
+ chipset_reset(CHIPSET_RESET_AP_WATCHDOG);
+}
+
void chipset_force_shutdown(enum chipset_shutdown_reason reason)
{
CPRINTS("%s(%d)", __func__, reason);
@@ -134,6 +153,10 @@ void chipset_reset(enum chipset_reset_reason reason)
enum power_state power_chipset_init(void)
{
+ /* Enable reboot / watchdog / sleep control inputs from AP */
+ gpio_enable_interrupt(GPIO_WARM_RESET_REQ);
+ gpio_enable_interrupt(GPIO_AP_IN_SLEEP_L);
+
if (system_jumped_to_this_image()) {
if ((power_get_signals() & IN_ALL_S0) == IN_ALL_S0) {
disable_sleep(SLEEP_MASK_AP_RUN);
@@ -272,6 +295,7 @@ enum power_state power_handle_state(enum power_state state)
booted = 1;
/* Enable S3 power supplies, release AP reset. */
power_seq_run(s5s3_power_seq, ARRAY_SIZE(s5s3_power_seq));
+ gpio_enable_interrupt(GPIO_AP_EC_WATCHDOG_L);
/* Call hooks now that rails are up */
hook_notify(HOOK_CHIPSET_STARTUP);
@@ -332,6 +356,7 @@ enum power_state power_handle_state(enum power_state state)
/* Call hooks before we remove power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN);
+ gpio_disable_interrupt(GPIO_AP_EC_WATCHDOG_L);
power_seq_run(s3s5_power_seq, ARRAY_SIZE(s3s5_power_seq));
/* Start shutting down */