diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-04-24 09:58:04 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-04-25 04:54:04 +0000 |
commit | df299ce8200f4e54d4134d5c821824848b7b3ba8 (patch) | |
tree | 5cbb5271c095002d8934a223f3a4e89553838f48 /common | |
parent | 82ec2a52c5ae7e4316d0aba15137876489f94398 (diff) | |
download | chrome-ec-df299ce8200f4e54d4134d5c821824848b7b3ba8.tar.gz |
pd: continue dual-role toggling when detect Open/Ra
As a source, when we detect Open/Ra (active cable with no UFP)
then do not transition to debounce CC line, instead continue
dual-role toggling as if nothing is connected.
BUG=chrome-os-partner:35652, chrome-os-partner:39486
BRANCH=samus
TEST=test with samus and twinkie. on twinkie, simulate Open/Ra
with: "tw res ra nc" and verify that we continue dual-role toggling.
Then plug in zinger and verify we negotiate and start charging.
Also, tested case where we initially detect Open/Rd and start
debouncing, but then it turns into Open/Ra:
echo "tw res rd nc" > /dev/ttyUSB0; sleep 0.05; echo "tw res ra nc" > /dev/ttyUSB0
In this case, samus transitions to SRC_DEBOUNCE briefly, then goes
back to disconnected state and continues dual-role toggling.
Change-Id: Idabac60b9e2f54639d7a6305d96e9984b0600519
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/267087
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/usb_pd_protocol.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 978e862d3e..dc4986d2cc 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1932,7 +1932,8 @@ void pd_task(void) /* Vnc monitoring */ cc1_volt = pd_adc_read(port, 0); cc2_volt = pd_adc_read(port, 1); - if (!CC_NC(cc1_volt) || !CC_NC(cc2_volt)) { + if (CC_RD(cc1_volt) || CC_RD(cc2_volt) || + (CC_RA(cc1_volt) && CC_RA(cc2_volt))) { #ifdef CONFIG_USBC_BACKWARDS_COMPATIBLE_DFP /* Enable VBUS */ if (pd_set_power_supply_ready(port)) @@ -1961,7 +1962,17 @@ void pd_task(void) cc1_volt = pd_adc_read(port, 0); cc2_volt = pd_adc_read(port, 1); - if (CC_NC(cc1_volt) && CC_NC(cc2_volt)) { + if (CC_RD(cc1_volt) && CC_RD(cc2_volt)) { + /* Debug accessory */ + new_cc_state = PD_CC_DEBUG_ACC; + } else if (CC_RD(cc1_volt) || CC_RD(cc2_volt)) { + /* UFP attached */ + new_cc_state = PD_CC_UFP_ATTACHED; + } else if (CC_RA(cc1_volt) && CC_RA(cc2_volt)) { + /* Audio accessory */ + new_cc_state = PD_CC_AUDIO_ACC; + } else { + /* No UFP */ #ifdef CONFIG_USBC_BACKWARDS_COMPATIBLE_DFP /* No connection any more, remove VBUS */ pd_power_supply_reset(port); @@ -1969,18 +1980,6 @@ void pd_task(void) set_state(port, PD_STATE_SRC_DISCONNECTED); timeout = 5*MSEC; break; - } else if (CC_RA(cc1_volt) && CC_RA(cc2_volt)) { - /* Audio accessory */ - new_cc_state = PD_CC_AUDIO_ACC; - } else if (CC_RD(cc1_volt) && CC_RD(cc2_volt)) { - /* Debug accessory */ - new_cc_state = PD_CC_DEBUG_ACC; - } else if (CC_RD(cc1_volt) || CC_RD(cc2_volt)) { - /* UFP attached */ - new_cc_state = PD_CC_UFP_ATTACHED; - } else { - /* Powered cable, no UFP */ - new_cc_state = PD_CC_NO_UFP; } /* Debounce the cc state */ |