diff options
author | Denis Brockus <dbrockus@google.com> | 2021-02-18 12:59:59 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-02 00:13:36 +0000 |
commit | 6eefa5b67108dd76414629b335ad3ef7cb725f84 (patch) | |
tree | c8e7d6fc055b71bea3458c8a80daba3bccfa6663 /common | |
parent | 198834ed267b7ea742fe1438c95e40e35d1097e0 (diff) | |
download | chrome-ec-6eefa5b67108dd76414629b335ad3ef7cb725f84.tar.gz |
TCPMv2: PD Timers - Add PE HardReset to framework
BUG=b:178029034
BRANCH=none
TEST=make runtests
Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: Id00a8bdd9b2c7967e6080211c35144af46def800
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2707904
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')
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index f7e8eeb9a9..ea99df6a4a 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -612,13 +612,6 @@ static struct policy_engine { uint64_t discover_identity_timer; /* - * This timer is used in a Source to ensure that the Sink has had - * sufficient time to process Hard Reset Signaling before turning - * off its power supply to VBUS. - */ - uint64_t ps_hard_reset_timer; - - /* * This timer is used to ensure that the time before the next Sink * Request Message, after a Wait Message has been received from the * Source in response to a Sink Request Message. @@ -2830,7 +2823,7 @@ static void pe_src_hard_reset_entry(int port) pe[port].no_response_timer = get_time().val + PD_T_NO_RESPONSE; /* Start PSHardResetTimer */ - pe[port].ps_hard_reset_timer = get_time().val + PD_T_PS_HARD_RESET; + pd_timer_enable(port, PE_TIMER_PS_HARD_RESET, PD_T_PS_HARD_RESET); /* Clear error flags */ PE_CLR_FLAG(port, PE_FLAGS_VDM_REQUEST_NAKED | @@ -2844,10 +2837,15 @@ static void pe_src_hard_reset_run(int port) * Transition to the PE_SRC_Transition_to_default state when: * 1) The PSHardResetTimer times out. */ - if (get_time().val > pe[port].ps_hard_reset_timer) + if (pd_timer_is_expired(port, PE_TIMER_PS_HARD_RESET)) set_state_pe(port, PE_SRC_TRANSITION_TO_DEFAULT); } +static void pe_src_hard_reset_exit(int port) +{ + pd_timer_disable(port, PE_TIMER_PS_HARD_RESET); +} + /** * PE_SRC_Hard_Reset_Received */ @@ -2859,7 +2857,7 @@ static void pe_src_hard_reset_received_entry(int port) pe[port].no_response_timer = get_time().val + PD_T_NO_RESPONSE; /* Start PSHardResetTimer */ - pe[port].ps_hard_reset_timer = get_time().val + PD_T_PS_HARD_RESET; + pd_timer_enable(port, PE_TIMER_PS_HARD_RESET, PD_T_PS_HARD_RESET); } static void pe_src_hard_reset_received_run(int port) @@ -2868,10 +2866,15 @@ static void pe_src_hard_reset_received_run(int port) * Transition to the PE_SRC_Transition_to_default state when: * 1) The PSHardResetTimer times out. */ - if (get_time().val > pe[port].ps_hard_reset_timer) + if (pd_timer_is_expired(port, PE_TIMER_PS_HARD_RESET)) set_state_pe(port, PE_SRC_TRANSITION_TO_DEFAULT); } +static void pe_src_hard_reset_received_exit(int port) +{ + pd_timer_disable(port, PE_TIMER_PS_HARD_RESET); +} + /** * PE_SRC_Transition_To_Default */ @@ -6861,10 +6864,12 @@ static __const_data const struct usb_state pe_states[] = { [PE_SRC_HARD_RESET] = { .entry = pe_src_hard_reset_entry, .run = pe_src_hard_reset_run, + .exit = pe_src_hard_reset_exit, }, [PE_SRC_HARD_RESET_RECEIVED] = { .entry = pe_src_hard_reset_received_entry, .run = pe_src_hard_reset_received_run, + .exit = pe_src_hard_reset_received_exit, }, [PE_SRC_TRANSITION_TO_DEFAULT] = { .entry = pe_src_transition_to_default_entry, |