diff options
author | Diana Z <dzigterman@chromium.org> | 2020-10-16 15:24:54 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-19 23:20:56 +0000 |
commit | dc5a1a0294ac6933205866a41e0f6ae1c4e4c615 (patch) | |
tree | df19f43dc15730b9158b5d6c8c5cad7129f1ba03 | |
parent | e1d70859fa3543c5ae5b4bed820aca2ca277ea17 (diff) | |
download | chrome-ec-dc5a1a0294ac6933205866a41e0f6ae1c4e4c615.tar.gz |
TCPMv2: Add debug detach interface
Some TCPCs may require special commands to be run after a debug
accessory leaves the Attached.SNK/SRC states. Add an interface to
support this, and call it from the TC when needed.
BRANCH=None
BUG=b:159495742,b:170259606
TEST=make -j buildall
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I79c7ebc308958c598cfa228598362c97b9b00e86
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2481941
-rw-r--r-- | common/usbc/usb_tc_drp_acc_trysrc_sm.c | 6 | ||||
-rw-r--r-- | driver/tcpm/tcpm.h | 9 | ||||
-rw-r--r-- | include/usb_pd_tcpm.h | 8 |
3 files changed, 23 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 0c3767263d..3382c3b84c 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -2474,6 +2474,9 @@ static void tc_attached_snk_exit(const int port) /* Stop drawing power */ sink_stop_drawing_current(port); + + if (TC_CHK_FLAG(port, TC_FLAGS_TS_DTS_PARTNER)) + tcpm_debug_detach(port); } /** @@ -2970,6 +2973,9 @@ static void tc_attached_src_exit(const int port) /* Clear PR swap flag after checking for Vconn */ TC_CLR_FLAG(port, TC_FLAGS_REQUEST_PR_SWAP); + + if (TC_CHK_FLAG(port, TC_FLAGS_TS_DTS_PARTNER)) + tcpm_debug_detach(port); } static __maybe_unused void check_drp_connection(const int port) diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h index e1db30ecb8..7450bbf7c3 100644 --- a/driver/tcpm/tcpm.h +++ b/driver/tcpm/tcpm.h @@ -312,6 +312,15 @@ static inline int tcpm_debug_accessory(int port, bool enable) return EC_SUCCESS; } +static inline int tcpm_debug_detach(int port) +{ + if (tcpc_config[port].drv->debug_detach) + return tcpc_config[port].drv->debug_detach(port); + + /* No special handling for debug disconnections? Success! */ + return EC_SUCCESS; +} + #ifdef CONFIG_USB_PD_TCPC_LOW_POWER static inline int tcpm_enter_low_power_mode(int port) { diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h index b4cd7654a7..91837a55c3 100644 --- a/include/usb_pd_tcpm.h +++ b/include/usb_pd_tcpm.h @@ -326,6 +326,14 @@ struct tcpm_drv { */ int (*debug_accessory)(int port, bool enable); + /** + * Break debug connection, if TCPC requires specific commands to be run + * in order to correctly exit a debug connection. + * + * @param port Type-C port number + */ + int (*debug_detach)(int port); + #ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE /** * Enable TCPC auto DRP toggling. |