public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Vignesh R <vigneshr@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RESEND PATCH v5 01/12] dm: core: implement dev_map_phsymem()
Date: Wed, 6 Jul 2016 09:58:55 +0530	[thread overview]
Message-ID: <20160706042906.13482-2-vigneshr@ti.com> (raw)
In-Reply-To: <20160706042906.13482-1-vigneshr@ti.com>

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>
---
 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 eb75b1734f9b..f7fb0cc0fa7c 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>
@@ -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);
diff --git a/include/dm/device.h b/include/dm/device.h
index f03bcd3b49ee..1bfcf3bcbc01 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -467,6 +467,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.9.0

  reply	other threads:[~2016-07-06  4:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06  4:28 [U-Boot] [RESEND PATCH v3 00/12] Convert davinci_spi to DM Vignesh R
2016-07-06  4:28 ` Vignesh R [this message]
2016-07-06 23:19   ` [U-Boot] [RESEND PATCH v5 01/12] dm: core: implement dev_map_phsymem() Simon Glass
2016-07-09 14:50     ` Jagan Teki
2016-07-11  4:39       ` Vignesh R
2016-07-06  4:28 ` [U-Boot] [RESEND PATCH v6 02/12] spi: davinci_spi: Convert to driver to adapt to DM Vignesh R
2016-07-06  4:28 ` [U-Boot] [RESEND PATCH v3 03/12] keystone2: spi: do not define DM_SPI and DM_SPI_FLASH for SPL build Vignesh R
2016-07-06  4:28 ` [U-Boot] [RESEND PATCH v3 04/12] ARM: dts: keystone2: add SPI aliases for davinci SPI nodes Vignesh R
2016-07-06  4:28 ` [U-Boot] [RESEND PATCH v3 05/12] ARM: dts: k2hk: Enable Davinci SPI controller Vignesh R
2016-07-06  4:29 ` [U-Boot] [RESEND PATCH v3 06/12] defconfig: k2hk_evm_defconfig: enable SPI driver model Vignesh R
2016-07-06  4:29 ` [U-Boot] [RESEND PATCH v3 07/12] ARM: dts: k2e: Enable Davinci SPI controller Vignesh R
2016-07-06  4:29 ` [U-Boot] [RESEND PATCH v3 08/12] defconfig: k2e_evm_defconfig: enable SPI driver model Vignesh R
2016-07-06  4:29 ` [U-Boot] [RESEND PATCH v3 09/12] ARM: dts: k2l: Enable Davinci SPI controller Vignesh R
2016-07-06  4:29 ` [U-Boot] [RESEND PATCH v3 10/12] defconfig: k2l_evm_defconfig: enable SPI driver model Vignesh R
2016-07-06  4:29 ` [U-Boot] [RESEND PATCH v3 11/12] ARM: dts: k2g: add support for Davinci SPI controller Vignesh R
2016-07-06  4:29 ` [U-Boot] [RESEND PATCH v3 12/12] defconfig: k2g_evm_defconfig: enable SPI driver model Vignesh R
2016-07-06  7:16   ` Jagan Teki
2016-07-06  7:25 ` [U-Boot] [RESEND PATCH v3 00/12] Convert davinci_spi to DM Jagan Teki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160706042906.13482-2-vigneshr@ti.com \
    --to=vigneshr@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox