[U-Boot] [PATCH v5] dm: core: implement dev_map_physmem()
Vignesh R
vigneshr at ti.com
Mon May 16 11:16:47 CEST 2016
This API helps to map physical register addresss pace of device to
virtual address space easily. Its just a wrapper around map_physmem()
with MAP_NOCACHE flag.
Signed-off-by: Vignesh R <vigneshr at ti.com>
Suggested-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Jagan Teki <jteki at openedev.com>
---
v5: Fix comments by Simon Glass <sjg at chromium.org>
drivers/core/device.c | 11 +++++++++++
include/dm/device.h | 13 +++++++++++++
2 files changed, 24 insertions(+)
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 1322991d6c7b..0406fc82f8d1 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -10,6 +10,7 @@
*/
#include <common.h>
+#include <asm/io.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <malloc.h>
@@ -678,6 +679,16 @@ void *dev_get_addr_ptr(struct udevice *dev)
return (void *)(uintptr_t)dev_get_addr_index(dev, 0);
}
+void *dev_map_physmem(struct udevice *dev, unsigned long size)
+{
+ fdt_addr_t addr = dev_get_addr(dev);
+
+ if (addr == FDT_ADDR_T_NONE)
+ return NULL;
+
+ return map_physmem(addr, size, MAP_NOCACHE);
+}
+
bool device_has_children(struct udevice *dev)
{
return !list_empty(&dev->child_head);
diff --git a/include/dm/device.h b/include/dm/device.h
index 8970fc015c7e..9509c0b72ccb 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -464,6 +464,19 @@ fdt_addr_t dev_get_addr(struct udevice *dev);
void *dev_get_addr_ptr(struct udevice *dev);
/**
+ * dev_map_physmem() - Read device address from reg property of the
+ * device node and map the address into CPU address
+ * space.
+ *
+ * @dev: Pointer to device
+ * @size: size of the memory to map
+ *
+ * @return mapped address, or NULL if the device does not have reg
+ * property.
+ */
+void *dev_map_physmem(struct udevice *dev, unsigned long size);
+
+/**
* dev_get_addr_index() - Get the indexed reg property of a device
*
* @dev: Pointer to a device
--
2.8.2
More information about the U-Boot
mailing list