]> git.sur5r.net Git - u-boot/commitdiff
dm: introduce dev_get_addr interface
authorPeng Fan <Peng.Fan@freescale.com>
Tue, 10 Feb 2015 06:46:32 +0000 (14:46 +0800)
committerSimon Glass <sjg@chromium.org>
Thu, 12 Feb 2015 22:17:29 +0000 (15:17 -0700)
Abstracting dev_get_addr can improve drivers that want to
get device's address.

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Acked-by: Igor Grinberg <grinberg@compulab.co.il>
Acked-by: Simon Glass <sjg@chromium.org>
drivers/core/device.c
include/dm/device.h

index b73d3b8961de337c1ec871d3d4ed2c1b24285e59..73c3e07c28b32c19fd01b76435172ab7419c8fa0 100644 (file)
@@ -449,3 +449,15 @@ enum uclass_id device_get_uclass_id(struct udevice *dev)
 {
        return dev->uclass->uc_drv->id;
 }
+
+#ifdef CONFIG_OF_CONTROL
+fdt_addr_t dev_get_addr(struct udevice *dev)
+{
+       return fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
+}
+#else
+fdt_addr_t dev_get_addr(struct udevice *dev)
+{
+       return FDT_ADDR_T_NONE;
+}
+#endif
index 81afa8c6281f8f9c55dbd968bfd4b344f8cf872a..7a48eb88b8ccf1ce1b52d8ffb898d8b2610c4e56 100644 (file)
@@ -12,6 +12,7 @@
 #define _DM_DEVICE_H
 
 #include <dm/uclass-id.h>
+#include <fdtdec.h>
 #include <linker_lists.h>
 #include <linux/list.h>
 
@@ -351,4 +352,13 @@ int device_find_first_child(struct udevice *parent, struct udevice **devp);
  */
 int device_find_next_child(struct udevice **devp);
 
+/**
+ * dev_get_addr() - Get the reg property of a device
+ *
+ * @dev: Pointer to a device
+ *
+ * @return addr
+ */
+fdt_addr_t dev_get_addr(struct udevice *dev);
+
 #endif