summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2019-09-25 13:54:27 -0600
committerCommit Bot <commit-bot@chromium.org>2019-10-10 22:49:32 +0000
commit1092c786f7876745ec0d68dd52284d252e1abee5 (patch)
treef01f92fee6104f41c2aa3ba9752e2f023cf55c3b
parent552f9e9ce218718629b8178ef12823958b2044fa (diff)
downloadchrome-ec-1092c786f7876745ec0d68dd52284d252e1abee5.tar.gz
usbc: update CRCReceiveTimer
Shorten the CRCReceiveTimer and document that either the pe send or error function will get called in response to a prl_ send message. BRANCH=none BUG=none TEST=build; Change-Id: Icc43886cadfdcd67c943b25aebfdfb55b2693ade Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1825514 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
-rw-r--r--common/usbc/usb_prl_sm.c25
-rw-r--r--include/usb_prl_sm.h9
2 files changed, 16 insertions, 18 deletions
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c
index fa6759edaf..411ec61ad6 100644
--- a/common/usbc/usb_prl_sm.c
+++ b/common/usbc/usb_prl_sm.c
@@ -156,8 +156,8 @@ static struct protocol_layer_tx {
uint32_t flags;
/* protocol timer */
uint64_t sink_tx_timer;
- /* tcpc transmit timeout */
- uint64_t tcpc_tx_timeout;
+ /* GoodCRC receive timeout */
+ uint64_t crc_receive_timer;
/* Last SOP* we transmitted to */
uint8_t sop;
/* message id counters for all 6 port partners */
@@ -630,16 +630,12 @@ static void prl_tx_construct_message(int port)
PDMSG_CLR_FLAG(port, PRL_FLAGS_TX_COMPLETE);
/* Pass message to PHY Layer */
- tcpm_transmit(port, pdmsg[port].xmit_type, header,
- pdmsg[port].chk_buf);
-}
-
-/*
- * PrlTxWaitForPhyResponse
- */
-static void prl_tx_wait_for_phy_response_entry(const int port)
-{
- prl_tx[port].tcpc_tx_timeout = get_time().val + PD_T_TCPC_TX_TIMEOUT;
+ tcpm_transmit(port, pdmsg[port].xmit_type, header, pdmsg[port].chk_buf);
+ /*
+ * tReceive is 0.9ms to 1.1ms, but we need to account for round trip
+ * communication delay over I2C with the TCPC
+ */
+ prl_tx[port].crc_receive_timer = get_time().val + (10 * MSEC);
}
static void prl_tx_wait_for_phy_response_run(const int port)
@@ -649,11 +645,11 @@ static void prl_tx_wait_for_phy_response_run(const int port)
/*
* NOTE: The TCPC will set xmit_status to TCPC_TX_COMPLETE_DISCARDED
* when a GoodCRC containing an incorrect MessageID is received.
- * This condition satifies the PRL_Tx_Match_MessageID state
+ * This condition satisfies the PRL_Tx_Match_MessageID state
* requirement.
*/
- if (get_time().val > prl_tx[port].tcpc_tx_timeout ||
+ if (get_time().val > prl_tx[port].crc_receive_timer ||
prl_tx[port].xmit_status == TCPC_TX_COMPLETE_FAILED ||
prl_tx[port].xmit_status == TCPC_TX_COMPLETE_DISCARDED) {
@@ -1607,7 +1603,6 @@ static const struct usb_state prl_tx_states[] = {
.run = prl_tx_layer_reset_for_transmit_run,
},
[PRL_TX_WAIT_FOR_PHY_RESPONSE] = {
- .entry = prl_tx_wait_for_phy_response_entry,
.run = prl_tx_wait_for_phy_response_run,
.exit = prl_tx_wait_for_phy_response_exit,
},
diff --git a/include/usb_prl_sm.h b/include/usb_prl_sm.h
index 32b3ba8d06..694d4fd923 100644
--- a/include/usb_prl_sm.h
+++ b/include/usb_prl_sm.h
@@ -58,7 +58,8 @@ void prl_set_rev(int port, enum pd_rev_type rev);
enum pd_rev_type prl_get_rev(int port);
/**
- * Sends a PD control message
+ * Sends a PD control message. Either pe_message_sent() or pe_report_error() is
+ * guaranteed to be called in response to this call.
*
* @param port USB-C port number
* @param type Transmit type
@@ -69,7 +70,8 @@ void prl_send_ctrl_msg(int port, enum tcpm_transmit_type type,
enum pd_ctrl_msg_type msg);
/**
- * Sends a PD data message
+ * Sends a PD data message. Either pe_message_sent() or pe_report_error() is
+ * guaranteed to be called in response to this call.
*
* @param port USB-C port number
* @param type Transmit type
@@ -80,7 +82,8 @@ void prl_send_data_msg(int port, enum tcpm_transmit_type type,
enum pd_data_msg_type msg);
/**
- * Sends a PD extended data message
+ * Sends a PD extended data message. Either pe_message_sent() or
+ * pe_report_error() is guaranteed to be called in response to this call.
*
* @param port USB-C port number
* @param type Transmit type