diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index a088c6e91e37..141a14305335 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -1724,6 +1724,14 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev, rlen = 1; } else if (port->data_role == TYPEC_HOST) { tcpm_register_partner_altmodes(port); + } else { + /* Do dr_swap for ufp if the port supports drd */ + if (port->typec_caps.data == TYPEC_PORT_DRD && + !IS_ERR_OR_NULL(port->port_altmode[0])) { + port->vdm_sm_running = false; + port->upcoming_state = DR_SWAP_SEND; + tcpm_ams_start(port, DATA_ROLE_SWAP); + } } break; case CMD_ENTER_MODE: @@ -1755,6 +1763,16 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev, tcpm_ams_finish(port); switch (cmd) { case CMD_DISCOVER_IDENT: + /* Do dr_swap for ufp if the port supports drd */ + if (port->typec_caps.data == TYPEC_PORT_DRD && + port->data_role == TYPEC_DEVICE && + !IS_ERR_OR_NULL(port->port_altmode[0])) { + port->vdm_sm_running = false; + port->upcoming_state = DR_SWAP_SEND; + tcpm_ams_start(port, DATA_ROLE_SWAP); + break; + } + fallthrough; case CMD_DISCOVER_SVID: case CMD_DISCOVER_MODES: case VDO_CMD_VENDOR(0) ... VDO_CMD_VENDOR(15):