[ARM] 4714/2: Headers for IXP4xx built-in Ethernet and WAN drivers
[safe/jmp/linux-2.6] / include / asm-arm / arch-ixp4xx / io.h
index 80d05ec..de181ce 100644 (file)
 #ifndef __ASM_ARM_ARCH_IO_H
 #define __ASM_ARM_ARCH_IO_H
 
+#include <linux/bitops.h>
+
 #include <asm/hardware.h>
 
 #define IO_SPACE_LIMIT 0xffff0000
 
-#define        BIT(x)  ((1)<<(x))
-
-
 extern int (*ixp4xx_pci_read)(u32 addr, u32 cmd, u32* data);
 extern int ixp4xx_pci_write(u32 addr, u32 cmd, u32 data);
 
@@ -38,7 +37,7 @@ extern int ixp4xx_pci_write(u32 addr, u32 cmd, u32 data);
  * 2) If > 64MB of memory space is required, the IXP4xx can be configured
  *    to use indirect registers to access PCI (as we do below for I/O
  *    transactions). This allows for up to 128MB (0x48000000 to 0x4fffffff)
- *    of memory on the bus. The disadvantadge of this is that every 
+ *    of memory on the bus. The disadvantage of this is that every 
  *    PCI access requires three local register accesses plus a spinlock,
  *    but in some cases the performance hit is acceptable. In addition,
  *    you cannot mmap() PCI devices in this case.
@@ -59,30 +58,27 @@ extern int ixp4xx_pci_write(u32 addr, u32 cmd, u32 data);
  * fallback to the default.
  */
 static inline void __iomem *
-__ixp4xx_ioremap(unsigned long addr, size_t size, unsigned long flags, unsigned long align)
+__ixp4xx_ioremap(unsigned long addr, size_t size, unsigned int mtype)
 {
-       extern void __iomem * __ioremap(unsigned long, size_t, unsigned long, unsigned long);
-       if((addr < 0x48000000) || (addr > 0x4fffffff))
-               return __ioremap(addr, size, flags, align);
+       if((addr < PCIBIOS_MIN_MEM) || (addr > 0x4fffffff))
+               return __arm_ioremap(addr, size, mtype);
 
-       return (void *)addr;
+       return (void __iomem *)addr;
 }
 
 static inline void
 __ixp4xx_iounmap(void __iomem *addr)
 {
-       extern void __iounmap(void __iomem *addr);
-
-       if ((u32)addr >= VMALLOC_START)
+       if ((__force u32)addr >= VMALLOC_START)
                __iounmap(addr);
 }
 
-#define __arch_ioremap(a, s, f, x)     __ixp4xx_ioremap(a, s, f, x)
+#define __arch_ioremap(a, s, f)                __ixp4xx_ioremap(a, s, f)
 #define        __arch_iounmap(a)               __ixp4xx_iounmap(a)
 
-#define        writeb(p, v)                    __ixp4xx_writeb(p, v)
-#define        writew(p, v)                    __ixp4xx_writew(p, v)
-#define        writel(p, v)                    __ixp4xx_writel(p, v)
+#define        writeb(v, p)                    __ixp4xx_writeb(v, p)
+#define        writew(v, p)                    __ixp4xx_writew(v, p)
+#define        writel(v, p)                    __ixp4xx_writel(v, p)
 
 #define        writesb(p, v, l)                __ixp4xx_writesb(p, v, l)
 #define        writesw(p, v, l)                __ixp4xx_writesw(p, v, l)
@@ -97,8 +93,9 @@ __ixp4xx_iounmap(void __iomem *addr)
 #define        readsl(p, v, l)                 __ixp4xx_readsl(p, v, l)
 
 static inline void 
