Merge branch 'locks' of git://linux-nfs.org/~bfields/linux
[safe/jmp/linux-2.6] / include / asm-powerpc / io.h
index 53bff8b..0d0589e 100644 (file)
 
 /* Check of existence of legacy devices */
 extern int check_legacy_ioport(unsigned long base_port);
-#define PNPBIOS_BASE   0xf000  /* only relevant for PReP */
+#define I8042_DATA_REG 0x60
+#define FDC_BASE       0x3f0
+/* only relevant for PReP */
+#define _PIDXR         0x279
+#define _PNPWRP                0xa79
+#define PNPBIOS_BASE   0xf000
 
 #include <linux/compiler.h>
 #include <asm/page.h>
@@ -81,7 +86,7 @@ extern unsigned long pci_dram_offset;
  */
 
 #ifdef CONFIG_PPC64
-#define IO_SET_SYNC_FLAG()     do { get_paca()->io_sync = 1; } while(0)
+#define IO_SET_SYNC_FLAG()     do { local_paca->io_sync = 1; } while(0)
 #else
 #define IO_SET_SYNC_FLAG()
 #endif
@@ -133,12 +138,12 @@ DEF_MMIO_IN_BE(in_be64, 64, ld);
 /* There is no asm instructions for 64 bits reverse loads and stores */
 static inline u64 in_le64(const volatile u64 __iomem *addr)
 {
-       return le64_to_cpu(in_be64(addr));
+       return swab64(in_be64(addr));
 }
 
 static inline void out_le64(volatile u64 __iomem *addr, u64 val)
 {
-       out_be64(addr, cpu_to_le64(val));
+       out_be64(addr, swab64(val));
 }
 #endif /* __powerpc64__ */
 
@@ -185,53 +190,6 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,
  * of the accessors.
  */
 
