diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-01-09 11:11:56 -0800 |
---|---|---|
committer | Alec Berg <alecaberg@chromium.org> | 2015-01-10 23:44:09 +0000 |
commit | 5c26087ef381fbe8469498eb65ecb10fc62ba349 (patch) | |
tree | 438c520f99c4da9175d277addc21f7d8eb592169 | |
parent | 8fbb6e8070bbe4dacbca44f48c49fe548a5c3e39 (diff) | |
download | chrome-ec-5c26087ef381fbe8469498eb65ecb10fc62ba349.tar.gz |
pd: avoid multiple role swaps on connect
Avoid multiple power and data swaps on connect by clearing our
local flag for checking our role when we receive a role swap.
This means if the port partner sends a role swap on connect before
us and we accept, then we will not turn around and ask for another
swap.
BUG=none
BRANCH=samus
TEST=connect samus to samus and make sure only one swap on connect.
Change-Id: I2414b5bd5ffc54701b5758047e5d7e51ca3ff596
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/239951
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index d54c20dcac..8a837be345 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1161,6 +1161,11 @@ static void handle_ctrl_request(int port, uint16_t head, #ifdef CONFIG_USB_PD_DUAL_ROLE if (pd_check_power_swap(port)) { send_control(port, PD_CTRL_ACCEPT); + /* + * Clear flag for checking power role to avoid + * immediately requesting another swap. + */ + pd[port].flags &= ~PD_FLAGS_CHECK_PR_ROLE; if (pd[port].power_role == PD_ROLE_SINK) set_state(port, PD_STATE_SNK_SWAP_SNK_DISABLE); else @@ -1174,7 +1179,12 @@ static void handle_ctrl_request(int port, uint16_t head, break; case PD_CTRL_DR_SWAP: if (pd_check_data_swap(port, pd[port].data_role)) { - /* Accept switch and perform data swap */ + /* + * Accept switch and perform data swap. Clear + * flag for checking data role to avoid + * immediately requesting another swap. + */ + pd[port].flags &= ~PD_FLAGS_CHECK_DR_ROLE; if (send_control(port, PD_CTRL_ACCEPT) >= 0) pd_dr_swap(port); } else { |