From bc3a927a03c6a4096602deae5b7b342f3b5caf75 Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Thu, 22 May 2014 08:16:30 -0700 Subject: pd: detect sink disconnection For non-PD aware sink, ensure that we detect their disconnection when the CC goes back above Vnc. Signed-off-by: Vincent Palatin BRANCH=none BUG=chrome-os-partner:28782 TEST=on Samus, put the port in source mode (using the "pd charger" console command), then plug and unplug the type-C to type-A cable and see the PD state going from Disconnected to Discovery and the other way round (using "pd state" console command). Change-Id: Ic9e19fee78f0c5e1fc742e2443eaf4b804ee5ee9 Reviewed-on: https://chromium-review.googlesource.com/202445 Reviewed-by: Alec Berg Commit-Queue: Vincent Palatin Tested-by: Vincent Palatin --- common/usb_pd_protocol.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 179ac828d0..214d5f15a0 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -811,6 +811,16 @@ void pd_task(void) timeout = 10*MSEC; break; case PD_STATE_SRC_DISCOVERY: + /* Detect disconnect by monitoring Vnc */ + cc1_volt = pd_adc_read(pd_polarity); + if (cc1_volt > PD_SRC_VNC) { + /* The sink disappeared ... */ + pd_power_supply_reset(); + pd_task_state = PD_STATE_SRC_DISCONNECTED; + /* Debouncing */ + timeout = 50*MSEC; + break; + } /* Query capabilites of the other side */ res = send_source_cap(ctxt); /* packet was acked => PD capable device) */ -- cgit v1.2.1