Skip to contentSkip to conversation

dm: core: add functions to get memory-mapped I/O addresses

PATCH Superseded Daniel Schwierzeck 2 participants 3 messages Apr 29, 2018 – May 6, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 dm: core: add functions to get memory-mapped I/O addresses

From: Álvaro Fernández Rojas <[email protected]>

---
This replaces/updates patch 01/17 from patch series
https://patchwork.ozlabs.org/cover/889542/. The update fixes some issues with Sandbox and adds unit-tests. The remaining patches from the patch series can be applied as-is when this patch has been committed.

Changes in v3:
- replace ioremap() with map_physmem()
- add unit tests
- fix checkpatch.pl warnings

Changes in v2:
- new patch

 drivers/core/fdtaddr.c | 15 +++++++++++++++
 drivers/core/read.c    | 15 +++++++++++++++
 include/dm/fdtaddr.h   | 22 ++++++++++++++++++++++
 include/dm/read.h      | 32 ++++++++++++++++++++++++++++++++
 test/dm/test-fdt.c     | 42 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 126 insertions(+)
drivers/core/fdtaddr.c +15 -0
index 9a3b4c312a..afea47bf7c 100644
@@ -137,6 +137,21 @@ void *devfdt_get_addr_ptr(struct udevice *dev)
 	return (void *)(uintptr_t)devfdt_get_addr_index(dev, 0);
 }
 
+void *devfdt_remap_addr_index(struct udevice *dev, int index)
+{
+	fdt_addr_t addr = devfdt_get_addr(dev);
+
+	if (addr == FDT_ADDR_T_NONE)
+		return NULL;
+
+	return map_physmem(addr, 0, MAP_NOCACHE);
+}
+
+void *devfdt_remap_addr(struct udevice *dev)
+{
+	return devfdt_remap_addr_index(dev, 0);
+}
+
 void *devfdt_map_physmem(struct udevice *dev, unsigned long size)
 {
 	fdt_addr_t addr = devfdt_get_addr(dev);
drivers/core/read.c +15 -0
index 601d1322d6..615551b8f3 100644
@@ -58,6 +58,16 @@ fdt_addr_t dev_read_addr_index(struct udevice *dev, int index)
 		return devfdt_get_addr_index(dev, index);
 }
 
+void *dev_remap_addr_index(struct udevice *dev, int index)
+{
+	fdt_addr_t addr = dev_read_addr_index(dev, index);
+
+	if (addr == FDT_ADDR_T_NONE)
+		return NULL;
+
+	return map_physmem(addr, 0, MAP_NOCACHE);
+}
+
 fdt_addr_t dev_read_addr(struct udevice *dev)
 {
 	return dev_read_addr_index(dev, 0);
@@ -70,6 +80,11 @@ void *dev_read_addr_ptr(struct udevice *dev)
 	return (addr == FDT_ADDR_T_NONE) ? NULL : map_sysmem(addr, 0);
 }
 
