20 #include <linux/types.h>
21 #include <asm/virtconvert.h>
22 #include <asm/string.h>
31 static inline unsigned short _swapw(
unsigned short v)
33 return ((v << 8) | (v >> 8));
36 static inline unsigned long _swapl(
unsigned long v)
38 return ((v << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8) | (v >> 24));
44 #define __raw_readb __builtin_read8
45 #define __raw_readw __builtin_read16
46 #define __raw_readl __builtin_read32
48 #define __raw_writeb(datum, addr) __builtin_write8(addr, datum)
49 #define __raw_writew(datum, addr) __builtin_write16(addr, datum)
50 #define __raw_writel(datum, addr) __builtin_write32(addr, datum)
52 static inline void io_outsb(
unsigned int addr,
const void *
buf,
int len)
61 static inline void io_outsw(
unsigned int addr,
const void *buf,
int len)
63 unsigned long __ioaddr = (
unsigned long) addr;
70 extern void __outsl_ns(
unsigned int addr,
const void *buf,
int len);
71 extern void __outsl_sw(
unsigned int addr,
const void *buf,
int len);
72 static inline void __outsl(
unsigned int addr,
const void *buf,
int len,
int swap)
74 unsigned long __ioaddr = (
unsigned long) addr;
77 __outsl_ns(__ioaddr, buf, len);
79 __outsl_sw(__ioaddr, buf, len);
82 static inline void io_insb(
unsigned long addr,
void *buf,
int len)
90 static inline void io_insw(
unsigned long addr,
void *buf,
int len)
98 extern void __insl_ns(
unsigned long addr,
void *buf,
int len);
99 extern void __insl_sw(
unsigned long addr,
void *buf,
int len);
100 static inline void __insl(
unsigned long addr,
void *buf,
int len,
int swap)
103 __insl_ns(addr, buf, len);
105 __insl_sw(addr, buf, len);
108 #define mmiowb() mb()
125 static inline void memcpy_toio(
volatile void __iomem *dst,
const void *src,
int count)
155 static inline void outb(
uint8_t datum,
unsigned long addr)
160 static inline void outw(
uint16_t datum,
unsigned long addr)
163 datum = _swapw(datum);
167 static inline void outl(
uint32_t datum,
unsigned long addr)
170 datum = _swapl(datum);
174 #define inb_p(addr) inb(addr)
175 #define inw_p(addr) inw(addr)
176 #define inl_p(addr) inl(addr)
177 #define outb_p(x,addr) outb(x,addr)
178 #define outw_p(x,addr) outw(x,addr)
179 #define outl_p(x,addr) outl(x,addr)
181 #define outsb(a,b,l) io_outsb(a,b,l)
182 #define outsw(a,b,l) io_outsw(a,b,l)
183 #define outsl(a,b,l) __outsl(a,b,l,0)
185 #define insb(a,b,l) io_insb(a,b,l)
186 #define insw(a,b,l) io_insw(a,b,l)
187 #define insl(a,b,l) __insl(a,b,l,0)
189 #define IO_SPACE_LIMIT 0xffffffff
215 #define readb_relaxed readb
216 #define readw_relaxed readw
217 #define readl_relaxed readl
229 datum = _swapw(datum);
239 datum = _swapl(datum);
248 #define IOMAP_FULL_CACHING 0
249 #define IOMAP_NOCACHE_SER 1
250 #define IOMAP_NOCACHE_NONSER 2
251 #define IOMAP_WRITETHROUGH 3
257 return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
262 return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
267 return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
272 return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
275 #define ioremap_wc ioremap_nocache
288 static inline void flush_write_buffers(
void)
290 __asm__ __volatile__ (
"membar" : : :
"memory");
344 io_insb((
unsigned long) p, dst, count);
349 io_insw((
unsigned long) p, dst, count);
354 __insl_ns((
unsigned long) p, dst, count);
359 io_outsb((
unsigned long) p, src, count);
364 io_outsw((
unsigned long) p, src, count);
369 __outsl_ns((
unsigned long) p, src, count);
383 #define xlate_dev_mem_ptr(p) __va(p)
388 #define xlate_dev_kmem_ptr(p) p