summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-03-24 15:58:20 -0600
committerCommit Bot <commit-bot@chromium.org>2021-03-31 16:00:39 +0000
commit9b4324744dc8ce02d076edb60c7d7b787c57bc71 (patch)
tree02e7009fa759d7ccd7b8a92d0246e7d6eed69577
parentaa34bca17489797735deba81ce50836025c2c2c6 (diff)
downloadchrome-ec-9b4324744dc8ce02d076edb60c7d7b787c57bc71.tar.gz
TCPMv2: Call debug detach on toggle changes
When our power state changes partway through a debug connection starting, we may end up transitioning straight from a source to a sink role without calling the debug detach routine. Ensure that dual role changes call the debug detach when forcing state changes between source and sink, where we were not previously Attached. BRANCH=None BUG=b:183619502 TEST=on galith, firmware_UserRequestRecovery can pass Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Id2214487be9be4209dbd9bece94492bc4ac9c05e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2786068 Reviewed-by: Henry Sun <henrysun@google.com> Commit-Queue: Henry Sun <henrysun@google.com> Tested-by: Henry Sun <henrysun@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2795064 Tested-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index 8daf8704e2..269ded1159 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -1810,7 +1810,12 @@ static void pd_update_dual_role_config(int port)
* Change to sink if port is currently a source AND (new DRP
* state is force sink OR new DRP state is toggle off and we are
* in the source disconnected state).
+ *
+ * Force a debug detach in case there was an incomplete debug
+ * connection in progress.
*/
+ if (get_state_tc(port) != TC_ATTACHED_SRC)
+ tcpm_debug_detach(port);
set_state_tc(port, TC_UNATTACHED_SNK);
} else if (tc[port].power_role == PD_ROLE_SINK &&
drp_state[port] == PD_DRP_FORCE_SOURCE) {
@@ -1818,6 +1823,8 @@ static void pd_update_dual_role_config(int port)
* Change to source if port is currently a sink and the
* new DRP state is force source.
*/
+ if (get_state_tc(port) != TC_ATTACHED_SNK)
+ tcpm_debug_detach(port);
set_state_tc(port, TC_UNATTACHED_SRC);
}
}