Handle options that are integers (e.g. HZ) or strings properly.
[linux-2.6.git] / include / asm-ppc / io.h
index 5946df5..680555b 100644 (file)
@@ -2,12 +2,12 @@
 #ifndef _PPC_IO_H
 #define _PPC_IO_H
 
-#include <linux/config.h>
 #include <linux/string.h>
 #include <linux/types.h>
 
 #include <asm/page.h>
 #include <asm/byteorder.h>
+#include <asm/synch.h>
 #include <asm/mmu.h>
 
 #define SIO_CONFIG_RA  0x398
 
 #if defined(CONFIG_4xx)
 #include <asm/ibm4xx.h>
+#elif defined(CONFIG_PPC_MPC52xx)
+#include <asm/mpc52xx.h>
 #elif defined(CONFIG_8xx)
 #include <asm/mpc8xx.h>
 #elif defined(CONFIG_8260)
 #include <asm/mpc8260.h>
+#elif defined(CONFIG_83xx)
+#include <asm/mpc83xx.h>
 #elif defined(CONFIG_85xx)
 #include <asm/mpc85xx.h>
 #elif defined(CONFIG_APUS)
@@ -54,12 +58,12 @@ extern unsigned long pci_dram_offset;
  * is actually performed (i.e. the data has come back) before we start
  * executing any following instructions.
  */
