diff options
author | Sam Hurst <shurst@google.com> | 2016-11-29 13:58:51 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-12-02 16:52:52 -0800 |
commit | 22858a07a5076cb0c97d22c32071d2ff540934f6 (patch) | |
tree | 2226278cb8da91b5403801e9614fc11b711c1d4e /chip/host | |
parent | c5ebdd4a04984fc0962810912eb775e6a33f1167 (diff) | |
download | chrome-ec-22858a07a5076cb0c97d22c32071d2ff540934f6.tar.gz |
usb pd: Resend request after receiving a WAIT in response to a request
When a WAIT is received in response to a request, wait SinkRequestTime
before resending the request.
BUG=chrome-os-partner:34984
TEST=make -j buildall
BRANCH=none
Change-Id: I5c8429c4a7b9cf06609996f924b8d9d535ab6b5f
Reviewed-on: https://chromium-review.googlesource.com/414533
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'chip/host')
-rw-r--r-- | chip/host/usb_pd_phy.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/chip/host/usb_pd_phy.c b/chip/host/usb_pd_phy.c index 1a8e74b97e..96d7f06ea8 100644 --- a/chip/host/usb_pd_phy.c +++ b/chip/host/usb_pd_phy.c @@ -42,9 +42,30 @@ static const uint16_t enc4b5b[] = { 0x17, 0x1A, 0x1B, 0x1C, 0x1D}; /* Test utilities */ +static void pd_test_reset_phy(int port) +{ + int i; + int enc_len = PD_BIT_LEN / 5; + + for (i = 0; i < PD_BIT_LEN; i++) + pd_phy[port].bits[i] = 0; + + for (i = 0; i < enc_len; i++) + pd_phy[port].out_msg[i] = 0; + + pd_phy[port].total = 0; + pd_phy[port].has_preamble = 0; + pd_phy[port].rx_started = 0; + pd_phy[port].rx_monitoring = 0; + pd_phy[port].preamble_written = 0; + pd_phy[port].has_msg = 0; + pd_phy[port].last_edge_written = 0; + pd_phy[port].verified_idx = 0; +} void pd_test_rx_set_preamble(int port, int has_preamble) { + pd_phy[port].total = 0; pd_phy[port].has_preamble = has_preamble; } @@ -105,7 +126,8 @@ void pd_simulate_rx(int port) { if (!pd_phy[port].rx_monitoring) return; - pd_rx_start(port); + + pd_phy[port].rx_started = 1; pd_rx_disable_monitoring(port); pd_rx_event(port); } @@ -241,6 +263,7 @@ int pd_start_tx(int port, int polarity, int bit_len) pd_phy[port].has_msg = 0; pd_phy[port].preamble_written = 0; pd_phy[port].verified_idx = 0; + pd_phy[port].total = 0; /* * Hand over to test runner. The test runner must wake us after @@ -254,19 +277,23 @@ int pd_start_tx(int port, int polarity, int bit_len) void pd_tx_done(int port, int polarity) { - /* Nothing to do */ + pd_test_reset_phy(port); } void pd_rx_start(int port) { ASSERT(pd_phy[port].hw_init_done); + + task_wake(TASK_ID_TEST_RUNNER); + task_wait_event(-1); + pd_phy[port].rx_started = 1; } void pd_rx_complete(int port) { ASSERT(pd_phy[port].hw_init_done); - pd_phy[port].rx_started = 0; + pd_test_reset_phy(port); } int pd_rx_started(int port) |