diff options
author | Abe Levkoy <alevkoy@chromium.org> | 2020-04-30 12:16:31 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-12 01:02:56 +0000 |
commit | 5017fef617a6bdff3340a22915d2a79446591d7d (patch) | |
tree | 9b18dfc02211aa969af28bbf42d899b31765a68a /common/usb_pd_policy.c | |
parent | af7303f8b929fa0fc11173a27a1fc16666706d9b (diff) | |
download | chrome-ec-5017fef617a6bdff3340a22915d2a79446591d7d.tar.gz |
TCPMv2: Define fields for SVID discovery state
Index discovery results by SOP type and track SVID discovery state for
each type. Define accessors for this state and modify existing accessors
to be SOP-type-aware.
BUG=b:152419850,b:152418267
TEST=make buildall; attach port partner; observe discovery via Twinkie
BRANCH=none
Change-Id: I24ee19aac087c5752a3a822ab2b0c9da7a55af1b
Signed-off-by: Abe Levkoy <alevkoy@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2174464
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'common/usb_pd_policy.c')
-rw-r--r-- | common/usb_pd_policy.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index 4721fcc07d..d85f347351 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -499,8 +499,12 @@ static int dfp_discover_svids(uint32_t *payload) return 1; } -struct pd_discovery *pd_get_am_discovery(int port) +struct pd_discovery *pd_get_am_discovery(int port, enum tcpm_transmit_type type) { + /* + * TCPMv2 separates discovered data by partner (SOP vs. SOP'); TCPMv1 + * depends on both types being in the same structure. + */ return &discovery[port]; } @@ -548,7 +552,12 @@ static int process_am_discover_svids(int port, int cnt, uint32_t *payload) { int prev_svid_cnt = discovery[port].svid_cnt; - dfp_consume_svids(port, cnt, payload); + /* + * The pd_discovery structure stores SOP and SOP' discovery results + * separately, but TCPMv1 depends on one-dimensional storage of SVIDs + * and modes. Therefore, always use TCPC_TX_SOP in TCPMv1. + */ + dfp_consume_svids(port, TCPC_TX_SOP, cnt, payload); /* * Ref: USB Type-C Cable and Connector Specification, @@ -846,7 +855,13 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, rsize = process_am_discover_svids(port, cnt, payload); break; case CMD_DISCOVER_MODES: - dfp_consume_modes(port, cnt, payload); + /* + * The pd_discovery structure stores SOP and SOP' + * discovery results separately, but TCPMv1 depends on + * one-dimensional storage of SVIDs and modes. + * Therefore, always use TCPC_TX_SOP in TCPMv1. + */ + dfp_consume_modes(port, TCPC_TX_SOP, cnt, payload); if (is_tbt_compat_enabled(port) && is_tbt_compat_mode(port, cnt, payload)) { rsize = process_tbt_compat_discover_modes( |