dm: core: implement dev_map_physmem()
authorVignesh R <vigneshr@ti.com>
Wed, 6 Jul 2016 04:28:55 +0000 (09:58 +0530)
committerJagan Teki <jteki@openedev.com>
Sat, 9 Jul 2016 14:46:08 +0000 (20:16 +0530)
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@ti.com>
Suggested-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jagan Teki <jteki@openedev.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
drivers/core/device.c
include/dm/device.h

index eb75b1734f9b973e406c8cfca80c8f6a9231c0e9..f7fb0cc0fa7c60000153897316b1ef7ff5ae8e95 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <asm/io.h>
 #include <fdtdec.h>
 #include <fdt_support.h>
 #include <malloc.h>
@@ -697,6 +698,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);
index f03bcd3b49ee45f962126f67272587364ec52356..1bfcf3bcbc012ae0994625b78ce166a5070ca897 100644 (file)
@@ -466,6 +466,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
  *