summaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2021-02-22 10:39:38 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-02-22 10:39:38 +0100
commita017e79fccb66e2c2e75ac44e5c3e214b509dd2a (patch)
tree6880209d0dfda025f46961739abc762eb055c79f /include/asm-generic
parenta4d21cda3ca4fa82bbd71026c072af991c189400 (diff)
parent582523142975c7993af81ff8007ff8e0e96f6dee (diff)
downloadbarebox-a017e79fccb66e2c2e75ac44e5c3e214b509dd2a.tar.gz
barebox-a017e79fccb66e2c2e75ac44e5c3e214b509dd2a.tar.xz
Merge branch 'for-next/asm-io'
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/io.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 76e6d0dc11..a4b0dc4b43 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -11,6 +11,7 @@
#ifndef __ASM_GENERIC_IO_H
#define __ASM_GENERIC_IO_H
+#include <linux/string.h> /* for memset() and memcpy() */
#include <linux/types.h>
#include <asm/byteorder.h>
@@ -424,4 +425,58 @@ static inline void iowrite64be(u64 value, volatile void __iomem *addr)
#define IOMEM(addr) ((void __force __iomem *)(addr))
#endif
+#define __io_virt(x) ((void __force *)(x))
+
+#ifndef memset_io
+#define memset_io memset_io
+/**
+ * memset_io Set a range of I/O memory to a constant value
+ * @addr: The beginning of the I/O-memory range to set
+ * @val: The value to set the memory to
+ * @count: The number of bytes to set
+ *
+ * Set a range of I/O memory to a given value.
+ */
+static inline void memset_io(volatile void __iomem *addr, int value,
+ size_t size)
+{
+ memset(__io_virt(addr), value, size);
+}
+#endif
+
+#ifndef memcpy_fromio
+#define memcpy_fromio memcpy_fromio
+/**
+ * memcpy_fromio Copy a block of data from I/O memory
+ * @dst: The (RAM) destination for the copy
+ * @src: The (I/O memory) source for the data
+ * @count: The number of bytes to copy
+ *
+ * Copy a block of data from I/O memory.
+ */
+static inline void memcpy_fromio(void *buffer,
+ const volatile void __iomem *addr,
+ size_t size)
+{
+ memcpy(buffer, __io_virt(addr), size);
+}
+#endif
+
+#ifndef memcpy_toio
+#define memcpy_toio memcpy_toio
+/**
+ * memcpy_toio Copy a block of data into I/O memory
+ * @dst: The (I/O memory) destination for the copy
+ * @src: The (RAM) source for the data
+ * @count: The number of bytes to copy
+ *
+ * Copy a block of data to I/O memory.
+ */
+static inline void memcpy_toio(volatile void __iomem *addr, const void *buffer,
+ size_t size)
+{
+ memcpy(__io_virt(addr), buffer, size);
+}
+#endif
+
#endif /* __ASM_GENERIC_IO_H */