fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / asm-arm / arch-s3c2410 / io.h
index dd2961d..6b35a4f 100644 (file)
@@ -4,16 +4,13 @@
  *
  * Copyright (C) 1997 Russell King
  *          (C) 2003 Simtec Electronics
- *
- * Modifications:
- *  06-Dec-1997        RMK     Created.
- *  02-Sep-2003 BJD    Modified for S3C2410
- *
- */
+*/
 
 #ifndef __ASM_ARM_ARCH_IO_H
 #define __ASM_ARM_ARCH_IO_H
 
+#include <asm/hardware.h>
+
 #define IO_SPACE_LIMIT 0xffffffff
 
 /*
 
 #define __PORT_PCIO(x) ((x) < (1<<28))
 
-#define PCIO_BASE       (S3C2410_VA_ISA_WORD)
-#define PCIO_BASE_b     (S3C2410_VA_ISA_BYTE)
-#define PCIO_BASE_w     (S3C2410_VA_ISA_WORD)
-#define PCIO_BASE_l     (S3C2410_VA_ISA_WORD)
+#define PCIO_BASE       (S3C24XX_VA_ISA_WORD)
+#define PCIO_BASE_b     (S3C24XX_VA_ISA_BYTE)
+#define PCIO_BASE_w     (S3C24XX_VA_ISA_WORD)
+#define PCIO_BASE_l     (S3C24XX_VA_ISA_WORD)
 /*
  * Dynamic IO functions - let the compiler
  * optimize the expressions
@@ -65,12 +62,9 @@ static inline unsigned sz __in##fnsuffix (unsigned int port)         \
        return (unsigned sz)value;                                      \
 }
 
-static inline unsigned int __ioaddr (unsigned int port)
+static inline void __iomem *__ioaddr (unsigned long port)
 {
-       if (__PORT_PCIO(port))
-               return (unsigned int)(PCIO_BASE + (port));
-       else
-               return (unsigned int)(0 + (port));
+       return __PORT_PCIO(port) ? (PCIO_BASE + port) : (void __iomem *)port;
 }
 
 #define DECLARE_IO(sz,fnsuffix,instr)  \
@@ -99,7 +93,7 @@ DECLARE_IO(int,l,"")
        else                                                            \
                __asm__ __volatile__(                                   \
                "strb   %0, [%1, #0]    @ outbc"                        \
-               : : "r" (value), "r" ((port)));         \
+               : : "r" (value), "r" ((port)));                         \
 })
 
 #define __inbc(port)                                                   \
@@ -112,35 +106,61 @@ DECLARE_IO(int,l,"")
        else                                                            \
                __asm__ __volatile__(                                   \
                "ldrb   %0, [%1, #0]    @ inbc"                         \
-               : "=r" (result) : "r" ((port)));        \
+               : "=r" (result) : "r" ((port)));                        \
        result;                                                         \
 })
 
 #define __outwc(value,port)                                            \
 ({                                                                     \
        unsigned long v = value;                                        \
-       if (__PORT_PCIO((port)))                                        \
-               __asm__ __volatile__(                                   \
-               "strh   %0, [%1, %2]    @ outwc"                        \
-               : : "r" (v), "r" (PCIO_BASE), "Jr" ((port)));   \
-       else                                                            \
+       if (__PORT_PCIO((port))) {                                      \
+               if ((port) < 256 && (port) > -256)                      \
+                       __asm__ __volatile__(                           \
+                       "strh   %0, [%1, %2]    @ outwc"                \
+                       : : "r" (v), "r" (PCIO_BASE), "Jr" ((port)));   \
+               else if ((port) > 0)                                    \
+                       __asm__ __volatile__(                           \
+                       "strh   %0, [%1, %2]    @ outwc"                \
+                       : : "r" (v),                                    \
+                           "r" (PCIO_BASE + ((port) & ~0xff)),         \
+                            "Jr" (((port) & 0xff)));                   \
+               else                                                    \
+                       __asm__ __volatile__(                           \
+                       "strh   %0, [%1, #0]    @ outwc"                \
+                       : : "r" (v),                                    \
+                           "r" (PCIO_BASE + (port)));                  \
+       } else                                                          \
                __asm__ __volatile__(                                   \
                "strh   %0, [%1, #0]    @ outwc"                        \
-               : : "r" (v), "r" ((port)));     \
+               : : "r" (v), "r" ((port)));                             \
 })
 
 #define __inwc(port)                                                   \
 ({                                                                     \
        unsigned short result;                                          \
-       if (__PORT_PCIO((port)))                                        \
-               __asm__ __volatile__(                                   \
-               "ldrh   %0, [%1, %2]    @ inwc"                         \
-               : "=r" (result) : "r" (PCIO_BASE), "Jr" ((port)));      \
-       else                                                            \
+       if (__PORT_PCIO((port))) {                                      \
+               if ((port) < 256 && (port) > -256 )                     \
+                       __asm__ __volatile__(                           \
+                       "ldrh   %0, [%1, %2]    @ inwc"                 \
+                       : "=r" (result)                                 \
+                       : "r" (PCIO_BASE),                              \
+                         "Jr" ((port)));                               \
+               else if ((port) > 0)                                    \
+                       __asm__ __volatile__(                           \
+                       "ldrh   %0, [%1, %2]    @ inwc"                 \
+                       : "=r" (result)                                 \
+                       : "r" (PCIO_BASE + ((port) & ~0xff)),           \
+                         "Jr" (((port) & 0xff)));                      \
+               else                                                    \
+                       __asm__ __volatile__(                           \
+                       "ldrh   %0, [%1, #0]    @ inwc"                 \
+                       : "=r" (result)                                 \
+                       : "r" (PCIO_BASE + ((port))));                  \
+       } else                                                          \
                __asm__ __volatile__(                                   \
                "ldrh   %0, [%1, #0]    @ inwc"                         \
-               : "=r" (result) : "r" ((port)));                \
-       result;                                         \
+               : "=r" (result) : "r" ((port)));                        \
+       result;                                                         \
 })
 
 #define __outlc(value,port)                                            \
@@ -170,7 +190,7 @@ DECLARE_IO(int,l,"")
        result;                                                         \
 })
 
-#define __ioaddrc(port)        (__PORT_PCIO((port)) ? PCIO_BASE + ((port)) : ((port)))
+#define __ioaddrc(port)        ((__PORT_PCIO(port) ? PCIO_BASE + (port) : (void __iomem *)(port)))
 
 #define inb(p)         (__builtin_constant_p((p)) ? __inbc(p)     : __inb(p))
 #define inw(p)         (__builtin_constant_p((p)) ? __inwc(p)     : __inw(p))
@@ -180,7 +200,7 @@ DECLARE_IO(int,l,"")
 #define outl(v,p)      (__builtin_constant_p((p)) ? __outlc(v,p) : __outl(v,p))
 #define __ioaddr(p)    (__builtin_constant_p((p)) ? __ioaddr(p)  : __ioaddrc(p))
 /* the following macro is deprecated */
-#define ioaddr(port)                   __ioaddr((port))
+#define ioaddr(port)   __ioaddr((port))
 
 #define insb(p,d,l)    __raw_readsb(__ioaddr(p),d,l)
 #define insw(p,d,l)    __raw_readsw(__ioaddr(p),d,l)