summaryrefslogtreecommitdiff
path: root/common/usb_pd_alt_mode_dfp.c
diff options
context:
space:
mode:
authorAyushee <ayushee.shah@intel.com>2020-07-01 03:19:57 -0700
committerCommit Bot <commit-bot@chromium.org>2020-07-06 21:07:16 +0000
commit1da311fab28081b89afa34f725aa800ca970ace1 (patch)
tree3259feb6390998b615e19ffdfeae4ddf6a718663 /common/usb_pd_alt_mode_dfp.c
parentc069beafbef2d94817acbd9108c93768160f3ae6 (diff)
downloadchrome-ec-1da311fab28081b89afa34f725aa800ca970ace1.tar.gz
usb_pd: Limit USB4 speed based on speed supported by port
For boards that do not support Thunderbolt compatible speed, shouldn't support USB4 speed as well. Hence this commit returns USB_R30_SS_U2_ONLY speed for boards not supporting Thunderbolt compatible speed. BUG=b:160273134 BRANCH=None TEST=Tested on Volteer with USB3 DB, able to enter into USB+DP mode with USB4 port partner and cable. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I14335ea28f0082b0f222ea2299b0d63e66e17697 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2277826 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/usb_pd_alt_mode_dfp.c')
-rw-r--r--common/usb_pd_alt_mode_dfp.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c
index b39f37a4e8..df07441103 100644
--- a/common/usb_pd_alt_mode_dfp.c
+++ b/common/usb_pd_alt_mode_dfp.c
@@ -928,43 +928,36 @@ bool is_usb4_vdo(int port, int cnt, uint32_t *payload)
* For Cable rev 3.0: USB4 cable speed is set according to speed supported by
* the port and the response received from the cable, whichever is least.
*
- * For Cable rev 2.0: Since board_is_tbt_usb4_port() should not enabled if the
- * port supports speed less than USB_R20_SS_U31_GEN1_GEN2, USB4 cable speed is
- * set according to the cable response.
+ * For Cable rev 2.0: If board_is_tbt_usb4_port() is less than
+ * TBT_SS_U32_GEN1_GEN2, return USB_R30_SS_U2_ONLY speed since the board
+ * doesn't support superspeed else the USB4 cable speed is set according to
+ * the cable response.
*/
-static enum usb_rev30_ss board_get_max_usb_cable_speed(int port)
+enum usb_rev30_ss get_usb4_cable_speed(int port)
{
- struct pd_discovery *disc =
- pd_get_am_discovery(port, TCPC_TX_SOP_PRIME);
+ struct pd_discovery *disc;
+ enum tbt_compat_cable_speed tbt_speed = board_get_max_tbt_speed(port);
+ enum usb_rev30_ss max_usb4_speed;
+
+
+ if (tbt_speed < TBT_SS_U32_GEN1_GEN2)
+ return USB_R30_SS_U2_ONLY;
+
/*
* Converting Thunderbolt-Compatible board speed to equivalent USB4
* speed.
*/
- enum usb_rev30_ss max_usb4_speed =
- board_get_max_tbt_speed(port) == TBT_SS_TBT_GEN3 ?
+ max_usb4_speed = tbt_speed == TBT_SS_TBT_GEN3 ?
USB_R30_SS_U40_GEN3 : USB_R30_SS_U32_U40_GEN2;
- return max_usb4_speed < disc->identity.product_t1.p_rev30.ss ?
- max_usb4_speed : disc->identity.product_t1.p_rev30.ss;
-}
-
-enum usb_rev30_ss get_usb4_cable_speed(int port)
-{
- enum usb_rev30_ss max_rev30_usb4_speed;
-
if (is_rev3_vdo(port, TCPC_TX_SOP_PRIME)) {
- max_rev30_usb4_speed = board_get_max_usb_cable_speed(port);
- if (!IS_ENABLED(CONFIG_USB_PD_TBT_GEN3_CAPABLE) ||
- max_rev30_usb4_speed != USB_R30_SS_U32_U40_GEN2 ||
- get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE)
- return max_rev30_usb4_speed;
+ disc = pd_get_am_discovery(port, TCPC_TX_SOP_PRIME);
+
+ return max_usb4_speed < disc->identity.product_t1.p_rev30.ss ?
+ max_usb4_speed : disc->identity.product_t1.p_rev30.ss;
}
- /*
- * Converting Thunderolt-Compatible cable speed to equivalent USB4 cable
- * speed.
- */
- return get_tbt_cable_speed(port) == TBT_SS_TBT_GEN3 ?
- USB_R30_SS_U40_GEN3 : USB_R30_SS_U32_U40_GEN2;
+
+ return max_usb4_speed;
}
uint32_t get_enter_usb_msg_payload(int port)