From 06bfa637b0e77b2f0fa05560b4bdd846000baac0 Mon Sep 17 00:00:00 2001 From: li feng Date: Wed, 10 Feb 2021 23:29:20 -0800 Subject: TCPMv2: Exit modes on AP reset In AP driven mode entry, in the cases of AP reset, kernel panic, etc, EC will exit modes to ensure next time AP boot up, it can enter same Alt modes. BUG=b:168746787 BRANCH=None TEST=On Voxel, EC binary has AP mode entry enabled, OS has AP mode switch enabled. Boot up system with TBT dock, "ectool usbpdmuxinfo" shows DP=1; "reboot" from AP console, after reboot, get DP=1; hot plug TBT dock, get DP=1; browse as guest, get TBT=1, and enumerated in sysfs. "reboot" from AP console again, after reboot, get DP=1. TEST=On Voxel, EC binary has EC driven mode entry, OS is same as above. Boot up system with TBT dock, get TBT=1; "reboot" from AP console, get TBT=1 after reset and enumerated. Signed-off-by: li feng Change-Id: I127c23ec58f55d7672babf1762ac5fb17e24cc7e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2689671 Commit-Queue: Abe Levkoy Reviewed-by: Abe Levkoy Reviewed-by: Vijay P Hiremath Reviewed-by: Ayushee Shah --- common/usbc/usb_tc_drp_acc_trysrc_sm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index 3737d6d7a5..ab94531cf7 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -3718,6 +3718,19 @@ static void pd_chipset_suspend(void) } DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, pd_chipset_suspend, HOOK_PRIO_DEFAULT); +static void pd_chipset_reset(void) +{ + int i; + + if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY)) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + /* Exit mode. PD can enter mode again after reset */ + dpm_set_mode_exit_request(i); + } + } +} +DECLARE_HOOK(HOOK_CHIPSET_RESET, pd_chipset_reset, HOOK_PRIO_DEFAULT); + static void pd_chipset_startup(void) { int i; -- cgit v1.2.1