summaryrefslogtreecommitdiff
path: root/common/usbc/tbt_alt_mode.c
diff options
context:
space:
mode:
authorAyushee <ayushee.shah@intel.com>2020-08-03 15:29:33 -0700
committerCommit Bot <commit-bot@chromium.org>2020-08-07 02:04:45 +0000
commit1c95a4357913547541e8ab3ea4d4d4092983fc99 (patch)
treea5d8e3942dac0180a0c33b79b6ae0dc96c6eba82 /common/usbc/tbt_alt_mode.c
parent556eed34e390a4ed257cb56c4f1ab9c444158921 (diff)
downloadchrome-ec-1c95a4357913547541e8ab3ea4d4d4092983fc99.tar.gz
TBT: Enter DP mode if Thunderbolt mode isn't supported
This commit checks if the Thunderbolt mode is supported at TBT_START. If the port/port-partner/cable doesn't support Thunderbolt mode, fall back on DP mode instead. BUG=b:162776463 BRANCH=None TEST=Able to detect Thunderbolt docks as Display port dock on port 0. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I424772c96afa9f3f11e5d4d9daa562bbbb011381 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2335883 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Diffstat (limited to 'common/usbc/tbt_alt_mode.c')
-rw-r--r--common/usbc/tbt_alt_mode.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/common/usbc/tbt_alt_mode.c b/common/usbc/tbt_alt_mode.c
index 5c763ea287..6baa2e75d7 100644
--- a/common/usbc/tbt_alt_mode.c
+++ b/common/usbc/tbt_alt_mode.c
@@ -311,25 +311,32 @@ void intel_vdm_naked(int port, enum tcpm_transmit_type type, uint8_t vdm_cmd)
}
}
-int tbt_setup_next_vdm(int port, int vdo_count, uint32_t *vdm,
- enum tcpm_transmit_type *tx_type)
+static bool tbt_mode_is_supported(int port, int vdo_count)
{
const struct pd_discovery *disc =
pd_get_am_discovery(port, TCPC_TX_SOP);
+
+ return disc->identity.idh.modal_support &&
+ is_tbt_cable_superspeed(port) &&
+ get_tbt_cable_speed(port) >= TBT_SS_U31_GEN1;
+}
+
+int tbt_setup_next_vdm(int port, int vdo_count, uint32_t *vdm,
+ enum tcpm_transmit_type *tx_type)
+{
struct svdm_amode_data *modep;
int vdo_count_ret = 0;
- if (vdo_count < VDO_MAX_SIZE ||
- !disc->identity.idh.modal_support ||
- !is_tbt_cable_superspeed(port) ||
- get_tbt_cable_speed(port) < TBT_SS_U31_GEN1) {
- return -1;
- }
-
*tx_type = TCPC_TX_SOP;
+ if (vdo_count < VDO_MAX_SIZE)
+ return -1;
+
switch (tbt_state[port]) {
case TBT_START:
+ if (!tbt_mode_is_supported(port, vdo_count))
+ return 0;
+
if (!retry_done)
tbt_prints("attempt to enter mode", port);
else