[PATCH] ARM: 2748/1: ixp2000 implementation of the iomap api
authorLennert Buytenhek <buytenh@wantstofly.org>
Fri, 24 Jun 2005 22:11:31 +0000 (23:11 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 24 Jun 2005 22:11:31 +0000 (23:11 +0100)
Patch from Lennert Buytenhek

A number of ixp2000 models have a bug where the byte lanes for PCI I/O
transactions are swapped.  We already work around this in our versions
of {in,out}{b,w,l}, but we also need to perform these workarounds in a
custom implementation of the new iomap API, provided in this patch.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Signed-off-by: Deepak Saxena
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
include/asm-arm/arch-ixp2000/io.h

index e5c742bc233039285abfa0be5d4450da2994c1a4..5e56b47446e0c4a2ba6e8fe9ea1d7a5dd3ed9e02 100644 (file)
 #define insw(p,d,l)            __raw_readsw(alignw(___io(p)),d,l)
 #define insl(p,d,l)            __raw_readsl(___io(p),d,l)
 
+#define __is_io_address(p)     ((((unsigned long)(p)) & ~(IXP2000_PCI_IO_SIZE - 1)) == IXP2000_PCI_IO_VIRT_BASE)
+
+#define ioread8(p)                                             \
+       ({                                                      \
+               unsigned int __v;                               \
+                                                               \
+               if (__is_io_address(p)) {                       \
+                       __v = __raw_readb(alignb(p));           \
+               } else {                                        \
+                       __v = __raw_readb(p);                   \
+               }                                               \
+                                                               \
+               __v;                                            \
+       })                                                      \
+
+#define ioread16(p)                                            \
+       ({                                                      \
+               unsigned int __v;                               \
+                                                               \
+               if (__is_io_address(p)) {                       \
+                       __v = __raw_readw(alignw(p));           \
+               } else {                                        \
+                       __v = le16_to_cpu(__raw_readw(p));      \
+               }                                               \
+                                                               \
+               __v;                                            \
+       })
+
+#define ioread32(p)                                            \
+       ({                                                      \
+               unsigned int __v;                               \
+                                                               \
+               if (__is_io_address(p)) {                       \
+                       __v = __raw_readl(p);                   \
+               } else {                                        \
+                       __v = le32_to_cpu(__raw_readl(p));      \
+               }                                               \
+                                                               \
+                __v;                                           \
+       })
+
+#define iowrite8(v,p)                                          \
+       ({                                                      \
+               if (__is_io_address(p)) {                       \
+                       __raw_writeb((v), alignb(p));           \
+               } else {                                        \
+                       __raw_writeb((v), p);                   \
+               }                                               \
+       })
+
+#define iowrite16(v,p)                                         \
+       ({                                                      \
+               if (__is_io_address(p)) {                       \
+                       __raw_writew((v), alignw(p));           \
+               } else {                                        \
+                       __raw_writew(cpu_to_le16(v), p);        \
+               }                                               \
+       })
+
+#define iowrite32(v,p)                                         \
+       ({                                                      \
+               if (__is_io_address(p)) {                       \
+                       __raw_writel((v), p);                   \
+               } else {                                        \
+                       __raw_writel(cpu_to_le32(v), p);        \
+               }                                               \
+       })
+
+#define ioport_map(port, nr)   ___io(port)
+
+#define ioport_unmap(addr)
+
 
 #ifdef CONFIG_ARCH_IXDP2X01
 /*