diff mbox series

microblaze: Add support for little/big endian in/out api's

Message ID 71ba8a45e37f56664f2d8911c92432b5d95104a1.1598529276.git.michal.simek@xilinx.com
State Accepted
Commit 78d844c6ac5fcbedc7f8fbe64db3ea3ad9961ebd
Delegated to: Michal Simek
Headers show
Series microblaze: Add support for little/big endian in/out api's | expand

Commit Message

Michal Simek Aug. 27, 2020, 11:54 a.m. UTC
From: T Karthik Reddy <t.karthik.reddy@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.reddy@xilinx.com>
Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

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

Comments

Michal Simek Sept. 23, 2020, 12:04 p.m. UTC | #1
čt 27. 8. 2020 v 13:54 odesílatel Michal Simek <michal.simek@xilinx.com> napsal:
>
> From: T Karthik Reddy <t.karthik.reddy@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.reddy@xilinx.com>
> Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@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
>

Applied.
M
diff mbox series

Patch

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))