summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-05-22 15:15:28 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-05-23 04:53:24 +0000
commitb19bd8f4382cbb8cd2572d0f9f51a14c91192c1c (patch)
tree56f5ff0ffaf7890aa9ec045023ea4aecc4ef8c6a
parent3dff34e653ff407b111ea9356e67af7edc02d3f2 (diff)
downloadchrome-ec-b19bd8f4382cbb8cd2572d0f9f51a14c91192c1c.tar.gz
pd: detect source disconnection
For non-PD aware source, ensure that we detect their disconnection when the CC goes back below Vnc. BUG=none BRANCH=none TEST=when zinger gets into state where it is not talking PD, remove charger and make sure we transition to disconnected state. Change-Id: I675ff6d3300eda680acdd7814f0163f222eeb516 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/201156 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/usb_pd_protocol.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 55a5c97334..2727bdc05a 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -750,6 +750,16 @@ void pd_task(void)
timeout = 10*MSEC;
break;
case PD_STATE_SNK_DISCOVERY:
+ /* For non-PD aware source, detect source disconnect */
+ cc1_volt = pd_adc_read(pd_polarity);
+ if (cc1_volt < PD_SNK_VA) {
+ /* The source disappeared ... */
+ pd_task_state = PD_STATE_SNK_DISCONNECTED;
+ /* Debouncing */
+ timeout = 50*MSEC;
+ break;
+ }
+
res = send_control(ctxt, PD_CTRL_GET_SOURCE_CAP);
/* packet was acked => PD capable device) */
if (res >= 0) {