public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers
@ 2026-01-27 11:03 Markus Schneider-Pargmann (TI.com)
  2026-01-27 11:03 ` [PATCH v4 1/7] dm: core: lists_bind_fdt: Remove unused variable Markus Schneider-Pargmann (TI.com)
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-27 11:03 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher, Marek Vasut, Rasmus Villemoes,
	Neil Armstrong, Markus Schneider-Pargmann (TI.com), Simon Glass

Hi,

musb currently uses a wrapper driver that binds on the parent device of
the actual musb devices to manage the differentiation between gadget and
host modes. However in the upstream devicetree this parent devicetree
node can not be used to match the wrapper driver.

To be able to probe the musb devices in host/gadget mode directly, this
series introduces support for returning -ENODEV in bind functions
resulting in iterating the remaining drivers potentially binding to
other drivers that match the compatible.

It also changes the address parsing of musb-ctrl to be able to parse
relative addresses.

Best
Markus

Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
Changes in v4:
- Remove log message changes and push into separate patch as suggested
  by Mattijs
- Fix commit message as pointed out by Mattijs
- Link to v3: https://lore.kernel.org/r/20260114-topic-musb-probing-v2026-01-v3-0-ebb8d990b9df@baylibre.com

Changes in v3:
- Add short paragraph about performance implications to the commit
  message
- Add a new line in the test
- Link to v2: https://lore.kernel.org/r/20260108-topic-musb-probing-v2026-01-v2-0-2a47c6e0e73a@baylibre.com

Changes in v2:
- Added a few patches to remove nearly unused variables
- Changed the inner loop in lists_bind_fdt to support set drv and not
  set entry->of_match.
- Cleanup the loop a bit more
- Link to v1: https://lore.kernel.org/r/20251126-topic-musb-probing-v2026-01-v1-0-ff8d8c487130@baylibre.com

---
Markus Schneider-Pargmann (TI) (1):
      dm: core: lists_bind_fdt: Indent continuation debug log message

Markus Schneider-Pargmann (TI.com) (6):
      dm: core: lists_bind_fdt: Remove unused variable
      dm: core: lists_bind_fdt: Replace found variable
      dm: core: Support multiple drivers with same compatibles
      test: dm: Add compatible multimatch test
      usb: musb-new: Relative ctrl_mod address parsing
      usb: musb-new: Add compatibles for ti,musb-am33xx

 arch/sandbox/dts/test.dts      |  4 +++
 drivers/core/lists.c           | 73 +++++++++++++++++++++---------------------
 drivers/usb/musb-new/ti-musb.c | 36 ++++++++++++++++++++-
 test/dm/core.c                 | 15 +++++++++
 test/dm/test-driver.c          | 26 +++++++++++++++
 5 files changed, 116 insertions(+), 38 deletions(-)
---
base-commit: aa4f687977a449686498236722ee5e93d8b39918
change-id: 20251125-topic-musb-probing-v2026-01-1343fff8176b

Best regards,
-- 
Markus Schneider-Pargmann (TI) <msp@baylibre.com>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v4 1/7] dm: core: lists_bind_fdt: Remove unused variable
  2026-01-27 11:03 [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
@ 2026-01-27 11:03 ` Markus Schneider-Pargmann (TI.com)
  2026-01-27 11:03 ` [PATCH v4 2/7] dm: core: lists_bind_fdt: Replace found variable Markus Schneider-Pargmann (TI.com)
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-27 11:03 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher, Marek Vasut, Rasmus Villemoes,
	Neil Armstrong, Markus Schneider-Pargmann (TI.com), Simon Glass

'result' is unused in this function, remove it.

Reviewed-by: Simon Glass <simon.glass@canonical.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
 drivers/core/lists.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index c7be504b6fc69ec2870a6766eed35cb9eba46a97..52ba6c7bfa007b660b854de62c97ad3c1761f1a5 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -207,7 +207,6 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 	bool found = false;
 	const char *name, *compat_list, *compat;
 	int compat_length, i;
-	int result = 0;
 	int ret = 0;
 
 	if (devp)
@@ -283,9 +282,9 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 		break;
 	}
 
-	if (!found && !result && ret != -ENODEV)
+	if (!found && ret != -ENODEV)
 		log_debug("No match for node '%s'\n", name);
 
-	return result;
+	return 0;
 }
 #endif

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 2/7] dm: core: lists_bind_fdt: Replace found variable
  2026-01-27 11:03 [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
  2026-01-27 11:03 ` [PATCH v4 1/7] dm: core: lists_bind_fdt: Remove unused variable Markus Schneider-Pargmann (TI.com)
