patch-2.2.18 linux/include/asm-arm/arch-ebsa285/io.h
Next file: linux/include/asm-arm/arch-ebsa285/irq.h
Previous file: linux/include/asm-arm/arch-ebsa285/hardware.h
Back to the patch index
Back to the overall index
- Lines: 201
- Date:
Fri Sep 15 23:32:34 2000
- Orig file:
v2.2.17/include/asm-arm/arch-ebsa285/io.h
- Orig date:
Fri Apr 21 12:46:48 2000
diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/include/asm-arm/arch-ebsa285/io.h linux/include/asm-arm/arch-ebsa285/io.h
@@ -18,132 +18,33 @@
#undef ARCH_IO_DELAY
#define ARCH_READWRITE
-/*
- * Dynamic IO functions - let the compiler
- * optimize the expressions
- */
-#define DECLARE_DYN_OUT(fnsuffix,instr,typ) \
-extern __inline__ void \
-__out##fnsuffix (unsigned int value, unsigned int port) \
-{ \
- __asm__ __volatile__( \
- "str%?" ##instr## " %0, [%1, %2] @ out"###fnsuffix \
- : \
- : "r" (value), "r" (PCIO_BASE), typ (port)); \
-}
+#define __pci_io_addr(x) (PCIO_BASE + (unsigned int)(x))
-#define DECLARE_DYN_IN(sz,fnsuffix,instr,typ) \
-extern __inline__ unsigned sz \
-__in##fnsuffix (unsigned int port) \
-{ \
- unsigned long value; \
- __asm__ __volatile__( \
- "ldr%?" ##instr## " %0, [%1, %2] @ in"###fnsuffix \
- : "=&r" (value) \
- : "r" (PCIO_BASE), typ (port)); \
- return (unsigned sz)value; \
-}
+#define __inb(p) (*(volatile unsigned char *)__pci_io_addr(p))
+#define __inl(p) (*(volatile unsigned long *)__pci_io_addr(p))
-extern __inline__ unsigned int __ioaddr (unsigned int port) \
-{ \
- return (unsigned int)(PCIO_BASE + port); \
+extern __inline__ unsigned int __inw(unsigned int port)
+{
+ unsigned int value;
+ __asm__ __volatile__(
+ "ldr%?h %0, [%1, %2] @ inw"
+ : "=&r" (value)
+ : "r" (PCIO_BASE), "r" (port));
+ return value;
}
-#define DECLARE_IO(sz,fnsuffix,instr,typ) \
- DECLARE_DYN_OUT(fnsuffix,instr,typ) \
- DECLARE_DYN_IN(sz,fnsuffix,instr,typ)
-
-DECLARE_IO(char,b,"b","Jr")
-DECLARE_IO(short,w,"h","r")
-DECLARE_IO(long,l,"","Jr")
-
-#undef DECLARE_IO
-#undef DECLARE_DYN_OUT
-#undef DECLARE_DYN_IN
-
-/*
- * Constant address IO functions
- *
- * These have to be macros for the 'J' constraint to work -
- * +/-4096 immediate operand.
- */
-#define __outbc(value,port) \
-({ \
- __asm__ __volatile__( \
- "str%?b %0, [%1, %2] @ outbc" \
- : \
- : "r" (value), "r" (PCIO_BASE), "Jr" (port)); \
-})
-#define __inbc(port) \
-({ \
- unsigned char result; \
- __asm__ __volatile__( \
- "ldr%?b %0, [%1, %2] @ inbc" \
- : "=r" (result) \
- : "r" (PCIO_BASE), "Jr" (port)); \
- result; \
-})
-
-#define __outwc(value,port) \
-({ \
- __asm__ __volatile__( \
- "str%?h %0, [%1, %2] @ outwc" \
- : \
- : "r" (value), "r" (PCIO_BASE), "r" (port)); \
-})
-
-#define __inwc(port) \
-({ \
- unsigned short result; \
- __asm__ __volatile__( \
- "ldr%?h %0, [%1, %2] @ inwc" \
- : "=r" (result) \
- : "r" (PCIO_BASE), "r" (port)); \
- result & 0xffff; \
-})
-
-#define __outlc(value,port) \
-({ \
- __asm__ __volatile__( \
- "str%? %0, [%1, %2] @ outlc" \
- : \
- : "r" (value), "r" (PCIO_BASE), "Jr" (port)); \
-})
+#define __outb(v,p) (*(volatile unsigned char *)__pci_io_addr(p) = (v))
+#define __outl(v,p) (*(volatile unsigned long *)__pci_io_addr(p) = (v))
-#define __inlc(port) \
-({ \
- unsigned long result; \
- __asm__ __volatile__( \
- "ldr%? %0, [%1, %2] @ inlc" \
- : "=r" (result) \
- : "r" (PCIO_BASE), "Jr" (port)); \
- result; \
-})
-
-#define __ioaddrc(port) \
-({ \
- unsigned long addr; \
- addr = PCIO_BASE + port; \
- addr; \
-})
-
-/*
- * Translated address IO functions
- *
- * IO address has already been translated to a virtual address
- */
-#define outb_t(v,p) \
- (*(volatile unsigned char *)(p) = (v))
-
-#define inb_t(p) \
- (*(volatile unsigned char *)(p))
-
-#define outl_t(v,p) \
- (*(volatile unsigned long *)(p) = (v))
+extern __inline__ void __outw(unsigned int value, unsigned int port)
+{
+ __asm__ __volatile__(
+ "str%?h %0, [%1, %2] @ outw"
+ : : "r" (value), "r" (PCIO_BASE), "r" (port));
+}
-#define inl_t(p) \
- (*(volatile unsigned long *)(p))
+#define __ioaddr(p) __pci_io_addr(p)
/*
* ioremap support - validate a PCI memory address,
@@ -160,6 +61,8 @@
*/
#define IO_FUDGE_FACTOR PCIMEM_BASE
+#define __pci_mem_addr(x) ((void *)(IO_FUDGE_FACTOR + (unsigned long)(x)))
+
/*
* ioremap takes a PCI memory address, as specified in
* linux/Documentation/IO-mapping.txt
@@ -176,30 +79,14 @@
#define ioremap_nocache(iomem_addr,size) ioremap((iomem_addr),(size))
-extern void iounmap(void *addr);
-
-#define DECLARE_PCI_WRITE(typ,fnsuffix) \
-static inline void write##fnsuffix(unsigned typ val, unsigned int addr) \
-{ \
- *(volatile unsigned typ *)(IO_FUDGE_FACTOR + addr) = val; \
-}
-
-#define DECLARE_PCI_READ(typ,fnsuffix) \
-static inline unsigned typ read##fnsuffix (unsigned int addr) \
-{ \
- return *(volatile unsigned typ *)(IO_FUDGE_FACTOR + addr); \
-}
+#define iounmap(_addr) do { __iounmap(__pci_mem_addr((_addr))); } while (0)
-#define DECLARE_PCI(typ,fnsuffix) \
- DECLARE_PCI_WRITE(typ,fnsuffix) \
- DECLARE_PCI_READ(typ,fnsuffix)
-
-DECLARE_PCI(char,b)
-DECLARE_PCI(short,w)
-DECLARE_PCI(long,l)
-
-#undef DECLARE_PCI
-#undef DECLARE_PCI_READ
-#undef DECLARE_PCI_WRITE
+#define readb(addr) (*(volatile unsigned char *)__pci_mem_addr(addr))
+#define readw(addr) (*(volatile unsigned short *)__pci_mem_addr(addr))
+#define readl(addr) (*(volatile unsigned long *)__pci_mem_addr(addr))
+
+#define writeb(b,addr) (*(volatile unsigned char *)__pci_mem_addr(addr) = (b))
+#define writew(b,addr) (*(volatile unsigned short *)__pci_mem_addr(addr) = (b))
+#define writel(b,addr) (*(volatile unsigned long *)__pci_mem_addr(addr) = (b))
#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)