]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
core: Add {ofnode, dev}_translate_address functions
authorMario Six <mario.six@gdsys.cc>
Mon, 15 Jan 2018 10:07:19 +0000 (11:07 +0100)
committerSimon Glass <sjg@chromium.org>
Sun, 21 Jan 2018 17:01:02 +0000 (10:01 -0700)
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Mario Six <mario.six@gdsys.cc>
drivers/core/ofnode.c
drivers/core/read.c
include/dm/ofnode.h
include/dm/read.h

index e0428e2a363bc60ebb4016e22315a840fe6e97c4..98f4b539ea4d6de876f1058104a260b7a400e035 100644 (file)
@@ -649,3 +649,11 @@ int ofnode_read_resource_byname(ofnode node, const char *name,
 
        return ofnode_read_resource(node, index, res);
 }
+
+u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr)
+{
+       if (ofnode_is_np(node))
+               return of_translate_address(ofnode_to_np(node), in_addr);
+       else
+               return fdt_translate_address(gd->fdt_blob, ofnode_to_offset(node), in_addr);
+}
index aba8747708723888e011f5b7b5e57976bbe6ddbb..ce33ecdadde0b6093318788a15d299044f1a11e9 100644 (file)
@@ -195,3 +195,8 @@ int dev_read_resource_byname(struct udevice *dev, const char *name,
 {
        return ofnode_read_resource_byname(dev_ofnode(dev), name, res);
 }
+
+u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr)
+{
+       return ofnode_translate_address(dev_ofnode(dev), in_addr);
+}
index 8b9932a569ce5a33a813f3bdb11ed2fc880c210b..c359a60f9536a78830d33c23497ba412991e111d 100644 (file)
@@ -652,4 +652,17 @@ int ofnode_read_resource_byname(ofnode node, const char *name,
             ofnode_valid(node); \
             node = ofnode_next_subnode(node))
 
+/**
+ * ofnode_translate_address() - Tranlate a device-tree address
+ *
+ * Translate an address from the device-tree into a CPU physical address. This
+ * function walks up the tree and applies the various bus mappings along the
+ * way.
+ *
+ * @ofnode: Device tree node giving the context in which to translate the
+ *          address
+ * @in_addr: pointer to the address to translate
+ * @return the translated address; OF_BAD_ADDR on error
+ */
+u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr);
 #endif
index 8114037e9771d1110b45a648f82cdf8358666bfb..2551e5f0dcf8916f5898b2babdd0e03e16e36bba 100644 (file)
@@ -410,6 +410,18 @@ int dev_read_resource(struct udevice *dev, uint index, struct resource *res);
 int dev_read_resource_byname(struct udevice *dev, const char *name,
                             struct resource *res);
 
+/**
+ * dev_translate_address() - Tranlate a device-tree address
+ *
+ * Translate an address from the device-tree into a CPU physical address.  This
+ * function walks up the tree and applies the various bus mappings along the
+ * way.
+ *
+ * @dev: device giving the context in which to translate the address
+ * @in_addr: pointer to the address to translate
+ * @return the translated address; OF_BAD_ADDR on error
+ */
+u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr);
 #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
 
 static inline int dev_read_u32_default(struct udevice *dev,
@@ -582,6 +594,11 @@ static inline int dev_read_resource_byname(struct udevice *dev,
        return ofnode_read_resource_byname(dev_ofnode(dev), name, res);
 }
 
+static inline u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr)
+{
+       return ofnode_translate_address(dev_ofnode(dev), in_addr);
+}
+
 #endif /* CONFIG_DM_DEV_READ_INLINE */
 
 /**