blob: 0e601fe50162bebed52dc0bd8e35863ad2e60c0f [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łasacba36222009-11-15 01:25:06 +010058
59static inline int is_pci_memory(u32 addr)
60{
61 return (addr >= PCIBIOS_MIN_MEM) && (addr <= 0x4FFFFFFF);
62}
63
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +010064static inline void __iomem * __indirect_ioremap(unsigned long addr, size_t size,
65 unsigned int mtype)
Russell Kinga09e64f2008-08-05 16:14:15 +010066{
Krzysztof Hałasacba36222009-11-15 01:25:06 +010067 if (!is_pci_memory(addr))
Russell Kinga09e64f2008-08-05 16:14:15 +010068 return __arm_ioremap(addr, size, mtype);
69
70 return (void __iomem *)addr;
71}
72
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +010073static inline void __indirect_iounmap(void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +010074{
Krzysztof Hałasacba36222009-11-15 01:25:06 +010075 if (!is_pci_memory((__force u32)addr))
Russell Kinga09e64f2008-08-05 16:14:15 +010076 __iounmap(addr);
77}
78
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +010079#define __arch_ioremap(a, s, f) __indirect_ioremap(a, s, f)
80#define __arch_iounmap(a) __indirect_iounmap(a)
Russell Kinga09e64f2008-08-05 16:14:15 +010081
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +010082#define writeb(v, p) __indirect_writeb(v, p)
83#define writew(v, p) __indirect_writew(v, p)
84#define writel(v, p) __indirect_writel(v, p)
Russell Kinga09e64f2008-08-05 16:14:15 +010085
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +010086#define writesb(p, v, l) __indirect_writesb(p, v, l)
87#define writesw(p, v, l) __indirect_writesw(p, v, l)
88#define writesl(p, v, l) __indirect_writesl(p, v, l)
Russell Kinga09e64f2008-08-05 16:14:15 +010089
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +010090#define readb(p) __indirect_readb(p)
91#define readw(p) __indirect_readw(p)
92#define readl(p) __indirect_readl(p)
93
94#define readsb(p, v, l) __indirect_readsb(p, v, l)
95#define readsw(p, v, l) __indirect_readsw(p, v, l)
96#define readsl(p, v, l) __indirect_readsl(p, v, l)
97
98static inline void __indirect_writeb(u8 value, volatile void __iomem *p)
Russell Kinga09e64f2008-08-05 16:14:15 +010099{
100 u32 addr = (u32)p;
101 u32 n, byte_enables, data;
102
Krzysztof Hałasacba36222009-11-15 01:25:06 +0100103 if (!is_pci_memory(addr)) {
Russell Kinga09e64f2008-08-05 16:14:15 +0100104 __raw_writeb(value, addr);
105 return;
106 }
107
108 n = addr % 4;
109 byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL;
110 data = value << (8*n);
111 ixp4xx_pci_write(addr, byte_enables | NP_CMD_MEMWRITE, data);
112}
113
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100114static inline void __indirect_writesb(volatile void __iomem *bus_addr,
115 const u8 *vaddr, int count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100116{
117 while (count--)
118 writeb(*vaddr++, bus_addr);
119}
120
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100121static inline void __indirect_writew(u16 value, volatile void __iomem *p)
Russell Kinga09e64f2008-08-05 16:14:15 +0100122{
123 u32 addr = (u32)p;
124 u32 n, byte_enables, data;
125
Krzysztof Hałasacba36222009-11-15 01:25:06 +0100126 if (!is_pci_memory(addr)) {
Russell Kinga09e64f2008-08-05 16:14:15 +0100127 __raw_writew(value, addr);
128 return;
129 }
130
131 n = addr % 4;
132 byte_enables = (0xf & ~(BIT(n) | BIT(n+1))) << IXP4XX_PCI_NP_CBE_BESL;
133 data = value << (8*n);
134 ixp4xx_pci_write(addr, byte_enables | NP_CMD_MEMWRITE, data);
135}
136
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100137static inline void __indirect_writesw(volatile void __iomem *bus_addr,
138 const u16 *vaddr, int count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100139{
140 while (count--)
141 writew(*vaddr++, bus_addr);
142}
143
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100144static inline void __indirect_writel(u32 value, volatile void __iomem *p)
Russell Kinga09e64f2008-08-05 16:14:15 +0100145{
146 u32 addr = (__force u32)p;
Krzysztof Hałasacba36222009-11-15 01:25:06 +0100147
148 if (!is_pci_memory(addr)) {
Russell Kinga09e64f2008-08-05 16:14:15 +0100149 __raw_writel(value, p);
150 return;
151 }
152
153 ixp4xx_pci_write(addr, NP_CMD_MEMWRITE, value);
154}
155
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100156static inline void __indirect_writesl(volatile void __iomem *bus_addr,
157 const u32 *vaddr, int count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100158{
159 while (count--)
160 writel(*vaddr++, bus_addr);
161}
162
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100163static inline unsigned char __indirect_readb(const volatile void __iomem *p)
Russell Kinga09e64f2008-08-05 16:14:15 +0100164{
165 u32 addr = (u32)p;
166 u32 n, byte_enables, data;
167
Krzysztof Hałasacba36222009-11-15 01:25:06 +0100168 if (!is_pci_memory(addr))
Russell Kinga09e64f2008-08-05 16:14:15 +0100169 return __raw_readb(addr);
170
171 n = addr % 4;
172 byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL;
173 if (ixp4xx_pci_read(addr, byte_enables | NP_CMD_MEMREAD, &data))
174 return 0xff;
175
176 return data >> (8*n);
177}
178
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100179static inline void __indirect_readsb(const volatile void __iomem *bus_addr,
180 u8 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100181{
182 while (count--)
183 *vaddr++ = readb(bus_addr);
184}
185
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100186static inline unsigned short __indirect_readw(const volatile void __iomem *p)
Russell Kinga09e64f2008-08-05 16:14:15 +0100187{
188 u32 addr = (u32)p;
189 u32 n, byte_enables, data;
190
Krzysztof Hałasacba36222009-11-15 01:25:06 +0100191 if (!is_pci_memory(addr))
Russell Kinga09e64f2008-08-05 16:14:15 +0100192 return __raw_readw(addr);
193
194 n = addr % 4;
195 byte_enables = (0xf & ~(BIT(n) | BIT(n+1))) << IXP4XX_PCI_NP_CBE_BESL;
196 if (ixp4xx_pci_read(addr, byte_enables | NP_CMD_MEMREAD, &data))
197 return 0xffff;
198
199 return data>>(8*n);
200}
201
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100202static inline void __indirect_readsw(const volatile void __iomem *bus_addr,
203 u16 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100204{
205 while (count--)
206 *vaddr++ = readw(bus_addr);
207}
208
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100209static inline unsigned long __indirect_readl(const volatile void __iomem *p)
Russell Kinga09e64f2008-08-05 16:14:15 +0100210{
211 u32 addr = (__force u32)p;
212 u32 data;
213
Krzysztof Hałasacba36222009-11-15 01:25:06 +0100214 if (!is_pci_memory(addr))
Russell Kinga09e64f2008-08-05 16:14:15 +0100215 return __raw_readl(p);
216
217 if (ixp4xx_pci_read(addr, NP_CMD_MEMREAD, &data))
218 return 0xffffffff;
219
220 return data;
221}
222
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100223static inline void __indirect_readsl(const volatile void __iomem *bus_addr,
224 u32 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100225{
226 while (count--)
227 *vaddr++ = readl(bus_addr);
228}
229
230
231/*
232 * We can use the built-in functions b/c they end up calling writeb/readb
233 */
234#define memset_io(c,v,l) _memset_io((c),(v),(l))
235#define memcpy_fromio(a,c,l) _memcpy_fromio((a),(c),(l))
236#define memcpy_toio(c,a,l) _memcpy_toio((c),(a),(l))
237
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100238#endif /* CONFIG_IXP4XX_INDIRECT_PCI */
Russell Kinga09e64f2008-08-05 16:14:15 +0100239
240#ifndef CONFIG_PCI
241
Russell King0560cf52008-11-30 11:45:54 +0000242#define __io(v) __typesafe_io(v)
Russell Kinga09e64f2008-08-05 16:14:15 +0100243
244#else
245
246/*
247 * IXP4xx does not have a transparent cpu -> PCI I/O translation
248 * window. Instead, it has a set of registers that must be tweaked
249 * with the proper byte lanes, command types, and address for the
250 * transaction. This means that we need to override the default
251 * I/O functions.
252 */
Russell Kinga09e64f2008-08-05 16:14:15 +0100253
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100254static inline void outb(u8 value, u32 addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100255{
256 u32 n, byte_enables, data;
257 n = addr % 4;
258 byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL;
259 data = value << (8*n);
260 ixp4xx_pci_write(addr, byte_enables | NP_CMD_IOWRITE, data);
261}
262
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100263static inline void outsb(u32 io_addr, const u8 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100264{
265 while (count--)
266 outb(*vaddr++, io_addr);
267}
268
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100269static inline void outw(u16 value, u32 addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100270{
271 u32 n, byte_enables, data;
272 n = addr % 4;
273 byte_enables = (0xf & ~(BIT(n) | BIT(n+1))) << IXP4XX_PCI_NP_CBE_BESL;
274 data = value << (8*n);
275 ixp4xx_pci_write(addr, byte_enables | NP_CMD_IOWRITE, data);
276}
277
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100278static inline void outsw(u32 io_addr, const u16 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100279{
280 while (count--)
281 outw(cpu_to_le16(*vaddr++), io_addr);
282}
283
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100284static inline void outl(u32 value, u32 addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100285{
286 ixp4xx_pci_write(addr, NP_CMD_IOWRITE, value);
287}
288
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100289static inline void outsl(u32 io_addr, const u32 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100290{
291 while (count--)
Krzysztof Hałasa9f2c9492009-11-11 00:21:48 +0100292 outl(cpu_to_le32(*vaddr++), io_addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100293}
294
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100295static inline u8 inb(u32 addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100296{
297 u32 n, byte_enables, data;
298 n = addr % 4;
299 byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL;
300 if (ixp4xx_pci_read(addr, byte_enables | NP_CMD_IOREAD, &data))
301 return 0xff;
302
303 return data >> (8*n);
304}
305
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100306static inline void insb(u32 io_addr, u8 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100307{
308 while (count--)
309 *vaddr++ = inb(io_addr);
310}
311
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100312static inline u16 inw(u32 addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100313{
314 u32 n, byte_enables, data;
315 n = addr % 4;
316 byte_enables = (0xf & ~(BIT(n) | BIT(n+1))) << IXP4XX_PCI_NP_CBE_BESL;
317 if (ixp4xx_pci_read(addr, byte_enables | NP_CMD_IOREAD, &data))
318 return 0xffff;
319
320 return data>>(8*n);
321}
322
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100323static inline void insw(u32 io_addr, u16 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100324{
325 while (count--)
326 *vaddr++ = le16_to_cpu(inw(io_addr));
327}
328
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100329static inline u32 inl(u32 addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100330{
331 u32 data;
332 if (ixp4xx_pci_read(addr, NP_CMD_IOREAD, &data))
333 return 0xffffffff;
334
335 return data;
336}
337
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100338static inline void insl(u32 io_addr, u32 *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100339{
340 while (count--)
Krzysztof Hałasa9f2c9492009-11-11 00:21:48 +0100341 *vaddr++ = le32_to_cpu(inl(io_addr));
Russell Kinga09e64f2008-08-05 16:14:15 +0100342}
343
344#define PIO_OFFSET 0x10000UL
345#define PIO_MASK 0x0ffffUL
346
347#define __is_io_address(p) (((unsigned long)p >= PIO_OFFSET) && \
348 ((unsigned long)p <= (PIO_MASK + PIO_OFFSET)))
Krzysztof Hałasa9f2c9492009-11-11 00:21:48 +0100349
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100350#define ioread8(p) ioread8(p)
351static inline unsigned int ioread8(const void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100352{
353 unsigned long port = (unsigned long __force)addr;
354 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100355 return (unsigned int)inb(port & PIO_MASK);
Russell Kinga09e64f2008-08-05 16:14:15 +0100356 else
357#ifndef CONFIG_IXP4XX_INDIRECT_PCI
358 return (unsigned int)__raw_readb(port);
359#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100360 return (unsigned int)__indirect_readb(addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100361#endif
362}
363
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100364#define ioread8_rep(p, v, c) ioread8_rep(p, v, c)
365static inline void ioread8_rep(const void __iomem *addr, void *vaddr, u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100366{
367 unsigned long port = (unsigned long __force)addr;
368 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100369 insb(port & PIO_MASK, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100370 else
371#ifndef CONFIG_IXP4XX_INDIRECT_PCI
372 __raw_readsb(addr, vaddr, count);
373#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100374 __indirect_readsb(addr, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100375#endif
376}
377
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100378#define ioread16(p) ioread16(p)
379static inline unsigned int ioread16(const void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100380{
381 unsigned long port = (unsigned long __force)addr;
382 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100383 return (unsigned int)inw(port & PIO_MASK);
Russell Kinga09e64f2008-08-05 16:14:15 +0100384 else
385#ifndef CONFIG_IXP4XX_INDIRECT_PCI
386 return le16_to_cpu(__raw_readw((u32)port));
387#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100388 return (unsigned int)__indirect_readw(addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100389#endif
390}
391
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100392#define ioread16_rep(p, v, c) ioread16_rep(p, v, c)
393static inline void ioread16_rep(const void __iomem *addr, void *vaddr,
394 u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100395{
396 unsigned long port = (unsigned long __force)addr;
397 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100398 insw(port & PIO_MASK, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100399 else
400#ifndef CONFIG_IXP4XX_INDIRECT_PCI
401 __raw_readsw(addr, vaddr, count);
402#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100403 __indirect_readsw(addr, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100404#endif
405}
406
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100407#define ioread32(p) ioread32(p)
408static inline unsigned int ioread32(const void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100409{
410 unsigned long port = (unsigned long __force)addr;
411 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100412 return (unsigned int)inl(port & PIO_MASK);
Russell Kinga09e64f2008-08-05 16:14:15 +0100413 else {
414#ifndef CONFIG_IXP4XX_INDIRECT_PCI
415 return le32_to_cpu((__force __le32)__raw_readl(addr));
416#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100417 return (unsigned int)__indirect_readl(addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100418#endif
419 }
420}
421
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100422#define ioread32_rep(p, v, c) ioread32_rep(p, v, c)
423static inline void ioread32_rep(const void __iomem *addr, void *vaddr,
424 u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100425{
426 unsigned long port = (unsigned long __force)addr;
427 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100428 insl(port & PIO_MASK, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100429 else
430#ifndef CONFIG_IXP4XX_INDIRECT_PCI
431 __raw_readsl(addr, vaddr, count);
432#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100433 __indirect_readsl(addr, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100434#endif
435}
436
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100437#define iowrite8(v, p) iowrite8(v, p)
438static inline void iowrite8(u8 value, void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100439{
440 unsigned long port = (unsigned long __force)addr;
441 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100442 outb(value, port & PIO_MASK);
Russell Kinga09e64f2008-08-05 16:14:15 +0100443 else
444#ifndef CONFIG_IXP4XX_INDIRECT_PCI
445 __raw_writeb(value, port);
446#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100447 __indirect_writeb(value, addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100448#endif
449}
450
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100451#define iowrite8_rep(p, v, c) iowrite8_rep(p, v, c)
452static inline void iowrite8_rep(void __iomem *addr, const void *vaddr,
453 u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100454{
455 unsigned long port = (unsigned long __force)addr;
456 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100457 outsb(port & PIO_MASK, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100458 else
459#ifndef CONFIG_IXP4XX_INDIRECT_PCI
460 __raw_writesb(addr, vaddr, count);
461#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100462 __indirect_writesb(addr, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100463#endif
464}
465
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100466#define iowrite16(v, p) iowrite16(v, p)
467static inline void iowrite16(u16 value, void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100468{
469 unsigned long port = (unsigned long __force)addr;
470 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100471 outw(value, port & PIO_MASK);
Russell Kinga09e64f2008-08-05 16:14:15 +0100472 else
473#ifndef CONFIG_IXP4XX_INDIRECT_PCI
474 __raw_writew(cpu_to_le16(value), addr);
475#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100476 __indirect_writew(value, addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100477#endif
478}
479
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100480#define iowrite16_rep(p, v, c) iowrite16_rep(p, v, c)
481static inline void iowrite16_rep(void __iomem *addr, const void *vaddr,
482 u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100483{
484 unsigned long port = (unsigned long __force)addr;
485 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100486 outsw(port & PIO_MASK, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100487 else
488#ifndef CONFIG_IXP4XX_INDIRECT_PCI
489 __raw_writesw(addr, vaddr, count);
490#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100491 __indirect_writesw(addr, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100492#endif
493}
494
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100495#define iowrite32(v, p) iowrite32(v, p)
496static inline void iowrite32(u32 value, void __iomem *addr)
Russell Kinga09e64f2008-08-05 16:14:15 +0100497{
498 unsigned long port = (unsigned long __force)addr;
499 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100500 outl(value, port & PIO_MASK);
Russell Kinga09e64f2008-08-05 16:14:15 +0100501 else
502#ifndef CONFIG_IXP4XX_INDIRECT_PCI
503 __raw_writel((u32 __force)cpu_to_le32(value), addr);
504#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100505 __indirect_writel(value, addr);
Russell Kinga09e64f2008-08-05 16:14:15 +0100506#endif
507}
508
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100509#define iowrite32_rep(p, v, c) iowrite32_rep(p, v, c)
510static inline void iowrite32_rep(void __iomem *addr, const void *vaddr,
511 u32 count)
Russell Kinga09e64f2008-08-05 16:14:15 +0100512{
513 unsigned long port = (unsigned long __force)addr;
514 if (__is_io_address(port))
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100515 outsl(port & PIO_MASK, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100516 else
517#ifndef CONFIG_IXP4XX_INDIRECT_PCI
518 __raw_writesl(addr, vaddr, count);
519#else
Krzysztof Hałasa28f85cd2009-11-14 19:44:44 +0100520 __indirect_writesl(addr, vaddr, count);
Russell Kinga09e64f2008-08-05 16:14:15 +0100521#endif
522}
523
Russell Kinga09e64f2008-08-05 16:14:15 +0100524#define ioport_map(port, nr) ((void __iomem*)(port + PIO_OFFSET))
525#define ioport_unmap(addr)
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100526#endif /* CONFIG_PCI */
Russell Kinga09e64f2008-08-05 16:14:15 +0100527
Krzysztof Hałasa58e570d2009-11-14 22:55:42 +0100528#endif /* __ASM_ARM_ARCH_IO_H */