[PATCH v3 2/4] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode

From: Utkarsh Patel
Date: Thu Nov 19 2020 - 01:34:05 EST


Configure Thunderbolt 3 cable generation value by filling Thunderbolt 3
cable discover mode VDO to support rounded Thunderbolt 3 cables.
While we are here use Thunderbolt 3 cable discover mode VDO to fill active
cable plug link training value.

Suggested-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
Signed-off-by: Utkarsh Patel <utkarsh.h.patel@xxxxxxxxx>

--
Changes in v3:
- Added a check for cable's TBT support before filling TBT3 discover mode
VDO.

Changes in v2:
- No change.
--
---
drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 8111ed1fc574..68b17ee1d1ae 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -514,8 +514,18 @@ static int cros_typec_enable_usb4(struct cros_typec_data *typec,
else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
data.eudo |= EUDO_CABLE_TYPE_RE_TIMER << EUDO_CABLE_TYPE_SHIFT;

- data.active_link_training = !!(pd_ctrl->control_flags &
- USB_PD_CTRL_ACTIVE_LINK_UNIDIR);
+ /*
+ * Filling TBT3 Cable VDO when TBT3 cable is being used to establish
+ * USB4 connection.
+ */
+ if (pd_ctrl->cable_gen) {
+ data.tbt_cable_vdo = TBT_MODE;
+
+ if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
+ data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;
+
+ data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
+ }

port->state.alt = NULL;
port->state.data = &data;
--
2.17.1