summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyushee Shah <ayushee.shah@intel.com>2021-01-21 20:50:06 -0800
committerCommit Bot <commit-bot@chromium.org>2021-02-11 20:41:23 +0000
commit9c95c05d6d44f50ec11f7a249bb8755de071e0e1 (patch)
treead6fda73af1823d63183b9c3ee429537159f6f35
parenta56c816a329d4c78d54518c16f995bcf21d4a714 (diff)
downloadchrome-ec-9c95c05d6d44f50ec11f7a249bb8755de071e0e1.tar.gz
TCPMv2: Update exit mode sequence
On exit mode request - Instead to entering safe mode -> USB mode, this CL updates the sequence to - 1. Set Mux, retimer to disconnect 2. Send exit mode to cable/port-partner 3. Set mux and retimer to USB mode BUG=b:173459141 BRANCH=None TEST=Able to re-enter into alternate mode with AP driver approach Change-Id: I6f8f2d4523736100057de4425b3df64b90858e70 Signed-off-by: Ayushee Shah <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2643523 Reviewed-by: Divya S Sasidharan <divya.s.sasidharan@intel.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--common/usb_common.c11
-rw-r--r--common/usb_pd_alt_mode_dfp.c2
-rw-r--r--common/usbc/dp_alt_mode.c3
-rw-r--r--common/usbc/tbt_alt_mode.c9
-rw-r--r--include/usb_common.h11
5 files changed, 32 insertions, 4 deletions
diff --git a/common/usb_common.c b/common/usb_common.c
index 81e9d2f24f..7005e4a8b0 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -470,6 +470,17 @@ void usb_mux_set_safe_mode(int port)
ppc_set_sbu(port, 0);
}
+void usb_mux_set_safe_mode_exit(int port)
+{
+ if (IS_ENABLED(CONFIG_USBC_SS_MUX))
+ usb_mux_set(port, USB_PD_MUX_NONE, USB_SWITCH_CONNECT,
+ polarity_rm_dts(pd_get_polarity(port)));
+
+ /* Isolate the SBU lines. */
+ if (IS_ENABLED(CONFIG_USBC_PPC_SBU))
+ ppc_set_sbu(port, 0);
+}
+
static void pd_send_hard_reset(int port)
{
task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_SEND_HARD_RESET);
diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c
index e3964d4ca7..3c9a641490 100644
--- a/common/usb_pd_alt_mode_dfp.c
+++ b/common/usb_pd_alt_mode_dfp.c
@@ -1232,6 +1232,8 @@ __overridable int svdm_dp_attention(int port, uint32_t *payload)
__overridable void svdm_exit_dp_mode(int port)
{
+ dp_flags[port] = 0;
+ dp_status[port] = 0;
#ifdef CONFIG_USB_PD_DP_HPD_GPIO
svdm_set_hpd_gpio(port, 0);
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
diff --git a/common/usbc/dp_alt_mode.c b/common/usbc/dp_alt_mode.c
index af5db7263b..8e22c23170 100644
--- a/common/usbc/dp_alt_mode.c
+++ b/common/usbc/dp_alt_mode.c
@@ -261,7 +261,8 @@ int dp_setup_next_vdm(int port, int vdo_count, uint32_t *vdm)
if (!(modep && modep->opos))
return -1;
- svdm_safe_dp_mode(port);
+ usb_mux_set_safe_mode_exit(port);
+
vdm[0] = VDO(USB_SID_DISPLAYPORT,
1, /* structured */
CMD_EXIT_MODE);
diff --git a/common/usbc/tbt_alt_mode.c b/common/usbc/tbt_alt_mode.c
index 72a633c451..793de4c778 100644
--- a/common/usbc/tbt_alt_mode.c
+++ b/common/usbc/tbt_alt_mode.c
@@ -488,7 +488,8 @@ int tbt_setup_next_vdm(int port, int vdo_count, uint32_t *vdm,
if (!(modep && modep->opos))
return -1;
- usb_mux_set_safe_mode(port);
+ usb_mux_set_safe_mode_exit(port);
+
vdm[0] = VDO(USB_VID_INTEL, 1, CMD_EXIT_MODE) |
VDO_OPOS(modep->opos) |
VDO_CMDT(CMDT_INIT) |
@@ -502,7 +503,8 @@ int tbt_setup_next_vdm(int port, int vdo_count, uint32_t *vdm,
if (!(modep && modep->opos))
return -1;
- usb_mux_set_safe_mode(port);
+ usb_mux_set_safe_mode_exit(port);
+
vdm[0] = VDO(USB_VID_INTEL, 1, CMD_EXIT_MODE) |
VDO_OPOS(modep->opos) |
VDO_CMDT(CMDT_INIT) |
@@ -517,7 +519,8 @@ int tbt_setup_next_vdm(int port, int vdo_count, uint32_t *vdm,
if (!(modep && modep->opos))
return -1;
- usb_mux_set_safe_mode(port);
+ usb_mux_set_safe_mode_exit(port);
+
vdm[0] = VDO(USB_VID_INTEL, 1, CMD_EXIT_MODE) |
VDO_OPOS(modep->opos) |
VDO_CMDT(CMDT_INIT) |
diff --git a/include/usb_common.h b/include/usb_common.h
index 526143138a..00440390df 100644
--- a/include/usb_common.h
+++ b/include/usb_common.h
@@ -174,6 +174,17 @@ void set_usb_mux_with_current_data_role(int port);
void usb_mux_set_safe_mode(int port);
/**
+ * Configure the USB MUX in safe mode while exiting an alternate mode.
+ * Although the TCSS (virtual mux) has a distinct safe mode state, it
+ * needs to be in a disconnected state to properly exit an alternate
+ * mode. Therefore, do not treat the virtual mux as a special case, as
+ * usb_mux_set_safe_mode does.
+ *
+ * @param port The PD port number
+ */
+void usb_mux_set_safe_mode_exit(int port);
+
+/**
* Get the PD flags stored in BB Ram
*
* @param port USB-C port number