[PATCH v2 16/22] thunderbolt: Add add_links to tb_nhi_ops

Sven Peter sven at kernel.org
Sun Sep 6 11:36:39 PDT 2026


PCI NHI drivers discover device links through ACPI or PCI topology but
platform drivers, like the Apple Silicon one, can use neither of those
methods. Instead, add a callback so that platform drivers can discover
and add these links through e.g. device tree connections.

Signed-off-by: Sven Peter <sven at kernel.org>
---
 drivers/thunderbolt/nhi.h | 2 ++
 drivers/thunderbolt/tb.c  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h
index e4964772a442..addb8bcb4849 100644
--- a/drivers/thunderbolt/nhi.h
+++ b/drivers/thunderbolt/nhi.h
@@ -65,6 +65,7 @@ extern const struct dev_pm_ops nhi_pm_ops;
  * @ring_configure: NHI specific hook to program the ring options registers
  *		    and enable the ring with the given flags. If not set
  *		    the standard USB4 NHI registers are used.
+ * @add_links: NHI specific hook to add device links to tunneled native ports
  * @is_present: Whether the device is currently present on the parent bus
  * @init_interrupts: NHI specific interrupt initialization hook
  * @reset_interface: Resets the host interface
@@ -85,6 +86,7 @@ struct tb_nhi_ops {
 	void (*ring_interrupt_active)(struct tb_ring *ring, bool active);
 	void (*ring_interrupt_mask)(struct tb_ring *ring, bool mask);
 	void (*ring_configure)(struct tb_ring *ring, u32 flags, u32 e2e_flags);
+	bool (*add_links)(struct tb_nhi *nhi);
 	bool (*is_present)(struct tb_nhi *nhi);
 	int (*init_interrupts)(struct tb_nhi *nhi);
 	void (*reset_interface)(struct tb_nhi *nhi);
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index d2832323cc36..72418a07166e 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -3434,7 +3434,8 @@ struct tb *tb_probe(struct tb_nhi *nhi)
 	 * before the PCIe/USB stack is resumed so complain here if we
 	 * found them missing.
 	 */
-	if (!tb_apple_add_links(nhi) && !tb_acpi_add_links(nhi))
+	if (!(nhi->ops->add_links && nhi->ops->add_links(nhi)) &&
+	    !tb_apple_add_links(nhi) && !tb_acpi_add_links(nhi))
 		tb_warn(tb, "device links to tunneled native ports are missing!\n");
 
 	return tb;

-- 
2.55.0





More information about the linux-arm-kernel mailing list