[PATCH] w1: Adds a sysfs entry (w1_master_search) that allows you to disable/enable...
[linux-2.6/verdex.git] / include / asm-arm / arch-ixp2000 / io.h
blob083462668e184a8953ef49ed8eb9753c38d35d24
1 /*
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
28 * things manually.
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; })
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 easily
57 * make it contiguous 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 (((u32)port >= (u32)IXDP2X01_CS8900_VIRT_BASE) &&
79 ((u32)port <= (u32)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 (((u32)port >= (u32)IXDP2X01_CS8900_VIRT_BASE) &&
104 ((u32)port <= (u32)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 (((u32)port >= (u32)IXDP2X01_CS8900_VIRT_BASE) &&
128 ((u32)port <= (u32)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 (((u32)port >= (u32)IXDP2X01_CS8900_VIRT_BASE) &&
141 ((u32)port <= (u32)IXDP2X01_CS8900_VIRT_END))) {
142 *port = value;
143 return;
146 __raw_writew((value),alignw(___io(ptr)));
148 #endif /* IXDP2x01 */
150 #endif