Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 1 | /* |
| 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 Pettersson | dee2b90 | 2009-08-09 21:21:57 +0200 | [diff] [blame] | 20 | #define IO_SPACE_LIMIT 0x0000ffff |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 21 | |
| 22 | extern int (*ixp4xx_pci_read)(u32 addr, u32 cmd, u32* data); |
| 23 | extern 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 King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 52 | /* |
| 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łasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 58 | static inline void __iomem * __indirect_ioremap(unsigned long addr, size_t size, |
| 59 | unsigned int mtype) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 60 | { |
| 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łasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 67 | static inline void __indirect_iounmap(void __iomem *addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 68 | { |
| 69 | if ((__force u32)addr >= VMALLOC_START) |
| 70 | __iounmap(addr); |
| 71 | } |
| 72 | |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 73 | #define __arch_ioremap(a, s, f) __indirect_ioremap(a, s, f) |
| 74 | #define __arch_iounmap(a) __indirect_iounmap(a) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 75 | |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 76 | #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 King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 79 | |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 80 | #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 King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 83 | |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 84 | #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 | |
| 92 | static inline void __indirect_writeb(u8 value, volatile void __iomem *p) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 93 | { |
| 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łasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 108 | static inline void __indirect_writesb(volatile void __iomem *bus_addr, |
| 109 | const u8 *vaddr, int count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 110 | { |
| 111 | while (count--) |
| 112 | writeb(*vaddr++, bus_addr); |
| 113 | } |
| 114 | |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 115 | static inline void __indirect_writew(u16 value, volatile void __iomem *p) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 116 | { |
| 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łasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 131 | static inline void __indirect_writesw(volatile void __iomem *bus_addr, |
| 132 | const u16 *vaddr, int count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 133 | { |
| 134 | while (count--) |
| 135 | writew(*vaddr++, bus_addr); |
| 136 | } |
| 137 | |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 138 | static inline void __indirect_writel(u32 value, volatile void __iomem *p) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 139 | { |
| 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łasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 149 | static inline void __indirect_writesl(volatile void __iomem *bus_addr, |
| 150 | const u32 *vaddr, int count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 151 | { |
| 152 | while (count--) |
| 153 | writel(*vaddr++, bus_addr); |
| 154 | } |
| 155 | |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 156 | static inline unsigned char __indirect_readb(const volatile void __iomem *p) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 157 | { |
| 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łasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 172 | static inline void __indirect_readsb(const volatile void __iomem *bus_addr, |
| 173 | u8 *vaddr, u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 174 | { |
| 175 | while (count--) |
| 176 | *vaddr++ = readb(bus_addr); |
| 177 | } |
| 178 | |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 179 | static inline unsigned short __indirect_readw(const volatile void __iomem *p) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 180 | { |
| 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łasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 195 | static inline void __indirect_readsw(const volatile void __iomem *bus_addr, |
| 196 | u16 *vaddr, u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 197 | { |
| 198 | while (count--) |
| 199 | *vaddr++ = readw(bus_addr); |
| 200 | } |
| 201 | |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 202 | static inline unsigned long __indirect_readl(const volatile void __iomem *p) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 203 | { |
| 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łasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 216 | static inline void __indirect_readsl(const volatile void __iomem *bus_addr, |
| 217 | u32 *vaddr, u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 218 | { |
| 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łasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 231 | #endif /* CONFIG_IXP4XX_INDIRECT_PCI */ |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 232 | |
| 233 | #ifndef CONFIG_PCI |
| 234 | |
Russell King | 0560cf5 | 2008-11-30 11:45:54 +0000 | [diff] [blame] | 235 | #define __io(v) __typesafe_io(v) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 236 | |
| 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 King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 246 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 247 | static inline void outb(u8 value, u32 addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 248 | { |
| 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łasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 256 | static inline void outsb(u32 io_addr, const u8 *vaddr, u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 257 | { |
| 258 | while (count--) |
| 259 | outb(*vaddr++, io_addr); |
| 260 | } |
| 261 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 262 | static inline void outw(u16 value, u32 addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 263 | { |
| 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łasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 271 | static inline void outsw(u32 io_addr, const u16 *vaddr, u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 272 | { |
| 273 | while (count--) |
| 274 | outw(cpu_to_le16(*vaddr++), io_addr); |
| 275 | } |
| 276 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 277 | static inline void outl(u32 value, u32 addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 278 | { |
| 279 | ixp4xx_pci_write(addr, NP_CMD_IOWRITE, value); |
| 280 | } |
| 281 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 282 | static inline void outsl(u32 io_addr, const u32 *vaddr, u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 283 | { |
| 284 | while (count--) |
Krzysztof Hałasa | 9f2c949 | 2009-11-11 00:21:48 +0100 | [diff] [blame] | 285 | outl(cpu_to_le32(*vaddr++), io_addr); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 286 | } |
| 287 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 288 | static inline u8 inb(u32 addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 289 | { |
| 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łasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 299 | static inline void insb(u32 io_addr, u8 *vaddr, u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 300 | { |
| 301 | while (count--) |
| 302 | *vaddr++ = inb(io_addr); |
| 303 | } |
| 304 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 305 | static inline u16 inw(u32 addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 306 | { |
| 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łasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 316 | static inline void insw(u32 io_addr, u16 *vaddr, u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 317 | { |
| 318 | while (count--) |
| 319 | *vaddr++ = le16_to_cpu(inw(io_addr)); |
| 320 | } |
| 321 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 322 | static inline u32 inl(u32 addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 323 | { |
| 324 | u32 data; |
| 325 | if (ixp4xx_pci_read(addr, NP_CMD_IOREAD, &data)) |
| 326 | return 0xffffffff; |
| 327 | |
| 328 | return data; |
| 329 | } |
| 330 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 331 | static inline void insl(u32 io_addr, u32 *vaddr, u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 332 | { |
| 333 | while (count--) |
Krzysztof Hałasa | 9f2c949 | 2009-11-11 00:21:48 +0100 | [diff] [blame] | 334 | *vaddr++ = le32_to_cpu(inl(io_addr)); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 335 | } |
| 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łasa | 9f2c949 | 2009-11-11 00:21:48 +0100 | [diff] [blame] | 342 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 343 | #define ioread8(p) ioread8(p) |
| 344 | static inline unsigned int ioread8(const void __iomem *addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 345 | { |
| 346 | unsigned long port = (unsigned long __force)addr; |
| 347 | if (__is_io_address(port)) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 348 | return (unsigned int)inb(port & PIO_MASK); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 349 | else |
| 350 | #ifndef CONFIG_IXP4XX_INDIRECT_PCI |
| 351 | return (unsigned int)__raw_readb(port); |
| 352 | #else |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 353 | return (unsigned int)__indirect_readb(addr); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 354 | #endif |
| 355 | } |
| 356 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 357 | #define ioread8_rep(p, v, c) ioread8_rep(p, v, c) |
| 358 | static inline void ioread8_rep(const void __iomem *addr, void *vaddr, u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 359 | { |
| 360 | unsigned long port = (unsigned long __force)addr; |
| 361 | if (__is_io_address(port)) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 362 | insb(port & PIO_MASK, vaddr, count); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 363 | else |
| 364 | #ifndef CONFIG_IXP4XX_INDIRECT_PCI |
| 365 | __raw_readsb(addr, vaddr, count); |
| 366 | #else |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 367 | __indirect_readsb(addr, vaddr, count); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 368 | #endif |
| 369 | } |
| 370 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 371 | #define ioread16(p) ioread16(p) |
| 372 | static inline unsigned int ioread16(const void __iomem *addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 373 | { |
| 374 | unsigned long port = (unsigned long __force)addr; |
| 375 | if (__is_io_address(port)) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 376 | return (unsigned int)inw(port & PIO_MASK); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 377 | else |
| 378 | #ifndef CONFIG_IXP4XX_INDIRECT_PCI |
| 379 | return le16_to_cpu(__raw_readw((u32)port)); |
| 380 | #else |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 381 | return (unsigned int)__indirect_readw(addr); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 382 | #endif |
| 383 | } |
| 384 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 385 | #define ioread16_rep(p, v, c) ioread16_rep(p, v, c) |
| 386 | static inline void ioread16_rep(const void __iomem *addr, void *vaddr, |
| 387 | u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 388 | { |
| 389 | unsigned long port = (unsigned long __force)addr; |
| 390 | if (__is_io_address(port)) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 391 | insw(port & PIO_MASK, vaddr, count); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 392 | else |
| 393 | #ifndef CONFIG_IXP4XX_INDIRECT_PCI |
| 394 | __raw_readsw(addr, vaddr, count); |
| 395 | #else |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 396 | __indirect_readsw(addr, vaddr, count); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 397 | #endif |
| 398 | } |
| 399 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 400 | #define ioread32(p) ioread32(p) |
| 401 | static inline unsigned int ioread32(const void __iomem *addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 402 | { |
| 403 | unsigned long port = (unsigned long __force)addr; |
| 404 | if (__is_io_address(port)) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 405 | return (unsigned int)inl(port & PIO_MASK); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 406 | else { |
| 407 | #ifndef CONFIG_IXP4XX_INDIRECT_PCI |
| 408 | return le32_to_cpu((__force __le32)__raw_readl(addr)); |
| 409 | #else |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 410 | return (unsigned int)__indirect_readl(addr); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 411 | #endif |
| 412 | } |
| 413 | } |
| 414 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 415 | #define ioread32_rep(p, v, c) ioread32_rep(p, v, c) |
| 416 | static inline void ioread32_rep(const void __iomem *addr, void *vaddr, |
| 417 | u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 418 | { |
| 419 | unsigned long port = (unsigned long __force)addr; |
| 420 | if (__is_io_address(port)) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 421 | insl(port & PIO_MASK, vaddr, count); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 422 | else |
| 423 | #ifndef CONFIG_IXP4XX_INDIRECT_PCI |
| 424 | __raw_readsl(addr, vaddr, count); |
| 425 | #else |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 426 | __indirect_readsl(addr, vaddr, count); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 427 | #endif |
| 428 | } |
| 429 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 430 | #define iowrite8(v, p) iowrite8(v, p) |
| 431 | static inline void iowrite8(u8 value, void __iomem *addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 432 | { |
| 433 | unsigned long port = (unsigned long __force)addr; |
| 434 | if (__is_io_address(port)) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 435 | outb(value, port & PIO_MASK); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 436 | else |
| 437 | #ifndef CONFIG_IXP4XX_INDIRECT_PCI |
| 438 | __raw_writeb(value, port); |
| 439 | #else |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 440 | __indirect_writeb(value, addr); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 441 | #endif |
| 442 | } |
| 443 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 444 | #define iowrite8_rep(p, v, c) iowrite8_rep(p, v, c) |
| 445 | static inline void iowrite8_rep(void __iomem *addr, const void *vaddr, |
| 446 | u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 447 | { |
| 448 | unsigned long port = (unsigned long __force)addr; |
| 449 | if (__is_io_address(port)) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 450 | outsb(port & PIO_MASK, vaddr, count); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 451 | else |
| 452 | #ifndef CONFIG_IXP4XX_INDIRECT_PCI |
| 453 | __raw_writesb(addr, vaddr, count); |
| 454 | #else |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 455 | __indirect_writesb(addr, vaddr, count); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 456 | #endif |
| 457 | } |
| 458 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 459 | #define iowrite16(v, p) iowrite16(v, p) |
| 460 | static inline void iowrite16(u16 value, void __iomem *addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 461 | { |
| 462 | unsigned long port = (unsigned long __force)addr; |
| 463 | if (__is_io_address(port)) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 464 | outw(value, port & PIO_MASK); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 465 | else |
| 466 | #ifndef CONFIG_IXP4XX_INDIRECT_PCI |
| 467 | __raw_writew(cpu_to_le16(value), addr); |
| 468 | #else |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 469 | __indirect_writew(value, addr); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 470 | #endif |
| 471 | } |
| 472 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 473 | #define iowrite16_rep(p, v, c) iowrite16_rep(p, v, c) |
| 474 | static inline void iowrite16_rep(void __iomem *addr, const void *vaddr, |
| 475 | u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 476 | { |
| 477 | unsigned long port = (unsigned long __force)addr; |
| 478 | if (__is_io_address(port)) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 479 | outsw(port & PIO_MASK, vaddr, count); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 480 | else |
| 481 | #ifndef CONFIG_IXP4XX_INDIRECT_PCI |
| 482 | __raw_writesw(addr, vaddr, count); |
| 483 | #else |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 484 | __indirect_writesw(addr, vaddr, count); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 485 | #endif |
| 486 | } |
| 487 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 488 | #define iowrite32(v, p) iowrite32(v, p) |
| 489 | static inline void iowrite32(u32 value, void __iomem *addr) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 490 | { |
| 491 | unsigned long port = (unsigned long __force)addr; |
| 492 | if (__is_io_address(port)) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 493 | outl(value, port & PIO_MASK); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 494 | else |
| 495 | #ifndef CONFIG_IXP4XX_INDIRECT_PCI |
| 496 | __raw_writel((u32 __force)cpu_to_le32(value), addr); |
| 497 | #else |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 498 | __indirect_writel(value, addr); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 499 | #endif |
| 500 | } |
| 501 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 502 | #define iowrite32_rep(p, v, c) iowrite32_rep(p, v, c) |
| 503 | static inline void iowrite32_rep(void __iomem *addr, const void *vaddr, |
| 504 | u32 count) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 505 | { |
| 506 | unsigned long port = (unsigned long __force)addr; |
| 507 | if (__is_io_address(port)) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 508 | outsl(port & PIO_MASK, vaddr, count); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 509 | else |
| 510 | #ifndef CONFIG_IXP4XX_INDIRECT_PCI |
| 511 | __raw_writesl(addr, vaddr, count); |
| 512 | #else |
Krzysztof Hałasa | 28f85cd | 2009-11-14 19:44:44 +0100 | [diff] [blame] | 513 | __indirect_writesl(addr, vaddr, count); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 514 | #endif |
| 515 | } |
| 516 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 517 | #define ioport_map(port, nr) ((void __iomem*)(port + PIO_OFFSET)) |
| 518 | #define ioport_unmap(addr) |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 519 | #endif /* CONFIG_PCI */ |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 520 | |
Krzysztof Hałasa | 58e570d | 2009-11-14 22:55:42 +0100 | [diff] [blame^] | 521 | #endif /* __ASM_ARM_ARCH_IO_H */ |