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.h64
1 files changed, 26 insertions, 38 deletions
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 448303bdb85..33bbbae4ddc 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -12,7 +12,6 @@
12#define __ASM_GENERIC_IO_H 12#define __ASM_GENERIC_IO_H
13 13
14#include <asm/page.h> /* I/O is all done through memory accesses */ 14#include <asm/page.h> /* I/O is all done through memory accesses */
15#include <asm/cacheflush.h>
16#include <linux/types.h> 15#include <linux/types.h>
17 16
18#ifdef CONFIG_GENERIC_IOMAP 17#ifdef CONFIG_GENERIC_IOMAP
@@ -83,19 +82,25 @@ static inline void __raw_writel(u32 b, volatile void __iomem *addr)
83#define writel(b,addr) __raw_writel(__cpu_to_le32(b),addr) 82#define writel(b,addr) __raw_writel(__cpu_to_le32(b),addr)
84 83
85#ifdef CONFIG_64BIT 84#ifdef CONFIG_64BIT
85#ifndef __raw_readq
86static inline u64 __raw_readq(const volatile void __iomem *addr) 86static inline u64 __raw_readq(const volatile void __iomem *addr)
87{ 87{
88 return *(const volatile u64 __force *) addr; 88 return *(const volatile u64 __force *) addr;
89} 89}
90#endif
91
90#define readq(addr) __le64_to_cpu(__raw_readq(addr)) 92#define readq(addr) __le64_to_cpu(__raw_readq(addr))
91 93
94#ifndef __raw_writeq
92static inline void __raw_writeq(u64 b, volatile void __iomem *addr) 95static inline void __raw_writeq(u64 b, volatile void __iomem *addr)
93{ 96{
94 *(volatile u64 __force *) addr = b; 97 *(volatile u64 __force *) addr = b;
95} 98}
96#define writeq(b,addr) __raw_writeq(__cpu_to_le64(b),addr)
97#endif 99#endif
98 100
101#define writeq(b, addr) __raw_writeq(__cpu_to_le64(b), addr)
102#endif /* CONFIG_64BIT */
103
99#ifndef PCI_IOBASE 104#ifndef PCI_IOBASE
100#define PCI_IOBASE ((void __iomem *) 0) 105#define PCI_IOBASE ((void __iomem *) 0)
101#endif 106#endif
@@ -148,7 +153,7 @@ static inline void insb(unsigned long addr, void *buffer, int count)
148 if (count) { 153 if (count) {
149 u8 *buf = buffer; 154 u8 *buf = buffer;
150 do { 155 do {
151 u8 x = inb(addr); 156 u8 x = __raw_readb(addr + PCI_IOBASE);
152 *buf++ = x; 157 *buf++ = x;
153 } while (--count); 158 } while (--count);
154 } 159 }
@@ -161,7 +166,7 @@ static inline void insw(unsigned long addr, void *buffer, int count)
161 if (count) { 166 if (count) {
162 u16 *buf = buffer; 167 u16 *buf = buffer;
163 do { 168 do {
164 u16 x = inw(addr); 169 u16 x = __raw_readw(addr + PCI_IOBASE);
165 *buf++ = x; 170 *buf++ = x;
166 } while (--count); 171 } while (--count);
167 } 172 }
@@ -174,7 +179,7 @@ static inline void insl(unsigned long addr, void *buffer, int count)
174 if (count) { 179 if (count) {
175 u32 *buf = buffer; 180 u32 *buf = buffer;
176 do { 181 do {
177 u32 x = inl(addr); 182 u32 x = __raw_readl(addr + PCI_IOBASE);
178 *buf++ = x; 183 *buf++ = x;
179 } while (--count); 184 } while (--count);
180 } 185 }
@@ -187,7 +192,7 @@ static inline void outsb(unsigned long addr, const void *buffer, int count)
187 if (count) { 192 if (count) {
188 const u8 *buf = buffer; 193 const u8 *buf = buffer;
189 do { 194 do {
190 outb(*buf++, addr); 195 __raw_writeb(*buf++, addr + PCI_IOBASE);
191 } while (--count); 196 } while (--count);
192 } 197 }
193} 198}
@@ -199,7 +204,7 @@ static inline void outsw(unsigned long addr, const void *buffer, int count)
199 if (count) { 204 if (count) {
200 const u16 *buf = buffer; 205 const u16 *buf = buffer;
201 do { 206 do {
202 outw(*buf++, addr); 207 __raw_writew(*buf++, addr + PCI_IOBASE);
203 } while (--count); 208 } while (--count);
204 } 209 }
205} 210}
@@ -211,42 +216,12 @@ static inline void outsl(unsigned long addr, const void *buffer, int count)
211 if (count) { 216 if (count) {
212 const u32 *buf = buffer; 217 const u32 *buf = buffer;
213 do { 218 do {
214 outl(*buf++, addr); 219 __raw_writel(*buf++, addr + PCI_IOBASE);
215 } while (--count); 220 } while (--count);
216 } 221 }
217} 222}
218#endif 223#endif
219 224
220static inline void readsl(const void __iomem *addr, void *buf, int len)
221{
222 insl(addr - PCI_IOBASE, buf, len);
223}
224
225static inline void readsw(const void __iomem *addr, void *buf, int len)
226{
227 insw(addr - PCI_IOBASE, buf, len);
228}
229
230static inline void readsb(const void __iomem *addr, void *buf, int len)
231{
232 insb(addr - PCI_IOBASE, buf, len);
233}
234
235static inline void writesl(const void __iomem *addr, const void *buf, int len)
236{
237 outsl(addr - PCI_IOBASE, buf, len);
238}
239
240static inline void writesw(const void __iomem *addr, const void *buf, int len)
241{
242 outsw(addr - PCI_IOBASE, buf, len);
243}
244
245static inline void writesb(const void __iomem *addr, const void *buf, int len)
246{
247 outsb(addr - PCI_IOBASE, buf, len);
248}
249
250#ifndef CONFIG_GENERIC_IOMAP 225#ifndef CONFIG_GENERIC_IOMAP
251#define ioread8(addr) readb(addr) 226#define ioread8(addr) readb(addr)
252#define ioread16(addr) readw(addr) 227#define ioread16(addr) readw(addr)
@@ -286,15 +261,20 @@ static inline void writesb(const void __iomem *addr, const void *buf, int len)
286 261
287#ifndef CONFIG_GENERIC_IOMAP 262#ifndef CONFIG_GENERIC_IOMAP
288struct pci_dev; 263struct pci_dev;
264extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
265
266#ifndef pci_iounmap
289static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p) 267static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
290{ 268{
291} 269}
270#endif
292#endif /* CONFIG_GENERIC_IOMAP */ 271#endif /* CONFIG_GENERIC_IOMAP */
293 272
294/* 273/*
295 * Change virtual addresses to physical addresses and vv. 274 * Change virtual addresses to physical addresses and vv.
296 * These are pretty trivial 275 * These are pretty trivial
297 */ 276 */
277#ifndef virt_to_phys
298static inline unsigned long virt_to_phys(volatile void *address) 278static inline unsigned long virt_to_phys(volatile void *address)
299{ 279{
300 return __pa((unsigned long)address); 280 return __pa((unsigned long)address);
@@ -304,6 +284,7 @@ static inline void *phys_to_virt(unsigned long address)
304{ 284{
305 return __va(address); 285 return __va(address);
306} 286}
287#endif
307 288
308/* 289/*
309 * Change "struct page" to physical address. 290 * Change "struct page" to physical address.
@@ -363,9 +344,16 @@ static inline void *bus_to_virt(unsigned long address)
363} 344}
364#endif 345#endif
365 346
347#ifndef memset_io
366#define memset_io(a, b, c) memset(__io_virt(a), (b), (c)) 348#define memset_io(a, b, c) memset(__io_virt(a), (b), (c))
349#endif
350
351#ifndef memcpy_fromio
367#define memcpy_fromio(a, b, c) memcpy((a), __io_virt(b), (c)) 352#define memcpy_fromio(a, b, c) memcpy((a), __io_virt(b), (c))
353#endif
354#ifndef memcpy_toio
368#define memcpy_toio(a, b, c) memcpy(__io_virt(a), (b), (c)) 355#define memcpy_toio(a, b, c) memcpy(__io_virt(a), (b), (c))
356#endif
369 357
370#endif /* __KERNEL__ */ 358#endif /* __KERNEL__ */
371 359