diff options
author | Keith Short <keithshort@chromium.org> | 2020-08-11 17:32:59 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-18 21:35:16 +0000 |
commit | a19da87f1f4aff9d0a20c08b1d2f5ef73957ddb8 (patch) | |
tree | 169f2e3cae452960d8d5ae0201a6f8fa45f0983c | |
parent | 5cf6b55666bd59f5d2af5b261c4cfb11b754a5c0 (diff) | |
download | chrome-ec-a19da87f1f4aff9d0a20c08b1d2f5ef73957ddb8.tar.gz |
TCPMv2: Debounce VBUS on SRC to SNK swap
Copying TCPMv1 behavior, debounce VBUS at the completion of a SRC to SNK
swap to allow the TCPC/PPC to update the VBUS state following receipt of
the PS_RDY message from the partner.
BUG=b:162347811
BRANCH=none
TEST=make buildall
TEST=Force power role swaps and observe no false disconnects.
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: Ia0644cde64d14044b7e291bf582b68ac4278af0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363411
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
-rw-r--r-- | common/usbc/usb_tc_drp_acc_trysrc_sm.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index 32dff84fa1..c8bf4f589a 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -395,6 +395,11 @@ static struct type_c { * the state definitions. */ uint64_t pd_debounce; + /* + * Time to ignore Vbus absence due to external IC debounce detection + * logic immediately after a power role swap. + */ + uint64_t vbus_debounce_time; #ifdef CONFIG_USB_PD_TRY_SRC /* * Time a port shall wait before it can determine it is @@ -805,6 +810,16 @@ void tc_pr_swap_complete(int port, bool success) { TC_CLR_FLAG(port, TC_FLAGS_PR_SWAP_IN_PROGRESS); + if (IS_ATTACHED_SNK(port)) { + /* + * Give the ADCs in the TCPC or PPC time to react following + * a PS_RDY message received during a SRC to SNK swap. + * Note: This is empirically determined, not strictly + * part of the USB PD spec. + */ + tc[port].vbus_debounce_time = get_time().val + PD_T_DEBOUNCE; + } + /* * AutoDischargeDisconnect was either turned off near the SNK->SRC * PR-Swap message or when we hit Safe0V on SRC->SNK PR-Swap. @@ -2192,8 +2207,12 @@ static void tc_attached_snk_run(const int port) */ if (!TC_CHK_FLAG(port, TC_FLAGS_POWER_OFF_SNK) && !TC_CHK_FLAG(port, TC_FLAGS_PR_SWAP_IN_PROGRESS)) { - /* Detach detection */ - if (!pd_is_vbus_present(port)) { + /* + * Detach detection, but only after allowing for a debounce + * of the VBUS state. + */ + if ((tc[port].vbus_debounce_time < get_time().val) && + !pd_is_vbus_present(port)) { if (IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP)) { pd_dfp_exit_mode(port, TCPC_TX_SOP, 0, 0); pd_dfp_exit_mode(port, TCPC_TX_SOP_PRIME, 0, 0); |