diff options
author | Sam Hurst <shurst@google.com> | 2020-01-30 14:06:46 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-12 23:44:00 +0000 |
commit | 36d2d918d324214afdb2e6cb05de9ed40ee681ef (patch) | |
tree | f92817af05b265b7ed86a5b5dee72fef26096a1e | |
parent | 7f3b64dd6abccf6fdb592eaf06901166cd2833bd (diff) | |
download | chrome-ec-36d2d918d324214afdb2e6cb05de9ed40ee681ef.tar.gz |
TCPMv2: Allow reduced functionality to PD2.0 features
Some TCPCs only work with PD2.0 messages. So a config flag
is added to restrict the TCPMv2 stack to working at PD2.0
revision.
If the config flag is defined, the PD revision is fixed at
PD2.0. In a future CL, the config flag can also be used
to reduce code size by not compiling in PD3.0 features.
BUG=chromium:1021235
BRANCH=none
TEST=make -j buildall
Manual tests:
Verified that the stack only works at PD2.0 rev,
using a twinki and several docks.
Signed-off-by: Sam Hurst <shurst@google.com>
Change-Id: Ic5fc8d24baec3bdecffb4dd54a6aac28d72550cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2032145
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Commit-Queue: Sam Hurst <shurst@google.com>
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 8 | ||||
-rw-r--r-- | common/usbc/usb_prl_sm.c | 10 | ||||
-rw-r--r-- | include/config.h | 15 | ||||
-rw-r--r-- | include/usb_pd.h | 6 |
4 files changed, 28 insertions, 11 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 2f627f367f..c490508674 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -1335,8 +1335,7 @@ static void pe_src_send_capabilities_run(int port) * ports. */ prl_set_rev(port, TCPC_TX_SOP, - (PD_HEADER_REV(emsg[port].header) > PD_REV30) ? - PD_REV30 : PD_HEADER_REV(emsg[port].header)); + MIN(PD_REVISION, PD_HEADER_REV(emsg[port].header))); /* * If port partner runs PD 2.0, cable communication must @@ -2034,7 +2033,6 @@ static void pe_snk_wait_for_capabilities_run(int port) static void pe_snk_evaluate_capability_entry(int port) { uint32_t *pdo = (uint32_t *)emsg[port].buf; - uint32_t header = emsg[port].header; uint32_t num = emsg[port].len >> 2; int i; @@ -2044,8 +2042,8 @@ static void pe_snk_evaluate_capability_entry(int port) pe[port].hard_reset_counter = 0; /* Set to highest revision supported by both ports. */ - prl_set_rev(port, TCPC_TX_SOP, (PD_HEADER_REV(header) > PD_REV30) ? - PD_REV30 : PD_HEADER_REV(header)); + prl_set_rev(port, TCPC_TX_SOP, + MIN(PD_REVISION, PD_HEADER_REV(emsg[port].header))); /* * If port partner runs PD 2.0, cable communication must diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index 9314049bf8..1cc5636118 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -322,11 +322,11 @@ static void prl_init(int port) * partner doesn't support this revision, the Protocol Engine will * lower this value to the revision supported by the partner. */ - pdmsg[port].rev[TCPC_TX_SOP] = PD_REV30; - pdmsg[port].rev[TCPC_TX_SOP_PRIME] = PD_REV30; - pdmsg[port].rev[TCPC_TX_SOP_PRIME_PRIME] = PD_REV30; - pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME] = PD_REV30; - pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME_PRIME] = PD_REV30; + pdmsg[port].rev[TCPC_TX_SOP] = PD_REVISION; + pdmsg[port].rev[TCPC_TX_SOP_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPC_TX_SOP_PRIME_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME_PRIME] = PD_REVISION; pdmsg[port].flags = 0; prl_hr[port].flags = 0; diff --git a/include/config.h b/include/config.h index ba48d21b71..89b622cd85 100644 --- a/include/config.h +++ b/include/config.h @@ -3746,7 +3746,20 @@ /* Define if this board, operating as a sink, can give power back to a source */ #undef CONFIG_USB_PD_GIVE_BACK -/* Enable USB PD Rev3.0 features */ +/* + * Enable USB PD Rev2.0 features only + * NOTE: + * This flag is only used with TCPMv2. The TCPMv2 stack defaults to PD3.0 + * and this flag disabled PD3.0 features. + */ +#undef CONFIG_USB_PD_REV20 + +/* + * Enable USB PD Rev3.0 features + * NOTE: + * This flag is only used with TCPMv1. The TCPMv1 stack defaults to PD2.0 + * and this flag enabled PD3.0 features. + */ #undef CONFIG_USB_PD_REV30 /* Major and Minor ChromeOS specific PD device Hardware IDs. */ diff --git a/include/usb_pd.h b/include/usb_pd.h index 8f313b8c64..cdd111d687 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -546,6 +546,12 @@ enum pd_rev_type { PD_REV30, }; +#ifdef CONFIG_USB_PD_REV20 +#define PD_REVISION PD_REV20 +#else +#define PD_REVISION PD_REV30 +#endif + /* Cable structure for storing cable attributes */ struct pd_cable { /* Note: the following fields are used by TCPMv1 */ |