From: T Karthik Reddy <t.karthik.re...@xilinx.com>

Add read/write memory utilities for 16 and 32 bits. Add these
api's for both little and big endian systems similar to arm
architecture.

Signed-off-by: T Karthik Reddy <t.karthik.re...@xilinx.com>
Signed-off-by: Ashok Reddy Soma <ashok.reddy.s...@xilinx.com>
Signed-off-by: Michal Simek <michal.si...@xilinx.com>
---

 arch/microblaze/include/asm/io.h | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/arch/microblaze/include/asm/io.h b/arch/microblaze/include/asm/io.h
index 8e6be0ae267f..632bb236fbbe 100644
--- a/arch/microblaze/include/asm/io.h
+++ b/arch/microblaze/include/asm/io.h
@@ -50,14 +50,24 @@
 #define outw(x, addr)  ((void)writew(x, addr))
 #define outl(x, addr)  ((void)writel(x, addr))
 
-/* Some #definitions to keep strange Xilinx code happy */
-#define in_8(addr)     readb(addr)
-#define in_be16(addr)  readw(addr)
-#define in_be32(addr)  readl(addr)
+#define out_arch(type, endian, addr, x)        \
+                __raw_write##type(cpu_to_##endian(x), addr)
+#define in_arch(type, endian, addr)    \
+               endian##_to_cpu(__raw_read##type(addr))
+
+#define out_le16(addr, x)      out_arch(w, le16, addr, x)
+#define out_le32(addr, x)      out_arch(l, le32, addr, x)
+
+#define in_le16(addr)          in_arch(w, le16, addr)
+#define in_le32(addr)          in_arch(l, le32, addr)
+
+#define in_8(addr)             readb(addr)
+#define in_be16(addr)          in_arch(w, be16, addr)
+#define in_be32(addr)          in_arch(l, be32, addr)
 
 #define out_8(addr, x)         outb(x, addr)
-#define out_be16(addr, x)      outw(x, addr)
-#define out_be32(addr, x)      outl(x, addr)
+#define out_be16(addr, x)      out_arch(w, be16, addr, x)
+#define out_be32(addr, x)      out_arch(l, be32, addr, x)
 
 #define inb_p(port)            inb((port))
 #define outb_p(val, port)      outb((val), (port))
-- 
2.28.0

Reply via email to