From: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
To: linux-usb@vger.kernel.org
Cc: mika.westerberg@linux.intel.com, andreas.noever@gmail.com,
michael.jamet@intel.com, YehezkelShB@gmail.com,
heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org
Subject: [PATCH 3/3] usb: typec: Connect Type-C port with associated USB4 port
Date: Mon, 14 Apr 2025 19:55:54 +0200 [thread overview]
Message-ID: <20250414175554.107228-4-alan.borzeszkowski@linux.intel.com> (raw)
In-Reply-To: <20250414175554.107228-1-alan.borzeszkowski@linux.intel.com>
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>
---
drivers/usb/typec/port-mapper.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/typec/port-mapper.c b/drivers/usb/typec/port-mapper.c
index d42da5720a25..cdbb7c11d714 100644
--- a/drivers/usb/typec/port-mapper.c
+++ b/drivers/usb/typec/port-mapper.c
@@ -8,6 +8,7 @@
#include <linux/acpi.h>
#include <linux/component.h>
+#include <linux/thunderbolt.h>
#include <linux/usb.h>
#include "class.h"
@@ -36,6 +37,11 @@ struct each_port_arg {
struct component_match *match;
};
+static int usb4_port_compare(struct device *dev, void *fwnode)
+{
+ return usb4_usb3_port_match(dev, fwnode);
+}
+
static int typec_port_compare(struct device *dev, void *fwnode)
{
return device_match_fwnode(dev, fwnode);
@@ -51,9 +57,22 @@ static int typec_port_match(struct device *dev, void *data)
if (con_adev == adev)
return 0;
- if (con_adev->pld_crc == adev->pld_crc)
+ if (con_adev->pld_crc == adev->pld_crc) {
+ struct fwnode_handle *adev_fwnode = acpi_fwnode_handle(adev);
+
component_match_add(&arg->port->dev, &arg->match, typec_port_compare,
- acpi_fwnode_handle(adev));
+ adev_fwnode);
+
+ /*
+ * If dev is USB 3.x port, it may have reference to the
+ * USB4 host interface in which case we can also link the
+ * Type-C port with the USB4 port.
+ */
+ if (fwnode_property_present(adev_fwnode, "usb4-host-interface"))
+ component_match_add(&arg->port->dev, &arg->match,
+ usb4_port_compare, adev_fwnode);
+ }
+
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2025-04-14 17:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-14 17:55 [PATCH 0/3] Introduce Thunderbolt/USB4 <-> USB Type-C port mapping Alan Borzeszkowski
2025-04-14 17:55 ` [PATCH 1/3] thunderbolt: Expose usb4_port_index() to other modules Alan Borzeszkowski
2025-04-14 17:55 ` [PATCH 2/3] thunderbolt: Add Thunderbolt/USB4 <-> USB3 match function Alan Borzeszkowski
2025-04-14 17:55 ` Alan Borzeszkowski [this message]
2025-04-14 19:03 ` [PATCH 0/3] Introduce Thunderbolt/USB4 <-> USB Type-C port mapping Greg KH
2025-04-15 9:32 ` Heikki Krogerus
2025-04-15 12:22 ` Greg KH
2025-04-15 12:22 ` Greg KH
2025-04-15 12:36 ` Mika Westerberg
2025-04-17 9:27 ` Mika Westerberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250414175554.107228-4-alan.borzeszkowski@linux.intel.com \
--to=alan.borzeszkowski@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-usb@vger.kernel.org \
--cc=michael.jamet@intel.com \
--cc=mika.westerberg@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.