diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index a43e56d31133a..68b5a99857ec9 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -1151,6 +1151,21 @@ static void cd321x_update_work(struct work_struct *work) new_role = USB_ROLE_DEVICE; else new_role = USB_ROLE_HOST; + } else if (new_connected && !cd321x->tbt_switch && + device_is_compatible(tps->dev, "apple,t8132-sn201202x") && + (st.data_status & (TPS_DATA_STATUS_TBT_CONNECTION | + CD321X_DATA_STATUS_USB4_CONNECTION))) { + /* + * In Thunderbolt 3 alt mode the controller reports neither a + * USB2 nor a USB3 connection. With a USB4/Thunderbolt router, + * the partner's USB is tunnelled through it. A T8132 port + * without a router has nothing to tunnel through, and a T8132 + * PHY without the CIO calibration serves the partner's USB 2.0 + * on D+/D- instead of the link. Give the port the USB role of + * its Type-C data role, or its USB controller never starts. + */ + new_role = TPS_STATUS_TO_TYPEC_DATAROLE(st.status) == TYPEC_HOST ? + USB_ROLE_HOST : USB_ROLE_DEVICE; } if (new_connected) { diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py b/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py index 86a95e0f4178e..eda67bec94e7f 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py @@ -194,6 +194,7 @@ def function(file, name): enum usb_role { USB_ROLE_NONE, USB_ROLE_HOST, USB_ROLE_DEVICE }; enum typec_pwr_opmode { TYPEC_PWR_MODE_USB, TYPEC_PWR_MODE_PD }; enum typec_orientation { TYPEC_ORIENTATION_NONE, TYPEC_ORIENTATION_NORMAL, TYPEC_ORIENTATION_REVERSE }; +enum typec_data_role { TYPEC_DEVICE, TYPEC_HOST }; struct usb_pd_identity { int id; }; static void * __attribute__((unused)) memchr_inv(const void *p, int c, size_t n) { const unsigned char *b = p; for (size_t i = 0; i < n; i++) if (b[i] != (unsigned char)c) return (void *)(b + i); return NULL; }