From 7983efdf80d2b55249c868386276af75db4c6be1 Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Fri, 16 Sep 2016 17:29:07 -0700 Subject: kevin: Fix EC watchdog on power-down after sysjump If the AP requests a shutdown before HOOK_INIT completes, we may yank our SPI pins before motion sense-related SPI sensor init has completed. BUG=chrome-os-partner:57518 BRANCH=Kevin TEST=Cold reset EC, verify EC doesn't watchdog. Change-Id: Ie8196fc1f6f52e119860378b001bf6037e7d5239 Signed-off-by: Shawn Nematbakhsh Reviewed-on: https://chromium-review.googlesource.com/386445 Reviewed-by: Aseda Aboagye (cherry picked from commit 0a17e821524d1ef66ac878e5573abf80cb440746) Reviewed-on: https://chromium-review.googlesource.com/387627 Commit-Ready: Shawn N Tested-by: Shawn N Reviewed-by: Shawn N --- board/kevin/board.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/board/kevin/board.c b/board/kevin/board.c index 9b594e8e76..53fc52c36f 100644 --- a/board/kevin/board.c +++ b/board/kevin/board.c @@ -298,8 +298,23 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_spi_enable, MOTION_SENSE_HOOK_PRIO - 1); +/* + * Don't yank our SPI pins until we know HOOK_INIT has completed, since we + * do sensor initialization from HOOK_INIT. + */ +static int hook_init_done; + +static void hook_init_last(void) +{ + hook_init_done = 1; +} +DECLARE_HOOK(HOOK_INIT, hook_init_last, HOOK_PRIO_LAST + 1); + static void board_spi_disable(void) { + while (!hook_init_done) + msleep(10); + spi_enable(CONFIG_SPI_ACCEL_PORT, 0); } DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, -- cgit v1.2.1