All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC v2] sh: Use big endian ioread/write for SH2 platforms
@ 2011-10-12  8:03 Phil Edworthy
  2011-10-14  3:33 ` Yoshinori Sato
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Edworthy @ 2011-10-12  8:03 UTC (permalink / raw)
  To: linux-sh

Commit 37b7a97884ba64bf7d403351ac2a9476ab4f1bba makes all ioread/iowrite
functions treat registers as little endian. For SH2 this is not the case,
they are big endian.

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
---
v2: Modified so that it's used on all SH2 devices

 arch/sh/include/asm/io.h |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
index 28c5aa5..65f2d5a 100644
--- a/arch/sh/include/asm/io.h
+++ b/arch/sh/include/asm/io.h
@@ -35,6 +35,7 @@
 #define __raw_readl(a)		(__chk_io_ptr(a), *(volatile u32 __force *)(a))
 #define __raw_readq(a)		(__chk_io_ptr(a), *(volatile u64 __force *)(a))
 
+#ifndef CONFIG_CPU_SH2
 #define readb_relaxed(c)	({ u8  __v = __raw_readb(c); __v; })
 #define readw_relaxed(c)	({ u16 __v = le16_to_cpu((__force __le16) \
 					__raw_readw(c)); __v; })
@@ -50,6 +51,23 @@
 					cpu_to_le32(v),c))
 #define writeq_relaxed(v,c)	((void)__raw_writeq((__force u64) \
 					cpu_to_le64(v),c))
+#else
+#define readb_relaxed(c)	({ u8  __v = __raw_readb(c); __v; })
+#define readw_relaxed(c)	({ u16 __v = be16_to_cpu((__force __be16) \
+					__raw_readw(c)); __v; })
+#define readl_relaxed(c)	({ u32 __v = be32_to_cpu((__force __be32) \
+					__raw_readl(c)); __v; })
+#define readq_relaxed(c)	({ u64 __v = be64_to_cpu((__force __be64) \
+					__raw_readq(c)); __v; })
+
+#define writeb_relaxed(v,c)	((void)__raw_writeb(v,c))
+#define writew_relaxed(v,c)	((void)__raw_writew((__force u16) \
+					cpu_to_be16(v),c))
+#define writel_relaxed(v,c)	((void)__raw_writel((__force u32) \
+					cpu_to_be32(v),c))
+#define writeq_relaxed(v,c)	((void)__raw_writeq((__force u64) \
+					cpu_to_be64(v),c))
+#endif
 
 #define readb(a)		({ u8  r_ = readb_relaxed(a); rmb(); r_; })
 #define readw(a)		({ u16 r_ = readw_relaxed(a); rmb(); r_; })
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH/RFC v2] sh: Use big endian ioread/write for SH2 platforms
  2011-10-12  8:03 [PATCH/RFC v2] sh: Use big endian ioread/write for SH2 platforms Phil Edworthy
@ 2011-10-14  3:33 ` Yoshinori Sato
  0 siblings, 0 replies; 2+ messages in thread
From: Yoshinori Sato @ 2011-10-14  3:33 UTC (permalink / raw)
  To: linux-sh

At Wed, 12 Oct 2011 09:03:24 +0100,
Phil Edworthy wrote:
> 
> Commit 37b7a97884ba64bf7d403351ac2a9476ab4f1bba makes all ioread/iowrite
> functions treat registers as little endian. For SH2 this is not the case,
> they are big endian.
> 
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
Looks good.
Thanks.

> ---
> v2: Modified so that it's used on all SH2 devices
> 
>  arch/sh/include/asm/io.h |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
> index 28c5aa5..65f2d5a 100644
> --- a/arch/sh/include/asm/io.h
> +++ b/arch/sh/include/asm/io.h
> @@ -35,6 +35,7 @@
>  #define __raw_readl(a)		(__chk_io_ptr(a), *(volatile u32 __force *)(a))
>  #define __raw_readq(a)		(__chk_io_ptr(a), *(volatile u64 __force *)(a))
>  
> +#ifndef CONFIG_CPU_SH2
>  #define readb_relaxed(c)	({ u8  __v = __raw_readb(c); __v; })
>  #define readw_relaxed(c)	({ u16 __v = le16_to_cpu((__force __le16) \
>  					__raw_readw(c)); __v; })
> @@ -50,6 +51,23 @@
>  					cpu_to_le32(v),c))
>  #define writeq_relaxed(v,c)	((void)__raw_writeq((__force u64) \
>  					cpu_to_le64(v),c))
> +#else
> +#define readb_relaxed(c)	({ u8  __v = __raw_readb(c); __v; })
> +#define readw_relaxed(c)	({ u16 __v = be16_to_cpu((__force __be16) \
> +					__raw_readw(c)); __v; })
> +#define readl_relaxed(c)	({ u32 __v = be32_to_cpu((__force __be32) \
> +					__raw_readl(c)); __v; })
> +#define readq_relaxed(c)	({ u64 __v = be64_to_cpu((__force __be64) \
> +					__raw_readq(c)); __v; })
> +
> +#define writeb_relaxed(v,c)	((void)__raw_writeb(v,c))
> +#define writew_relaxed(v,c)	((void)__raw_writew((__force u16) \
> +					cpu_to_be16(v),c))
> +#define writel_relaxed(v,c)	((void)__raw_writel((__force u32) \
> +					cpu_to_be32(v),c))
> +#define writeq_relaxed(v,c)	((void)__raw_writeq((__force u64) \
> +					cpu_to_be64(v),c))
> +#endif
>  
>  #define readb(a)		({ u8  r_ = readb_relaxed(a); rmb(); r_; })
>  #define readw(a)		({ u16 r_ = readw_relaxed(a); rmb(); r_; })
> -- 
> 1.7.0.4
> 

-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-14  3:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-12  8:03 [PATCH/RFC v2] sh: Use big endian ioread/write for SH2 platforms Phil Edworthy
2011-10-14  3:33 ` Yoshinori Sato

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.