13 #ifndef __ASM_ARM_ARCH_IO_H
14 #define __ASM_ARM_ARCH_IO_H
16 #include <linux/bitops.h>
18 #include <mach/hardware.h>
42 #ifdef CONFIG_IXP4XX_INDIRECT_PCI
51 static inline int is_pci_memory(
u32 addr)
56 #define writeb(v, p) __indirect_writeb(v, p)
57 #define writew(v, p) __indirect_writew(v, p)
58 #define writel(v, p) __indirect_writel(v, p)
60 #define writesb(p, v, l) __indirect_writesb(p, v, l)
61 #define writesw(p, v, l) __indirect_writesw(p, v, l)
62 #define writesl(p, v, l) __indirect_writesl(p, v, l)
64 #define readb(p) __indirect_readb(p)
65 #define readw(p) __indirect_readw(p)
66 #define readl(p) __indirect_readl(p)
68 #define readsb(p, v, l) __indirect_readsb(p, v, l)
69 #define readsw(p, v, l) __indirect_readsw(p, v, l)
70 #define readsl(p, v, l) __indirect_readsl(p, v, l)
72 static inline void __indirect_writeb(
u8 value,
volatile void __iomem *
p)
77 if (!is_pci_memory(addr)) {
84 data = value << (8*
n);
88 static inline void __indirect_writesb(
volatile void __iomem *bus_addr,
92 writeb(*vaddr++, bus_addr);
95 static inline void __indirect_writew(
u16 value,
volatile void __iomem *p)
100 if (!is_pci_memory(addr)) {
107 data = value << (8*
n);
111 static inline void __indirect_writesw(
volatile void __iomem *bus_addr,
112 const u16 *vaddr,
int count)
115 writew(*vaddr++, bus_addr);
118 static inline void __indirect_writel(
u32 value,
volatile void __iomem *p)
122 if (!is_pci_memory(addr)) {
130 static inline void __indirect_writesl(
volatile void __iomem *bus_addr,
131 const u32 *vaddr,
int count)
134 writel(*vaddr++, bus_addr);
137 static inline unsigned char __indirect_readb(
const volatile void __iomem *p)
142 if (!is_pci_memory(addr))
150 return data >> (8*
n);
153 static inline void __indirect_readsb(
const volatile void __iomem *bus_addr,
154 u8 *vaddr,
u32 count)
157 *vaddr++ =
readb(bus_addr);
160 static inline unsigned short __indirect_readw(
const volatile void __iomem *p)
165 if (!is_pci_memory(addr))
176 static inline void __indirect_readsw(
const volatile void __iomem *bus_addr,
180 *vaddr++ =
readw(bus_addr);
183 static inline unsigned long __indirect_readl(
const volatile void __iomem *p)
188 if (!is_pci_memory(addr))
197 static inline void __indirect_readsl(
const volatile void __iomem *bus_addr,
201 *vaddr++ =
readl(bus_addr);
208 #define memset_io(c,v,l) _memset_io((c),(v),(l))
209 #define memcpy_fromio(a,c,l) _memcpy_fromio((a),(c),(l))
210 #define memcpy_toio(c,a,l) _memcpy_toio((c),(a),(l))
216 #define __io(v) __typesafe_io(v)
228 static inline void outb(
u8 value,
u32 addr)
233 data = value << (8*
n);
240 outb(*vaddr++, io_addr);
248 data = value << (8*
n);
252 static inline void outsw(
u32 io_addr,
const u16 *vaddr,
u32 count)
263 static inline void outsl(
u32 io_addr,
const u32 *vaddr,
u32 count)
277 return data >> (8*
n);
280 static inline void insb(
u32 io_addr,
u8 *vaddr,
u32 count)
283 *vaddr++ =
inb(io_addr);
318 #define PIO_OFFSET 0x10000UL
319 #define PIO_MASK 0x0ffffUL
321 #define __is_io_address(p) (((unsigned long)p >= PIO_OFFSET) && \
322 ((unsigned long)p <= (PIO_MASK + PIO_OFFSET)))
324 #define ioread8(p) ioread8(p)
328 if (__is_io_address(port))
331 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
334 return (
unsigned int)__indirect_readb(addr);
338 #define ioread8_rep(p, v, c) ioread8_rep(p, v, c)
341 unsigned long port = (
unsigned long __force)addr;
342 if (__is_io_address(port))
345 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
348 __indirect_readsb(addr, vaddr, count);
352 #define ioread16(p) ioread16(p)
355 unsigned long port = (
unsigned long __force)addr;
356 if (__is_io_address(port))
359 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
362 return (
unsigned int)__indirect_readw(addr);
366 #define ioread16_rep(p, v, c) ioread16_rep(p, v, c)
370 unsigned long port = (
unsigned long __force)addr;
371 if (__is_io_address(port))
374 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
377 __indirect_readsw(addr, vaddr, count);
381 #define ioread32(p) ioread32(p)
384 unsigned long port = (
unsigned long __force)addr;
385 if (__is_io_address(port))
388 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
391 return (
unsigned int)__indirect_readl(addr);
396 #define ioread32_rep(p, v, c) ioread32_rep(p, v, c)
400 unsigned long port = (
unsigned long __force)addr;
401 if (__is_io_address(port))
404 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
407 __indirect_readsl(addr, vaddr, count);
411 #define iowrite8(v, p) iowrite8(v, p)
414 unsigned long port = (
unsigned long __force)addr;
415 if (__is_io_address(port))
418 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
421 __indirect_writeb(value, addr);
425 #define iowrite8_rep(p, v, c) iowrite8_rep(p, v, c)
429 unsigned long port = (
unsigned long __force)addr;
430 if (__is_io_address(port))
433 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
436 __indirect_writesb(addr, vaddr, count);
440 #define iowrite16(v, p) iowrite16(v, p)
443 unsigned long port = (
unsigned long __force)addr;
444 if (__is_io_address(port))
447 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
450 __indirect_writew(value, addr);
454 #define iowrite16_rep(p, v, c) iowrite16_rep(p, v, c)
458 unsigned long port = (
unsigned long __force)addr;
459 if (__is_io_address(port))
460 outsw(port & PIO_MASK, vaddr, count);
462 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
465 __indirect_writesw(addr, vaddr, count);
469 #define iowrite32(v, p) iowrite32(v, p)
472 unsigned long port = (
unsigned long __force)addr;
473 if (__is_io_address(port))
474 outl(value, port & PIO_MASK);
476 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
479 __indirect_writel(value, addr);
483 #define iowrite32_rep(p, v, c) iowrite32_rep(p, v, c)
487 unsigned long port = (
unsigned long __force)addr;
488 if (__is_io_address(port))
489 outsl(port & PIO_MASK, vaddr, count);
491 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
494 __indirect_writesl(addr, vaddr, count);
498 #define ioport_map(port, nr) ((void __iomem*)(port + PIO_OFFSET))
499 #define ioport_unmap(addr)