Skip to content

Commit aad6ad1

Browse files
uhpatelgregkh
authored andcommitted
platform/chrome: cros_ec_typec: Configure Retimer cable type
Connector class driver only configure cable type active or passive. Configure if the cable type is retimer or redriver with this change. This detail will be provided as a part of cable discover mode VDO. Signed-off-by: Utkarsh Patel <[email protected]> Acked-by: Prashant Malani <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 78e0ea4 commit aad6ad1

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

drivers/platform/chrome/cros_ec_typec.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,27 @@ static int cros_typec_usb_safe_state(struct cros_typec_port *port)
406406
return ret;
407407
}
408408

409+
/**
410+
* cros_typec_get_cable_vdo() - Get Cable VDO of the connected cable
411+
* @port: Type-C port data
412+
* @svid: Standard or Vendor ID to match
413+
*
414+
* Returns the Cable VDO if match is found and returns 0 if match is not found.
415+
*/
416+
static int cros_typec_get_cable_vdo(struct cros_typec_port *port, u16 svid)
417+
{
418+
struct list_head *head = &port->plug_mode_list;
419+
struct cros_typec_altmode_node *node;
420+
u32 ret = 0;
421+
422+
list_for_each_entry(node, head, list) {
423+
if (node->amode->svid == svid)
424+
return node->amode->vdo;
425+
}
426+
427+
return ret;
428+
}
429+
409430
/*
410431
* Spoof the VDOs that were likely communicated by the partner for TBT alt
411432
* mode.
@@ -432,6 +453,9 @@ static int cros_typec_enable_tbt(struct cros_typec_data *typec,
432453

433454
/* Cable Discover Mode VDO */
434455
data.cable_mode = TBT_MODE;
456+
457+
data.cable_mode |= cros_typec_get_cable_vdo(port, USB_TYPEC_TBT_SID);
458+
435459
data.cable_mode |= TBT_SET_CABLE_SPEED(pd_ctrl->cable_speed);
436460

437461
if (pd_ctrl->control_flags & USB_PD_CTRL_OPTICAL_CABLE)
@@ -522,8 +546,10 @@ static int cros_typec_enable_usb4(struct cros_typec_data *typec,
522546
/* Cable Type */
523547
if (pd_ctrl->control_flags & USB_PD_CTRL_OPTICAL_CABLE)
524548
data.eudo |= EUDO_CABLE_TYPE_OPTICAL << EUDO_CABLE_TYPE_SHIFT;
525-
else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
549+
else if (cros_typec_get_cable_vdo(port, USB_TYPEC_TBT_SID) & TBT_CABLE_RETIMER)
526550
data.eudo |= EUDO_CABLE_TYPE_RE_TIMER << EUDO_CABLE_TYPE_SHIFT;
551+
else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
552+
data.eudo |= EUDO_CABLE_TYPE_RE_DRIVER << EUDO_CABLE_TYPE_SHIFT;
527553

528554
data.active_link_training = !!(pd_ctrl->control_flags &
529555
USB_PD_CTRL_ACTIVE_LINK_UNIDIR);

0 commit comments

Comments
 (0)