diff options
author | Keith Short <keithshort@chromium.org> | 2020-12-22 10:25:27 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-09 00:44:50 +0000 |
commit | bba37794634898c72b9b94435f353ef2676dd33c (patch) | |
tree | e254fa766690be50e8b7e6ea908fa1d84f2fe296 | |
parent | 88d46d61c3081b7fc32225f3aed7426a1d62e36e (diff) | |
download | chrome-ec-bba37794634898c72b9b94435f353ef2676dd33c.tar.gz |
tcpmv2: Use cable soft reset state during VCS
BUG=b:152058087
BRANCH=volteer
TEST=Connect to monitor as SRC, verify SOP' soft reset sent after VCONN
swap and before SOP' DiscoveryIdentity.
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: If8b52ed033b1ee78d61958d6c9bf5d7ff01bc8dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2601143
Reviewed-by: Diana Z <dzigterman@chromium.org>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 99 |
1 files changed, 17 insertions, 82 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 9659614d49..dcbdf49071 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -488,16 +488,6 @@ GEN_NOT_SUPPORTED(PE_SNK_CHUNK_RECEIVED); #define PE_SNK_CHUNK_RECEIVED PE_SNK_CHUNK_RECEIVED_NOT_SUPPORTED #endif /* CONFIG_USB_PD_EXTENDED_MESSAGES */ -/* - * This enum is used to implement a state machine consisting of at most - * 3 states, inside a Policy Engine State. - */ -enum sub_state { - PE_SUB0, - PE_SUB1, - PE_SUB2 -}; - static enum sm_local_state local_state[CONFIG_USB_PD_PORT_MAX_COUNT]; /* @@ -579,9 +569,6 @@ static struct policy_engine { uint32_t curr_limit; uint32_t supply_voltage; - /* state specific state machine variable */ - enum sub_state sub; - /* PD_VDO_INVALID is used when there is an invalid VDO */ int32_t ama_vdo; int32_t vpd_vdo; @@ -1253,9 +1240,7 @@ void pe_report_error(int port, enum pe_error e, enum tcpm_transmit_type type) get_state_pe(port) == PE_VCS_CBL_SEND_SOFT_RESET || get_state_pe(port) == PE_VDM_IDENTITY_REQUEST_CBL) || (PE_CHK_FLAG(port, PE_FLAGS_FAST_ROLE_SWAP_PATH) && - get_state_pe(port) == PE_PRS_SNK_SRC_SEND_SWAP) || - (IS_ENABLED(CONFIG_USBC_VCONN) && - get_state_pe(port) == PE_VCS_SEND_PS_RDY_SWAP) + get_state_pe(port) == PE_PRS_SNK_SRC_SEND_SWAP) ) { PE_SET_FLAG(port, PE_FLAGS_PROTOCOL_ERROR); task_wake(PD_PORT_TO_TASK_ID(port)); @@ -6190,83 +6175,33 @@ static void pe_vcs_send_ps_rdy_swap_entry(int port) /* Send a PS_RDY Message */ send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_PS_RDY); - pe[port].sub = PE_SUB0; } static void pe_vcs_send_ps_rdy_swap_run(int port) { - /* TODO(b/152058087): TCPMv2: Break up pe_vcs_send_ps_rdy_swap */ - switch (pe[port].sub) { - case PE_SUB0: - - /* - * TODO: use DPM_REQUEST_SOP_PRIME_SOFT_RESET_SEND to - * send cable soft reset. - */ - PE_CLR_DPM_REQUEST(port, DPM_REQUEST_SOP_PRIME_SOFT_RESET_SEND); - + /* + * After a VCONN Swap the VCONN Source needs to reset + * the Cable Plug’s Protocol Layer in order to ensure + * MessageID synchronization. + */ + if (PE_CHK_FLAG(port, PE_FLAGS_TX_COMPLETE)) { + PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE); /* - * After a VCONN Swap the VCONN Source needs to reset - * the Cable Plug’s Protocol Layer in order to ensure - * MessageID synchronization. + * A VCONN Swap Shall reset the + * DiscoverIdentityCounter to zero */ - if (PE_CHK_FLAG(port, PE_FLAGS_TX_COMPLETE)) { - PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE); - - send_ctrl_msg(port, TCPC_TX_SOP_PRIME, - PD_CTRL_SOFT_RESET); - /* - * Ensures enough time for transmission completion, - * in the case of more delays. - */ - pe[port].sender_response_timer = get_time().val + - PD_T_SENDER_RESPONSE; - - pe[port].sub = PE_SUB1; - } - break; - case PE_SUB1: - if (PE_CHK_FLAG(port, PE_FLAGS_TX_COMPLETE)) { - PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE); - pe[port].sender_response_timer = get_time().val + - PD_T_SENDER_RESPONSE; - } - - /* Got ACCEPT or REJECT from Cable Plug */ - if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED) || - get_time().val > pe[port].sender_response_timer) { - PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED); - /* - * A VCONN Swap Shall reset the - * DiscoverIdentityCounter to zero - */ - pe[port].discover_identity_counter = 0; - pe[port].dr_swap_attempt_counter = 0; + pe[port].discover_identity_counter = 0; + pe[port].dr_swap_attempt_counter = 0; - if (pe[port].power_role == PD_ROLE_SOURCE) - set_state_pe(port, PE_SRC_READY); - else - set_state_pe(port, PE_SNK_READY); - } - break; - case PE_SUB2: - /* Do nothing */ - break; + /* A SOP' soft reset is required after VCONN swap */ + pd_dpm_request(port, DPM_REQUEST_SOP_PRIME_SOFT_RESET_SEND); + pe_set_ready_state(port); } if (PE_CHK_FLAG(port, PE_FLAGS_PROTOCOL_ERROR)) { PE_CLR_FLAG(port, PE_FLAGS_PROTOCOL_ERROR); - - if (pe[port].sub == PE_SUB0) { - /* PS_RDY didn't send, soft reset */ - pe_send_soft_reset(port, TCPC_TX_SOP); - } else { - /* - * Cable plug wasn't present, - * return to ready state - */ - pe_set_ready_state(port); - } + /* PS_RDY didn't send, soft reset */ + pe_send_soft_reset(port, TCPC_TX_SOP); } } |