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/usbc/usb_pd_dpm.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/usbc/usb_pd_dpm.c')
-rw-r--r-- | common/usbc/usb_pd_dpm.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index 7ea44d169e..e7136f41bc 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -8,6 +8,7 @@ * Refer to USB PD 3.0 spec, version 2.0, sections 8.2 and 8.3 */ +#include "charge_state.h" #include "compile_time_macros.h" #include "console.h" #include "usb_dp_alt_mode.h" @@ -79,6 +80,15 @@ void dpm_attempt_mode_entry(int port) if (pd_get_data_role(port) != PD_ROLE_DFP) return; /* + * Do not try to enter mode while CPU is off. + * CPU transitions (e.g b/158634281) can occur during the discovery + * phase or during enter/exit negotiations, and the state + * of the modes can get out of sync, causing the attempt to + * enter the mode to fail prematurely. + */ + if (chipset_in_or_transitioning_to_state(CHIPSET_STATE_ANY_OFF)) + return; + /* * If discovery has not occurred for modes, do not attempt to switch * to alt mode. */ |