@ 2026-01-27 11:03 ` Markus Schneider-Pargmann (TI.com)
  2026-01-27 11:03 ` [PATCH v4 3/7] dm: core: Support multiple drivers with same compatibles Markus Schneider-Pargmann (TI.com)
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-27 11:03 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher, Marek Vasut, Rasmus Villemoes,
	Neil Armstrong, Markus Schneider-Pargmann (TI.com), Simon Glass

'found' is only used at the end of the function to print a debug
message. No need to maintain a variable if we can just return 0
immediately when a driver was bound successfully.

Reviewed-by: Simon Glass <simon.glass@canonical.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
 drivers/core/lists.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 52ba6c7bfa007b660b854de62c97ad3c1761f1a5..9d1ca38212ee7f53b8894f964f096611c8ec20a5 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -204,7 +204,6 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 	const struct udevice_id *id;
 	struct driver *entry;
 	struct udevice *dev;
-	bool found = false;
 	const char *name, *compat_list, *compat;
 	int compat_length, i;
 	int ret = 0;
@@ -275,14 +274,14 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 				ret);
 			return log_msg_ret("bind", ret);
 		} else {
-			found = true;
 			if (devp)
 				*devp = dev;
+			return 0;
 		}
 		break;
 	}
 
-	if (!found && ret != -ENODEV)
+	if (ret != -ENODEV)
 		log_debug("No match for node '%s'\n", name);
 
 	return 0;

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 3/7] dm: core: Support multiple drivers with same compatibles
  2026-01-27 11:03 [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
  2026-01-27 11:03 ` [PATCH v4 1/7] dm: core: lists_bind_fdt: Remove unused variable Markus Schneider-Pargmann (TI.com)
  2026-01-27 11:03 ` [PATCH v4 2/7] dm: core: lists_bind_fdt: Replace found variable Markus Schneider-Pargmann (TI.com)
@ 2026-01-27 11:03 ` Markus Schneider-Pargmann (TI.com)
  2026-01-27 11:03 ` [PATCH v4 4/7] dm: core: lists_bind_fdt: Indent continuation debug log message Markus Schneider-Pargmann (TI)
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-27 11:03 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher, Marek Vasut, Rasmus Villemoes,
	Neil Armstrong, Markus Schneider-Pargmann (TI.com), Simon Glass

Currently once a driver matched the compatible string of a device, other
drivers are ignored. If the first matching driver returns -ENODEV, no
other possibly matching drivers are iterated with that compatible of the
device. Instead the next compatible in the list of compatibles is
selected, assuming only one driver matches one compatible at a time.

To be able to use the bind function to return -ENODEV and continue
matching other drivers with the same compatible, move the for loop a bit
to continue the for loop after -ENODEV was returned. The loop had to be
adjusted a bit to still support the 'drv' argument properly. Some
simplifications were done as well.

The modification will only add additional loop iterations if -ENODEV is
returned. Otherwise the exit and continue conditions for the loop stay
the same and do not cause any additional iterations and should not
impact performance.

This is required for ti-musb-host and ti-musb-peripheral which both
match on the same device but differ based on the dr_mode DT property.
Depending on this property, the driver is either UCLASS_USB or
UCLASS_USB_GADGET_GENERIC. By checking the DT property in the bind
function and returning -ENODEV the other driver can probe instead.

Reviewed-by: Simon Glass <simon.glass@canonical.com>
Acked-by: Dinesh Maniyam <dinesh.maniyam@altera.com>
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
 drivers/core/lists.c | 65 ++++++++++++++++++++++++++--------------------------
 1 file changed, 33 insertions(+), 32 deletions(-)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 9d1ca38212ee7f53b8894f964f096611c8ec20a5..813c3de52b23d78528686a7a8d9ecbe8cab62efd 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -235,50 +235,51 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 		log_debug("   - attempt to match compatible string '%s'\n",
 			  compat);
 
-		id = NULL;
 		for (entry = driver; entry != driver + n_ents; entry++) {
+			/* Search for drivers with matching drv or existing of_match */
 			if (drv) {
 				if (drv != entry)
 					continue;
-				if (!entry->of_match)
-					break;
+			} else if (!entry->of_match) {
+				continue;
 			}
-			ret = driver_check_compatible(entry->of_match, &id,
-						      compat);
-			if (!ret)
-				break;
-		}
-		if (entry == driver + n_ents)
-			continue;
 
-		if (pre_reloc_only) {
-			if (!ofnode_pre_reloc(node) &&
-			    !(entry->flags & DM_FLAG_PRE_RELOC)) {
-				log_debug("Skipping device pre-relocation\n");
-				return 0;
+			id = NULL;
+			if (entry->of_match) {
+				ret = driver_check_compatible(entry->of_match, &id,
+							      compat);
+				if (ret)
+					continue;
+				log_debug("   - found match at driver '%s' for '%s'\n",
+					  entry->name, id->compatible);
+			}
+
+			if (pre_reloc_only) {
+				if (!ofnode_pre_reloc(node) &&
+				    !(entry->flags & DM_FLAG_PRE_RELOC)) {
+					log_debug("Skipping device pre-relocation\n");
+					return 0;
+				}
+			}
+
+			ret = device_bind_with_driver_data(parent, entry, name,
+							   id ? id->data : 0, node,
+							   &dev);
+			if (!drv && ret == -ENODEV) {
+				log_debug("Driver '%s' refuses to bind\n", entry->name);
+				continue;
+			}
+			if (ret) {
+				dm_warn("Error binding driver '%s': %d\n", entry->name,
+					ret);
+				return log_msg_ret("bind", ret);
 			}
-		}
 
-		if (entry->of_match)
-			log_debug("   - found match at driver '%s' for '%s'\n",
-				  entry->name, id->compatible);
-		ret = device_bind_with_driver_data(parent, entry, name,
-						   id ? id->data : 0, node,
-						   &dev);
-		if (ret == -ENODEV) {
-			log_debug("Driver '%s' refuses to bind\n", entry->name);
-			continue;
-		}
-		if (ret) {
-			dm_warn("Error binding driver '%s': %d\n", entry->name,
-				ret);
-			return log_msg_ret("bind", ret);
-		} else {
 			if (devp)
 				*devp = dev;
+
 			return 0;
 		}
-		break;
 	}
 
 	if (ret != -ENODEV)

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 4/7] dm: core: lists_bind_fdt: Indent continuation debug log message
  2026-01-27 11:03 [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
                   ` (2 preceding siblings ...)
  2026-01-27 11:03 ` [PATCH v4 3/7] dm: core: Support multiple drivers with same compatibles Markus Schneider-Pargmann (TI.com)
@ 2026-01-27 11:03 ` Markus Schneider-Pargmann (TI)
  2026-02-04  0:23   ` Simon Glass
  2026-01-27 11:03 ` [PATCH v4 5/7] test: dm: Add compatible multimatch test Markus Schneider-Pargmann (TI.com)
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Markus Schneider-Pargmann (TI) @ 2026-01-27 11:03 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher, Marek Vasut, Rasmus Villemoes,
	Neil Armstrong, Markus Schneider-Pargmann (TI.com)

The loop in lists_bind_fdt uses an indented style for log messages
within the loop and normal messages for errors that lead to the exit of
the function. Due to the change of the previous patch that adds support
for continuation on -ENODEV returned by bind, the log message should be
indented.

Signed-off-by: Markus Schneider-Pargmann (TI) <msp@baylibre.com>
---
 drivers/core/lists.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 813c3de52b23d78528686a7a8d9ecbe8cab62efd..2545dc142f6bc3d01dca1e0618055a64978734f3 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -266,7 +266,7 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 							   id ? id->data : 0, node,
 							   &dev);
 			if (!drv && ret == -ENODEV) {
-				log_debug("Driver '%s' refuses to bind\n", entry->name);
+				log_debug("   - Driver '%s' refuses to bind\n", entry->name);
 				continue;
 			}
 			if (ret) {

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 5/7] test: dm: Add compatible multimatch test
  2026-01-27 11:03 [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
                   ` (3 preceding siblings ...)
  2026-01-27 11:03 ` [PATCH v4 4/7] dm: core: lists_bind_fdt: Indent continuation debug log message Markus Schneider-Pargmann (TI)
@ 2026-01-27 11:03 ` Markus Schneider-Pargmann (TI.com)
  2026-01-27 11:03 ` [PATCH v4 6/7] usb: musb-new: Relative ctrl_mod address parsing Markus Schneider-Pargmann (TI.com)
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-27 11:03 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher, Marek Vasut, Rasmus Villemoes,
	Neil Armstrong, Markus Schneider-Pargmann (TI.com), Simon Glass

Add a test for binding of multiple drivers with the same compatible. If
one of the drivers returns -ENODEV the other one needs to be bound.

Reviewed-by: Simon Glass <simon.glass@canonical.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
 arch/sandbox/dts/test.dts |  4 ++++
 test/dm/core.c            | 15 +++++++++++++++
 test/dm/test-driver.c     | 26 ++++++++++++++++++++++++++
 3 files changed, 45 insertions(+)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index cd53c170171c7b78a1b865577116fbd067798886..b7402d7042a55801f5ce912642233b1b03b691d6 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -457,6 +457,10 @@
 		mux-control-names = "mux0";
 	};
 
+	multimatch-test {
+		compatible = "sandbox,multimatch-test";
+	};
+
 	phy_provider0: gen_phy@0 {
 		compatible = "sandbox,phy";
 		#phy-cells = <1>;
diff --git a/test/dm/core.c b/test/dm/core.c
index 53693f4f7ed7c7265218e4154ebf81a044a3a431..78ee14af228ab20a6639bb076260296adaea2c92 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -1410,3 +1410,18 @@ static int dm_test_try_first_device(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_try_first_device, 0);
+
+/* Test that all drivers are iterated when bind returns -ENODEV */
+static int dm_test_multimatch(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+
+	ut_assertok(uclass_find_device_by_name(UCLASS_TEST, "multimatch-test",
+					       &dev));
+	ut_assertnonnull(dev);
+	ut_asserteq_str("test_multimatch_second", dev->driver->name);
+	ut_asserteq(2, dm_testdrv_op_count[DM_TEST_OP_BIND]);
+
+	return 0;
+}
+DM_TEST(dm_test_multimatch, UTF_SCAN_FDT);
diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c
index 759de3a5f77f4b64ea577a293586a737e4623f60..d628a6d766fc24f221ffcec3a5dbc6cc060e07bd 100644
--- a/test/dm/test-driver.c
+++ b/test/dm/test-driver.c
@@ -197,3 +197,29 @@ U_BOOT_DRIVER(test_act_dma_vital_clk_drv) = {
 	.unbind	= test_manual_unbind,
 	.flags	= DM_FLAG_VITAL | DM_FLAG_ACTIVE_DMA,
 };
+
+static int test_multimatch_first_bind(struct udevice *dev)
+{
+	dm_testdrv_op_count[DM_TEST_OP_BIND]++;
+
+	return -ENODEV;
+}
+
+static const struct udevice_id test_multimatch_ids[] = {
+	{ .compatible = "sandbox,multimatch-test" },
+	{ }
+};
+
+U_BOOT_DRIVER(test_multimatch_first) = {
+	.name	= "test_multimatch_first",
+	.id	= UCLASS_TEST,
+	.of_match = test_multimatch_ids,
+	.bind	= test_multimatch_first_bind,
+};
+
+U_BOOT_DRIVER(test_multimatch_second) = {
+	.name	= "test_multimatch_second",
+	.id	= UCLASS_TEST,
+	.of_match = test_multimatch_ids,
+	.bind	= test_manual_bind,
+};

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 6/7] usb: musb-new: Relative ctrl_mod address parsing
  2026-01-27 11:03 [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
                   ` (4 preceding siblings ...)
  2026-01-27 11:03 ` [PATCH v4 5/7] test: dm: Add compatible multimatch test Markus Schneider-Pargmann (TI.com)
@ 2026-01-27 11:03 ` Markus Schneider-Pargmann (TI.com)
  2026-01-27 21:15   ` Marek Vasut
  2026-01-27 11:03 ` [PATCH v4 7/7] usb: musb-new: Add compatibles for ti,musb-am33xx Markus Schneider-Pargmann (TI.com)
  2026-01-28 17:48 ` (subset) [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers Tom Rini
  7 siblings, 1 reply; 13+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-27 11:03 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher, Marek Vasut, Rasmus Villemoes,
	Neil Armstrong, Markus Schneider-Pargmann (TI.com)

For the upstream DT the ctrl_mod node is using a relative register
address which is not translated by the current code.

Make address parsing understand relative addresses.

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
 drivers/usb/musb-new/ti-musb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index bcd31adba522fc55190fc43fd2dbd2dec93a2731..d3c3d3057c1df2a5cc62df3c57d8b071bb0f12b8 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -93,7 +93,7 @@ static int ti_musb_of_to_plat(struct udevice *dev)
 
 	phys = fdtdec_lookup_phandle(fdt, node, "phys");
 	ctrl_mod = fdtdec_lookup_phandle(fdt, phys, "ti,ctrl_mod");
-	plat->ctrl_mod_base = (void *)fdtdec_get_addr(fdt, ctrl_mod, "reg");
+	plat->ctrl_mod_base = (void *)ofnode_get_addr(offset_to_ofnode(ctrl_mod));
 	usb_index = ti_musb_get_usb_index(node);
 	switch (usb_index) {
 	case 1:

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 7/7] usb: musb-new: Add compatibles for ti,musb-am33xx
  2026-01-27 11:03 [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
                   ` (5 preceding siblings ...)
  2026-01-27 11:03 ` [PATCH v4 6/7] usb: musb-new: Relative ctrl_mod address parsing Markus Schneider-Pargmann (TI.com)
@ 2026-01-27 11:03 ` Markus Schneider-Pargmann (TI.com)
  2026-01-27 21:15   ` Marek Vasut
  2026-01-28 17:48 ` (subset) [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers Tom Rini
  7 siblings, 1 reply; 13+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-27 11:03 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher, Marek Vasut, Rasmus Villemoes,
	Neil Armstrong, Markus Schneider-Pargmann (TI.com)

The upstream devicetree am33xx.dtsi does not have a "ti,am33xx-usb"
compatible, it uses "ti,sysc-omap4" for the same node. The
implementation of ti-musb uses a wrapper driver that binds to
ti,am33xx-usb and creates new devices ti-musb-host and
ti-musb-peripheral depending on the dr_mode property.

To avoid this wrapper driver with the upstream devicetree, add
compatibles for "ti,musb-am33xx" to both ti-musb-host and
ti-musb-peripheral. Add a bind function that checks for the correct
dr_mode value and rejects binding if it is not the correct driver.

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
 drivers/usb/musb-new/ti-musb.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index d3c3d3057c1df2a5cc62df3c57d8b071bb0f12b8..3ed6428d09883cf5af28b212c0d614b3d8ef9227 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -183,6 +183,16 @@ static int ti_musb_host_remove(struct udevice *dev)
 }
 
 #if CONFIG_IS_ENABLED(OF_CONTROL)
+static int ti_musb_host_bind(struct udevice *dev)
+{
+	enum usb_dr_mode dr_mode = usb_get_dr_mode(dev_ofnode(dev));
+
+	if (dr_mode != USB_DR_MODE_HOST && dr_mode != USB_DR_MODE_OTG)
+		return -ENODEV;
+
+	return 0;
+}
+
 static int ti_musb_host_of_to_plat(struct udevice *dev)
 {
 	struct ti_musb_plat *plat = dev_get_plat(dev);
@@ -200,12 +210,19 @@ static int ti_musb_host_of_to_plat(struct udevice *dev)
 
 	return 0;
 }
+
+static const struct udevice_id ti_musb_host_ids[] = {
+	{ .compatible = "ti,musb-am33xx" },
+	{ }
+};
 #endif
 
 U_BOOT_DRIVER(ti_musb_host) = {
 	.name	= "ti-musb-host",
 	.id	= UCLASS_USB,
 #if CONFIG_IS_ENABLED(OF_CONTROL)
+	.of_match = ti_musb_host_ids,
+	.bind = ti_musb_host_bind,
 	.of_to_plat = ti_musb_host_of_to_plat,
 #endif
 	.probe = ti_musb_host_probe,
@@ -221,6 +238,16 @@ struct ti_musb_peripheral {
 };
 
 #if CONFIG_IS_ENABLED(OF_CONTROL)
+static int ti_musb_peripheral_bind(struct udevice *dev)
+{
+	enum usb_dr_mode dr_mode = usb_get_dr_mode(dev_ofnode(dev));
+
+	if (dr_mode != USB_DR_MODE_PERIPHERAL)
+		return -ENODEV;
+
+	return 0;
+}
+
 static int ti_musb_peripheral_of_to_plat(struct udevice *dev)
 {
 	struct ti_musb_plat *plat = dev_get_plat(dev);
@@ -237,6 +264,11 @@ static int ti_musb_peripheral_of_to_plat(struct udevice *dev)
 
 	return 0;
 }
+
+static const struct udevice_id ti_musb_peripheral_ids[] = {
+	{ .compatible = "ti,musb-am33xx" },
+	{ }
+};
 #endif
 
 static int ti_musb_peripheral_probe(struct udevice *dev)
@@ -283,6 +315,8 @@ U_BOOT_DRIVER(ti_musb_peripheral) = {
 	.name	= "ti-musb-peripheral",
 	.id	= UCLASS_USB_GADGET_GENERIC,
 #if CONFIG_IS_ENABLED(OF_CONTROL)
+	.of_match = ti_musb_peripheral_ids,
+	.bind = ti_musb_peripheral_bind,
 	.of_to_plat = ti_musb_peripheral_of_to_plat,
 #endif
 	.ops	= &ti_musb_gadget_ops,

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 7/7] usb: musb-new: Add compatibles for ti,musb-am33xx
  2026-01-27 11:03 ` [PATCH v4 7/7] usb: musb-new: Add compatibles for ti,musb-am33xx Markus Schneider-Pargmann (TI.com)
@ 2026-01-27 21:15   ` Marek Vasut
  2026-01-30  9:05     ` Markus Schneider-Pargmann
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2026-01-27 21:15 UTC (permalink / raw)
  To: Markus Schneider-Pargmann (TI.com), u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Andrew Goodbody, Kory Maincent,
	Svyatoslav Ryhel, Christian Marangi, Dinesh Maniyam,
	Heiko Schocher, Rasmus Villemoes, Neil Armstrong

On 1/27/26 12:03 PM, Markus Schneider-Pargmann (TI.com) wrote:

[...]

> +static int ti_musb_host_bind(struct udevice *dev)
> +{
> +	enum usb_dr_mode dr_mode = usb_get_dr_mode(dev_ofnode(dev));
> +
> +	if (dr_mode != USB_DR_MODE_HOST && dr_mode != USB_DR_MODE_OTG)
> +		return -ENODEV;
> +
> +	return 0;
> +}

[...]

>   #if CONFIG_IS_ENABLED(OF_CONTROL)
> +static int ti_musb_peripheral_bind(struct udevice *dev)
> +{
> +	enum usb_dr_mode dr_mode = usb_get_dr_mode(dev_ofnode(dev));
> +
> +	if (dr_mode != USB_DR_MODE_PERIPHERAL)
> +		return -ENODEV;
How do you handle USB_DR_MODE_UNKNOWN , host or peripheral ?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 6/7] usb: musb-new: Relative ctrl_mod address parsing
  2026-01-27 11:03 ` [PATCH v4 6/7] usb: musb-new: Relative ctrl_mod address parsing Markus Schneider-Pargmann (TI.com)
@ 2026-01-27 21:15   ` Marek Vasut
  0 siblings, 0 replies; 13+ messages in thread
From: Marek Vasut @ 2026-01-27 21:15 UTC (permalink / raw)
  To: Markus Schneider-Pargmann (TI.com), u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Andrew Goodbody, Kory Maincent,
	Svyatoslav Ryhel, Christian Marangi, Dinesh Maniyam,
	Heiko Schocher, Rasmus Villemoes, Neil Armstrong

On 1/27/26 12:03 PM, Markus Schneider-Pargmann (TI.com) wrote:
> For the upstream DT the ctrl_mod node is using a relative register
> address which is not translated by the current code.
> 
> Make address parsing understand relative addresses.
> 
> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
> ---
>   drivers/usb/musb-new/ti-musb.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
> index bcd31adba522fc55190fc43fd2dbd2dec93a2731..d3c3d3057c1df2a5cc62df3c57d8b071bb0f12b8 100644
> --- a/drivers/usb/musb-new/ti-musb.c
> +++ b/drivers/usb/musb-new/ti-musb.c
> @@ -93,7 +93,7 @@ static int ti_musb_of_to_plat(struct udevice *dev)
>   
>   	phys = fdtdec_lookup_phandle(fdt, node, "phys");
>   	ctrl_mod = fdtdec_lookup_phandle(fdt, phys, "ti,ctrl_mod");
> -	plat->ctrl_mod_base = (void *)fdtdec_get_addr(fdt, ctrl_mod, "reg");
> +	plat->ctrl_mod_base = (void *)ofnode_get_addr(offset_to_ofnode(ctrl_mod));
Can you please also clean up the other two fdtdec_* calls above while 
you're at it ? Thanks

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (subset) [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers
  2026-01-27 11:03 [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
                   ` (6 preceding siblings ...)
  2026-01-27 11:03 ` [PATCH v4 7/7] usb: musb-new: Add compatibles for ti,musb-am33xx Markus Schneider-Pargmann (TI.com)
@ 2026-01-28 17:48 ` Tom Rini
  7 siblings, 0 replies; 13+ messages in thread
From: Tom Rini @ 2026-01-28 17:48 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek, Markus Schneider-Pargmann (TI.com)
  Cc: Simon Glass, Marek Vasut, Andrew Goodbody, Kory Maincent,
	Svyatoslav Ryhel, Christian Marangi, Dinesh Maniyam,
	Heiko Schocher, Marek Vasut, Rasmus Villemoes, Neil Armstrong,
	Simon Glass

On Tue, 27 Jan 2026 12:03:34 +0100, Markus Schneider-Pargmann (TI.com) wrote:

> musb currently uses a wrapper driver that binds on the parent device of
> the actual musb devices to manage the differentiation between gadget and
> host modes. However in the upstream devicetree this parent devicetree
> node can not be used to match the wrapper driver.
> 
> To be able to probe the musb devices in host/gadget mode directly, this
> series introduces support for returning -ENODEV in bind functions
> resulting in iterating the remaining drivers potentially binding to
> other drivers that match the compatible.
> 
> [...]

Applied to u-boot/master, thanks!

[1/7] dm: core: lists_bind_fdt: Remove unused variable
      commit: 6f3e63b4de851357d81f74211f14fd3b577cae6c
[2/7] dm: core: lists_bind_fdt: Replace found variable
      commit: 41cf66011fc80bd122c3ebbeda4218547c48c297
[3/7] dm: core: Support multiple drivers with same compatibles
      commit: 6668b8e7cc68ee287ef87e18aadc97bf88cea4db
[4/7] dm: core: lists_bind_fdt: Indent continuation debug log message
      commit: 87d7d8190f5cc17abc104f924e0f499fda2fd02e
[5/7] test: dm: Add compatible multimatch test
      commit: c7e0e3fd33ca9809605a6de0a58809daf1224bff
-- 
Tom



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 7/7] usb: musb-new: Add compatibles for ti,musb-am33xx
  2026-01-27 21:15   ` Marek Vasut
@ 2026-01-30  9:05     ` Markus Schneider-Pargmann
  0 siblings, 0 replies; 13+ messages in thread
From: Markus Schneider-Pargmann @ 2026-01-30  9:05 UTC (permalink / raw)
  To: Marek Vasut, Markus Schneider-Pargmann (TI.com), u-boot,
	Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Andrew Goodbody, Kory Maincent,
	Svyatoslav Ryhel, Christian Marangi, Dinesh Maniyam,
	Heiko Schocher, Rasmus Villemoes, Neil Armstrong, U-Boot

[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]

Hi Marek,

On Tue Jan 27, 2026 at 10:15 PM CET, Marek Vasut wrote:
> On 1/27/26 12:03 PM, Markus Schneider-Pargmann (TI.com) wrote:
>
> [...]
>
>> +static int ti_musb_host_bind(struct udevice *dev)
>> +{
>> +	enum usb_dr_mode dr_mode = usb_get_dr_mode(dev_ofnode(dev));
>> +
>> +	if (dr_mode != USB_DR_MODE_HOST && dr_mode != USB_DR_MODE_OTG)
>> +		return -ENODEV;
>> +
>> +	return 0;
>> +}
>
> [...]
>
>>   #if CONFIG_IS_ENABLED(OF_CONTROL)
>> +static int ti_musb_peripheral_bind(struct udevice *dev)
>> +{
>> +	enum usb_dr_mode dr_mode = usb_get_dr_mode(dev_ofnode(dev));
>> +
>> +	if (dr_mode != USB_DR_MODE_PERIPHERAL)
>> +		return -ENODEV;
> How do you handle USB_DR_MODE_UNKNOWN , host or peripheral ?

Thanks for seeing this, I checked, USB_DR_MODE_UNKNOWN will result in
none of the drivers binding. That's the same behavior as the previous
wrapper:

	static int ti_musb_wrapper_bind(struct udevice *parent)
	{
		[...]
			switch (dr_mode) {
			case USB_DR_MODE_PERIPHERAL:
				[...]
				break;
			case USB_DR_MODE_HOST:
				[...]
				break;
			default:
				break;
			};
		}
		return 0;
	}

Thanks for reviewing the patches.

Best
Markus

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 289 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 4/7] dm: core: lists_bind_fdt: Indent continuation debug log message
  2026-01-27 11:03 ` [PATCH v4 4/7] dm: core: lists_bind_fdt: Indent continuation debug log message Markus Schneider-Pargmann (TI)
@ 2026-02-04  0:23   ` Simon Glass
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2026-02-04  0:23 UTC (permalink / raw)
  To: Markus Schneider-Pargmann (TI)
  Cc: u-boot, Mattijs Korpershoek, Tom Rini, Marek Vasut,
	Andrew Goodbody, Kory Maincent, Svyatoslav Ryhel,
	Christian Marangi, Dinesh Maniyam, Heiko Schocher, Marek Vasut,
	Rasmus Villemoes, Neil Armstrong

