[U-Boot] [PATCH v3 1/4] dm: introduce dev_get_addr interface

Peng Fan Peng.Fan at freescale.com
Wed Jan 21 12:09:53 CET 2015


Abstracting dev_get_addr can improve drivers that want to
get device's address.

Signed-off-by: Peng Fan <Peng.Fan at freescale.com>
---
 drivers/core/device.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 963b16f..0ba5c76 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <fdtdec.h>
 #include <malloc.h>
+#include <libfdt.h>
 #include <dm/device.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
@@ -390,3 +391,21 @@ ulong dev_get_of_data(struct udevice *dev)
 {
 	return dev->of_id->data;
 }
+
+#ifdef CONFIG_OF_CONTROL
+void *dev_get_addr(struct udevice *dev)
+{
+	fdt_addr_t addr;
+
+	addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
+	if (addr == FDT_ADDR_T_NONE)
+		return NULL;
+	else
+		return (void *)addr;
+}
+#else
+void *dev_get_addr(struct udevice *dev)
+{
+	return NULL;
+}
+#endif
-- 
1.8.4




More information about the U-Boot mailing list