[PATCH] arm/io.h: add macros to read/write big/little endian register

Viresh Kumar viresh.kumar at st.com
Thu Feb 23 04:17:40 EST 2012


From: Pratyush Anand <pratyush.anand at st.com>

There are some peripheral (e.g dwc otg) whose registers can be configured to
work in either little or big endian mode. Therefore macros like out_be32,
in_be32, out_le32 and in_le32 have been added to support such peripherals.

Signed-off-by: Pratyush Anand <pratyush.anand at st.com>
Signed-off-by: Viresh Kumar <viresh.kumar at st.com>
---
 arch/arm/include/asm/io.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 9275828..a1ccac0 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -192,6 +192,16 @@ static inline void __iomem *__typesafe_io(unsigned long addr)
 #define insw_p(port,to,len)	insw(port,to,len)
 #define insl_p(port,to,len)	insl(port,to,len)
 
+/* Big Endian */
+#define out_be32(v, p)	({ __iowmb(); __raw_writel((__force __u32) \
+					cpu_to_be32(v), __io(p)); })
+#define in_be32(p)	({ __u32 __v = be32_to_cpu((__force __be32) \
+			__raw_readl(__io(p))); __iormb(); __v; })
+
+/* Little endian */
+#define out_le32(v, p)		outl(v, p)
+#define in_le32(p)		inl(p)
+
 /*
  * String version of IO memory access ops:
  */
-- 
1.7.8.110.g4cb5d




More information about the linux-arm-kernel mailing list