2 * linux/include/asm-arm/arch-ixp2000/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) (a)
22 * The A? revisions of the IXP2000s assert byte lanes for PCI I/O
23 * transactions the other way round (MEM transactions don't have this
24 * issue), so if we want to support those models, we need to override
25 * the standard I/O functions.
27 * B0 and later have a bit that can be set to 1 to get the proper
28 * behavior for I/O transactions, which then allows us to use the
29 * standard I/O functions. This is what we do if the user does not
30 * explicitly ask for support for pre-B0.
32 #ifdef CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO
33 #define ___io(p) ((void __iomem *)((p)+IXP2000_PCI_IO_VIRT_BASE))
35 #define alignb(addr) (void __iomem *)((unsigned long)(addr) ^ 3)
36 #define alignw(addr) (void __iomem *)((unsigned long)(addr) ^ 2)
38 #define outb(v,p) __raw_writeb((v),alignb(___io(p)))
39 #define outw(v,p) __raw_writew((v),alignw(___io(p)))
40 #define outl(v,p) __raw_writel((v),___io(p))
42 #define inb(p) ({ unsigned int __v = __raw_readb(alignb(___io(p))); __v; })
44 ({ unsigned int __v = (__raw_readw(alignw(___io(p)))); __v; })
46 ({ unsigned int __v = (__raw_readl(___io(p))); __v; })
48 #define outsb(p,d,l) __raw_writesb(alignb(___io(p)),d,l)
49 #define outsw(p,d,l) __raw_writesw(alignw(___io(p)),d,l)
50 #define outsl(p,d,l) __raw_writesl(___io(p),d,l)
52 #define insb(p,d,l) __raw_readsb(alignb(___io(p)),d,l)
53 #define insw(p,d,l) __raw_readsw(alignw(___io(p)),d,l)
54 #define insl(p,d,l) __raw_readsl(___io(p),d,l)
56 #define __is_io_address(p) ((((unsigned long)(p)) & ~(IXP2000_PCI_IO_SIZE - 1)) == IXP2000_PCI_IO_VIRT_BASE)
62 if (__is_io_address(p)) { \
63 __v = __raw_readb(alignb(p)); \
65 __v = __raw_readb(p); \
75 if (__is_io_address(p)) { \
76 __v = __raw_readw(alignw(p)); \
78 __v = le16_to_cpu(__raw_readw(p)); \
88 if (__is_io_address(p)) { \
89 __v = __raw_readl(p); \
91 __v = le32_to_cpu(__raw_readl(p)); \
97 #define iowrite8(v,p) \
99 if (__is_io_address(p)) { \
100 __raw_writeb((v), alignb(p)); \
102 __raw_writeb((v), p); \
106 #define iowrite16(v,p) \
108 if (__is_io_address(p)) { \
109 __raw_writew((v), alignw(p)); \
111 __raw_writew(cpu_to_le16(v), p); \
115 #define iowrite32(v,p) \
117 if (__is_io_address(p)) { \
118 __raw_writel((v), p); \
120 __raw_writel(cpu_to_le32(v), p); \
124 #define ioport_map(port, nr) ___io(port)
126 #define ioport_unmap(addr)
128 #define __io(p) ((void __iomem *)((p)+IXP2000_PCI_IO_VIRT_BASE))
132 #ifdef CONFIG_ARCH_IXDP2X01
134 * This is an ugly hack but the CS8900 on the 2x01's does not sit in any sort
135 * of "I/O space" and is just direct mapped into a 32-bit-only addressable
136 * bus. The address space for this bus is such that we can't really easily
137 * make it contiguous to the PCI I/O address range, and it also does not
138 * need swapping like PCI addresses do (IXDP2x01 is a BE platform).
139 * B/C of this we can't use the standard in/out functions and need to
140 * runtime check if the incoming address is a PCI address or for
148 #include <asm/mach-types.h>
150 static inline void insw(u32 ptr
, void *buf
, int length
)
152 register volatile u32
*port
= (volatile u32
*)ptr
;
155 * Is this cycle meant for the CS8900?
157 if ((machine_is_ixdp2401() || machine_is_ixdp2801()) &&
158 (((u32
)port
>= (u32
)IXDP2X01_CS8900_VIRT_BASE
) &&
159 ((u32
)port
<= (u32
)IXDP2X01_CS8900_VIRT_END
))) {
166 *buf8
++ = (u8
)(tmp32
>> 8);
172 __raw_readsw(alignw(___io(ptr
)),buf
,length
);
175 static inline void outsw(u32 ptr
, void *buf
, int length
)
177 register volatile u32
*port
= (volatile u32
*)ptr
;
180 * Is this cycle meant for the CS8900?
182 if ((machine_is_ixdp2401() || machine_is_ixdp2801()) &&
183 (((u32
)port
>= (u32
)IXDP2X01_CS8900_VIRT_BASE
) &&
184 ((u32
)port
<= (u32
)IXDP2X01_CS8900_VIRT_END
))) {
189 tmp32
|= (*buf8
++) << 8;
195 __raw_writesw(alignw(___io(ptr
)),buf
,length
);
199 static inline u16
inw(u32 ptr
)
201 register volatile u32
*port
= (volatile u32
*)ptr
;
204 * Is this cycle meant for the CS8900?
206 if ((machine_is_ixdp2401() || machine_is_ixdp2801()) &&
207 (((u32
)port
>= (u32
)IXDP2X01_CS8900_VIRT_BASE
) &&
208 ((u32
)port
<= (u32
)IXDP2X01_CS8900_VIRT_END
))) {
212 return __raw_readw(alignw(___io(ptr
)));
215 static inline void outw(u16 value
, u32 ptr
)
217 register volatile u32
*port
= (volatile u32
*)ptr
;
219 if ((machine_is_ixdp2401() || machine_is_ixdp2801()) &&
220 (((u32
)port
>= (u32
)IXDP2X01_CS8900_VIRT_BASE
) &&
221 ((u32
)port
<= (u32
)IXDP2X01_CS8900_VIRT_END
))) {
226 __raw_writew((value
),alignw(___io(ptr
)));
228 #endif /* IXDP2x01 */