summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyushee Shah <ayushee.shah@intel.com>2021-02-26 13:02:30 -0800
committerCommit Bot <commit-bot@chromium.org>2021-03-10 02:03:58 +0000
commit43fe3569949f74ece62d6a82829355c39a010d65 (patch)
tree6e354ed3d13cca1c4569c75697e2ea57f2d8f983
parentd3372a419d5e4c78fedb70a125390a005938df10 (diff)
downloadchrome-ec-43fe3569949f74ece62d6a82829355c39a010d65.tar.gz
USB4: For AP mode entry, add support for active cables
For AP mode entry, request to enter Thunderbolt cable mode entry prior to entering USB4 mode if - 1. Thunderbolt Mode SOP' VDO active/passive bit (B25) is TBT_CABLE_ACTIVE or 2. It's an active cable with VDM version < 2.0 or VDO version < 1.3 BUG=b:181286325 BRANCH=None TEST=Able to enter USB4 mode with LRD cable Signed-off-by: Ayushee Shah <ayushee.shah@intel.com> Change-Id: Ie223fa3d95c2357a0e50aeea93444e6f7639cc3f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2724653 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--common/usbc/tbt_alt_mode.c31
-rw-r--r--common/usbc/usb_pd_dpm.c24
-rw-r--r--include/usb_tbt_alt_mode.h10
3 files changed, 47 insertions, 18 deletions
diff --git a/common/usbc/tbt_alt_mode.c b/common/usbc/tbt_alt_mode.c
index 793de4c778..3ce66f7e5d 100644
--- a/common/usbc/tbt_alt_mode.c
+++ b/common/usbc/tbt_alt_mode.c
@@ -222,6 +222,37 @@ static void tbt_active_cable_exit_mode(int port)
tbt_state[port] = TBT_EXIT_SOP_PRIME;
}
+bool tbt_cable_entry_required_for_usb4(int port)
+{
+ struct pd_discovery *disc_sop_prime;
+ union tbt_mode_resp_cable cable_mode_resp;
+
+ /* Request to enter Thunderbolt mode for the cable prior to entering
+ * USB4 mode if -
+ * 1. Thunderbolt Mode SOP' VDO active/passive bit (B25) is
+ * TBT_CABLE_ACTIVE or
+ * 2. It's an active cable with VDM version < 2.0 or
+ * VDO version < 1.3
+ */
+ if (tbt_cable_entry_is_done(port))
+ return false;
+
+ cable_mode_resp.raw_value =
+ pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME);
+
+ if (cable_mode_resp.tbt_active_passive == TBT_CABLE_ACTIVE)
+ return true;
+
+ if (get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE) {
+ disc_sop_prime = pd_get_am_discovery(port, TCPC_TX_SOP_PRIME);
+ if (pd_get_vdo_ver(port, TCPC_TX_SOP_PRIME) < VDM_VER20 ||
+ disc_sop_prime->identity.product_t1.a_rev30.vdo_ver <
+ VDO_VERSION_1_3)
+ return true;
+ }
+ return false;
+}
+
void intel_vdm_acked(int port, enum tcpm_transmit_type type, int vdo_count,
uint32_t *vdm)
{
diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c
index 716c63d175..7e7c002721 100644
--- a/common/usbc/usb_pd_dpm.c
+++ b/common/usbc/usb_pd_dpm.c
@@ -280,26 +280,14 @@ static void dpm_attempt_mode_entry(int port)
enter_usb_port_partner_is_capable(port) &&
enter_usb_cable_is_capable(port) &&
dpm_mode_entry_requested(port, TYPEC_MODE_USB4)) {
- struct pd_discovery *disc_sop_prime =
- pd_get_am_discovery(port, TCPC_TX_SOP_PRIME);
- union tbt_mode_resp_cable cable_mode_resp = {
- .raw_value = pd_get_tbt_mode_vdo(port,
- TCPC_TX_SOP_PRIME) };
/*
- * Enter USB mode if -
- * 1. It's a passive cable and Thunderbolt Mode SOP' VDO
- * active/passive bit (B25) is TBT_CABLE_PASSIVE or
- * 2. It's a active cable with VDM version >= 2.0 and
- * VDO version >= 1.3 or
- * 3. The cable has entered Thunderbolt mode.
+ * For certain cables, enter Thunderbolt alt mode with the
+ * cable and USB4 mode with the port partner.
*/
- if ((get_usb_pd_cable_type(port) == IDH_PTYPE_PCABLE &&
- cable_mode_resp.tbt_active_passive == TBT_CABLE_PASSIVE) ||
- (get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE &&
- pd_get_vdo_ver(port, TCPC_TX_SOP_PRIME) >= VDM_VER20 &&
- disc_sop_prime->identity.product_t1.a_rev30.vdo_ver >=
- VDO_VERSION_1_3) ||
- tbt_cable_entry_is_done(port)) {
+ if (tbt_cable_entry_required_for_usb4(port)) {
+ vdo_count = tbt_setup_next_vdm(port,
+ ARRAY_SIZE(vdm), vdm, &tx_type);
+ } else {
pd_dpm_request(port, DPM_REQUEST_ENTER_USB);
return;
}
diff --git a/include/usb_tbt_alt_mode.h b/include/usb_tbt_alt_mode.h
index 3be7c60205..01604d72ae 100644
--- a/include/usb_tbt_alt_mode.h
+++ b/include/usb_tbt_alt_mode.h
@@ -30,6 +30,16 @@ void tbt_init(int port);
void tbt_exit_mode_request(int port);
/*
+ * Checks whether Thunderbolt cable mode entry is required prior to entering
+ * USB4.
+ *
+ * @param port USB-C port number
+ * @return True if Thunderbolt cable mode entry is required
+ * False otherwise
+ */
+bool tbt_cable_entry_required_for_usb4(int port);
+
+/*
* Checks whether the mode entry sequence for Thunderbolt alternate mode is
* done for a port.
*