-extern inline int in_8(volatile unsigned char __iomem *addr)
+extern inline int in_8(const volatile unsigned char __iomem *addr)
 {
        int ret;
 
        __asm__ __volatile__(
-               "lbz%U1%X1 %0,%1;\n"
+               "sync; lbz%U1%X1 %0,%1;\n"
                "twi 0,%0,0;\n"
                "isync" : "=r" (ret) : "m" (*addr));
        return ret;
@@ -70,22 +74,22 @@ extern inline void out_8(volatile unsigned char __iomem *addr, int val)
        __asm__ __volatile__("stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
 }
 
-extern inline int in_le16(volatile unsigned short __iomem *addr)
+extern inline int in_le16(const volatile unsigned short __iomem *addr)
 {
        int ret;
 
-       __asm__ __volatile__("lhbrx %0,0,%1;\n"
+       __asm__ __volatile__("sync; lhbrx %0,0,%1;\n"
                             "twi 0,%0,0;\n"
                             "isync" : "=r" (ret) :
                              "r" (addr), "m" (*addr));
        return ret;
 }
 
-extern inline int in_be16(volatile unsigned short __iomem *addr)
+extern inline int in_be16(const volatile unsigned short __iomem *addr)
 {
        int ret;
 
-       __asm__ __volatile__("lhz%U1%X1 %0,%1;\n"
+       __asm__ __volatile__("sync; lhz%U1%X1 %0,%1;\n"
                             "twi 0,%0,0;\n"
                             "isync" : "=r" (ret) : "m" (*addr));
        return ret;
@@ -93,31 +97,31 @@ extern inline int in_be16(volatile unsigned short __iomem *addr)
 
 extern inline void out_le16(volatile unsigned short __iomem *addr, int val)
 {
-       __asm__ __volatile__("sthbrx %1,0,%2; eieio" : "=m" (*addr) :
+       __asm__ __volatile__("sync; sthbrx %1,0,%2" : "=m" (*addr) :
                              "r" (val), "r" (addr));
 }
 
 extern inline void out_be16(volatile unsigned short __iomem *addr, int val)
 {
-       __asm__ __volatile__("sth%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
+       __asm__ __volatile__("sync; sth%U0%X0 %1,%0" : "=m" (*addr) : "r" (val));
 }
 
-extern inline unsigned in_le32(volatile unsigned __iomem *addr)
+extern inline unsigned in_le32(const volatile unsigned __iomem *addr)
 {
        unsigned ret;
 
-       __asm__ __volatile__("lwbrx %0,0,%1;\n"
+       __asm__ __volatile__("sync; lwbrx %0,0,%1;\n"
                             "twi 0,%0,0;\n"
                             "isync" : "=r" (ret) :
                             "r" (addr), "m" (*addr));
        return ret;
 }
 
-extern inline unsigned in_be32(volatile unsigned __iomem *addr)
+extern inline unsigned in_be32(const volatile unsigned __iomem *addr)
 {
        unsigned ret;
 
-       __asm__ __volatile__("lwz%U1%X1 %0,%1;\n"
+       __asm__ __volatile__("sync; lwz%U1%X1 %0,%1;\n"
                             "twi 0,%0,0;\n"
                             "isync" : "=r" (ret) : "m" (*addr));
        return ret;
@@ -125,16 +129,19 @@ extern inline unsigned in_be32(volatile unsigned __iomem *addr)
 
 extern inline void out_le32(volatile unsigned __iomem *addr, int val)
 {
-       __asm__ __volatile__("stwbrx %1,0,%2; eieio" : "=m" (*addr) :
+       __asm__ __volatile__("sync; stwbrx %1,0,%2" : "=m" (*addr) :
                             "r" (val), "r" (addr));
 }
 
 extern inline void out_be32(volatile unsigned __iomem *addr, int val)
 {
-       __asm__ __volatile__("stw%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
+       __asm__ __volatile__("sync; stw%U0%X0 %1,%0" : "=m" (*addr) : "r" (val));
 }
-
-static inline __u8 readb(volatile void __iomem *addr)
+#if defined (CONFIG_8260_PCI9)
+#define readb(addr) in_8((volatile u8 *)(addr))
+#define writeb(b,addr) out_8((volatile u8 *)(addr), (b))
+#else
+static inline __u8 readb(const volatile void __iomem *addr)
 {
        return in_8(addr);
 }
@@ -142,12 +149,14 @@ static inline void writeb(__u8 b, volatile void __iomem *addr)
 {
        out_8(addr, b);
 }
+#endif
+
 #if defined(CONFIG_APUS)
-static inline __u16 readw(volatile void __iomem *addr)
+static inline __u16 readw(const volatile void __iomem *addr)
 {
        return *(__force volatile __u16 *)(addr);
 }
-static inline __u32 readl(volatile void __iomem *addr)
+static inline __u32 readl(const volatile void __iomem *addr)
 {
        return *(__force volatile __u32 *)(addr);
 }
@@ -159,12 +168,18 @@ static inline void writel(__u32 b, volatile void __iomem *addr)
 {
        *(__force volatile __u32 *)(addr) = b;
 }
+#elif defined (CONFIG_8260_PCI9)
+/* Use macros if PCI9 workaround enabled */
+#define readw(addr) in_le16((volatile u16 *)(addr))
+#define readl(addr) in_le32((volatile u32 *)(addr))
+#define writew(b,addr) out_le16((volatile u16 *)(addr),(b))
+#define writel(b,addr) out_le32((volatile u32 *)(addr),(b))
 #else
-static inline __u16 readw(volatile void __iomem *addr)
+static inline __u16 readw(const volatile void __iomem *addr)
 {
        return in_le16(addr);
 }
-static inline __u32 readl(volatile void __iomem *addr)
+static inline __u32 readl(const volatile void __iomem *addr)
 {
        return in_le32(addr);
 }
@@ -182,15 +197,15 @@ static inline void writel(__u32 b, volatile void __iomem *addr)
 #define readw_relaxed(addr) readw(addr)
 #define readl_relaxed(addr) readl(addr)
 
-static inline __u8 __raw_readb(volatile void __iomem *addr)
+static inline __u8 __raw_readb(const volatile void __iomem *addr)
 {
        return *(__force volatile __u8 *)(addr);
 }
-static inline __u16 __raw_readw(volatile void __iomem *addr)
+static inline __u16 __raw_readw(const volatile void __iomem *addr)
 {
        return *(__force volatile __u16 *)(addr);
 }
-static inline __u32 __raw_readl(volatile void __iomem *addr)
+static inline __u32 __raw_readl(const volatile void __iomem *addr)
 {
        return *(__force volatile __u32 *)(addr);
 }
@@ -223,9 +238,9 @@ static inline void __raw_writel(__u32 b, volatile void __iomem *addr)
 #define outsl(port, buf, nl)   _outsl_ns((port)+___IO_BASE, (buf), (nl))
 
 /*
- * On powermacs, we will get a machine check exception if we
- * try to read data from a non-existent I/O port.  Because the
- * machine check is an asynchronous exception, it isn't
+ * On powermacs and 8xx we will get a machine check exception 
+ * if we try to read data from a non-existent I/O port. Because
+ * the machine check is an asynchronous exception, it isn't
  * well-defined which instruction SRR0 will point to when the
  * exception occurs.
  * With the sequence below (twi; isync; nop), we have found that
@@ -244,7 +259,8 @@ extern __inline__ unsigned int name(unsigned int port)      \
 {                                                      \
        unsigned int x;                                 \
        __asm__ __volatile__(                           \
-                       op "    %0,0,%1\n"              \
+               "sync\n"                                \
+               "0:"    op "    %0,0,%1\n"              \
                "1:     twi     0,%0,0\n"               \
                "2:     isync\n"                        \
                "3:     nop\n"                          \
@@ -255,6 +271,7 @@ extern __inline__ unsigned int name(unsigned int port)      \
                ".previous\n"                           \
                ".section __ex_table,\"a\"\n"           \
                "       .align  2\n"                    \
+               "       .long   0b,5b\n"                \
                "       .long   1b,5b\n"                \
                "       .long   2b,5b\n"                \
                "       .long   3b,5b\n"                \
@@ -268,11 +285,13 @@ extern __inline__ unsigned int name(unsigned int port)    \
 extern __inline__ void name(unsigned int val, unsigned int port) \
 {                                                      \
        __asm__ __volatile__(                           \
-               op " %0,0,%1\n"                         \
+               "sync\n"                                \
+               "0:" op " %0,0,%1\n"                    \
                "1:     sync\n"                         \
                "2:\n"                                  \
                ".section __ex_table,\"a\"\n"           \
                "       .align  2\n"                    \
+               "       .long   0b,2b\n"                \
                "       .long   1b,2b\n"                \
                ".previous"                             \
                : : "r" (val), "r" (port + ___IO_BASE));        \
@@ -332,11 +351,16 @@ extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, int nl);
 
 #define IO_SPACE_LIMIT ~0
 
+#if defined (CONFIG_8260_PCI9)
+#define memset_io(a,b,c)       memset((void *)(a),(b),(c))
+#define memcpy_fromio(a,b,c)   memcpy((a),(void *)(b),(c))
+#define memcpy_toio(a,b,c)     memcpy((void *)(a),(b),(c))
+#else
 static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
 {
        memset((void __force *)addr, val, count);
 }
-static inline void memcpy_fromio(void *dst, volatile void __iomem *src, int count)
+static inline void memcpy_fromio(void *dst,const volatile void __iomem *src, int count)
 {
        memcpy(dst, (void __force *) src, count);
 }
@@ -344,6 +368,9 @@ static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int
 {
        memcpy((void __force *) dst, src, count);
 }
+#endif
+
+#define eth_io_copy_and_sum(a,b,c,d)           eth_copy_and_sum((a),(void __force *)(void __iomem *)(b),(c),(d))
 
 /*
  * Map in an area of physical address space, for accessing
@@ -419,16 +446,6 @@ extern inline void * phys_to_virt(unsigned long address)
 #define page_to_phys(page)     (page_to_pfn(page) << PAGE_SHIFT)
 #define page_to_bus(page)      (page_to_phys(page) + PCI_DRAM_OFFSET)
 
-/*
- * Enforce In-order Execution of I/O:
- * Acts as a barrier to ensure all previous I/O accesses have
- * completed before any further ones are issued.
- */
-extern inline void eieio(void)
-{
-       __asm__ __volatile__ ("eieio" : : : "memory");
-}
-
 /* Enforce in-order execution of data I/O.
  * No distinction between read/write on PPC; use eieio for all three.
  */
@@ -488,32 +505,32 @@ static inline void iowrite32(u32 val, void __iomem *addr)
 
 static inline void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
 {
-       _insb((u8 __force *) addr, dst, count);
+       _insb(addr, dst, count);
 }
 
 static inline void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
 {
-       _insw_ns((u16 __force *) addr, dst, count);
+       _insw_ns(addr, dst, count);
 }
 
 static inline void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
 {
-       _insl_ns((u32 __force *) addr, dst, count);
+       _insl_ns(addr, dst, count);
 }
 
 static inline void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
 {
-       _outsb((u8 __force *) addr, src, count);
+       _outsb(addr, src, count);
 }
 
 static inline void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
 {
-       _outsw_ns((u16 __force *) addr, src, count);
+       _outsw_ns(addr, src, count);
 }
 
 static inline void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
 {
-       _outsl_ns((u32 __force *) addr, src, count);
+       _outsl_ns(addr, src, count);
 }
 
 /* Create a virtual mapping cookie for an IO port range */
@@ -531,4 +548,39 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
 #include <asm/mpc8260_pci9.h>
 #endif
 
+#ifdef CONFIG_NOT_COHERENT_CACHE
+
+#define dma_cache_inv(_start,_size) \
+       invalidate_dcache_range(_start, (_start + _size))
+#define dma_cache_wback(_start,_size) \
+       clean_dcache_range(_start, (_start + _size))
+#define dma_cache_wback_inv(_start,_size) \
+       flush_dcache_range(_start, (_start + _size))
+
+#else
+
+#define dma_cache_inv(_start,_size)            do { } while (0)
+#define dma_cache_wback(_start,_size)          do { } while (0)
+#define dma_cache_wback_inv(_start,_size)      do { } while (0)
+
+#endif
+
+/*
+ * Convert a physical pointer to a virtual kernel pointer for /dev/mem
+ * access
+ */
+#define xlate_dev_mem_ptr(p)   __va(p)
+
+/*
+ * Convert a virtual cached pointer to an uncached pointer
+ */
+#define xlate_dev_kmem_ptr(p)  p
+
+/* access ports */
+#define setbits32(_addr, _v) out_be32((_addr), in_be32(_addr) |  (_v))
+#define clrbits32(_addr, _v) out_be32((_addr), in_be32(_addr) & ~(_v))
+
+#define setbits16(_addr, _v) out_be16((_addr), in_be16(_addr) |  (_v))
+#define clrbits16(_addr, _v) out_be16((_addr), in_be16(_addr) & ~(_v))
+
 #endif /* __KERNEL__ */