summaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorÁlvaro Fernández Rojas <noltari@gmail.com>2018-12-03 19:37:09 +0100
committerSimon Glass <sjg@chromium.org>2018-12-05 06:06:44 -0700
commit7959882049a9b389c131eff9a128437ee8ebe08e (patch)
treea0b31f0e5dbf3d95ae731918a675c075614db3be /include/dm
parentbb48470df21c0ce4ebed47f5dc3ea25ff02fd4dd (diff)
dm: core: add functions to get/remap I/O addresses by name
This functions allow us to get and remap I/O addresses by name, which is useful when there are multiple reg addresses indexed by reg-names property. This is needed in bmips dma/eth patch series, but can also be used on many other drivers. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/fdtaddr.h13
-rw-r--r--include/dm/read.h36
2 files changed, 49 insertions, 0 deletions
diff --git a/include/dm/fdtaddr.h b/include/dm/fdtaddr.h
index 49a6ffd5f8..c171d9bc2f 100644
--- a/include/dm/fdtaddr.h
+++ b/include/dm/fdtaddr.h
@@ -56,6 +56,19 @@ void *devfdt_remap_addr(struct udevice *dev);
void *devfdt_remap_addr_index(struct udevice *dev, int index);
/**
+ * devfdt_remap_addr_name() - Get the reg property of a device, indexed by
+ * name, as a memory-mapped I/O pointer
+ * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
+ * 'reg-names' property providing named-based identification. @index
+ * indicates the value to search for in 'reg-names'.
+ *
+ * @dev: Pointer to a device
+ *
+ * @return Pointer to addr, or NULL if there is no such property
+ */
+void *devfdt_remap_addr_name(struct udevice *dev, const char *name);
+
+/**
* devfdt_map_physmem() - Read device address from reg property of the
* device node and map the address into CPU address
* space.
diff --git a/include/dm/read.h b/include/dm/read.h
index a27b8554fb..efcbee15ec 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -125,6 +125,31 @@ fdt_addr_t dev_read_addr_index(struct udevice *dev, int index);
void *dev_remap_addr_index(struct udevice *dev, int index);
/**
+ * dev_read_addr_name() - Get the reg property of a device, indexed by name
+ *
+ * @dev: Device to read from
+ * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
+ * 'reg-names' property providing named-based identification. @index
+ * indicates the value to search for in 'reg-names'.
+ *
+ * @return address or FDT_ADDR_T_NONE if not found
+ */
+fdt_addr_t dev_read_addr_name(struct udevice *dev, const char* name);
+
+/**
+ * dev_remap_addr_name() - Get the reg property of a device, indexed by name,
+ * as a memory-mapped I/O pointer
+ *
+ * @dev: Device to read from
+ * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
+ * 'reg-names' property providing named-based identification. @index
+ * indicates the value to search for in 'reg-names'.
+ *
+ * @return pointer or NULL if not found
+ */
+void *dev_remap_addr_name(struct udevice *dev, const char* name);
+
+/**
* dev_read_addr() - Get the reg property of a device
*
* @dev: Device to read from
@@ -494,6 +519,12 @@ static inline fdt_addr_t dev_read_addr_index(struct udevice *dev, int index)
return devfdt_get_addr_index(dev, index);
}
+static inline fdt_addr_t dev_read_addr_name(struct udevice *dev,
+ const char *name)
+{
+ return devfdt_get_addr_name(dev, name);
+}
+
static inline fdt_addr_t dev_read_addr(struct udevice *dev)
{
return devfdt_get_addr(dev);
@@ -514,6 +545,11 @@ static inline void *dev_remap_addr_index(struct udevice *dev, int index)
return devfdt_remap_addr_index(dev, index);
}
+static inline void *dev_remap_addr_name(struct udevice *dev, const char *name)
+{
+ return devfdt_remap_addr_name(dev, name);
+}
+
static inline fdt_addr_t dev_read_addr_size(struct udevice *dev,
const char *propname,
fdt_size_t *sizep)