+void *dev_remap_addr(struct udevice *dev)
+{
+	return dev_remap_addr_index(dev, 0);
+}
+
 fdt_addr_t dev_read_addr_size(struct udevice *dev, const char *property,
 			      fdt_size_t *sizep)
 {
include/dm/fdtaddr.h +22 -0
index c46f0e91d0..82fc5f931d 100644
@@ -34,6 +34,28 @@ fdt_addr_t devfdt_get_addr(struct udevice *dev);
  */
 void *devfdt_get_addr_ptr(struct udevice *dev);
 
+/**
+ * devfdt_remap_addr() - Return pointer to the memory-mapped I/O address
+ *                           of the reg property of a device
+ *
+ * @dev: Pointer to a device
+ *
+ * @return Pointer to addr, or NULL if there is no such property
+ */
+void *devfdt_remap_addr(struct udevice *dev);
+
+/**
+ * devfdt_remap_addr_index() - Return indexed pointer to the memory-mapped
+ *                                 I/O address of the reg property of a device
+ * @index: the 'reg' property can hold a list of <addr, size> pairs
+ *	   and @index is used to select which one is required
+ *
+ * @dev: Pointer to a device
+ *
+ * @return Pointer to addr, or NULL if there is no such property
+ */
+void *devfdt_remap_addr_index(struct udevice *dev, int index);
+
 /**
  * devfdt_map_physmem() - Read device address from reg property of the
  *                     device node and map the address into CPU address
include/dm/read.h +32 -0
index f14c7a7ba8..c826a2235c 100644
@@ -113,6 +113,18 @@ int dev_read_size(struct udevice *dev, const char *propname);
  */
 fdt_addr_t dev_read_addr_index(struct udevice *dev, int index);
 
+/**
+ * dev_remap_addr_index() - Get the indexed reg property of a device
+ *                               as a memory-mapped I/O pointer
+ *
+ * @dev: Device to read from
+ * @index: the 'reg' property can hold a list of <addr, size> pairs
+ *	   and @index is used to select which one is required
+ *
+ * @return pointer or NULL if not found
+ */
+void *dev_remap_addr_index(struct udevice *dev, int index);
+
 /**
  * dev_read_addr() - Get the reg property of a device
  *
@@ -132,6 +144,16 @@ fdt_addr_t dev_read_addr(struct udevice *dev);
  */
 void *dev_read_addr_ptr(struct udevice *dev);
 
+/**
+ * dev_remap_addr() - Get the reg property of a device as a
+ *                         memory-mapped I/O pointer
+ *
+ * @dev: Device to read from
+ *
+ * @return pointer or NULL if not found
+ */
+void *dev_remap_addr(struct udevice *dev);
+
 /**
  * dev_read_addr_size() - get address and size from a device property
  *
@@ -483,6 +505,16 @@ static inline void *dev_read_addr_ptr(struct udevice *dev)
 	return devfdt_get_addr_ptr(dev);
 }
 
+static inline void *dev_remap_addr(struct udevice *dev)
+{
+	return devfdt_remap_addr(dev);
+}
+
+static inline void *dev_remap_addr_index(struct udevice *dev, int index)
+{
+	return devfdt_remap_addr_index(dev, index);
+}
+
 static inline fdt_addr_t dev_read_addr_size(struct udevice *dev,
 					    const char *propname,
 					    fdt_size_t *sizep)
test/dm/test-fdt.c +42 -0

45 lines not on this page · raw message

Signature · 1 line
2.17.0
#1 lore raw

PATCH v3 1/1 dm: core: add functions to get memory-mapped I/O addresses

Quoted 21 lines · Daniel Schwierzeck

From: Álvaro Fernández Rojas <[email protected]>

---
This replaces/updates patch 01/17 from patch series
https://patchwork.ozlabs.org/cover/889542/. The update fixes some issues with Sandbox and adds unit-tests. The remaining patches from the patch series can be applied as-is when this patch has been committed.

Changes in v3:
- replace ioremap() with map_physmem()
- add unit tests
- fix checkpatch.pl warnings

Changes in v2:
- new patch

Quoted 6 lines
 drivers/core/fdtaddr.c | 15 +++++++++++++++
 drivers/core/read.c    | 15 +++++++++++++++
 include/dm/fdtaddr.h   | 22 ++++++++++++++++++++++
 include/dm/read.h      | 32 ++++++++++++++++++++++++++++++++
 test/dm/test-fdt.c     | 42 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 126 insertions(+)
#2 lore raw

PATCH v3 1/1 dm: core: add functions to get memory-mapped I/O addresses

In reply to Daniel Schwierzeck
Quoted 21 lines · Daniel Schwierzeck

From: Álvaro Fernández Rojas <[email protected]>

---
This replaces/updates patch 01/17 from patch series
https://patchwork.ozlabs.org/cover/889542/. The update fixes some issues with Sandbox and adds unit-tests. The remaining patches from the patch series can be applied as-is when this patch has been committed.

Changes in v3:
- replace ioremap() with map_physmem()
- add unit tests
- fix checkpatch.pl warnings

Changes in v2:
- new patch

Quoted 7 lines
 drivers/core/fdtaddr.c | 15 +++++++++++++++
 drivers/core/read.c    | 15 +++++++++++++++
 include/dm/fdtaddr.h   | 22 ++++++++++++++++++++++
 include/dm/read.h      | 32 ++++++++++++++++++++++++++++++++
 test/dm/test-fdt.c     | 42 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 126 insertions(+)

applied to u-boot-mips/next

Signature · 9 lines
- Daniel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180506/21bc9263/attachment.sig>