aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic/io.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-generic/io.h')
-rw-r--r--include/asm-generic/io.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index bcee6365dca0..4644c9a7f724 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -19,7 +19,9 @@
19#include <asm-generic/iomap.h> 19#include <asm-generic/iomap.h>
20#endif 20#endif
21 21
22#ifndef mmiowb
22#define mmiowb() do {} while (0) 23#define mmiowb() do {} while (0)
24#endif
23 25
24/*****************************************************************************/ 26/*****************************************************************************/
25/* 27/*
@@ -28,39 +30,51 @@
28 * differently. On the simple architectures, we just read/write the 30 * differently. On the simple architectures, we just read/write the
29 * memory location directly. 31 * memory location directly.
30 */ 32 */
33#ifndef __raw_readb
31static inline u8 __raw_readb(const volatile void __iomem *addr) 34static inline u8 __raw_readb(const volatile void __iomem *addr)
32{ 35{
33 return *(const volatile u8 __force *) addr; 36 return *(const volatile u8 __force *) addr;
34} 37}
38#endif
35 39
40#ifndef __raw_readw
36static inline u16 __raw_readw(const volatile void __iomem *addr) 41static inline u16 __raw_readw(const volatile void __iomem *addr)
37{ 42{
38 return *(const volatile u16 __force *) addr; 43 return *(const volatile u16 __force *) addr;
39} 44}
45#endif
40 46
47#ifndef __raw_readl
41static inline u32 __raw_readl(const volatile void __iomem *addr) 48static inline u32 __raw_readl(const volatile void __iomem *addr)
42{ 49{
43 return *(const volatile u32 __force *) addr; 50 return *(const volatile u32 __force *) addr;
44} 51}
52#endif
45 53
46#define readb __raw_readb 54#define readb __raw_readb
47#define readw(addr) __le16_to_cpu(__raw_readw(addr)) 55#define readw(addr) __le16_to_cpu(__raw_readw(addr))
48#define readl(addr) __le32_to_cpu(__raw_readl(addr)) 56#define readl(addr) __le32_to_cpu(__raw_readl(addr))
49 57
58#ifndef __raw_writeb
50static inline void __raw_writeb(u8 b, volatile void __iomem *addr) 59static inline void __raw_writeb(u8 b, volatile void __iomem *addr)
51{ 60{
52 *(volatile u8 __force *) addr = b; 61 *(volatile u8 __force *) addr = b;
53} 62}
63#endif
54 64
65#ifndef __raw_writew
55static inline void __raw_writew(u16 b, volatile void __iomem *addr) 66static inline void __raw_writew(u16 b, volatile void __iomem *addr)
56{ 67{
57 *(volatile u16 __force *) addr = b; 68 *(volatile u16 __force *) addr = b;
58} 69}
70#endif
59 71
72#ifndef __raw_writel
60static inline void __raw_writel(u32 b, volatile void __iomem *addr) 73static inline void __raw_writel(u32 b, volatile void __iomem *addr)
61{ 74{
62 *(volatile u32 __force *) addr = b; 75 *(volatile u32 __force *) addr = b;
63} 76}
77#endif
64 78
65#define writeb __raw_writeb 79#define writeb __raw_writeb
66#define writew(b,addr) __raw_writew(__cpu_to_le16(b),addr) 80#define writew(b,addr) __raw_writew(__cpu_to_le16(b),addr)
@@ -122,6 +136,7 @@ static inline void outl(u32 b, unsigned long addr)
122#define outw_p(x, addr) outw((x), (addr)) 136#define outw_p(x, addr) outw((x), (addr))
123#define outl_p(x, addr) outl((x), (addr)) 137#define outl_p(x, addr) outl((x), (addr))
124 138
139#ifndef insb
125static inline void insb(unsigned long addr, void *buffer, int count) 140static inline void insb(unsigned long addr, void *buffer, int count)
126{ 141{
127 if (count) { 142 if (count) {
@@ -132,7 +147,9 @@ static inline void insb(unsigned long addr, void *buffer, int count)
132 } while (--count); 147 } while (--count);
133 } 148 }
134} 149}
150#endif
135 151
152#ifndef insw
136static inline void insw(unsigned long addr, void *buffer, int count) 153static inline void insw(unsigned long addr, void *buffer, int count)
137{ 154{
138 if (count) { 155 if (count) {
@@ -143,7 +160,9 @@ static inline void insw(unsigned long addr, void *buffer, int count)
143 } while (--count); 160 } while (--count);
144 } 161 }
145} 162}
163#endif
146 164
165#ifndef insl
147static inline void insl(unsigned long addr, void *buffer, int count) 166static inline void insl(unsigned long addr, void *buffer, int count)
148{ 167{
149 if (count) { 168 if (count) {
@@ -154,7 +173,9 @@ static inline void insl(unsigned long addr, void *buffer, int count)
154 } while (--count); 173 } while (--count);
155 } 174 }
156} 175}
176#endif
157 177
178#ifndef outsb
158static inline void outsb(unsigned long addr, const void *buffer, int count) 179static inline void outsb(unsigned long addr, const void *buffer, int count)
159{ 180{
160 if (count) { 181 if (count) {
@@ -164,7 +185,9 @@ static inline void outsb(unsigned long addr, const void *buffer, int count)
164 } while (--count); 185 } while (--count);
165 } 186 }
166} 187}
188#endif
167 189
190#ifndef outsw
168static inline void outsw(unsigned long addr, const void *buffer, int count) 191static inline void outsw(unsigned long addr, const void *buffer, int count)
169{ 192{
170 if (count) { 193 if (count) {
@@ -174,7 +197,9 @@ static inline void outsw(unsigned long addr, const void *buffer, int count)
174 } while (--count); 197 } while (--count);
175 } 198 }
176} 199}
200#endif
177 201
202#ifndef outsl
178static inline void outsl(unsigned long addr, const void *buffer, int count) 203static inline void outsl(unsigned long addr, const void *buffer, int count)
179{ 204{
180 if (count) { 205 if (count) {
@@ -184,15 +209,50 @@ static inline void outsl(unsigned long addr, const void *buffer, int count)
184 } while (--count); 209 } while (--count);
185 } 210 }
186} 211}
212#endif
213
214static inline void readsl(const void __iomem *addr, void *buf, int len)
215{
216 insl((unsigned long)addr, buf, len);
217}
218
219static inline void readsw(const void __iomem *addr, void *buf, int len)
220{
221 insw((unsigned long)addr, buf, len);
222}
223
224static inline void readsb(const void __iomem *addr, void *buf, int len)
225{
226 insb((unsigned long)addr, buf, len);
227}
228
229static inline void writesl(const void __iomem *addr, const void *buf, int len)
230{
231 outsl((unsigned long)addr, buf, len);
232}
233
234static inline void writesw(const void __iomem *addr, const void *buf, int len)
235{
236 outsw((unsigned long)addr, buf, len);
237}
238
239static inline void writesb(const void __iomem *addr, const void *buf, int len)
240{
241 outsb((unsigned long)addr, buf, len);
242}
187 243
188#ifndef CONFIG_GENERIC_IOMAP 244#ifndef CONFIG_GENERIC_IOMAP
189#define ioread8(addr) readb(addr) 245#define ioread8(addr) readb(addr)
190#define ioread16(addr) readw(addr) 246#define ioread16(addr) readw(addr)
247#define ioread16be(addr) be16_to_cpu(ioread16(addr))
191#define ioread32(addr) readl(addr) 248#define ioread32(addr) readl(addr)
249#define ioread32be(addr) be32_to_cpu(ioread32(addr))
192 250
193#define iowrite8(v, addr) writeb((v), (addr)) 251#define iowrite8(v, addr) writeb((v), (addr))
194#define iowrite16(v, addr) writew((v), (addr)) 252#define iowrite16(v, addr) writew((v), (addr))
253#define iowrite16be(v, addr) iowrite16(be16_to_cpu(v), (addr))
195#define iowrite32(v, addr) writel((v), (addr)) 254#define iowrite32(v, addr) writel((v), (addr))
255#define iowrite32be(v, addr) iowrite32(be32_to_cpu(v), (addr))
196 256
197#define ioread8_rep(p, dst, count) \ 257#define ioread8_rep(p, dst, count) \
198 insb((unsigned long) (p), (dst), (count)) 258 insb((unsigned long) (p), (dst), (count))