summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-11-05 13:31:42 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-11 00:10:56 +0000
commit5142cdce2d72069c0970fe33b2b7f18bbd5ee469 (patch)
tree602e6652f43dd060e316aa3884e11fbca6210e89
parent493898bd6a9771f8b4bb588b7e59dbf9aa457228 (diff)
downloadchrome-ec-5142cdce2d72069c0970fe33b2b7f18bbd5ee469.tar.gz
pd: move tDRPHold to after vbus is on
Move tDRPHold timeout to after vbus is on. This makes sure we give the right amount of time for a dual-role device to recognize that it should be the UFP. BUG=none BRANCH=samus TEST=make buildall Change-Id: I8432eb172783c689d636a435073bb86828488b06 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/227720 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
-rw-r--r--common/usb_pd_protocol.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index e5686c0d73..d49e7a0041 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1416,10 +1416,6 @@ void pd_task(void)
set_state(port, PD_STATE_SRC_STARTUP);
caps_count = 0;
-#ifdef CONFIG_USB_PD_DUAL_ROLE
- /* Keep VBUS up for the hold period */
- next_role_swap = get_time().val + PD_T_DRP_HOLD;
-#endif
}
#ifdef CONFIG_USB_PD_DUAL_ROLE
/* Swap roles if time expired or VBUS is present */
@@ -1446,6 +1442,11 @@ void pd_task(void)
PD_STATE_SRC_DISCOVERY);
break;
case PD_STATE_SRC_DISCOVERY:
+#ifdef CONFIG_USB_PD_DUAL_ROLE
+ /* Keep VBUS up for the hold period */
+ if (pd[port].last_state != pd[port].task_state)
+ next_role_swap = get_time().val + PD_T_DRP_HOLD;
+#endif
/* Send source cap some minimum number of times */
if (caps_count < PD_CAPS_COUNT) {
/* Query capabilites of the other side */
@@ -1808,7 +1809,8 @@ void pd_task(void)
if (!pd_is_connected(port) || pd_is_power_swapping(port))
continue;
#endif
- if (pd[port].power_role == PD_ROLE_SOURCE) {
+ if (pd[port].power_role == PD_ROLE_SOURCE &&
+ pd[port].task_state != PD_STATE_SRC_STARTUP) {
/* Source: detect disconnect by monitoring CC */
cc1_volt = pd_adc_read(port, pd[port].polarity);
#ifdef CONFIG_USB_PD_DUAL_ROLE