Skip to content

Commit 46c5bbd

Browse files
Heikki KrogerusEnric Balletbo i Serra
authored andcommitted
platform/chrome: cros_ec_typec: USB4 support
With USB4 mode the mux driver needs the Enter_USB Data Object (EUDO) that was used when the USB mode was entered. Though the object is not available in the driver, it is possible to construct it from the information we have. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Prashant Malani <pmalani@chromium.org> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
1 parent be020f0 commit 46c5bbd

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

‎drivers/platform/chrome/cros_ec_typec.c‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/platform_data/cros_ec_proto.h>
1414
#include <linux/platform_data/cros_usbpd_notify.h>
1515
#include <linux/platform_device.h>
16+
#include <linux/usb/pd.h>
1617
#include <linux/usb/typec.h>
1718
#include <linux/usb/typec_altmode.h>
1819
#include <linux/usb/typec_dp.h>
@@ -496,6 +497,34 @@ static int cros_typec_enable_dp(struct cros_typec_data *typec,
496497
return typec_mux_set(port->mux, &port->state);
497498
}
498499

500+
static int cros_typec_enable_usb4(struct cros_typec_data *typec,
501+
int port_num,
502+
struct ec_response_usb_pd_control_v2 *pd_ctrl)
503+
{
504+
struct cros_typec_port *port = typec->ports[port_num];
505+
struct enter_usb_data data;
506+
507+
data.eudo = EUDO_USB_MODE_USB4 << EUDO_USB_MODE_SHIFT;
508+
509+
/* Cable Speed */
510+
data.eudo |= pd_ctrl->cable_speed << EUDO_CABLE_SPEED_SHIFT;
511+
512+
/* Cable Type */
513+
if (pd_ctrl->control_flags & USB_PD_CTRL_OPTICAL_CABLE)
514+
data.eudo |= EUDO_CABLE_TYPE_OPTICAL << EUDO_CABLE_TYPE_SHIFT;
515+
else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
516+
data.eudo |= EUDO_CABLE_TYPE_RE_TIMER << EUDO_CABLE_TYPE_SHIFT;
517+
518+
data.active_link_training = !!(pd_ctrl->control_flags &
519+
USB_PD_CTRL_ACTIVE_LINK_UNIDIR);
520+
521+
port->state.alt = NULL;
522+
port->state.data = &data;
523+
port->state.mode = TYPEC_MODE_USB4;
524+
525+
return typec_mux_set(port->mux, &port->state);
526+
}
527+
499528
static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
500529
uint8_t mux_flags,
501530
struct ec_response_usb_pd_control_v2 *pd_ctrl)
@@ -516,7 +545,9 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
516545
if (ret)
517546
return ret;
518547

519-
if (mux_flags & USB_PD_MUX_TBT_COMPAT_ENABLED) {
548+
if (mux_flags & USB_PD_MUX_USB4_ENABLED) {
549+
ret = cros_typec_enable_usb4(typec, port_num, pd_ctrl);
550+
} else if (mux_flags & USB_PD_MUX_TBT_COMPAT_ENABLED) {
520551
ret = cros_typec_enable_tbt(typec, port_num, pd_ctrl);
521552
} else if (mux_flags & USB_PD_MUX_DP_ENABLED) {
522553
ret = cros_typec_enable_dp(typec, port_num, pd_ctrl);

0 commit comments

Comments
 (0)