GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / arm / mach-ebsa110 / io.c
blob62b3fb29bf17de6db65342bd8bffe2e1efa64b99
2 #include <linux/module.h>
3 #include <linux/kernel.h>
4 #include <linux/types.h>
5 #include <linux/io.h>
7 #include <mach/hardware.h>
8 #include <asm/page.h>
10 static void __iomem *__isamem_convert_addr(const volatile void __iomem *addr)
12 u32 ret, a = (u32 __force) addr;
15 * The PCMCIA controller is wired up as follows:
16 * +---------+---------+---------+---------+---------+---------+
17 * PCMCIA | 2 2 2 2 | 1 1 1 1 | 1 1 1 1 | 1 1 | | |
18 * | 3 2 1 0 | 9 8 7 6 | 5 4 3 2 | 1 0 9 8 | 7 6 5 4 | 3 2 1 0 |
19 * +---------+---------+---------+---------+---------+---------+
20 * CPU | 2 2 2 2 | 2 1 1 1 | 1 1 1 1 | 1 1 1 | | |
21 * | 4 3 2 1 | 0 9 9 8 | 7 6 5 4 | 3 2 0 9 | 8 7 6 5 | 4 3 2 x |
22 * +---------+---------+---------+---------+---------+---------+
24 * This means that we can access PCMCIA regions as follows:
25 * 0x*10000 -> 0x*1ffff
26 * 0x*70000 -> 0x*7ffff
27 * 0x*90000 -> 0x*9ffff
28 * 0x*f0000 -> 0x*fffff
30 ret = (a & 0xf803fe) << 1;
31 ret |= (a & 0x03fc00) << 2;
33 ret += 0xe8000000;
35 if ((a & 0x20000) == (a & 0x40000) >> 1)
36 return (void __iomem *)ret;
38 BUG();
39 return NULL;
43 * read[bwl] and write[bwl]
45 u8 __readb(const volatile void __iomem *addr)
47 void __iomem *a = __isamem_convert_addr(addr);
48 u32 ret;
50 if ((unsigned long)addr & 1)
51 ret = __raw_readl(a);
52 else
53 ret = __raw_readb(a);
54 return ret;
57 u16 __readw(const volatile void __iomem *addr)
59 void __iomem *a = __isamem_convert_addr(addr);
61 if ((unsigned long)addr & 1)
62 BUG();
64 return __raw_readw(a);
67 u32 __readl(const volatile void __iomem *addr)
69 void __iomem *a = __isamem_convert_addr(addr);
70 u32 ret;
72 if ((unsigned long)addr & 3)
73 BUG();
75 ret = __raw_readw(a);
76 ret |= __raw_readw(a + 4) << 16;
77 return ret;
80 EXPORT_SYMBOL(__readb);
81 EXPORT_SYMBOL(__readw);
82 EXPORT_SYMBOL(__readl);
84 void readsw(const void __iomem *addr, void *data, int len)
86 void __iomem *a = __isamem_convert_addr(addr);
88 BUG_ON((unsigned long)addr & 1);
90 __raw_readsw(a, data, len);
92 EXPORT_SYMBOL(readsw);
94 void readsl(const void __iomem *addr, void *data, int len)
96 void __iomem *a = __isamem_convert_addr(addr);
98 BUG_ON((unsigned long)addr & 3);
100 __raw_readsl(a, data, len);
102 EXPORT_SYMBOL(readsl);
104 void __writeb(u8 val, void __iomem *addr)
106 void __iomem *a = __isamem_convert_addr(addr);
108 if ((unsigned long)addr & 1)
109 __raw_writel(val, a);
110 else
111 __raw_writeb(val, a);
114 void __writew(u16 val, void __iomem *addr)
116 void __iomem *a = __isamem_convert_addr(addr);
118 if ((unsigned long)addr & 1)
119 BUG();
121 __raw_writew(val, a);
124 void __writel(u32 val, void __iomem *addr)
126 void __iomem *a = __isamem_convert_addr(addr);
128 if ((unsigned long)addr & 3)
129 BUG();
131 __raw_writew(val, a);
132 __raw_writew(val >> 16, a + 4);
135 EXPORT_SYMBOL(__writeb);
136 EXPORT_SYMBOL(__writew);
137 EXPORT_SYMBOL(__writel);
139 void writesw(void __iomem *addr, const void *data, int len)
141 void __iomem *a = __isamem_convert_addr(addr);
143 BUG_ON((unsigned long)addr & 1);
145 __raw_writesw(a, data, len);
147 EXPORT_SYMBOL(writesw);
149 void writesl(void __iomem *addr, const void *data, int len)
151 void __iomem *a = __isamem_convert_addr(addr);
153 BUG_ON((unsigned long)addr & 3);
155 __raw_writesl(a, data, len);
157 EXPORT_SYMBOL(writesl);
159 #define SUPERIO_PORT(p) \
160 (((p) >> 3) == (0x3f8 >> 3) || \
161 ((p) >> 3) == (0x2f8 >> 3) || \
162 ((p) >> 3) == (0x378 >> 3))
165 * We're addressing an 8 or 16-bit peripheral which tranfers
166 * odd addresses on the low ISA byte lane.
168 u8 __inb8(unsigned int port)
170 u32 ret;
173 * The SuperIO registers use sane addressing techniques...
175 if (SUPERIO_PORT(port))
176 ret = __raw_readb((void __iomem *)ISAIO_BASE + (port << 2));
177 else {
178 void __iomem *a = (void __iomem *)ISAIO_BASE + ((port & ~1) << 1);
181 * Shame nothing else does
183 if (port & 1)
184 ret = __raw_readl(a);
185 else
186 ret = __raw_readb(a);
188 return ret;
192 * We're addressing a 16-bit peripheral which transfers odd
193 * addresses on the high ISA byte lane.
195 u8 __inb16(unsigned int port)
197 unsigned int offset;
200 * The SuperIO registers use sane addressing techniques...
202 if (SUPERIO_PORT(port))
203 offset = port << 2;
204 else
205 offset = (port & ~1) << 1 | (port & 1);
207 return __raw_readb((void __iomem *)ISAIO_BASE + offset);
210 u16 __inw(unsigned int port)
212 unsigned int offset;
215 * The SuperIO registers use sane addressing techniques...
217 if (SUPERIO_PORT(port))
218 offset = port << 2;
219 else {
220 offset = port << 1;
221 BUG_ON(port & 1);
223 return __raw_readw((void __iomem *)ISAIO_BASE + offset);
227 * Fake a 32-bit read with two 16-bit reads. Needed for 3c589.
229 u32 __inl(unsigned int port)
231 void __iomem *a;
233 if (SUPERIO_PORT(port) || port & 3)
234 BUG();
236 a = (void __iomem *)ISAIO_BASE + ((port & ~1) << 1);
238 return __raw_readw(a) | __raw_readw(a + 4) << 16;
241 EXPORT_SYMBOL(__inb8);
242 EXPORT_SYMBOL(__inb16);
243 EXPORT_SYMBOL(__inw);
244 EXPORT_SYMBOL(__inl);
246 void __outb8(u8 val, unsigned int port)
249 * The SuperIO registers use sane addressing techniques...
251 if (SUPERIO_PORT(port))
252 __raw_writeb(val, (void __iomem *)ISAIO_BASE + (port << 2));
253 else {
254 void __iomem *a = (void __iomem *)ISAIO_BASE + ((port & ~1) << 1);
257 * Shame nothing else does
259 if (port & 1)
260 __raw_writel(val, a);
261 else
262 __raw_writeb(val, a);
266 void __outb16(u8 val, unsigned int port)
268 unsigned int offset;
271 * The SuperIO registers use sane addressing techniques...
273 if (SUPERIO_PORT(port))
274 offset = port << 2;
275 else
276 offset = (port & ~1) << 1 | (port & 1);
278 __raw_writeb(val, (void __iomem *)ISAIO_BASE + offset);
281 void __outw(u16 val, unsigned int port)
283 unsigned int offset;
286 * The SuperIO registers use sane addressing techniques...
288 if (SUPERIO_PORT(port))
289 offset = port << 2;
290 else {
291 offset = port << 1;
292 BUG_ON(port & 1);
294 __raw_writew(val, (void __iomem *)ISAIO_BASE + offset);
297 void __outl(u32 val, unsigned int port)
299 BUG();
302 EXPORT_SYMBOL(__outb8);
303 EXPORT_SYMBOL(__outb16);
304 EXPORT_SYMBOL(__outw);
305 EXPORT_SYMBOL(__outl);
307 void outsb(unsigned int port, const void *from, int len)
309 u32 off;
311 if (SUPERIO_PORT(port))
312 off = port << 2;
313 else {
314 off = (port & ~1) << 1;
315 if (port & 1)
316 BUG();
319 __raw_writesb((void __iomem *)ISAIO_BASE + off, from, len);
322 void insb(unsigned int port, void *from, int len)
324 u32 off;
326 if (SUPERIO_PORT(port))
327 off = port << 2;
328 else {
329 off = (port & ~1) << 1;
330 if (port & 1)
331 BUG();
334 __raw_readsb((void __iomem *)ISAIO_BASE + off, from, len);
337 EXPORT_SYMBOL(outsb);
338 EXPORT_SYMBOL(insb);
340 void outsw(unsigned int port, const void *from, int len)
342 u32 off;
344 if (SUPERIO_PORT(port))
345 off = port << 2;
346 else {
347 off = (port & ~1) << 1;
348 if (port & 1)
349 BUG();
352 __raw_writesw((void __iomem *)ISAIO_BASE + off, from, len);
355 void insw(unsigned int port, void *from, int len)
357 u32 off;
359 if (SUPERIO_PORT(port))
360 off = port << 2;
361 else {
362 off = (port & ~1) << 1;
363 if (port & 1)
364 BUG();
367 __raw_readsw((void __iomem *)ISAIO_BASE + off, from, len);
370 EXPORT_SYMBOL(outsw);
371 EXPORT_SYMBOL(insw);
374 * We implement these as 16-bit insw/outsw, mainly for
375 * 3c589 cards.
377 void outsl(unsigned int port, const void *from, int len)
379 u32 off = port << 1;
381 if (SUPERIO_PORT(port) || port & 3)
382 BUG();
384 __raw_writesw((void __iomem *)ISAIO_BASE + off, from, len << 1);
387 void insl(unsigned int port, void *from, int len)
389 u32 off = port << 1;
391 if (SUPERIO_PORT(port) || port & 3)
392 BUG();
394 __raw_readsw((void __iomem *)ISAIO_BASE + off, from, len << 1);
397 EXPORT_SYMBOL(outsl);
398 EXPORT_SYMBOL(insl);