summaryrefslogtreecommitdiff
path: root/driver/tcpm/stub.c
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-07-27 17:05:49 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-08-01 21:05:30 +0000
commit64bbfe253c7ec2d0fd34cf309d4685448a2fa13d (patch)
tree374c666a1107269c7b5ea51fa7e63eb5c1b5ee53 /driver/tcpm/stub.c
parent0267aa062fade24964cb89473f89dec799b0955e (diff)
downloadchrome-ec-64bbfe253c7ec2d0fd34cf309d4685448a2fa13d.tar.gz
tcpc: add RX message buffer and don't send goodCRC when full
Add RX message buffer to the TCPC (currently two deep). If the buffer is full and message is received, don't send goodCRC. BUG=chrome-os-partner:43482 BRANCH=none TEST=tested on glados. saw that with back to back PD packets, we send goodCRC to both packets and process them in order, taking about 7ms per packet. also tested buffer size of 1 and verified that with back to back PD packets, we don't send goodCRC to second packet. Change-Id: I7f44b3c3a186ae61be8ca03017deec6e6b6c6f9f Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/289005 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'driver/tcpm/stub.c')
-rw-r--r--driver/tcpm/stub.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/driver/tcpm/stub.c b/driver/tcpm/stub.c
index 01163a42ff..444730fc18 100644
--- a/driver/tcpm/stub.c
+++ b/driver/tcpm/stub.c
@@ -75,13 +75,8 @@ int tcpm_set_msg_header(int port, int power_role, int data_role)
int tcpm_alert_status(int port, int *alert)
{
- int rv;
-
/* Read TCPC Alert register */
- rv = tcpc_alert_status(port, alert);
- /* Clear all bits being processed by the protocol layer */
- tcpc_alert_status_clear(port, *alert);
- return rv;
+ return tcpc_alert_status(port, alert);
}
int tcpm_set_rx_enable(int port, int enable)
@@ -96,7 +91,12 @@ int tcpm_alert_mask_set(int port, uint16_t mask)
int tcpm_get_message(int port, uint32_t *payload, int *head)
{
- return tcpc_get_message(port, payload, head);
+ int ret = tcpc_get_message(port, payload, head);
+
+ /* Read complete, clear RX status alert bit */
+ tcpc_alert_status_clear(port, TCPC_REG_ALERT_RX_STATUS);
+
+ return ret;
}
int tcpm_transmit(int port, enum tcpm_transmit_type type, uint16_t header,
@@ -112,6 +112,14 @@ void tcpc_alert(int port)
/* Read the Alert register from the TCPC */
tcpm_alert_status(port, &status);
+ /*
+ * Clear alert status for everything except RX_STATUS, which shouldn't
+ * be cleared until we have successfully retrieved message.
+ */
+ if (status & ~TCPC_REG_ALERT_RX_STATUS)
+ tcpc_alert_status_clear(port,
+ status & ~TCPC_REG_ALERT_RX_STATUS);
+
if (status & TCPC_REG_ALERT_CC_STATUS) {
/* CC status changed, wake task */
task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_CC, 0);