summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/usb_pd_alt_mode_dfp.c21
-rw-r--r--common/usb_pd_policy.c3
-rw-r--r--common/usbc/tbt_alt_mode.c3
-rw-r--r--include/usb_pd.h10
4 files changed, 15 insertions, 22 deletions
diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c
index b0347067ce..8f2643ff1d 100644
--- a/common/usb_pd_alt_mode_dfp.c
+++ b/common/usb_pd_alt_mode_dfp.c
@@ -757,7 +757,7 @@ void set_tbt_compat_mode_ready(int port)
* Ref: USB Type-C Cable and Connector Specification
* Figure F-1 TBT3 Discovery Flow
*/
-bool is_tbt_cable_superspeed(int port)
+static bool is_tbt_cable_superspeed(int port)
{
struct pd_discovery *disc;
@@ -791,10 +791,15 @@ bool is_tbt_cable_superspeed(int port)
enum tbt_compat_cable_speed get_tbt_cable_speed(int port)
{
- union tbt_mode_resp_cable cable_mode_resp = {
- .raw_value = pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME) };
- enum tbt_compat_cable_speed max_tbt_speed =
- board_get_max_tbt_speed(port);
+ union tbt_mode_resp_cable cable_mode_resp;
+ enum tbt_compat_cable_speed max_tbt_speed;
+
+ if (!is_tbt_cable_superspeed(port))
+ return TBT_SS_RES_0;
+
+ cable_mode_resp.raw_value =
+ pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME);
+ max_tbt_speed = board_get_max_tbt_speed(port);
/*
* Ref: USB Type-C Cable and Connector Specification,
@@ -872,13 +877,9 @@ enum tbt_compat_rounded_support get_tbt_rounded_support(int port)
return cable_mode_resp.tbt_rounded;
}
-/* Return the current cable speed received from Cable Discover Mode command */
__overridable enum tbt_compat_cable_speed board_get_max_tbt_speed(int port)
{
- union tbt_mode_resp_cable cable_mode_resp = {
- .raw_value = pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME) };
-
- return cable_mode_resp.tbt_cable_speed;
+ return TBT_SS_TBT_GEN3;
}
/*
* ############################################################################
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c
index 5ad4188e54..b480981a2d 100644
--- a/common/usb_pd_policy.c
+++ b/common/usb_pd_policy.c
@@ -487,7 +487,8 @@ static int process_am_discover_ident_sop_prime(int port, int cnt,
* Disable Thunderbolt-compatible mode if the cable does not support
* superspeed.
*/
- if (is_tbt_compat_enabled(port) && !is_tbt_cable_superspeed(port))
+ if (is_tbt_compat_enabled(port) &&
+ get_tbt_cable_speed(port) < TBT_SS_U31_GEN1)
disable_tbt_compat_mode(port);
return dfp_discover_svids(payload);
diff --git a/common/usbc/tbt_alt_mode.c b/common/usbc/tbt_alt_mode.c
index 144126baa1..23261adb5e 100644
--- a/common/usbc/tbt_alt_mode.c
+++ b/common/usbc/tbt_alt_mode.c
@@ -405,8 +405,7 @@ static bool tbt_mode_is_supported(int port, int vdo_count)
if (!disc->identity.idh.modal_support)
return false;
- if (!(is_tbt_cable_superspeed(port) &&
- get_tbt_cable_speed(port) >= TBT_SS_U31_GEN1))
+ if (get_tbt_cable_speed(port) < TBT_SS_U31_GEN1)
return false;
/*
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 52557778cd..19ae64b45f 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -2168,14 +2168,6 @@ uint32_t pd_get_tbt_mode_vdo(int port, enum tcpm_transmit_type type);
void set_tbt_compat_mode_ready(int port);
/**
- * Checks if the attached cable supports superspeed
- *
- * @param port USB-C port number
- * @return True if cable is superspeed, false otherwise
- */
-bool is_tbt_cable_superspeed(int port);
-
-/**
* Returns Thunderbolt-compatible cable speed according to the port if,
* port supports lesser speed than the cable
*
@@ -2197,7 +2189,7 @@ int enter_tbt_compat_mode(int port, enum tcpm_transmit_type sop,
uint32_t *payload);
/**
- * Return maximum allowed speed for Thunderbolt-compatible mode
+ * Return maximum speed supported by the port to enter into Thunderbolt mode
*
* NOTE: Chromebooks require that all USB-C ports support the same features,
* so the maximum speed returned by this function should be set to the lowest