diff options
author | Haavard Skinnemoen <hskinnemoen@atmel.com> | 2006-09-26 02:32:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-26 11:48:54 -0400 |
commit | 5f97f7f9400de47ae837170bb274e90ad3934386 (patch) | |
tree | 514451e6dc6b46253293a00035d375e77b1c65ed /include/asm-avr32/io.h | |
parent | 53e62d3aaa60590d4a69b4e07c29f448b5151047 (diff) |
[PATCH] avr32 architecture
This adds support for the Atmel AVR32 architecture as well as the AT32AP7000
CPU and the AT32STK1000 development board.
AVR32 is a new high-performance 32-bit RISC microprocessor core, designed for
cost-sensitive embedded applications, with particular emphasis on low power
consumption and high code density. The AVR32 architecture is not binary
compatible with earlier 8-bit AVR architectures.
The AVR32 architecture, including the instruction set, is described by the
AVR32 Architecture Manual, available from
http://www.atmel.com/dyn/resources/prod_documents/doc32000.pdf
The Atmel AT32AP7000 is the first CPU implementing the AVR32 architecture. It
features a 7-stage pipeline, 16KB instruction and data caches and a full
Memory Management Unit. It also comes with a large set of integrated
peripherals, many of which are shared with the AT91 ARM-based controllers from
Atmel.
Full data sheet is available from
http://www.atmel.com/dyn/resources/prod_documents/doc32003.pdf
while the CPU core implementation including caches and MMU is documented by
the AVR32 AP Technical Reference, available from
http://www.atmel.com/dyn/resources/prod_documents/doc32001.pdf
Information about the AT32STK1000 development board can be found at
http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3918
including a BSP CD image with an earlier version of this patch, development
tools (binaries and source/patches) and a root filesystem image suitable for
booting from SD card.
Alternatively, there's a preliminary "getting started" guide available at
http://avr32linux.org/twiki/bin/view/Main/GettingStarted which provides links
to the sources and patches you will need in order to set up a cross-compiling
environment for avr32-linux.
This patch, as well as the other patches included with the BSP and the
toolchain patches, is actively supported by Atmel Corporation.
[dmccr@us.ibm.com: Fix more pxx_page macro locations]
[bunk@stusta.de: fix `make defconfig']
Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Dave McCracken <dmccr@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-avr32/io.h')
-rw-r--r-- | include/asm-avr32/io.h | 253 |
1 files changed, 253 insertions, 0 deletions
diff --git a/include/asm-avr32/io.h b/include/asm-avr32/io.h new file mode 100644 index 000000000000..2fc8f111dce9 --- /dev/null +++ b/include/asm-avr32/io.h | |||
@@ -0,0 +1,253 @@ | |||
1 | #ifndef __ASM_AVR32_IO_H | ||
2 | #define __ASM_AVR32_IO_H | ||
3 | |||
4 | #include <linux/string.h> | ||
5 | |||
6 | #ifdef __KERNEL__ | ||
7 | |||
8 | #include <asm/addrspace.h> | ||
9 | #include <asm/byteorder.h> | ||
10 | |||
11 | /* virt_to_phys will only work when address is in P1 or P2 */ | ||
12 | static __inline__ unsigned long virt_to_phys(volatile void *address) | ||
13 | { | ||
14 | return PHYSADDR(address); | ||
15 | } | ||
16 | |||
17 | static __inline__ void * phys_to_virt(unsigned long address) | ||
18 | { | ||
19 | return (void *)P1SEGADDR(address); | ||
20 | } | ||
21 | |||
22 | #define cached_to_phys(addr) ((unsigned long)PHYSADDR(addr)) | ||
23 | #define uncached_to_phys(addr) ((unsigned long)PHYSADDR(addr)) | ||
24 | #define phys_to_cached(addr) ((void *)P1SEGADDR(addr)) | ||
25 | #define phys_to_uncached(addr) ((void *)P2SEGADDR(addr)) | ||
26 | |||
27 | /* | ||
28 | * Generic IO read/write. These perform native-endian accesses. Note | ||
29 | * that some architectures will want to re-define __raw_{read,write}w. | ||
30 | */ | ||
31 | extern void __raw_writesb(unsigned int addr, const void *data, int bytelen); | ||
32 | extern void __raw_writesw(unsigned int addr, const void *data, int wordlen); | ||
33 | extern void __raw_writesl(unsigned int addr, const void *data, int longlen); | ||
34 | |||
35 | extern void __raw_readsb(unsigned int addr, void *data, int bytelen); | ||
36 | extern void __raw_readsw(unsigned int addr, void *data, int wordlen); | ||
37 | extern void __raw_readsl(unsigned int addr, void *data, int longlen); | ||
38 | |||
39 | static inline void writeb(unsigned char b, volatile void __iomem *addr) | ||
40 | { | ||
41 | *(volatile unsigned char __force *)addr = b; | ||
42 | } | ||
43 | static inline void writew(unsigned short b, volatile void __iomem *addr) | ||
44 | { | ||
45 | *(volatile unsigned short __force *)addr = b; | ||
46 | } | ||
47 | static inline void writel(unsigned int b, volatile void __iomem *addr) | ||
48 | { | ||
49 | *(volatile unsigned int __force *)addr = b; | ||
50 | } | ||
51 | #define __raw_writeb writeb | ||
52 | #define __raw_writew writew | ||
53 | #define __raw_writel writel | ||
54 | |||
55 | static inline unsigned char readb(const volatile void __iomem *addr) | ||
56 | { | ||
57 | return *(const volatile unsigned char __force *)addr; | ||
58 | } | ||
59 | static inline unsigned short readw(const volatile void __iomem *addr) | ||
60 | { | ||
61 | return *(const volatile unsigned short __force *)addr; | ||
62 | } | ||
63 | static inline unsigned int readl(const volatile void __iomem *addr) | ||
64 | { | ||
65 | return *(const volatile unsigned int __force *)addr; | ||
66 | } | ||
67 | #define __raw_readb readb | ||
68 | #define __raw_readw readw | ||
69 | #define __raw_readl readl | ||
70 | |||
71 | #define writesb(p, d, l) __raw_writesb((unsigned int)p, d, l) | ||
72 | #define writesw(p, d, l) __raw_writesw((unsigned int)p, d, l) | ||
73 | #define writesl(p, d, l) __raw_writesl((unsigned int)p, d, l) | ||
74 | |||
75 | #define readsb(p, d, l) __raw_readsb((unsigned int)p, d, l) | ||
76 | #define readsw(p, d, l) __raw_readsw((unsigned int)p, d, l) | ||
77 | #define readsl(p, d, l) __raw_readsl((unsigned int)p, d, l) | ||
78 | |||
79 | /* | ||
80 | * These two are only here because ALSA _thinks_ it needs them... | ||
81 | */ | ||
82 | static inline void memcpy_fromio(void * to, const volatile void __iomem *from, | ||
83 | unsigned long count) | ||
84 | { | ||
85 | char *p = to; | ||
86 | while (count) { | ||
87 | count--; | ||
88 | *p = readb(from); | ||
89 | p++; | ||
90 | from++; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | static inline void memcpy_toio(volatile void __iomem *to, const void * from, | ||
95 | unsigned long count) | ||
96 | { | ||
97 | const char *p = from; | ||
98 | while (count) { | ||
99 | count--; | ||
100 | writeb(*p, to); | ||
101 | p++; | ||
102 | to++; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | static inline void memset_io(volatile void __iomem *addr, unsigned char val, | ||
107 | unsigned long count) | ||
108 | { | ||
109 | memset((void __force *)addr, val, count); | ||
110 | } | ||
111 | |||
112 | /* | ||
113 | * Bad read/write accesses... | ||
114 | */ | ||
115 | extern void __readwrite_bug(const char *fn); | ||
116 | |||
117 | #define IO_SPACE_LIMIT 0xffffffff | ||
118 | |||
119 | /* Convert I/O port address to virtual address */ | ||
120 | #define __io(p) ((void __iomem *)phys_to_uncached(p)) | ||
121 | |||
122 | /* | ||
123 | * IO port access primitives | ||
124 | * ------------------------- | ||
125 | * | ||
126 | * The AVR32 doesn't have special IO access instructions; all IO is memory | ||
127 | * mapped. Note that these are defined to perform little endian accesses | ||
128 | * only. Their primary purpose is to access PCI and ISA peripherals. | ||
129 | * | ||
130 | * Note that for a big endian machine, this implies that the following | ||
131 | * big endian mode connectivity is in place. | ||
132 | * | ||
133 | * The machine specific io.h include defines __io to translate an "IO" | ||
134 | * address to a memory address. | ||
135 | * | ||
136 | * Note that we prevent GCC re-ordering or caching values in expressions | ||
137 | * by introducing sequence points into the in*() definitions. Note that | ||
138 | * __raw_* do not guarantee this behaviour. | ||
139 | * | ||
140 | * The {in,out}[bwl] macros are for emulating x86-style PCI/ISA IO space. | ||
141 | */ | ||
142 | #define outb(v, p) __raw_writeb(v, __io(p)) | ||
143 | #define outw(v, p) __raw_writew(cpu_to_le16(v), __io(p)) | ||
144 | #define outl(v, p) __raw_writel(cpu_to_le32(v), __io(p)) | ||
145 | |||
146 | #define inb(p) __raw_readb(__io(p)) | ||
147 | #define inw(p) le16_to_cpu(__raw_readw(__io(p))) | ||
148 | #define inl(p) le32_to_cpu(__raw_readl(__io(p))) | ||
149 | |||
150 | static inline void __outsb(unsigned long port, void *addr, unsigned int count) | ||
151 | { | ||
152 | while (count--) { | ||
153 | outb(*(u8 *)addr, port); | ||
154 | addr++; | ||
155 | } | ||
156 | } | ||
157 | |||
158 | static inline void __insb(unsigned long port, void *addr, unsigned int count) | ||
159 | { | ||
160 | while (count--) { | ||
161 | *(u8 *)addr = inb(port); | ||
162 | addr++; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | static inline void __outsw(unsigned long port, void *addr, unsigned int count) | ||
167 | { | ||
168 | while (count--) { | ||
169 | outw(*(u16 *)addr, port); | ||
170 | addr += 2; | ||
171 | } | ||
172 | } | ||
173 | |||
174 | static inline void __insw(unsigned long port, void *addr, unsigned int count) | ||
175 | { | ||
176 | while (count--) { | ||
177 | *(u16 *)addr = inw(port); | ||
178 | addr += 2; | ||
179 | } | ||
180 | } | ||
181 | |||
182 | static inline void __outsl(unsigned long port, void *addr, unsigned int count) | ||
183 | { | ||
184 | while (count--) { | ||
185 | outl(*(u32 *)addr, port); | ||
186 | addr += 4; | ||
187 | } | ||
188 | } | ||
189 | |||
190 | static inline void __insl(unsigned long port, void *addr, unsigned int count) | ||
191 | { | ||
192 | while (count--) { | ||
193 | *(u32 *)addr = inl(port); | ||
194 | addr += 4; | ||
195 | } | ||
196 | } | ||
197 | |||
198 | #define outsb(port, addr, count) __outsb(port, addr, count) | ||
199 | #define insb(port, addr, count) __insb(port, addr, count) | ||
200 | #define outsw(port, addr, count) __outsw(port, addr, count) | ||
201 | #define insw(port, addr, count) __insw(port, addr, count) | ||
202 | #define outsl(port, addr, count) __outsl(port, addr, count) | ||
203 | #define insl(port, addr, count) __insl(port, addr, count) | ||
204 | |||
205 | extern void __iomem *__ioremap(unsigned long offset, size_t size, | ||
206 | unsigned long flags); | ||
207 | extern void __iounmap(void __iomem *addr); | ||
208 | |||
209 | /* | ||
210 | * ioremap - map bus memory into CPU space | ||
211 | * @offset bus address of the memory | ||
212 | * @size size of the resource to map | ||
213 | * | ||
214 | * ioremap performs a platform specific sequence of operations to make | ||
215 | * bus memory CPU accessible via the readb/.../writel functions and | ||
216 | * the other mmio helpers. The returned address is not guaranteed to | ||
217 | * be usable directly as a virtual address. | ||
218 | */ | ||
219 | #define ioremap(offset, size) \ | ||
220 | __ioremap((offset), (size), 0) | ||
221 | |||
222 | #define iounmap(addr) \ | ||
223 | __iounmap(addr) | ||
224 | |||
225 | #define cached(addr) P1SEGADDR(addr) | ||
226 | #define uncached(addr) P2SEGADDR(addr) | ||
227 | |||
228 | #define virt_to_bus virt_to_phys | ||
229 | #define bus_to_virt phys_to_virt | ||
230 | #define page_to_bus page_to_phys | ||
231 | #define bus_to_page phys_to_page | ||
232 | |||
233 | #define dma_cache_wback_inv(_start, _size) \ | ||
234 | flush_dcache_region(_start, _size) | ||
235 | #define dma_cache_inv(_start, _size) \ | ||
236 | invalidate_dcache_region(_start, _size) | ||
237 | #define dma_cache_wback(_start, _size) \ | ||
238 | clean_dcache_region(_start, _size) | ||
239 | |||
240 | /* | ||
241 | * Convert a physical pointer to a virtual kernel pointer for /dev/mem | ||
242 | * access | ||
243 | */ | ||
244 | #define xlate_dev_mem_ptr(p) __va(p) | ||
245 | |||
246 | /* | ||
247 | * Convert a virtual cached pointer to an uncached pointer | ||
248 | */ | ||
249 | #define xlate_dev_kmem_ptr(p) p | ||
250 | |||
251 | #endif /* __KERNEL__ */ | ||
252 | |||
253 | #endif /* __ASM_AVR32_IO_H */ | ||