Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: typec: Connect Type-C port with associated USB4 port

If USB3.x device references USB4 host interface, USB4 port can be
connected with appropriate Type-C port. By using component framework,
and in turn by creating symlinks, userspace can benefit from having
Thunderbolt/USB4 connection to Type-C ports.

Note: This change introduces dependency on Thunderbolt driver as it's
required to properly map USB4 port to Type-C port.

Signed-off-by: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

authored by

Alan Borzeszkowski and committed by
Mika Westerberg
4fd7a1f0 e80c2359

+21 -2
+21 -2
drivers/usb/typec/port-mapper.c
··· 8 8 9 9 #include <linux/acpi.h> 10 10 #include <linux/component.h> 11 + #include <linux/thunderbolt.h> 11 12 #include <linux/usb.h> 12 13 13 14 #include "class.h" ··· 37 36 struct component_match *match; 38 37 }; 39 38 39 + static int usb4_port_compare(struct device *dev, void *fwnode) 40 + { 41 + return usb4_usb3_port_match(dev, fwnode); 42 + } 43 + 40 44 static int typec_port_compare(struct device *dev, void *fwnode) 41 45 { 42 46 return device_match_fwnode(dev, fwnode); ··· 57 51 if (con_adev == adev) 58 52 return 0; 59 53 60 - if (con_adev->pld_crc == adev->pld_crc) 54 + if (con_adev->pld_crc == adev->pld_crc) { 55 + struct fwnode_handle *adev_fwnode = acpi_fwnode_handle(adev); 56 + 61 57 component_match_add(&arg->port->dev, &arg->match, typec_port_compare, 62 - acpi_fwnode_handle(adev)); 58 + adev_fwnode); 59 + 60 + /* 61 + * If dev is USB 3.x port, it may have reference to the 62 + * USB4 host interface in which case we can also link the 63 + * Type-C port with the USB4 port. 64 + */ 65 + if (fwnode_property_present(adev_fwnode, "usb4-host-interface")) 66 + component_match_add(&arg->port->dev, &arg->match, 67 + usb4_port_compare, adev_fwnode); 68 + } 69 + 63 70 return 0; 64 71 } 65 72