summaryrefslogtreecommitdiff
path: root/common/usbc/usb_tc_drp_acc_trysrc_sm.c
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@google.com>2021-02-17 13:47:39 -0700
committerCommit Bot <commit-bot@chromium.org>2021-03-02 00:11:56 +0000
commitecba4b517e09173fcda50cbbf9d1c29d38ff9833 (patch)
tree4ceaa6b04226f2710ea0ded8f4ce7c81887ff8ab /common/usbc/usb_tc_drp_acc_trysrc_sm.c
parentf1c3eba9f99dbb1cdf8f2a7301e0e6176120c068 (diff)
downloadchrome-ec-ecba4b517e09173fcda50cbbf9d1c29d38ff9833.tar.gz
TCPMv2: PD Timers - Add TC VBusDebounce to framework
BUG=b:178029034 BRANCH=none TEST=make runtests Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I0e58111bcc3205647efd11ede207ec75a4af4891 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2707808 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'common/usbc/usb_tc_drp_acc_trysrc_sm.c')
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index 080842af68..fb8e1f8249 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -15,6 +15,7 @@
#include "usb_mux.h"
#include "usb_pd.h"
#include "usb_pd_dpm.h"
+#include "usb_pd_timer.h"
#include "usb_pe_sm.h"
#include "usb_prl_sm.h"
#include "usb_sm.h"
@@ -409,11 +410,6 @@ 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
@@ -617,7 +613,7 @@ void tc_request_power_swap(int port)
TC_SET_FLAG(port, TC_FLAGS_PR_SWAP_IN_PROGRESS);
/* Let tc_pr_swap_complete start the Vbus debounce */
- tc[port].vbus_debounce_time = TIMER_DISABLED;
+ pd_timer_disable(port, TC_TIMER_VBUS_DEBOUNCE);
}
/*
@@ -893,7 +889,7 @@ void tc_pr_swap_complete(int port, bool success)
* Note: Swap in progress should not be cleared until the
* debounce is completed.
*/
- tc[port].vbus_debounce_time = get_time().val + PD_T_DEBOUNCE;
+ pd_timer_enable(port, TC_TIMER_VBUS_DEBOUNCE, PD_T_DEBOUNCE);
} else {
/* PR Swap is no longer in progress */
TC_CLR_FLAG(port, TC_FLAGS_PR_SWAP_IN_PROGRESS);
@@ -2461,7 +2457,7 @@ static void tc_attached_snk_run(const int port)
* Debounce Vbus before we drop that we are doing a PR_Swap
*/
if (TC_CHK_FLAG(port, TC_FLAGS_PR_SWAP_IN_PROGRESS) &&
- tc[port].vbus_debounce_time < get_time().val) {
+ pd_timer_is_expired(port, TC_TIMER_VBUS_DEBOUNCE)) {
/* PR Swap is no longer in progress */
TC_CLR_FLAG(port, TC_FLAGS_PR_SWAP_IN_PROGRESS);
@@ -2615,6 +2611,8 @@ static void tc_attached_snk_exit(const int port)
if (TC_CHK_FLAG(port, TC_FLAGS_TS_DTS_PARTNER))
tcpm_debug_detach(port);
+
+ pd_timer_disable(port, TC_TIMER_VBUS_DEBOUNCE);
}
/**