summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-06-12 15:09:22 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-13 02:53:18 +0000
commit31171730a82ff379389f46147e8194e92a6f5369 (patch)
treebf4a7c7e025f8799f4e0ca293a9551c813876b3e
parent1599e7a6f1734b457e8f35c287c90182189a7461 (diff)
downloadchrome-ec-31171730a82ff379389f46147e8194e92a6f5369.tar.gz
tcpc: Avoid missampling CC line immediately after transmit
Change TCPC to not sample CC ADC channels immediately after transmit because we are likely to get a response immediately after transmit and this could cause us to sample while traffic is on the line and cause us to record the wrong voltage. BUG=none BRANCH=smaug TEST=test on glados. put a print when TCPM is notified of CC voltage change. without this CL, we occasionally get a false CC voltage change. with this change, CC status stays consistent. Change-Id: I9199a0ed98632b1f26b2b5b98f34928e4de328bf Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/277296 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/usb_pd_tcpc.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c
index fa740ba4c4..09eeddae25 100644
--- a/common/usb_pd_tcpc.c
+++ b/common/usb_pd_tcpc.c
@@ -757,22 +757,25 @@ int tcpc_run(int port, int evt)
else
alert(port, TCPC_REG_ALERT1,
TCPC_REG_ALERT1_TX_DISCARDED);
- }
-
- /* CC pull changed, wait 1ms for CC voltage to stabilize */
- if (evt & PD_EVENT_CC)
- usleep(MSEC);
-
- /* check CC lines */
- for (i = 0; i < 2; i++) {
- /* read CC voltage */
- cc = pd_adc_read(port, i);
-
- /* convert voltage to status, and check status change */
- cc = cc_voltage_to_status(port, cc);
- if (pd[port].cc_status[i] != cc) {
- pd[port].cc_status[i] = cc;
- alert(port, TCPC_REG_ALERT1, TCPC_REG_ALERT1_CC_STATUS);
+ } else {
+ /* If we have nothing to transmit, then sample CC lines */
+
+ /* CC pull changed, wait 1ms for CC voltage to stabilize */
+ if (evt & PD_EVENT_CC)
+ usleep(MSEC);
+
+ /* check CC lines */
+ for (i = 0; i < 2; i++) {
+ /* read CC voltage */
+ cc = pd_adc_read(port, i);
+
+ /* convert voltage to status, and check status change */
+ cc = cc_voltage_to_status(port, cc);
+ if (pd[port].cc_status[i] != cc) {
+ pd[port].cc_status[i] = cc;
+ alert(port, TCPC_REG_ALERT1,
+ TCPC_REG_ALERT1_CC_STATUS);
+ }
}
}