[U-Boot] [PATCH 8/8] dm: core: abolish u-boot, dm-pre-reloc property

Masahiro Yamada yamada.m at jp.panasonic.com
Mon Nov 17 09:19:45 CET 2014


The driver model provides two ways to pass the device information,
platform data and device tree.  Either way works to bind devices and
drivers, but there is inconsistency in terms of how to pass the
pre-reloc flag.

In the platform data way, the pre-reloc DM scan checks if each driver
has DM_FLAG_PRE_RELOC flag (this was changed to use U_BOOT_DRIVER_F
just before).  That is, each **driver** has the pre-reloc attribute.

In the device tree control, the existence of "u-boot,dm-pre-reloc" is
checked for each device node.  The driver flag "DM_FLAG_PRE_RELOC" is
never checked.  That is, each **device** owns the pre-reloc attribute.

Drivers should generally work both with platform data and device tree,
but this inconsistency has made our life difficult.

This commit abolishes "u-boot,dm-pre-reloc" property because:

 - Having a U-Boot specific property makes it difficult to share the
   device tree sources between Linux and U-Boot.

 - The number of devices is generally larger than that of drivers.
   Each driver often has multiple devices with different base
   addresses.  It seems more reasonable to add the pre-reloc attribute
   to drivers than devices.

Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
---

 arch/arm/dts/exynos5.dtsi   |  1 -
 doc/driver-model/README.txt |  5 ++---
 drivers/core/lists.c        |  6 +++---
 drivers/core/root.c         |  6 ++----
 drivers/core/simple-bus.c   |  2 +-
 include/dm/lists.h          | 13 ++++++++++---
 include/dm/root.h           |  4 ++--
 test/dm/test-fdt.c          |  2 +-
 test/dm/test.dts            |  2 --
 9 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/arch/arm/dts/exynos5.dtsi b/arch/arm/dts/exynos5.dtsi
index e539068..dc5405b 100644
--- a/arch/arm/dts/exynos5.dtsi
+++ b/arch/arm/dts/exynos5.dtsi
@@ -244,7 +244,6 @@
 		compatible = "samsung,exynos4210-uart";
 		reg = <0x12C30000 0x100>;
 		interrupts = <0 54 0>;
-		u-boot,dm-pre-reloc;
 		id = <3>;
 	};
 
diff --git a/doc/driver-model/README.txt b/doc/driver-model/README.txt
index e4114d5..06f6515 100644
--- a/doc/driver-model/README.txt
+++ b/doc/driver-model/README.txt
@@ -739,9 +739,8 @@ Pre-Relocation Support
 ----------------------
 
 For pre-relocation we simply call the driver model init function. Only
-drivers declared with U_BOOT_DRIVER_F or the device tree
-'u-boot,dm-pre-reloc' flag are initialised prior to relocation. This helps
-to reduce the driver model overhead.
+drivers declared with U_BOOT_DRIVER_F are initialised prior to relocation.
+This helps to reduce the driver model overhead.
 
 Then post relocation we throw that away and re-init driver model again.
 For drivers which require some sort of continuity between pre- and
diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 5b61ab5..2109a9f 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -106,11 +106,11 @@ static int driver_check_compatible(const void *blob, int offset,
 	return -ENOENT;
 }
 
-int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
-		   struct udevice **devp)
+int __lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
+		     struct udevice **devp, bool pre_reloc_only)
 {
 	struct driver *entry = ll_entry_start(struct driver, driver1);
-	struct driver *end = ll_entry_end(struct driver, driver2);
+	struct driver *end = driver_entry_end(pre_reloc_only);
 	struct udevice *dev;
 	bool found = false;
 	const char *name;
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 02970c8..2f0c409 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -87,10 +87,8 @@ int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
 	for (offset = fdt_first_subnode(blob, offset);
 	     offset > 0;
 	     offset = fdt_next_subnode(blob, offset)) {
-		if (pre_reloc_only &&
-		    !fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
-			continue;
-		err = lists_bind_fdt(parent, blob, offset, NULL);
+		err = __lists_bind_fdt(parent, blob, offset, NULL,
+				       pre_reloc_only);
 		if (err && !ret)
 			ret = err;
 	}
diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c
index 3ea4d82..483f8e2 100644
--- a/drivers/core/simple-bus.c
+++ b/drivers/core/simple-bus.c
@@ -26,7 +26,7 @@ static const struct udevice_id generic_simple_bus_ids[] = {
 	{ }
 };
 
-U_BOOT_DRIVER(simple_bus_drv) = {
+U_BOOT_DRIVER_F(simple_bus_drv) = {
 	.name	= "generic_simple_bus",
 	.id	= UCLASS_SIMPLE_BUS,
 	.of_match = generic_simple_bus_ids,
diff --git a/include/dm/lists.h b/include/dm/lists.h
index fbd428d..56bf6a7 100644
--- a/include/dm/lists.h
+++ b/include/dm/lists.h
@@ -53,7 +53,7 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id);
 int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
 
 /**
- * lists_bind_fdt() - bind a device tree node
+ * __lists_bind_fdt() - bind a device tree node
  *
  * This creates a new device bound to the given device tree node, with
  * @parent as its parent.
@@ -62,10 +62,17 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
  * @blob: device tree blob
  * @offset: offset of this device tree node
  * @devp: if non-NULL, returns a pointer to the bound device
+ * @pre_reloc_only: If true, bind only drivers declared with U_BOOT_DRIVER_F.
+ * If false bind all drivers.
  * @return 0 if device was bound, -EINVAL if the device tree is invalid,
  * other -ve value on error
  */
-int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
-		   struct udevice **devp);
+int __lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
+		     struct udevice **devp, bool pre_reloc_only);
 
+static inline int lists_bind_fdt(struct udevice *parent, const void *blob,
+				 int offset, struct udevice **devp)
+{
+	return __lists_bind_fdt(parent, blob, offset, devp, false);
+}
 #endif
diff --git a/include/dm/root.h b/include/dm/root.h
index 61d1cd8..960e888 100644
--- a/include/dm/root.h
+++ b/include/dm/root.h
@@ -39,8 +39,8 @@ int dm_scan_platdata(bool pre_reloc_only);
  * the top-level subnodes are examined.
  *
  * @blob: Pointer to device tree blob
- * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
- * flag. If false bind all drivers.
+ * @pre_reloc_only: If true, bind only drivers declared with U_BOOT_DRIVER_F.
+ * If false bind all drivers.
  * @return 0 if OK, -ve on error
  */
 int dm_scan_fdt(const void *blob, bool pre_reloc_only);
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index cd2c389..8cb1f76 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -64,7 +64,7 @@ static const struct udevice_id testfdt_ids[] = {
 	{ }
 };
 
-U_BOOT_DRIVER(testfdt_drv) = {
+U_BOOT_DRIVER_F(testfdt_drv) = {
 	.name	= "testfdt_drv",
 	.of_match	= testfdt_ids,
 	.id	= UCLASS_TEST_FDT,
diff --git a/test/dm/test.dts b/test/dm/test.dts
index 1fba792..86f024f 100644
--- a/test/dm/test.dts
+++ b/test/dm/test.dts
@@ -13,7 +13,6 @@
 
 	uart0: serial {
 		compatible = "sandbox,serial";
-		u-boot,dm-pre-reloc;
 	};
 
 	a-test {
@@ -21,7 +20,6 @@
 		compatible = "denx,u-boot-fdt-test";
 		ping-expect = <0>;
 		ping-add = <0>;
-		u-boot,dm-pre-reloc;
 	};
 
 	junk {
-- 
1.9.1



More information about the U-Boot mailing list