blob: c06d4a2911a69a69f3b1a0876496f2e005d2cafc [file] [log] [blame]
Russell Kinga09e64f2008-08-05 16:14:15 +01001/*
2 * arch/arm/mach-ixp4xx/include/mach/io.h
3 *
4 * Author: Deepak Saxena <dsaxena@plexity.net>
5 *
6 * Copyright (C) 2002-2005 MontaVista Software, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __ASM_ARM_ARCH_IO_H
14#define __ASM_ARM_ARCH_IO_H
15
16#include <linux/bitops.h>
17
18#include <mach/hardware.h>
19
Mikael Petterssondee2b902009-08-09 21:21:57 +020020#define IO_SPACE_LIMIT 0x0000ffff
Russell Kinga09e64f2008-08-05 16:14:15 +010021
22extern int (*ixp4xx_pci_read)(u32 addr, u32 cmd, u32* data);
23extern int ixp4xx_pci_write(u32 addr, u32 cmd, u32 data);
24
25
26/*
27 * IXP4xx provides two methods of accessing PCI memory space:
28 *
29 * 1) A direct mapped window from 0x48000000 to 0x4bffffff (64MB).
30 * To access PCI via this space, we simply ioremap() the BAR
31 * into the kernel and we can use the standard read[bwl]/write[bwl]
32 * macros. This is the preffered method due to speed but it
33 * limits the system to just 64MB of PCI memory. This can be
34 * problamatic if using video cards and other memory-heavy
35 * targets.
36 *
37 * 2) If > 64MB of memory space is required, the IXP4xx can be configured
38 * to use indirect registers to access PCI (as we do below for I/O
39 * transactions). This allows for up to 128MB (0x48000000 to 0x4fffffff)
40 * of memory on the bus. The disadvantage of this is that every
41 * PCI access requires three local register accesses plus a spinlock,
42 * but in some cases the performance hit is acceptable. In addition,
43 * you cannot mmap() PCI devices in this case.
44 *
45 */
46#ifndef CONFIG_IXP4XX_INDIRECT_PCI
47
48#define __mem_pci(a) (a)
49
50#else
51
Russell Kinga09e64f2008-08-05 16:14:15 +010052/*
53 * In the case of using indirect PCI, we simply return the actual PCI
54 * address and our read/write implementation use that to drive the
55 * access registers. If something outside of PCI is ioremap'd, we
56 * fallback to the default.
57 */
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +010058static inline void __iomem * __indirect_ioremap(unsigned long addr, size_t size,
59 unsigned int mtype)
Russell Kinga09e64f2008-08-05 16:14:15 +010060{
61 if((addr < PCIBIOS_MIN_MEM) || (addr > 0x4fffffff))
62 return __arm_ioremap(addr, size, mtype);
63
64 return (void __iomem *)addr;
65}
66
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +010067static inline void __indirect_iounmap(void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +010068{
69 if ((__force u32)addr >= VMALLOC_START)
70 __iounmap(addr);
71}
72
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +010073#define __arch_ioremap(a, s, f) __indirect_ioremap(a, s, f)
74#define __arch_iounmap(a) __indirect_iounmap(a)
Russell Kinga09e64f2008-08-05 16:14:15 +010075
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +010076#define writeb(v, p) __indirect_writeb(v, p)
77#define writew(v, p) __indirect_writew(v, p)
78#define writel(v, p) __indirect_writel(v, p)
Russell Kinga09e64f2008-08-05 16:14:15 +010079
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +010080#define writesb(p, v, l) __indirect_writesb(p, v, l)
81#define writesw(p, v, l) __indirect_writesw(p, v, l)
82#define writesl(p, v, l) __indirect_writesl(p, v, l)
Russell Kinga09e64f2008-08-05 16:14:15 +010083
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +010084#define readb(p) __indirect_readb(p)
85#define readw(p) __indirect_readw(p)
86#define readl(p) __indirect_readl(p)
87
88#define readsb(p, v, l) __indirect_readsb(p, v, l)
89#define readsw(p, v, l) __indirect_readsw(p, v, l)
90#define readsl(p, v, l) __indirect_readsl(p, v, l)
91
92static inline void __indirect_writeb(u8 value, volatile void __iomem *p)
Russell Kinga09e64f2008-08-05 16:14:15 +010093{
94 u32 addr = (u32)p;
95 u32 n, byte_enables, data;
96
97 if (addr >= VMALLOC_START) {
98 __raw_writeb(value, addr);
99 return;
100 }
101
102 n = addr % 4;
103 byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL;
104 data = value << (8*n);
105 ixp4xx_pci_write(addr, byte_enables | NP_CMD_MEMWRITE, data);
106}
107
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100108static inline void __indirect_writesb(volatile void __iomem *bus_addr,
109 const u8 *vaddr, int count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100110{
111 while (count--)
112 writeb(*vaddr++, bus_addr);
113}
114
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100115static inline void __indirect_writew(u16 value, volatile void __iomem *p)
Russell Kinga09e64f2008-08-05 16:14:15 +0100116{
117 u32 addr = (u32)p;
118 u32 n, byte_enables, data;
119
120 if (addr >= VMALLOC_START) {
121 __raw_writew(value, addr);
122 return;
123 }
124
125 n = addr % 4;
126 byte_enables = (0xf & ~(BIT(n) | BIT(n+1))) << IXP4XX_PCI_NP_CBE_BESL;
127 data = value << (8*n);
128 ixp4xx_pci_write(addr, byte_enables | NP_CMD_MEMWRITE, data);
129}
130
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100131static inline void __indirect_writesw(volatile void __iomem *bus_addr,
132 const u16 *vaddr, int count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100133{
134 while (count--)
135 writew(*vaddr++, bus_addr);
136}
137
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100138static inline void __indirect_writel(u32 value, volatile void __iomem *p)
Russell Kinga09e64f2008-08-05 16:14:15 +0100139{
140 u32 addr = (__force u32)p;
141 if (addr >= VMALLOC_START) {
142 __raw_writel(value, p);
143 return;
144 }
145
146 ixp4xx_pci_write(addr, NP_CMD_MEMWRITE, value);
147}
148
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100149static inline void __indirect_writesl(volatile void __iomem *bus_addr,
150 const u32 *vaddr, int count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100151{
152 while (count--)
153 writel(*vaddr++, bus_addr);
154}
155
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100156static inline unsigned char __indirect_readb(const volatile void __iomem *p)
Russell Kinga09e64f2008-08-05 16:14:15 +0100157{
158 u32 addr = (u32)p;
159 u32 n, byte_enables, data;
160
161 if (addr >= VMALLOC_START)
162 return __raw_readb(addr);
163
164 n = addr % 4;
165 byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL;
166 if (ixp4xx_pci_read(addr, byte_enables | NP_CMD_MEMREAD, &data))
167 return 0xff;
168
169 return data >> (8*n);
170}
171
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100172static inline void __indirect_readsb(const volatile void __iomem *bus_addr,
173 u8 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100174{
175 while (count--)
176 *vaddr++ = readb(bus_addr);
177}
178
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100179static inline unsigned short __indirect_readw(const volatile void __iomem *p)
Russell Kinga09e64f2008-08-05 16:14:15 +0100180{
181 u32 addr = (u32)p;
182 u32 n, byte_enables, data;
183
184 if (addr >= VMALLOC_START)
185 return __raw_readw(addr);
186
187 n = addr % 4;
188 byte_enables = (0xf & ~(BIT(n) | BIT(n+1))) << IXP4XX_PCI_NP_CBE_BESL;
189 if (ixp4xx_pci_read(addr, byte_enables | NP_CMD_MEMREAD, &data))
190 return 0xffff;
191
192 return data>>(8*n);
193}
194
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100195static inline void __indirect_readsw(const volatile void __iomem *bus_addr,
196 u16 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100197{
198 while (count--)
199 *vaddr++ = readw(bus_addr);
200}
201
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100202static inline unsigned long __indirect_readl(const volatile void __iomem *p)
Russell Kinga09e64f2008-08-05 16:14:15 +0100203{
204 u32 addr = (__force u32)p;
205 u32 data;
206
207 if (addr >= VMALLOC_START)
208 return __raw_readl(p);
209
210 if (ixp4xx_pci_read(addr, NP_CMD_MEMREAD, &data))
211 return 0xffffffff;
212
213 return data;
214}
215
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100216static inline void __indirect_readsl(const volatile void __iomem *bus_addr,
217 u32 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100218{
219 while (count--)
220 *vaddr++ = readl(bus_addr);
221}
222
223
224/*
225 * We can use the built-in functions b/c they end up calling writeb/readb
226 */
227#define memset_io(c,v,l) _memset_io((c),(v),(l))
228#define memcpy_fromio(a,c,l) _memcpy_fromio((a),(c),(l))
229#define memcpy_toio(c,a,l) _memcpy_toio((c),(a),(l))
230
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100231#endif /* CONFIG_IXP4XX_INDIRECT_PCI */
Russell Kinga09e64f2008-08-05 16:14:15 +0100232
233#ifndef CONFIG_PCI
234
Russell King0560cf52008-11-30 11:45:54 +0000235#define __io(v) __typesafe_io(v)
Russell Kinga09e64f2008-08-05 16:14:15 +0100236
237#else
238
239/*
240 * IXP4xx does not have a transparent cpu -> PCI I/O translation
241 * window. Instead, it has a set of registers that must be tweaked
242 * with the proper byte lanes, command types, and address for the
243 * transaction. This means that we need to override the default
244 * I/O functions.
245 */
Russell Kinga09e64f2008-08-05 16:14:15 +0100246
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100247static inline void outb(u8 value, u32 addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100248{
249 u32 n, byte_enables, data;
250 n = addr % 4;
251 byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL;
252 data = value << (8*n);
253 ixp4xx_pci_write(addr, byte_enables | NP_CMD_IOWRITE, data);
254}
255
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100256static inline void outsb(u32 io_addr, const u8 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100257{
258 while (count--)
259 outb(*vaddr++, io_addr);
260}
261
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100262static inline void outw(u16 value, u32 addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100263{
264 u32 n, byte_enables, data;
265 n = addr % 4;
266 byte_enables = (0xf & ~(BIT(n) | BIT(n+1))) << IXP4XX_PCI_NP_CBE_BESL;
267 data = value << (8*n);
268 ixp4xx_pci_write(addr, byte_enables | NP_CMD_IOWRITE, data);
269}
270
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100271static inline void outsw(u32 io_addr, const u16 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100272{
273 while (count--)
274 outw(cpu_to_le16(*vaddr++), io_addr);
275}
276
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100277static inline void outl(u32 value, u32 addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100278{
279 ixp4xx_pci_write(addr, NP_CMD_IOWRITE, value);
280}
281
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100282static inline void outsl(u32 io_addr, const u32 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100283{
284 while (count--)
Krzysztof Hałasa9f2c9492009-11-11 00:21:48 +0100285 outl(cpu_to_le32(*vaddr++), io_addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100286}
287
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100288static inline u8 inb(u32 addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100289{
290 u32 n, byte_enables, data;
291 n = addr % 4;
292 byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL;
293 if (ixp4xx_pci_read(addr, byte_enables | NP_CMD_IOREAD, &data))
294 return 0xff;
295
296 return data >> (8*n);
297}
298
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100299static inline void insb(u32 io_addr, u8 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100300{
301 while (count--)
302 *vaddr++ = inb(io_addr);
303}
304
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100305static inline u16 inw(u32 addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100306{
307 u32 n, byte_enables, data;
308 n = addr % 4;
309 byte_enables = (0xf & ~(BIT(n) | BIT(n+1))) << IXP4XX_PCI_NP_CBE_BESL;
310 if (ixp4xx_pci_read(addr, byte_enables | NP_CMD_IOREAD, &data))
311 return 0xffff;
312
313 return data>>(8*n);
314}
315
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100316static inline void insw(u32 io_addr, u16 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100317{
318 while (count--)
319 *vaddr++ = le16_to_cpu(inw(io_addr));
320}
321
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100322static inline u32 inl(u32 addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100323{
324 u32 data;
325 if (ixp4xx_pci_read(addr, NP_CMD_IOREAD, &data))
326 return 0xffffffff;
327
328 return data;
329}
330
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100331static inline void insl(u32 io_addr, u32 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100332{
333 while (count--)
Krzysztof Hałasa9f2c9492009-11-11 00:21:48 +0100334 *vaddr++ = le32_to_cpu(inl(io_addr));
Russell Kinga09e64f2008-08-05 16:14:15 +0100335}
336
337#define PIO_OFFSET 0x10000UL
338#define PIO_MASK 0x0ffffUL
339
340#define __is_io_address(p) (((unsigned long)p >= PIO_OFFSET) && \
341 ((unsigned long)p <= (PIO_MASK + PIO_OFFSET)))
Krzysztof Hałasa9f2c9492009-11-11 00:21:48 +0100342
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100343#define ioread8(p) ioread8(p)
344static inline unsigned int ioread8(const void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100345{
346 unsigned long port = (unsigned long __force)addr;
347 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100348 return (unsigned int)inb(port & PIO_MASK);
Russell Kinga09e64f2008-08-05 16:14:15 +0100349 else
350#ifndef CONFIG_IXP4XX_INDIRECT_PCI
351 return (unsigned int)__raw_readb(port);
352#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100353 return (unsigned int)__indirect_readb(addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100354#endif
355}
356
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100357#define ioread8_rep(p, v, c) ioread8_rep(p, v, c)
358static inline void ioread8_rep(const void __iomem *addr, void *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100359{
360 unsigned long port = (unsigned long __force)addr;
361 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100362 insb(port & PIO_MASK, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100363 else
364#ifndef CONFIG_IXP4XX_INDIRECT_PCI
365 __raw_readsb(addr, vaddr, count);
366#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100367 __indirect_readsb(addr, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100368#endif
369}
370
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100371#define ioread16(p) ioread16(p)
372static inline unsigned int ioread16(const void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100373{
374 unsigned long port = (unsigned long __force)addr;
375 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100376 return (unsigned int)inw(port & PIO_MASK);
Russell Kinga09e64f2008-08-05 16:14:15 +0100377 else
378#ifndef CONFIG_IXP4XX_INDIRECT_PCI
379 return le16_to_cpu(__raw_readw((u32)port));
380#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100381 return (unsigned int)__indirect_readw(addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100382#endif
383}
384
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100385#define ioread16_rep(p, v, c) ioread16_rep(p, v, c)
386static inline void ioread16_rep(const void __iomem *addr, void *vaddr,
387 u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100388{
389 unsigned long port = (unsigned long __force)addr;
390 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100391 insw(port & PIO_MASK, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100392 else
393#ifndef CONFIG_IXP4XX_INDIRECT_PCI
394 __raw_readsw(addr, vaddr, count);
395#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100396 __indirect_readsw(addr, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100397#endif
398}
399
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100400#define ioread32(p) ioread32(p)
401static inline unsigned int ioread32(const void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100402{
403 unsigned long port = (unsigned long __force)addr;
404 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100405 return (unsigned int)inl(port & PIO_MASK);
Russell Kinga09e64f2008-08-05 16:14:15 +0100406 else {
407#ifndef CONFIG_IXP4XX_INDIRECT_PCI
408 return le32_to_cpu((__force __le32)__raw_readl(addr));
409#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100410 return (unsigned int)__indirect_readl(addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100411#endif
412 }
413}
414
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100415#define ioread32_rep(p, v, c) ioread32_rep(p, v, c)
416static inline void ioread32_rep(const void __iomem *addr, void *vaddr,
417 u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100418{
419 unsigned long port = (unsigned long __force)addr;
420 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100421 insl(port & PIO_MASK, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100422 else
423#ifndef CONFIG_IXP4XX_INDIRECT_PCI
424 __raw_readsl(addr, vaddr, count);
425#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100426 __indirect_readsl(addr, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100427#endif
428}
429
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100430#define iowrite8(v, p) iowrite8(v, p)
431static inline void iowrite8(u8 value, void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100432{
433 unsigned long port = (unsigned long __force)addr;
434 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100435 outb(value, port & PIO_MASK);
Russell Kinga09e64f2008-08-05 16:14:15 +0100436 else
437#ifndef CONFIG_IXP4XX_INDIRECT_PCI
438 __raw_writeb(value, port);
439#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100440 __indirect_writeb(value, addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100441#endif
442}
443
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100444#define iowrite8_rep(p, v, c) iowrite8_rep(p, v, c)
445static inline void iowrite8_rep(void __iomem *addr, const void *vaddr,
446 u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100447{
448 unsigned long port = (unsigned long __force)addr;
449 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100450 outsb(port & PIO_MASK, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100451 else
452#ifndef CONFIG_IXP4XX_INDIRECT_PCI
453 __raw_writesb(addr, vaddr, count);
454#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100455 __indirect_writesb(addr, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100456#endif
457}
458
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100459#define iowrite16(v, p) iowrite16(v, p)
460static inline void iowrite16(u16 value, void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100461{
462 unsigned long port = (unsigned long __force)addr;
463 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100464 outw(value, port & PIO_MASK);
Russell Kinga09e64f2008-08-05 16:14:15 +0100465 else
466#ifndef CONFIG_IXP4XX_INDIRECT_PCI
467 __raw_writew(cpu_to_le16(value), addr);
468#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100469 __indirect_writew(value, addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100470#endif
471}
472
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100473#define iowrite16_rep(p, v, c) iowrite16_rep(p, v, c)
474static inline void iowrite16_rep(void __iomem *addr, const void *vaddr,
475 u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100476{
477 unsigned long port = (unsigned long __force)addr;
478 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100479 outsw(port & PIO_MASK, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100480 else
481#ifndef CONFIG_IXP4XX_INDIRECT_PCI
482 __raw_writesw(addr, vaddr, count);
483#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100484 __indirect_writesw(addr, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100485#endif
486}
487
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100488#define iowrite32(v, p) iowrite32(v, p)
489static inline void iowrite32(u32 value, void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100490{
491 unsigned long port = (unsigned long __force)addr;
492 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100493 outl(value, port & PIO_MASK);
Russell Kinga09e64f2008-08-05 16:14:15 +0100494 else
495#ifndef CONFIG_IXP4XX_INDIRECT_PCI
496 __raw_writel((u32 __force)cpu_to_le32(value), addr);
497#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100498 __indirect_writel(value, addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100499#endif
500}
501
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100502#define iowrite32_rep(p, v, c) iowrite32_rep(p, v, c)
503static inline void iowrite32_rep(void __iomem *addr, const void *vaddr,
504 u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100505{
506 unsigned long port = (unsigned long __force)addr;
507 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100508 outsl(port & PIO_MASK, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100509 else
510#ifndef CONFIG_IXP4XX_INDIRECT_PCI
511 __raw_writesl(addr, vaddr, count);
512#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100513 __indirect_writesl(addr, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100514#endif
515}
516
Russell Kinga09e64f2008-08-05 16:14:15 +0100517#define ioport_map(port, nr) ((void __iomem*)(port + PIO_OFFSET))
518#define ioport_unmap(addr)
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100519#endif /* CONFIG_PCI */
Russell Kinga09e64f2008-08-05 16:14:15 +0100520
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100521#endif /* __ASM_ARM_ARCH_IO_H */