From e70ecea5d6101bc6af159c5f7790f3111bd6e393 Mon Sep 17 00:00:00 2001 From: Edward Hill Date: Wed, 28 Oct 2020 16:26:31 -0600 Subject: morphius: Wait 500ms before allowing DP event to cause resume. Turning off the MST hub in S3 (via IOEX_HDMI_DATA_EN_DB) causes a VDM:Attention that immediately wakes us back up from S3. Wait 500ms after S3 entry before setting EC_MKBP_EVENT_DP_ALT_MODE_ENTERED in pd_notify_dp_alt_mode_entry(). BUG=b:167949458 BRANCH=zork TEST=powerd_dbus_suspend with display connected to MST hub DB Signed-off-by: Edward Hill Change-Id: I0d90d0a5130403b9aca1057725509814cac0d545 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2506424 Reviewed-by: Aseda Aboagye Reviewed-by: Denis Brockus --- baseboard/trogdor/usb_pd_policy.c | 2 +- board/asurada/usb_pd_policy.c | 2 +- board/morphius/board.c | 29 +++++++++++++++++++++++++++++ common/usb_pd_alt_mode_dfp.c | 4 ++-- common/usb_pd_host_cmd.c | 3 ++- include/usb_pd.h | 2 +- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/baseboard/trogdor/usb_pd_policy.c b/baseboard/trogdor/usb_pd_policy.c index b3f4b9877e..56332a3205 100644 --- a/baseboard/trogdor/usb_pd_policy.c +++ b/baseboard/trogdor/usb_pd_policy.c @@ -215,7 +215,7 @@ __override int svdm_dp_attention(int port, uint32_t *payload) * Wake up the AP. IRQ or level high indicates a DP sink is now * present. */ - pd_notify_dp_alt_mode_entry(); + pd_notify_dp_alt_mode_entry(port); /* Configure TCPC for the HPD event, for proper muxing */ usb_mux_hpd_update(port, lvl, irq); diff --git a/board/asurada/usb_pd_policy.c b/board/asurada/usb_pd_policy.c index c20d4f4746..ce27dd20d6 100644 --- a/board/asurada/usb_pd_policy.c +++ b/board/asurada/usb_pd_policy.c @@ -79,7 +79,7 @@ __override int svdm_dp_attention(int port, uint32_t *payload) * present. */ if (IS_ENABLED(CONFIG_MKBP_EVENT)) - pd_notify_dp_alt_mode_entry(); + pd_notify_dp_alt_mode_entry(port); /* Its initial DP status message prior to config */ if (!(dp_flags[port] & DP_FLAGS_DP_ON)) { diff --git a/board/morphius/board.c b/board/morphius/board.c index 8dca1c99ed..ce4a338260 100644 --- a/board/morphius/board.c +++ b/board/morphius/board.c @@ -28,6 +28,7 @@ #include "hooks.h" #include "keyboard_8042.h" #include "lid_switch.h" +#include "mkbp_event.h" #include "power.h" #include "power_button.h" #include "ps2_chip.h" @@ -50,6 +51,7 @@ static void board_gmr_tablet_switch_isr(enum gpio_signal signal); #include "gpio_list.h" static bool support_aoz_ppc; +static bool ignore_c1_dp; #ifdef HAS_TASK_MOTIONSENSE @@ -621,6 +623,12 @@ static void board_chipset_resume(void) } DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT); +static void board_chipset_suspend_delay(void) +{ + ignore_c1_dp = false; +} +DECLARE_DEFERRED(board_chipset_suspend_delay); + static void board_chipset_suspend(void) { /* SMART charge current */ @@ -634,6 +642,14 @@ static void board_chipset_suspend(void) ioex_set_level(IOEX_HDMI_POWER_EN_DB, 0); } + /* Wait 500ms before allowing DP event to cause resume. */ + if (ec_config_has_mst_hub_rtd2141b() + && (dp_flags[USBC_PORT_C1] & DP_FLAGS_DP_ON)) { + ignore_c1_dp = true; + hook_call_deferred(&board_chipset_suspend_delay_data, + 500 * MSEC); + } + ioex_set_level(IOEX_HDMI_DATA_EN_DB, 0); } DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); @@ -762,3 +778,16 @@ int board_sensor_at_360(void) return 0; } + +/* + * b/167949458: Suppress setting the host event for 500ms after entering S3. + * Otherwise turning off the MST hub in S3 (via IOEX_HDMI_DATA_EN_DB) causes + * a VDM:Attention that immediately wakes us back up from S3. + */ +__override void pd_notify_dp_alt_mode_entry(int port) +{ + if (port == USBC_PORT_C1 && ignore_c1_dp) + return; + cprints(CC_USBPD, "Notifying AP of DP Alt Mode Entry..."); + mkbp_send_event(EC_MKBP_EVENT_DP_ALT_MODE_ENTERED); +} diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c index 3bfbcc9f35..b7d81e2e64 100644 --- a/common/usb_pd_alt_mode_dfp.c +++ b/common/usb_pd_alt_mode_dfp.c @@ -1009,7 +1009,7 @@ __overridable int svdm_enter_dp_mode(int port, uint32_t mode_caps) /* * Wake the system up since we're entering DP AltMode. */ - pd_notify_dp_alt_mode_entry(); + pd_notify_dp_alt_mode_entry(port); return 0; } @@ -1121,7 +1121,7 @@ __overridable int svdm_dp_attention(int port, uint32_t *payload) * present. */ if (IS_ENABLED(CONFIG_MKBP_EVENT)) - pd_notify_dp_alt_mode_entry(); + pd_notify_dp_alt_mode_entry(port); /* Its initial DP status message prior to config */ if (!(dp_flags[port] & DP_FLAGS_DP_ON)) { diff --git a/common/usb_pd_host_cmd.c b/common/usb_pd_host_cmd.c index 39c70cecf0..b9458bca67 100644 --- a/common/usb_pd_host_cmd.c +++ b/common/usb_pd_host_cmd.c @@ -468,8 +468,9 @@ DECLARE_HOST_COMMAND(EC_CMD_USB_PD_FW_UPDATE, #endif /* CONFIG_HOSTCMD_FLASHPD && CONFIG_USB_PD_TCPMV2 */ #ifdef CONFIG_MKBP_EVENT -void pd_notify_dp_alt_mode_entry(void) +__overridable void pd_notify_dp_alt_mode_entry(int port) { + (void)port; CPRINTS("Notifying AP of DP Alt Mode Entry..."); mkbp_send_event(EC_MKBP_EVENT_DP_ALT_MODE_ENTERED); } diff --git a/include/usb_pd.h b/include/usb_pd.h index 6c9de3307e..e8040355af 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -2841,7 +2841,7 @@ void pd_set_polarity(int port, enum tcpc_cc_polarity polarity); * Notify the AP that we have entered into DisplayPort Alternate Mode. This * sets a DP_ALT_MODE_ENTERED MKBP event which may wake the AP. */ -void pd_notify_dp_alt_mode_entry(void); +__override_proto void pd_notify_dp_alt_mode_entry(int port); /* * Determines the PD state of the port partner according to Table 4-10 in USB PD -- cgit v1.2.1