-
-/*
- * Non ordered and non-swapping "raw" accessors
- */
-
-static inline unsigned char __raw_readb(const volatile void __iomem *addr)
-{
-       return *(volatile unsigned char __force *)addr;
-}
-static inline unsigned short __raw_readw(const volatile void __iomem *addr)
-{
-       return *(volatile unsigned short __force *)addr;
-}
-static inline unsigned int __raw_readl(const volatile void __iomem *addr)
-{
-       return *(volatile unsigned int __force *)addr;
-}
-static inline void __raw_writeb(unsigned char v, volatile void __iomem *addr)
-{
-       *(volatile unsigned char __force *)addr = v;
-}
-static inline void __raw_writew(unsigned short v, volatile void __iomem *addr)
-{
-       *(volatile unsigned short __force *)addr = v;
-}
-static inline void __raw_writel(unsigned int v, volatile void __iomem *addr)
-{
-       *(volatile unsigned int __force *)addr = v;
-}
-
-#ifdef __powerpc64__
-static inline unsigned long __raw_readq(const volatile void __iomem *addr)
-{
-       return *(volatile unsigned long __force *)addr;
-}
-static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
-{
-       *(volatile unsigned long __force *)addr = v;
-}
-#endif /* __powerpc64__ */
-
-/*
- *
- * PCI PIO and MMIO accessors.
- *
- */
-
 /*
  * Include the EEH definitions when EEH is enabled only so they don't get
  * in the way when building for 32 bits
@@ -291,7 +249,52 @@ do {                                                                       \
 #define PCI_FIX_ADDR(addr) (addr)
 #endif
 
+
+/*
+ * Non ordered and non-swapping "raw" accessors
+ */
+
+static inline unsigned char __raw_readb(const volatile void __iomem *addr)
+{
+       return *(volatile unsigned char __force *)PCI_FIX_ADDR(addr);
+}
+static inline unsigned short __raw_readw(const volatile void __iomem *addr)
+{
+       return *(volatile unsigned short __force *)PCI_FIX_ADDR(addr);
+}
+static inline unsigned int __raw_readl(const volatile void __iomem *addr)
+{
+       return *(volatile unsigned int __force *)PCI_FIX_ADDR(addr);
+}
+static inline void __raw_writeb(unsigned char v, volatile void __iomem *addr)
+{
+       *(volatile unsigned char __force *)PCI_FIX_ADDR(addr) = v;
+}
+static inline void __raw_writew(unsigned short v, volatile void __iomem *addr)
+{
+       *(volatile unsigned short __force *)PCI_FIX_ADDR(addr) = v;
+}
+static inline void __raw_writel(unsigned int v, volatile void __iomem *addr)
+{
+       *(volatile unsigned int __force *)PCI_FIX_ADDR(addr) = v;
+}
+
+#ifdef __powerpc64__
+static inline unsigned long __raw_readq(const volatile void __iomem *addr)
+{
+       return *(volatile unsigned long __force *)PCI_FIX_ADDR(addr);
+}
+static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
+{
+       *(volatile unsigned long __force *)PCI_FIX_ADDR(addr) = v;
+}
+#endif /* __powerpc64__ */
+
 /*
+ *
+ * PCI PIO and MMIO accessors.
+ *
+ *
  * On 32 bits, PIO operations have a recovery mechanism in case they trigger
  * machine checks (which they occasionally do when probing non existing
  * IO ports on some platforms, like PowerMac and 8xx).
@@ -304,7 +307,7 @@ do {                                                                        \
 #ifdef CONFIG_PPC32
 
 #define __do_in_asm(name, op)                          \
-extern __inline__ unsigned int name(unsigned int port) \
+static inline unsigned int name(unsigned int port)     \
 {                                                      \
        unsigned int x;                                 \
        __asm__ __volatile__(                           \
@@ -331,7 +334,7 @@ extern __inline__ unsigned int name(unsigned int port)      \
 }
 
 #define __do_out_asm(name, op)                         \
-extern __inline__ void name(unsigned int val, unsigned int port) \
+static inline void name(unsigned int val, unsigned int port) \
 {                                                      \
        __asm__ __volatile__(                           \
                "sync\n"                                \
@@ -604,9 +607,9 @@ static inline void iosync(void)
  *
  * * iounmap undoes such a mapping and can be hooked
  *
- * * __ioremap_explicit (and the pending __iounmap_explicit) are low level
- *   functions to create hand-made mappings for use only by the PCI code
- *   and cannot currently be hooked.
+ * * __ioremap_at (and the pending __iounmap_at) are low level functions to
+ *   create hand-made mappings for use only by the PCI code and cannot
+ *   currently be hooked. Must be page aligned.
  *
  * * __ioremap is the low level implementation used by ioremap and
  *   ioremap_flags and cannot be hooked (but can be used by a hook on one
@@ -626,19 +629,9 @@ extern void __iomem *__ioremap(phys_addr_t, unsigned long size,
                               unsigned long flags);
 extern void __iounmap(volatile void __iomem *addr);
 
-extern int __ioremap_explicit(phys_addr_t p_addr, unsigned long v_addr,
-                             unsigned long size, unsigned long flags);
-extern int __iounmap_explicit(volatile void __iomem *start,
-                             unsigned long size);
-
-extern void __iomem * reserve_phb_iospace(unsigned long size);
-
-/* Those are more 32 bits only functions */
-extern unsigned long iopa(unsigned long addr);
-extern unsigned long mm_ptov(unsigned long addr) __attribute_const__;
-extern void io_block_mapping(unsigned long virt, phys_addr_t phys,
-                            unsigned int size, int flags);
-
+extern void __iomem * __ioremap_at(phys_addr_t pa, void *ea,
+                                  unsigned long size, unsigned long flags);
+extern void __iounmap_at(void *ea, unsigned long size);
 
 /*
  * When CONFIG_PPC_INDIRECT_IO is set, we use the generic iomap implementation
@@ -648,8 +641,8 @@ extern void io_block_mapping(unsigned long virt, phys_addr_t phys,
  */
 #define HAVE_ARCH_PIO_SIZE             1
 #define PIO_OFFSET                     0x00000000UL
-#define PIO_MASK                       0x3fffffffUL
-#define PIO_RESERVED                   0x40000000UL
+#define PIO_MASK                       (FULL_IO_SIZE - 1)
+#define PIO_RESERVED                   (FULL_IO_SIZE)
 
 #define mmio_read16be(addr)            readw_be(addr)
 #define mmio_read32be(addr)            readl_be(addr)
@@ -734,6 +727,38 @@ static inline void * bus_to_virt(unsigned long address)
 
 #endif /* CONFIG_PPC32 */
 
+/* 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))
+
+#define setbits8(_addr, _v) out_8((_addr), in_8(_addr) |  (_v))
+#define clrbits8(_addr, _v) out_8((_addr), in_8(_addr) & ~(_v))
+
+/* Clear and set bits in one shot.  These macros can be used to clear and
+ * set multiple bits in a register using a single read-modify-write.  These
+ * macros can also be used to set a multiple-bit bit pattern using a mask,
+ * by specifying the mask in the 'clear' parameter and the new bit pattern
+ * in the 'set' parameter.
+ */
+
+#define clrsetbits(type, addr, clear, set) \
+       out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
+
+#ifdef __powerpc64__
+#define clrsetbits_be64(addr, clear, set) clrsetbits(be64, addr, clear, set)
+#define clrsetbits_le64(addr, clear, set) clrsetbits(le64, addr, clear, set)
+#endif
+
+#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
+#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
+
+#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
+#define clrsetbits_le16(addr, clear, set) clrsetbits(le32, addr, clear, set)
+
+#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
 
 #endif /* __KERNEL__ */