Go to the documentation of this file. 1 #ifndef __ASM_AVR32_IO_H
2 #define __ASM_AVR32_IO_H
5 #include <linux/kernel.h>
6 #include <linux/string.h>
7 #include <linux/types.h>
9 #include <asm/addrspace.h>
10 #include <asm/byteorder.h>
22 return (
void *)P1SEGADDR(address);
25 #define cached_to_phys(addr) ((unsigned long)PHYSADDR(addr))
26 #define uncached_to_phys(addr) ((unsigned long)PHYSADDR(addr))
27 #define phys_to_cached(addr) ((void *)P1SEGADDR(addr))
28 #define phys_to_uncached(addr) ((void *)P2SEGADDR(addr))
57 return *(
const volatile u8 __force *)addr;
70 # define __io(p) ((void *)phys_to_uncached(p))
77 #define SLOW_DOWN_IO do { } while (0)
79 #define __BUILD_MEMORY_SINGLE(pfx, bwl, type) \
81 pfx##write##bwl(type val, volatile void __iomem *addr) \
83 volatile type *__addr; \
86 __addr = (void *)__swizzle_addr_##bwl((unsigned long)(addr)); \
87 __val = pfx##ioswab##bwl(__addr, val); \
89 BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long)); \
94 static inline type pfx##read##bwl(const volatile void __iomem *addr) \
96 volatile type *__addr; \
99 __addr = (void *)__swizzle_addr_##bwl((unsigned long)(addr)); \
101 BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long)); \
104 return pfx##ioswab##bwl(__addr, __val); \
107 #define __BUILD_IOPORT_SINGLE(pfx, bwl, type, p, slow) \
108 static inline void pfx##out##bwl##p(type val, unsigned long port) \
110 volatile type *__addr; \
113 __addr = __io(__swizzle_addr_##bwl(port)); \
114 __val = pfx##ioswab##bwl(__addr, val); \
116 BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long)); \
122 static inline type pfx##in##bwl##p(unsigned long port) \
124 volatile type *__addr; \
127 __addr = __io(__swizzle_addr_##bwl(port)); \
129 BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long)); \
134 return pfx##ioswab##bwl(__addr, __val); \
137 #define __BUILD_MEMORY_PFX(bus, bwl, type) \
138 __BUILD_MEMORY_SINGLE(bus, bwl, type)
140 #define BUILDIO_MEM(bwl, type) \
141 __BUILD_MEMORY_PFX(, bwl, type) \
142 __BUILD_MEMORY_PFX(__mem_, bwl, type)
144 #define __BUILD_IOPORT_PFX(bus, bwl, type) \
145 __BUILD_IOPORT_SINGLE(bus, bwl, type, ,) \
146 __BUILD_IOPORT_SINGLE(bus, bwl, type, _p, SLOW_DOWN_IO)
148 #define BUILDIO_IOPORT(bwl, type) \
149 __BUILD_IOPORT_PFX(, bwl, type) \
150 __BUILD_IOPORT_PFX(__mem_, bwl, type)
160 #define readb_relaxed readb
161 #define readw_relaxed readw
162 #define readl_relaxed readl
164 #define readb_be __raw_readb
165 #define readw_be __raw_readw
166 #define readl_be __raw_readl
168 #define writeb_be __raw_writeb
169 #define writew_be __raw_writew
170 #define writel_be __raw_writel
172 #define __BUILD_MEMORY_STRING(bwl, type) \
173 static inline void writes##bwl(volatile void __iomem *addr, \
174 const void *data, unsigned int count) \
176 const type *__data = data; \
179 __mem_write##bwl(*__data++, addr); \
182 static inline void reads##bwl(const volatile void __iomem *addr, \
183 void *data, unsigned int count) \
185 type *__data = data; \
188 *__data++ = __mem_read##bwl(addr); \
191 #define __BUILD_IOPORT_STRING(bwl, type) \
192 static inline void outs##bwl(unsigned long port, const void *data, \
193 unsigned int count) \
195 const type *__data = data; \
198 __mem_out##bwl(*__data++, port); \
201 static inline void ins##bwl(unsigned long port, void *data, \
202 unsigned int count) \
204 type *__data = data; \
207 *__data++ = __mem_in##bwl(port); \
210 #define BUILDSTRING(bwl, type) \
211 __BUILD_MEMORY_STRING(bwl, type) \
212 __BUILD_IOPORT_STRING(bwl, type)
223 #define ioread8(p) ((unsigned int)readb(p))
225 #define ioread16(p) ((unsigned int)readw(p))
226 #define ioread16be(p) ((unsigned int)__raw_readw(p))
228 #define ioread32(p) ((unsigned int)readl(p))
229 #define ioread32be(p) ((unsigned int)__raw_readl(p))
231 #define iowrite8(v,p) writeb(v, p)
233 #define iowrite16(v,p) writew(v, p)
234 #define iowrite16be(v,p) __raw_writew(v, p)
236 #define iowrite32(v,p) writel(v, p)
237 #define iowrite32be(v,p) __raw_writel(v, p)
239 #define ioread8_rep(p,d,c) readsb(p,d,c)
240 #define ioread16_rep(p,d,c) readsw(p,d,c)
241 #define ioread32_rep(p,d,c) readsl(p,d,c)
243 #define iowrite8_rep(p,s,c) writesb(p,s,c)
244 #define iowrite16_rep(p,s,c) writesw(p,s,c)
245 #define iowrite32_rep(p,s,c) writesl(p,s,c)
269 #define IO_SPACE_LIMIT 0xffffffff
272 unsigned long flags);
285 #define ioremap(offset, size) \
286 __ioremap((offset), (size), 0)
288 #define ioremap_nocache(offset, size) \
289 __ioremap((offset), (size), 0)
291 #define iounmap(addr) \
294 #define cached(addr) P1SEGADDR(addr)
295 #define uncached(addr) P2SEGADDR(addr)
297 #define virt_to_bus virt_to_phys
298 #define bus_to_virt phys_to_virt
299 #define page_to_bus page_to_phys
300 #define bus_to_page phys_to_page
307 #define ioport_map(port, nr) ioremap(port, nr)
308 #define ioport_unmap(port) iounmap(port)
314 #define xlate_dev_mem_ptr(p) __va(p)
319 #define xlate_dev_kmem_ptr(p) p