-__ixp4xx_writeb(u8 value, u32 addr)
+__ixp4xx_writeb(u8 value, volatile void __iomem *p)
 {
+       u32 addr = (u32)p;
        u32 n, byte_enables, data;
 
        if (addr >= VMALLOC_START) {
@@ -113,15 +110,16 @@ __ixp4xx_writeb(u8 value, u32 addr)
 }
 
 static inline void
-__ixp4xx_writesb(u32 bus_addr, const u8 *vaddr, int count)
+__ixp4xx_writesb(volatile void __iomem *bus_addr, const u8 *vaddr, int count)
 {
        while (count--)
                writeb(*vaddr++, bus_addr);
 }
 
 static inline void 
-__ixp4xx_writew(u16 value, u32 addr)
+__ixp4xx_writew(u16 value, volatile void __iomem *p)
 {
+       u32 addr = (u32)p;
        u32 n, byte_enables, data;
 
        if (addr >= VMALLOC_START) {
@@ -136,17 +134,18 @@ __ixp4xx_writew(u16 value, u32 addr)
 }
 
 static inline void
-__ixp4xx_writesw(u32 bus_addr, const u16 *vaddr, int count)
+__ixp4xx_writesw(volatile void __iomem *bus_addr, const u16 *vaddr, int count)
 {
        while (count--)
                writew(*vaddr++, bus_addr);
 }
 
 static inline void 
-__ixp4xx_writel(u32 value, u32 addr)
+__ixp4xx_writel(u32 value, volatile void __iomem *p)
 {
+       u32 addr = (__force u32)p;
        if (addr >= VMALLOC_START) {
-               __raw_writel(value, addr);
+               __raw_writel(value, p);
                return;
        }
 
@@ -154,15 +153,16 @@ __ixp4xx_writel(u32 value, u32 addr)
 }
 
 static inline void
-__ixp4xx_writesl(u32 bus_addr, const u32 *vaddr, int count)
+__ixp4xx_writesl(volatile void __iomem *bus_addr, const u32 *vaddr, int count)
 {
        while (count--)
                writel(*vaddr++, bus_addr);
 }
 
 static inline unsigned char 
-__ixp4xx_readb(u32 addr)
+__ixp4xx_readb(const volatile void __iomem *p)
 {
+       u32 addr = (u32)p;
        u32 n, byte_enables, data;
 
        if (addr >= VMALLOC_START)
@@ -177,15 +177,16 @@ __ixp4xx_readb(u32 addr)
 }
 
 static inline void
-__ixp4xx_readsb(u32 bus_addr, u8 *vaddr, u32 count)
+__ixp4xx_readsb(const volatile void __iomem *bus_addr, u8 *vaddr, u32 count)
 {
        while (count--)
                *vaddr++ = readb(bus_addr);
 }
 
 static inline unsigned short 
-__ixp4xx_readw(u32 addr)
+__ixp4xx_readw(const volatile void __iomem *p)
 {
+       u32 addr = (u32)p;
        u32 n, byte_enables, data;
 
        if (addr >= VMALLOC_START)
@@ -200,19 +201,20 @@ __ixp4xx_readw(u32 addr)
 }
 
 static inline void 
-__ixp4xx_readsw(u32 bus_addr, u16 *vaddr, u32 count)
+__ixp4xx_readsw(const volatile void __iomem *bus_addr, u16 *vaddr, u32 count)
 {
        while (count--)
                *vaddr++ = readw(bus_addr);
 }
 
 static inline unsigned long 
-__ixp4xx_readl(u32 addr)
+__ixp4xx_readl(const volatile void __iomem *p)
 {
+       u32 addr = (__force u32)p;
        u32 data;
 
        if (addr >= VMALLOC_START)
-               return __raw_readl(addr);
+               return __raw_readl(p);
 
        if (ixp4xx_pci_read(addr, NP_CMD_MEMREAD, &data))
                return 0xffffffff;
@@ -221,7 +223,7 @@ __ixp4xx_readl(u32 addr)
 }
 
 static inline void 
-__ixp4xx_readsl(u32 bus_addr, u32 *vaddr, u32 count)
+__ixp4xx_readsl(const volatile void __iomem *bus_addr, u32 *vaddr, u32 count)
 {
        while (count--)
                *vaddr++ = readl(bus_addr);
@@ -235,27 +237,13 @@ __ixp4xx_readsl(u32 bus_addr, u32 *vaddr, u32 count)
 #define memcpy_fromio(a,c,l)           _memcpy_fromio((a),(c),(l))
 #define memcpy_toio(c,a,l)             _memcpy_toio((c),(a),(l))
 
-#define eth_io_copy_and_sum(s,c,l,b) \
-                               eth_copy_and_sum((s),__mem_pci(c),(l),(b))
+#endif
+
+#ifndef CONFIG_PCI
 
-static inline int
-check_signature(unsigned long bus_addr, const unsigned char *signature,
-               int length)
-{
-       int retval = 0;
-       do {
-               if (readb(bus_addr) != *signature)
-                       goto out;
-               bus_addr++;
-               signature++;
-               length--;
-       } while (length);
-       retval = 1;
-out:
-       return retval;
-}
+#define        __io(v)         v
 
-#endif
+#else
 
 /*
  * IXP4xx does not have a transparent cpu -> PCI I/O translation
@@ -389,7 +377,7 @@ __ixp4xx_insl(u32 io_addr, u32 *vaddr, u32 count)
 #define        __is_io_address(p)      (((unsigned long)p >= PIO_OFFSET) && \
                                        ((unsigned long)p <= (PIO_MASK + PIO_OFFSET)))
 static inline unsigned int
-__ixp4xx_ioread8(void __iomem *addr)
+__ixp4xx_ioread8(const void __iomem *addr)
 {
        unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
@@ -398,12 +386,12 @@ __ixp4xx_ioread8(void __iomem *addr)
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
                return (unsigned int)__raw_readb(port);
 #else
-               return (unsigned int)__ixp4xx_readb(port);
+               return (unsigned int)__ixp4xx_readb(addr);
 #endif
 }
 
 static inline void
-__ixp4xx_ioread8_rep(void __iomem *addr, void *vaddr, u32 count)
+__ixp4xx_ioread8_rep(const void __iomem *addr, void *vaddr, u32 count)
 {
        unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
@@ -412,12 +400,12 @@ __ixp4xx_ioread8_rep(void __iomem *addr, void *vaddr, u32 count)
 #ifndef        CONFIG_IXP4XX_INDIRECT_PCI
                __raw_readsb(addr, vaddr, count);
 #else
-               __ixp4xx_readsb(port, vaddr, count);
+               __ixp4xx_readsb(addr, vaddr, count);
 #endif
 }
 
 static inline unsigned int
-__ixp4xx_ioread16(void __iomem *addr)
+__ixp4xx_ioread16(const void __iomem *addr)
 {
        unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
@@ -426,12 +414,12 @@ __ixp4xx_ioread16(void __iomem *addr)
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
                return le16_to_cpu(__raw_readw((u32)port));
 #else
-               return (unsigned int)__ixp4xx_readw((u32)port);
+               return (unsigned int)__ixp4xx_readw(addr);
 #endif
 }
 
 static inline void
-__ixp4xx_ioread16_rep(void __iomem *addr, void *vaddr, u32 count)
+__ixp4xx_ioread16_rep(const void __iomem *addr, void *vaddr, u32 count)
 {
        unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
@@ -440,27 +428,27 @@ __ixp4xx_ioread16_rep(void __iomem *addr, void *vaddr, u32 count)
 #ifndef        CONFIG_IXP4XX_INDIRECT_PCI
                __raw_readsw(addr, vaddr, count);
 #else
-               __ixp4xx_readsw(port, vaddr, count);
+               __ixp4xx_readsw(addr, vaddr, count);
 #endif
 }
 
 static inline unsigned int
-__ixp4xx_ioread32(void __iomem *addr)
+__ixp4xx_ioread32(const void __iomem *addr)
 {
        unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
                return  (unsigned int)__ixp4xx_inl(port & PIO_MASK);
        else {
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
-               return le32_to_cpu(__raw_readl((u32)port));
+               return le32_to_cpu((__force __le32)__raw_readl(addr));
 #else
-               return (unsigned int)__ixp4xx_readl((u32)port);
+               return (unsigned int)__ixp4xx_readl(addr);
 #endif
        }
 }
 
 static inline void
-__ixp4xx_ioread32_rep(void __iomem *addr, void *vaddr, u32 count)
+__ixp4xx_ioread32_rep(const void __iomem *addr, void *vaddr, u32 count)
 {
        unsigned long port = (unsigned long __force)addr;
        if (__is_io_address(port))
@@ -469,7 +457,7 @@ __ixp4xx_ioread32_rep(void __iomem *addr, void *vaddr, u32 count)
 #ifndef        CONFIG_IXP4XX_INDIRECT_PCI
                __raw_readsl(addr, vaddr, count);
 #else
-               __ixp4xx_readsl(port, vaddr, count);
+               __ixp4xx_readsl(addr, vaddr, count);
 #endif
 }
 
@@ -483,7 +471,7 @@ __ixp4xx_iowrite8(u8 value, void __iomem *addr)
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
                __raw_writeb(value, port);
 #else
-               __ixp4xx_writeb(value, port);
+               __ixp4xx_writeb(value, addr);
 #endif
 }
 
@@ -497,7 +485,7 @@ __ixp4xx_iowrite8_rep(void __iomem *addr, const void *vaddr, u32 count)
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
                __raw_writesb(addr, vaddr, count);
 #else
-               __ixp4xx_writesb(port, vaddr, count);
+               __ixp4xx_writesb(addr, vaddr, count);
 #endif
 }
 
@@ -511,7 +499,7 @@ __ixp4xx_iowrite16(u16 value, void __iomem *addr)
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
                __raw_writew(cpu_to_le16(value), addr);
 #else
-               __ixp4xx_writew(value, port);
+               __ixp4xx_writew(value, addr);
 #endif
 }
 
@@ -525,7 +513,7 @@ __ixp4xx_iowrite16_rep(void __iomem *addr, const void *vaddr, u32 count)
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
                __raw_writesw(addr, vaddr, count);
 #else
-               __ixp4xx_writesw(port, vaddr, count);
+               __ixp4xx_writesw(addr, vaddr, count);
 #endif
 }
 
@@ -537,9 +525,9 @@ __ixp4xx_iowrite32(u32 value, void __iomem *addr)
                __ixp4xx_outl(value, port & PIO_MASK);
        else
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
-               __raw_writel(cpu_to_le32(value), port);
+               __raw_writel((u32 __force)cpu_to_le32(value), addr);
 #else
-               __ixp4xx_writel(value, port);
+               __ixp4xx_writel(value, addr);
 #endif
 }
 
@@ -553,7 +541,7 @@ __ixp4xx_iowrite32_rep(void __iomem *addr, const void *vaddr, u32 count)
 #ifndef CONFIG_IXP4XX_INDIRECT_PCI
                __raw_writesl(addr, vaddr, count);
 #else
-               __ixp4xx_writesl(port, vaddr, count);
+               __ixp4xx_writesl(addr, vaddr, count);
 #endif
 }
 
@@ -575,6 +563,7 @@ __ixp4xx_iowrite32_rep(void __iomem *addr, const void *vaddr, u32 count)
 
 #define        ioport_map(port, nr)            ((void __iomem*)(port + PIO_OFFSET))
 #define        ioport_unmap(addr)
+#endif // !CONFIG_PCI
 
 #endif //  __ASM_ARM_ARCH_IO_H