hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/usb/typec/tcpm/tcpm.c
....@@ -1724,6 +1724,14 @@
17241724 rlen = 1;
17251725 } else if (port->data_role == TYPEC_HOST) {
17261726 tcpm_register_partner_altmodes(port);
1727
+ } else {
1728
+ /* Do dr_swap for ufp if the port supports drd */
1729
+ if (port->typec_caps.data == TYPEC_PORT_DRD &&
1730
+ !IS_ERR_OR_NULL(port->port_altmode[0])) {
1731
+ port->vdm_sm_running = false;
1732
+ port->upcoming_state = DR_SWAP_SEND;
1733
+ tcpm_ams_start(port, DATA_ROLE_SWAP);
1734
+ }
17271735 }
17281736 break;
17291737 case CMD_ENTER_MODE:
....@@ -1755,6 +1763,16 @@
17551763 tcpm_ams_finish(port);
17561764 switch (cmd) {
17571765 case CMD_DISCOVER_IDENT:
1766
+ /* Do dr_swap for ufp if the port supports drd */
1767
+ if (port->typec_caps.data == TYPEC_PORT_DRD &&
1768
+ port->data_role == TYPEC_DEVICE &&
1769
+ !IS_ERR_OR_NULL(port->port_altmode[0])) {
1770
+ port->vdm_sm_running = false;
1771
+ port->upcoming_state = DR_SWAP_SEND;
1772
+ tcpm_ams_start(port, DATA_ROLE_SWAP);
1773
+ break;
1774
+ }
1775
+ fallthrough;
17581776 case CMD_DISCOVER_SVID:
17591777 case CMD_DISCOVER_MODES:
17601778 case VDO_CMD_VENDOR(0) ... VDO_CMD_VENDOR(15):