[PATCH] dm: automatically set DM_FLAG_PRE_RELOC based on device-tree property

Quentin Schulz foss+uboot at 0leil.net
Thu Sep 22 15:45:40 CEST 2022


From: Quentin Schulz <quentin.schulz at theobroma-systems.com>

One needs to set u-boot,dm-pre-reloc in a device Device Tree node so
that it is kept in SPL/TPL variant of the device tree. However, a device
is automatically probed only if it's flagged with DM_FLAG_PRE_RELOC,
regardless of u-boot,dm-pre-reloc DT property presence. This flag is
currently only set by drivers directly.

However, this flag should be allowed to be set on a per-device basis
even if the driver does not hardcode it so that the device will be
probed in SPL/TPL regardless of the driver's defaults.

This sets the DM_FLAG_PRE_RELOC for all U_BOOT_CLASS devices whose DT
node contains the u-boot,dm-pre-reloc property.

Cc: Quentin Schulz <foss+uboot at 0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz at theobroma-systems.com>
---
 drivers/core/lists.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index c49695b24f..86b75ffede 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -260,6 +260,9 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 				ret);
 			return log_msg_ret("bind", ret);
 		} else {
+			if (ofnode_pre_reloc(node))
+				dev_or_flags(dev, DM_FLAG_PRE_RELOC);
+
 			found = true;
 			if (devp)
 				*devp = dev;
-- 
2.37.3



More information about the U-Boot mailing list