From 0eae4e603588fbbce3c7028a3f6a78bb05ee860d Mon Sep 17 00:00:00 2001 From: Tim Wawrzynczak Date: Tue, 23 Jul 2019 14:10:34 -0600 Subject: hatch: Override board_hibernate In the board_hibernate function, shut down the AP, and wait 300ms for the chipset state machine to settle down. This allows the EC to actually hibernate; otherwise, it would simply reboot the device. BUG=b:135073910 BRANCH=none TEST=Verify that EC goes into hibernate with Alt+Volume Up+H, then boots back up from time 0 on PB press. Verified that EC will wake from hibernate on insertion of AC. Change-Id: Ie98333e9ce65778df8d07ce6ae165b5c7140edf1 Signed-off-by: Tim Wawrzynczak Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1715907 Reviewed-by: Furquan Shaikh Reviewed-by: Paul Fagerburg --- baseboard/hatch/baseboard.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/baseboard/hatch/baseboard.c b/baseboard/hatch/baseboard.c index 5ea397538c..83b57a04a9 100644 --- a/baseboard/hatch/baseboard.c +++ b/baseboard/hatch/baseboard.c @@ -114,6 +114,35 @@ static void baseboard_chipset_shutdown(void) DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, baseboard_chipset_shutdown, HOOK_PRIO_DEFAULT); +void board_hibernate(void) +{ + int port; + + /* + * To support hibernate from ectool, keyboard, and console, + * ensure that the AP is fully shutdown before hibernating. + */ +#ifdef HAS_TASK_CHIPSET + chipset_force_shutdown(CHIPSET_SHUTDOWN_BOARD_CUSTOM); +#endif + + /* + * If VBUS is not being provided by any of the PD ports, + * then enable the SNK FET to allow AC to pass through + * if it is later connected to ensure that AC_PRESENT + * will wake up the EC from this state + */ + for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; ++port) + ppc_vbus_sink_enable(port, 1); + + /* + * This seems like a hack, but the AP chipset state machine + * needs time to work through the transitions. Also, it + * works. + */ + msleep(300); +} + /******************************************************************************/ /* USB-C PPC Configuration */ struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = { -- cgit v1.2.1