MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / asm-arm / arch-ixp2000 / io.h
blob7463a3217f9297d9265bfe1387b3a7f4bfff558d
1 /*
2 * linux/include/asm-arm/arch-ixdp2000/io.h
4 * Original Author: Naeem M Afzal <naeem.m.afzal@intel.com>
5 * Maintainer: Deepak Saxena <dsaxena@plexity.net>
7 * Copyright (C) 2002 Intel Corp.
8 * Copyrgiht (C) 2003-2004 MontaVista Software, Inc.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #ifndef __ASM_ARM_ARCH_IO_H
16 #define __ASM_ARM_ARCH_IO_H
18 #define IO_SPACE_LIMIT 0xffffffff
19 #define __mem_pci(a) ((unsigned long)(a))
22 * Pick up VMALLOC_END
24 #define ___io(p) ((unsigned long)((p)+IXP2000_PCI_IO_VIRT_BASE))
27 * IXP200 does not do proper byte-lane conversion for PCI addresses,
28 * so we need to override standard functions.
30 #define alignb(addr) ((addr & ~3) + (3 - (addr & 3)))
31 #define alignw(addr) ((addr & ~2) + (2 - (addr & 2)))
33 #define outb(v,p) __raw_writeb(v,alignb(___io(p)))
34 #define outw(v,p) __raw_writew((v),alignw(___io(p)))
35 #define outl(v,p) __raw_writel((v),___io(p))
37 #define inb(p) ({ unsigned int __v = __raw_readb(alignb(___io(p))); __v; })
38 #define inw(p) \
39 ({ unsigned int __v = (__raw_readw(alignw(___io(p)))); __v; })
40 #define inl(p) \
41 ({ unsigned int __v = (__raw_readl(___io(p))); __v; })
43 #define outsb(p,d,l) __raw_writesb(alignb(___io(p)),d,l)
44 #define outsw(p,d,l) __raw_writesw(alignw(___io(p)),d,l)
45 #define outsl(p,d,l) __raw_writesl(___io(p),d,l)
47 #define insb(p,d,l) __raw_readsb(alignb(___io(p)),d,l)
48 #define insw(p,d,l) __raw_readsw(alignw(___io(p)),d,l)
49 #define insl(p,d,l) __raw_readsl(___io(p),d,l)
52 #ifdef CONFIG_ARCH_IXDP2X01
54 * This is an ugly hack but the CS8900 on the 2x01's does not sit in any sort
55 * of "I/O space" and is just direct mapped into a 32-bit-only addressable
56 * bus. The address space for this bus is such that we can't really easilly
57 * make it contigous to the PCI I/O address range, and it also does not
58 * need swapping like PCI addresses do (IXDP2x01 is a BE platform).
59 * B/C of this we can't use the standard in/out functions and need to
60 * runtime check if the incoming address is a PCI address or for
61 * the CS89x0.
63 #undef inw
64 #undef outw
65 #undef insw
66 #undef outsw
68 #include <asm/mach-types.h>
70 static inline void insw(u32 ptr, void *buf, int length)
72 register volatile u32 *port = (volatile u32 *)ptr;
75 * Is this cycle meant for the CS8900?
77 if ((machine_is_ixdp2401() || machine_is_ixdp2801()) &&
78 ((port >= IXDP2X01_CS8900_VIRT_BASE) &&
79 (port <= IXDP2X01_CS8900_VIRT_END))) {
80 u8 *buf8 = (u8*)buf;
81 register u32 tmp32;
83 do {
84 tmp32 = *port;
85 *buf8++ = (u8)tmp32;
86 *buf8++ = (u8)(tmp32 >> 8);
87 } while(--length);
89 return;
92 __raw_readsw(alignw(___io(ptr)),buf,length);
95 static inline void outsw(u32 ptr, void *buf, int length)
97 register volatile u32 *port = (volatile u32 *)ptr;
100 * Is this cycle meant for the CS8900?
102 if ((machine_is_ixdp2401() || machine_is_ixdp2801()) &&
103 ((port >= IXDP2X01_CS8900_VIRT_BASE) &&
104 (port <= IXDP2X01_CS8900_VIRT_END))) {
105 register u32 tmp32;
106 u8 *buf8 = (u8*)buf;
107 do {
108 tmp32 = *buf8++;
109 tmp32 |= (*buf8++) << 8;
110 *port = tmp32;
111 } while(--length);
112 return;
115 __raw_writesw(alignw(___io(ptr)),buf,length);
119 static inline u16 inw(u32 ptr)
121 register volatile u32 *port = (volatile u32 *)ptr;
124 * Is this cycle meant for the CS8900?
126 if ((machine_is_ixdp2401() || machine_is_ixdp2801()) &&
127 ((port >= IXDP2X01_CS8900_VIRT_BASE) &&
128 (port <= IXDP2X01_CS8900_VIRT_END))) {
129 return (u16)(*port);
132 return __raw_readw(alignw(___io(ptr)));
135 static inline void outw(u16 value, u32 ptr)
137 register volatile u32 *port = (volatile u32 *)ptr;
139 if ((machine_is_ixdp2401() || machine_is_ixdp2801()) &&
140 ((port >= IXDP2X01_CS8900_VIRT_BASE) &&
141 (port <= IXDP2X01_CS8900_VIRT_END))) {
142 *port = value;
143 return;
146 __raw_writew((value),alignw(___io(ptr)));
148 #endif /* IXDP2x01 */
150 #endif