[PATCH v3 1/3] dm: core: Bind another driver with the same compatible string

Michal Simek michal.simek at xilinx.com
Wed Oct 6 16:19:09 CEST 2021

When one IP can have multiple configurations (like timer and PWM) covered
by multiple drivers. Because it is the same IP it should also have the same
compatible string.
Current code look for the first driver which matches compatible string and
call bind function. If this is not the right driver which is express by
returning -ENODEV ("Driver XYZ refuses to bind") there is no reason not to
continue over compatible list to try to find out different driver with the
same compatible string which match it.

When the first compatible string is found core looks for driver bind()
function. If if assigned driver refuse to bind, core continue in a loop to
check if there is another driver which match compatible string.

This driver is going to be used with cdnc,ttc driver which has driver as
timer and also can be used as PWM. The difference is done via #pwm-cells
property in DT.

Signed-off-by: Michal Simek <michal.simek at xilinx.com>

Changes in v3:
- New patch in series

 drivers/core/lists.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 350b9d32687c..199ee3a8e0fc 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -221,12 +221,14 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 		compat = compat_list + i;
 		log_debug("   - attempt to match compatible string '%s'\n",
-		for (entry = driver; entry != driver + n_ents; entry++) {
+		entry = driver;
+		for (; entry != driver + n_ents; entry++) {
 			ret = driver_check_compatible(entry->of_match, &id,
 			if (!ret)
 		if (entry == driver + n_ents)
@@ -246,7 +248,8 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 						   id->data, node, &dev);
 		if (ret == -ENODEV) {
 			log_debug("Driver '%s' refuses to bind\n", entry->name);
-			continue;
+			entry++;
+			goto next;
 		if (ret) {
 			dm_warn("Error binding driver '%s': %d\n", entry->name,

More information about the U-Boot mailing list