diff options
author | Diana Z <dzigterman@chromium.org> | 2018-09-27 14:55:27 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-29 21:07:08 +0000 |
commit | 250e4d44be20159497014e7c3cf3f745cc5b0c01 (patch) | |
tree | 3b4f67a360e4a8a298010ba6823e1e93f1f97f33 | |
parent | 8a8bc9ef3307315ff4fc8669380226effb3dcd56 (diff) | |
download | chrome-ec-250e4d44be20159497014e7c3cf3f745cc5b0c01.tar.gz |
PD 3.0: Send Reject messages for refusing swaps
When refusing a PR_Swap, DR_Swap, or VCONN_Swap the Reject control message
needs to be used rather than Not_supported.
BRANCH=None
BUG=b:64411727
TEST=tested with a PD 3.0 hub which always requests a DR_swap upon
connection. Previously, it would leave its cc line at NG upon receiving
the unexpected Not_supported response and it now leaves the line at OK.
Change-Id: Ifafbadece5c45e51f4100be5e3590c07fcb27346
Signed-off-by: Diana Z <dzigterman@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1250023
Commit-Queue: Keith Short <keithshort@chromium.org>
Tested-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index edf6cee255..97aeb3eb2c 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -141,16 +141,18 @@ static uint8_t pd_try_src_enable; #ifdef CONFIG_USB_PD_REV30 /* - * The spec. revision is used to index into this array. + * The spec. revision is the argument for this macro. * Rev 0 (PD 1.0) - return PD_CTRL_REJECT * Rev 1 (PD 2.0) - return PD_CTRL_REJECT * Rev 2 (PD 3.0) - return PD_CTRL_NOT_SUPPORTED + * + * Note: this should only be used in locations where responding on a lower + * revision with a Reject is valid (ex. a source refusing a PR_Swap). For + * other uses of Not_Supported, use PD_CTRL_NOT_SUPPORTED directly. */ -static const uint8_t refuse[] = { - PD_CTRL_REJECT, PD_CTRL_REJECT, PD_CTRL_NOT_SUPPORTED}; -#define REFUSE(r) refuse[r] +#define NOT_SUPPORTED(r) (r < 2 ? PD_CTRL_REJECT : PD_CTRL_NOT_SUPPORTED) #else -#define REFUSE(r) PD_CTRL_REJECT +#define NOT_SUPPORTED(r) PD_CTRL_REJECT #endif #ifdef CONFIG_USB_PD_REV30 @@ -1779,7 +1781,7 @@ static void handle_ctrl_request(int port, uint16_t head, #ifdef CONFIG_USB_PD_DUAL_ROLE send_sink_cap(port); #else - send_control(port, REFUSE(pd[port].rev)); + send_control(port, NOT_SUPPORTED(pd[port].rev)); #endif break; #ifdef CONFIG_USB_PD_DUAL_ROLE @@ -1976,10 +1978,10 @@ static void handle_ctrl_request(int port, uint16_t head, PD_STATE_SNK_SWAP_SNK_DISABLE, PD_STATE_SRC_SWAP_SNK_DISABLE)); } else { - send_control(port, REFUSE(pd[port].rev)); + send_control(port, PD_CTRL_REJECT); } #else - send_control(port, REFUSE(pd[port].rev)); + send_control(port, NOT_SUPPORTED(pd[port].rev)); #endif break; case PD_CTRL_DR_SWAP: @@ -1993,7 +1995,7 @@ static void handle_ctrl_request(int port, uint16_t head, if (send_control(port, PD_CTRL_ACCEPT) >= 0) pd_dr_swap(port); } else { - send_control(port, REFUSE(pd[port].rev)); + send_control(port, PD_CTRL_REJECT); } break; @@ -2006,11 +2008,11 @@ static void handle_ctrl_request(int port, uint16_t head, set_state(port, PD_STATE_VCONN_SWAP_INIT); } else { - send_control(port, REFUSE(pd[port].rev)); + send_control(port, PD_CTRL_REJECT); } } #else - send_control(port, REFUSE(pd[port].rev)); + send_control(port, NOT_SUPPORTED(pd[port].rev)); #endif break; default: |