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)
20 #define ___io(p) ((void __iomem *)((p)+IXP2000_PCI_IO_VIRT_BASE))
23 * The IXP2400 before revision B0 asserts byte lanes for PCI I/O
24 * transactions the other way round (MEM transactions don't have this
25 * issue), so we need to override the standard functions. B0 and later
26 * have a bit that can be set to 1 to get the 'proper' behavior, but
27 * since that isn't available on the A? revisions we just keep doing
30 #define alignb(addr) (void __iomem *)((unsigned long)(addr) ^ 3)
31 #define alignw(addr) (void __iomem *)((unsigned long)(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; })
39 ({ unsigned int __v = (__raw_readw(alignw(___io(p)))); __v; })
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)
51 #define __is_io_address(p) ((((unsigned long)(p)) & ~(IXP2000_PCI_IO_SIZE - 1)) == IXP2000_PCI_IO_VIRT_BASE)
57 if (__is_io_address(p)) { \
58 __v = __raw_readb(alignb(p)); \
60 __v = __raw_readb(p); \
70 if (__is_io_address(p)) { \
71 __v = __raw_readw(alignw(p)); \
73 __v = le16_to_cpu(__raw_readw(p)); \
83 if (__is_io_address(p)) { \
84 __v = __raw_readl(p); \
86 __v = le32_to_cpu(__raw_readl(p)); \
92 #define iowrite8(v,p) \
94 if (__is_io_address(p)) { \
95 __raw_writeb((v), alignb(p)); \
97 __raw_writeb((v), p); \
101 #define iowrite16(v,p) \
103 if (__is_io_address(p)) { \
104 __raw_writew((v), alignw(p)); \
106 __raw_writew(cpu_to_le16(v), p); \
110 #define iowrite32(v,p) \
112 if (__is_io_address(p)) { \
113 __raw_writel((v), p); \
115 __raw_writel(cpu_to_le32(v), p); \
119 #define ioport_map(port, nr) ___io(port)
121 #define ioport_unmap(addr)
124 #ifdef CONFIG_ARCH_IXDP2X01
126 * This is an ugly hack but the CS8900 on the 2x01's does not sit in any sort
127 * of "I/O space" and is just direct mapped into a 32-bit-only addressable
128 * bus. The address space for this bus is such that we can't really easily
129 * make it contiguous to the PCI I/O address range, and it also does not
130 * need swapping like PCI addresses do (IXDP2x01 is a BE platform).
131 * B/C of this we can't use the standard in/out functions and need to
132 * runtime check if the incoming address is a PCI address or for
140 #include <asm/mach-types.h>
142 static inline void insw(u32 ptr, void *buf, int length)
144 register volatile u32 *port = (volatile u32 *)ptr;
147 * Is this cycle meant for the CS8900?
149 if ((machine_is_ixdp2401() || machine_is_ixdp2801()) &&
150 (((u32)port >= (u32)IXDP2X01_CS8900_VIRT_BASE) &&
151 ((u32)port <= (u32)IXDP2X01_CS8900_VIRT_END))) {
158 *buf8++ = (u8)(tmp32 >> 8);
164 __raw_readsw(alignw(___io(ptr)),buf,length);
167 static inline void outsw(u32 ptr, void *buf, int length)
169 register volatile u32 *port = (volatile u32 *)ptr;
172 * Is this cycle meant for the CS8900?
174 if ((machine_is_ixdp2401() || machine_is_ixdp2801()) &&
175 (((u32)port >= (u32)IXDP2X01_CS8900_VIRT_BASE) &&
176 ((u32)port <= (u32)IXDP2X01_CS8900_VIRT_END))) {
181 tmp32 |= (*buf8++) << 8;
187 __raw_writesw(alignw(___io(ptr)),buf,length);
191 static inline u16 inw(u32 ptr)
193 register volatile u32 *port = (volatile u32 *)ptr;
196 * Is this cycle meant for the CS8900?
198 if ((machine_is_ixdp2401() || machine_is_ixdp2801()) &&
199 (((u32)port >= (u32)IXDP2X01_CS8900_VIRT_BASE) &&
200 ((u32)port <= (u32)IXDP2X01_CS8900_VIRT_END))) {
204 return __raw_readw(alignw(___io(ptr)));
207 static inline void outw(u16 value, u32 ptr)
209 register volatile u32 *port = (volatile u32 *)ptr;
211 if ((machine_is_ixdp2401() || machine_is_ixdp2801()) &&
212 (((u32)port >= (u32)IXDP2X01_CS8900_VIRT_BASE) &&
213 ((u32)port <= (u32)IXDP2X01_CS8900_VIRT_END))) {
218 __raw_writew((value),alignw(___io(ptr)));
220 #endif /* IXDP2x01 */