On Wed, 28 Jan 2026 at 00:04, Markus Schneider-Pargmann (TI)
<msp@baylibre.com> wrote:
>
> The loop in lists_bind_fdt uses an indented style for log messages
> within the loop and normal messages for errors that lead to the exit of
> the function. Due to the change of the previous patch that adds support
> for continuation on -ENODEV returned by bind, the log message should be
> indented.
>
> Signed-off-by: Markus Schneider-Pargmann (TI) <msp@baylibre.com>
> ---
>  drivers/core/lists.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <simon.glass@canonical.com>


>
> diff --git a/drivers/core/lists.c b/drivers/core/lists.c
> index 813c3de52b23d78528686a7a8d9ecbe8cab62efd..2545dc142f6bc3d01dca1e0618055a64978734f3 100644
> --- a/drivers/core/lists.c
> +++ b/drivers/core/lists.c
> @@ -266,7 +266,7 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
>                                                            id ? id->data : 0, node,
>                                                            &dev);
>                         if (!drv && ret == -ENODEV) {
> -                               log_debug("Driver '%s' refuses to bind\n", entry->name);
> +                               log_debug("   - Driver '%s' refuses to bind\n", entry->name);
>                                 continue;
>                         }
>                         if (ret) {
>
> --
> 2.51.0
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-02-04  0:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27 11:03 [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
2026-01-27 11:03 ` [PATCH v4 1/7] dm: core: lists_bind_fdt: Remove unused variable Markus Schneider-Pargmann (TI.com)
2026-01-27 11:03 ` [PATCH v4 2/7] dm: core: lists_bind_fdt: Replace found variable Markus Schneider-Pargmann (TI.com)
2026-01-27 11:03 ` [PATCH v4 3/7] dm: core: Support multiple drivers with same compatibles Markus Schneider-Pargmann (TI.com)
2026-01-27 11:03 ` [PATCH v4 4/7] dm: core: lists_bind_fdt: Indent continuation debug log message Markus Schneider-Pargmann (TI)
2026-02-04  0:23   ` Simon Glass
2026-01-27 11:03 ` [PATCH v4 5/7] test: dm: Add compatible multimatch test Markus Schneider-Pargmann (TI.com)
2026-01-27 11:03 ` [PATCH v4 6/7] usb: musb-new: Relative ctrl_mod address parsing Markus Schneider-Pargmann (TI.com)
2026-01-27 21:15   ` Marek Vasut
2026-01-27 11:03 ` [PATCH v4 7/7] usb: musb-new: Add compatibles for ti,musb-am33xx Markus Schneider-Pargmann (TI.com)
2026-01-27 21:15   ` Marek Vasut
2026-01-30  9:05     ` Markus Schneider-Pargmann
2026-01-28 17:48 ` (subset) [PATCH v4 0/7] dm: core: Support same compatible in host/gadget musb drivers Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox