diff options
author | Andrew McRae <amcrae@google.com> | 2020-06-22 01:23:52 +1000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-06-24 07:15:59 +0000 |
commit | e6636517406afa7115825de36ac52b5498ca70c4 (patch) | |
tree | ca551b16e9a4b6ce14765b0e5d615e212611f38c /common/usb_pd_alt_mode_dfp.c | |
parent | 40d09f45d976574338455821a01faae79174a7c2 (diff) | |
download | chrome-ec-e6636517406afa7115825de36ac52b5498ca70c4.tar.gz |
TCPMv2: Refactor DP mode to use a state machine
Refactor the DP alt mode handling to use a state machine
to process the commands, ACKs and NAKs.
Also add states to handle detecting a NAK on a DP mode enter command,
and attempt to exit the mode and then retry.
When a partner enters alt mode (e.g a monitor with DP alt mode), and
the EC is reset or goes into recovery mode, the new negotiation will
fail because the command to enter alt mode when the partner is already
in that mode will fail with a NAK.
BUG=b:159073520
TEST=Tested on duffy with a type-C monitor.
BRANCH=none
Signed-off-by: Andrew McRae <amcrae@google.com>
Change-Id: I0b4506b17987ba71e51f019910db84b32a6da2c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2256620
Reviewed-by: Andrew McRae <amcrae@chromium.org>
Commit-Queue: Andrew McRae <amcrae@chromium.org>
Tested-by: Andrew McRae <amcrae@chromium.org>
Diffstat (limited to 'common/usb_pd_alt_mode_dfp.c')
-rw-r--r-- | common/usb_pd_alt_mode_dfp.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c index 421ae72024..233fb4ea0f 100644 --- a/common/usb_pd_alt_mode_dfp.c +++ b/common/usb_pd_alt_mode_dfp.c @@ -245,6 +245,12 @@ uint32_t pd_dfp_enter_mode(int port, enum tcpm_transmit_type type, if (modep->fx->enter(port, mode_caps) == -1) return 0; + /* + * Strictly speaking, this should only happen when the request + * has been ACKed. + * TODO: Redo setting the enter mode flag to incorporate + * it into the DP state machine. + */ pd_set_dfp_enter_mode_flag(port, true); /* SVDM to send to UFP for mode entry */ @@ -1237,7 +1243,7 @@ __overridable void svdm_exit_dp_mode(int port) baseboard_mst_enable_control(port, 0); #endif #ifdef CONFIG_USB_PD_TCPMV2 - dp_reset_next_command(port); + dp_teardown(port); #endif } |