diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-08-07 07:48:04 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-08-11 22:05:18 +0000 |
commit | dc1834593ad379211b2d6922b85cd664b6110610 (patch) | |
tree | efea37406e9447c531c8f4a6f136d9db494beaec | |
parent | e7e66acd663a84dae9ab3b0d637466abec8dee2b (diff) | |
download | chrome-ec-dc1834593ad379211b2d6922b85cd664b6110610.tar.gz |
pd: stop sending source cap after fixed number of attempts
As per the PD spec, give up on sending source cap packets
after nCapsCount number of attempts.
BUG=chrome-os-partner:28341
BRANCH=none
TEST=Connect samus to an unplugged zinger. Samus recognizes
a device has been plugged in and sends source cap for 5
seconds (50 attempts at 100ms retry period), then stops
sending source cap but remains in discovery state providing
VBUS.
Change-Id: I0aa25263f200299a0eb8d219883f825ae655129c
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/211335
-rw-r--r-- | common/usb_pd_protocol.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 371e03ead5..0df1c69605 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -966,6 +966,7 @@ void pd_task(void) #endif enum pd_states this_state; timestamp_t now; + int caps_count = 0; /* Initialize TX pins and put them in Hi-Z */ pd_tx_init(); @@ -1026,6 +1027,7 @@ void pd_task(void) /* Enable VBUS */ pd_set_power_supply_ready(port); set_state(port, PD_STATE_SRC_DISCOVERY); + 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; @@ -1047,13 +1049,19 @@ void pd_task(void) #endif break; case PD_STATE_SRC_DISCOVERY: - /* Query capabilites of the other side */ - res = send_source_cap(port); - /* packet was acked => PD capable device) */ - if (res >= 0) { - set_state(port, PD_STATE_SRC_NEGOCIATE); - } else { /* failed, retry later */ - timeout = PD_T_SEND_SOURCE_CAP; + /* Send source cap some minimum number of times */ + if (caps_count < PD_CAPS_COUNT) { + /* Query capabilites of the other side */ + res = send_source_cap(port); + /* packet was acked => PD capable device) */ + if (res >= 0) { + set_state(port, + PD_STATE_SRC_NEGOCIATE); + caps_count = 0; + } else { /* failed, retry later */ + timeout = PD_T_SEND_SOURCE_CAP; + caps_count++; + } } break; case PD_STATE_SRC_NEGOCIATE: |