diff options
author | Hirokazu Takata <takata@linux-m32r.org> | 2005-06-21 20:16:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-21 22:07:30 -0400 |
commit | 2368086344c3d67b0f4aecac39d620fb9b8795c3 (patch) | |
tree | aa55003e311abf6049acd23f5ff7f8bfd24eca4c /arch/m32r/kernel/io_mappi3.c | |
parent | d4c477ca5448f19afaaf6c0cfd655009ea9e614d (diff) |
[PATCH] m32r: Support M3A-2170(Mappi-III) platform
This patchset is for supporting a new m32r platform, M3A-2170(Mappi-III)
evaluation board. An M32R chip multiprocessor is equipped on the board.
http://http://www.linux-m32r.org/eng/platform/platform.html
* arch/m32r/Kconfig: Support Mappi-III platform.
* arch/m32r/kernel/Makefile: ditto.
* arch/m32r/kernel/io_mappi3.c: ditto.
* arch/m32r/kernel/setup.c: ditto.
* arch/m32r/kernel/setup_mappi3.c: ditto.
* include/asm-m32r/m32102.h: ditto.
* include/asm-m32r/m32r.h: ditto.
* include/asm-m32r/mappi3/mappi3_pld.h: ditto.
* include/asm-m32r/ide.h: CF support for Mappi-III.
* arch/m32r/kernel/setup_mappi3.c: ditto.
* arch/m32r/mappi3/defconfig.smp: A default config file for Mappi-III.
* arch/m32r/mappi3/dot.gdbinit: A default .gdbinit file for Mappi-III.
* arch/m32r/boot/compressed/m32r_sio.c: Modified for Mappi-III
- At boot time, m32r-g00ff bootloader makes MMU off for Mappi-III,
on the contrary it makes MMU on for Mappi-II.
* arch/m32r/kernel/io_mappi2.c: Update comments.
* arch/m32r/kernel/setup_mappi2.c: ditto.
Signed-off-by: Mamoru Sakugawa <sakugawa@linux-m32r.org>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/m32r/kernel/io_mappi3.c')
-rw-r--r-- | arch/m32r/kernel/io_mappi3.c | 378 |
1 files changed, 378 insertions, 0 deletions
diff --git a/arch/m32r/kernel/io_mappi3.c b/arch/m32r/kernel/io_mappi3.c new file mode 100644 index 000000000000..c80bde657854 --- /dev/null +++ b/arch/m32r/kernel/io_mappi3.c | |||
@@ -0,0 +1,378 @@ | |||
1 | /* | ||
2 | * linux/arch/m32r/kernel/io_mappi3.c | ||
3 | * | ||
4 | * Typical I/O routines for Mappi3 board. | ||
5 | * | ||
6 | * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata, | ||
7 | * Hitoshi Yamamoto, Mamoru Sakugawa | ||
8 | */ | ||
9 | |||
10 | #include <linux/config.h> | ||
11 | #include <asm/m32r.h> | ||
12 | #include <asm/page.h> | ||
13 | #include <asm/io.h> | ||
14 | #include <asm/byteorder.h> | ||
15 | |||
16 | #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) | ||
17 | #include <linux/types.h> | ||
18 | |||
19 | #define M32R_PCC_IOMAP_SIZE 0x1000 | ||
20 | |||
21 | #define M32R_PCC_IOSTART0 0x1000 | ||
22 | #define M32R_PCC_IOEND0 (M32R_PCC_IOSTART0 + M32R_PCC_IOMAP_SIZE - 1) | ||
23 | |||
24 | extern void pcc_ioread_byte(int, unsigned long, void *, size_t, size_t, int); | ||
25 | extern void pcc_ioread_word(int, unsigned long, void *, size_t, size_t, int); | ||
26 | extern void pcc_iowrite_byte(int, unsigned long, void *, size_t, size_t, int); | ||
27 | extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int); | ||
28 | #endif /* CONFIG_PCMCIA && CONFIG_M32R_CFC */ | ||
29 | |||
30 | #define PORT2ADDR(port) _port2addr(port) | ||
31 | #define PORT2ADDR_NE(port) _port2addr_ne(port) | ||
32 | #define PORT2ADDR_USB(port) _port2addr_usb(port) | ||
33 | |||
34 | static inline void *_port2addr(unsigned long port) | ||
35 | { | ||
36 | return (void *)(port + NONCACHE_OFFSET); | ||
37 | } | ||
38 | |||
39 | #define LAN_IOSTART 0x300 | ||
40 | #define LAN_IOEND 0x320 | ||
41 | |||
42 | #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) | ||
43 | static inline void *__port2addr_ata(unsigned long port) | ||
44 | { | ||
45 | static int dummy_reg; | ||
46 | |||
47 | switch (port) { | ||
48 | case 0x1f0: return (void *)0xb4002000; | ||
49 | case 0x1f1: return (void *)0xb4012800; | ||
50 | case 0x1f2: return (void *)0xb4012002; | ||
51 | case 0x1f3: return (void *)0xb4012802; | ||
52 | case 0x1f4: return (void *)0xb4012004; | ||
53 | case 0x1f5: return (void *)0xb4012804; | ||
54 | case 0x1f6: return (void *)0xb4012006; | ||
55 | case 0x1f7: return (void *)0xb4012806; | ||
56 | case 0x3f6: return (void *)0xb401200e; | ||
57 | default: return (void *)&dummy_reg; | ||
58 | } | ||
59 | } | ||
60 | #endif | ||
61 | |||
62 | static inline void *_port2addr_ne(unsigned long port) | ||
63 | { | ||
64 | return (void *)(port + NONCACHE_OFFSET + 0x10000000); | ||
65 | } | ||
66 | |||
67 | static inline void *_port2addr_usb(unsigned long port) | ||
68 | { | ||
69 | return (void *)(port + NONCACHE_OFFSET + 0x12000000); | ||
70 | } | ||
71 | static inline void delay(void) | ||
72 | { | ||
73 | __asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory"); | ||
74 | } | ||
75 | |||
76 | /* | ||
77 | * NIC I/O function | ||
78 | */ | ||
79 | |||
80 | static inline unsigned char _ne_inb(void *portp) | ||
81 | { | ||
82 | return (unsigned char) *(volatile unsigned char *)portp; | ||
83 | } | ||
84 | |||
85 | static inline unsigned short _ne_inw(void *portp) | ||
86 | { | ||
87 | return (unsigned short)le16_to_cpu(*(volatile unsigned short *)portp); | ||
88 | } | ||
89 | |||
90 | static inline void _ne_insb(void *portp, void * addr, unsigned long count) | ||
91 | { | ||
92 | unsigned char *buf = addr; | ||
93 | |||
94 | while (count--) | ||
95 | *buf++ = *(volatile unsigned char *)portp; | ||
96 | } | ||
97 | |||
98 | static inline void _ne_outb(unsigned char b, void *portp) | ||
99 | { | ||
100 | *(volatile unsigned char *)portp = (unsigned char)b; | ||
101 | } | ||
102 | |||
103 | static inline void _ne_outw(unsigned short w, void *portp) | ||
104 | { | ||
105 | *(volatile unsigned short *)portp = cpu_to_le16(w); | ||
106 | } | ||
107 | |||
108 | unsigned char _inb(unsigned long port) | ||
109 | { | ||
110 | if (port >= LAN_IOSTART && port < LAN_IOEND) | ||
111 | return _ne_inb(PORT2ADDR_NE(port)); | ||
112 | #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) | ||
113 | else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { | ||
114 | return *(volatile unsigned char *)__port2addr_ata(port); | ||
115 | } | ||
116 | #endif | ||
117 | #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) | ||
118 | else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { | ||
119 | unsigned char b; | ||
120 | pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0); | ||
121 | return b; | ||
122 | } else | ||
123 | #endif | ||
124 | return *(volatile unsigned char *)PORT2ADDR(port); | ||
125 | } | ||
126 | |||
127 | unsigned short _inw(unsigned long port) | ||
128 | { | ||
129 | if (port >= LAN_IOSTART && port < LAN_IOEND) | ||
130 | return _ne_inw(PORT2ADDR_NE(port)); | ||
131 | #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) | ||
132 | else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { | ||
133 | return *(volatile unsigned short *)__port2addr_ata(port); | ||
134 | } | ||
135 | #endif | ||
136 | #if defined(CONFIG_USB) | ||
137 | else if (port >= 0x340 && port < 0x3a0) | ||
138 | return *(volatile unsigned short *)PORT2ADDR_USB(port); | ||
139 | #endif | ||
140 | |||
141 | #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) | ||
142 | else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { | ||
143 | unsigned short w; | ||
144 | pcc_ioread_word(0, port, &w, sizeof(w), 1, 0); | ||
145 | return w; | ||
146 | } else | ||
147 | #endif | ||
148 | return *(volatile unsigned short *)PORT2ADDR(port); | ||
149 | } | ||
150 | |||
151 | unsigned long _inl(unsigned long port) | ||
152 | { | ||
153 | #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) | ||
154 | if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { | ||
155 | unsigned long l; | ||
156 | pcc_ioread_word(0, port, &l, sizeof(l), 1, 0); | ||
157 | return l; | ||
158 | } else | ||
159 | #endif | ||
160 | return *(volatile unsigned long *)PORT2ADDR(port); | ||
161 | } | ||
162 | |||
163 | unsigned char _inb_p(unsigned long port) | ||
164 | { | ||
165 | unsigned char v = _inb(port); | ||
166 | delay(); | ||
167 | return (v); | ||
168 | } | ||
169 | |||
170 | unsigned short _inw_p(unsigned long port) | ||
171 | { | ||
172 | unsigned short v = _inw(port); | ||
173 | delay(); | ||
174 | return (v); | ||
175 | } | ||
176 | |||
177 | unsigned long _inl_p(unsigned long port) | ||
178 | { | ||
179 | unsigned long v = _inl(port); | ||
180 | delay(); | ||
181 | return (v); | ||
182 | } | ||
183 | |||
184 | void _outb(unsigned char b, unsigned long port) | ||
185 | { | ||
186 | if (port >= LAN_IOSTART && port < LAN_IOEND) | ||
187 | _ne_outb(b, PORT2ADDR_NE(port)); | ||
188 | else | ||
189 | #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) | ||
190 | if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { | ||
191 | *(volatile unsigned char *)__port2addr_ata(port) = b; | ||
192 | } else | ||
193 | #endif | ||
194 | #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) | ||
195 | if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { | ||
196 | pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0); | ||
197 | } else | ||
198 | #endif | ||
199 | *(volatile unsigned char *)PORT2ADDR(port) = b; | ||
200 | } | ||
201 | |||
202 | void _outw(unsigned short w, unsigned long port) | ||
203 | { | ||
204 | if (port >= LAN_IOSTART && port < LAN_IOEND) | ||
205 | _ne_outw(w, PORT2ADDR_NE(port)); | ||
206 | else | ||
207 | #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) | ||
208 | if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { | ||
209 | *(volatile unsigned short *)__port2addr_ata(port) = w; | ||
210 | } else | ||
211 | #endif | ||
212 | #if defined(CONFIG_USB) | ||
213 | if (port >= 0x340 && port < 0x3a0) | ||
214 | *(volatile unsigned short *)PORT2ADDR_USB(port) = w; | ||
215 | else | ||
216 | #endif | ||
217 | #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) | ||
218 | if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { | ||
219 | pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0); | ||
220 | } else | ||
221 | #endif | ||
222 | *(volatile unsigned short *)PORT2ADDR(port) = w; | ||
223 | } | ||
224 | |||
225 | void _outl(unsigned long l, unsigned long port) | ||
226 | { | ||
227 | #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) | ||
228 | if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { | ||
229 | pcc_iowrite_word(0, port, &l, sizeof(l), 1, 0); | ||
230 | } else | ||
231 | #endif | ||
232 | *(volatile unsigned long *)PORT2ADDR(port) = l; | ||
233 | } | ||
234 | |||
235 | void _outb_p(unsigned char b, unsigned long port) | ||
236 | { | ||
237 | _outb(b, port); | ||
238 | delay(); | ||
239 | } | ||
240 | |||
241 | void _outw_p(unsigned short w, unsigned long port) | ||
242 | { | ||
243 | _outw(w, port); | ||
244 | delay(); | ||
245 | } | ||
246 | |||
247 | void _outl_p(unsigned long l, unsigned long port) | ||
248 | { | ||
249 | _outl(l, port); | ||
250 | delay(); | ||
251 | } | ||
252 | |||
253 | void _insb(unsigned int port, void * addr, unsigned long count) | ||
254 | { | ||
255 | if (port >= LAN_IOSTART && port < LAN_IOEND) | ||
256 | _ne_insb(PORT2ADDR_NE(port), addr, count); | ||
257 | #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) | ||
258 | else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { | ||
259 | unsigned char *buf = addr; | ||
260 | unsigned char *portp = __port2addr_ata(port); | ||
261 | while (count--) | ||
262 | *buf++ = *(volatile unsigned char *)portp; | ||
263 | } | ||
264 | #endif | ||
265 | #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) | ||
266 | else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { | ||
267 | pcc_ioread_byte(0, port, (void *)addr, sizeof(unsigned char), | ||
268 | count, 1); | ||
269 | } | ||
270 | #endif | ||
271 | else { | ||
272 | unsigned char *buf = addr; | ||
273 | unsigned char *portp = PORT2ADDR(port); | ||
274 | while (count--) | ||
275 | *buf++ = *(volatile unsigned char *)portp; | ||
276 | } | ||
277 | } | ||
278 | |||
279 | void _insw(unsigned int port, void * addr, unsigned long count) | ||
280 | { | ||
281 | unsigned short *buf = addr; | ||
282 | unsigned short *portp; | ||
283 | |||
284 | if (port >= LAN_IOSTART && port < LAN_IOEND) { | ||
285 | portp = PORT2ADDR_NE(port); | ||
286 | while (count--) | ||
287 | *buf++ = *(volatile unsigned short *)portp; | ||
288 | #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) | ||
289 | } else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { | ||
290 | pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short), | ||
291 | count, 1); | ||
292 | #endif | ||
293 | #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) | ||
294 | } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { | ||
295 | portp = __port2addr_ata(port); | ||
296 | while (count--) | ||
297 | *buf++ = *(volatile unsigned short *)portp; | ||
298 | #endif | ||
299 | } else { | ||
300 | portp = PORT2ADDR(port); | ||
301 | while (count--) | ||
302 | *buf++ = *(volatile unsigned short *)portp; | ||
303 | } | ||
304 | } | ||
305 | |||
306 | void _insl(unsigned int port, void * addr, unsigned long count) | ||
307 | { | ||
308 | unsigned long *buf = addr; | ||
309 | unsigned long *portp; | ||
310 | |||
311 | portp = PORT2ADDR(port); | ||
312 | while (count--) | ||
313 | *buf++ = *(volatile unsigned long *)portp; | ||
314 | } | ||
315 | |||
316 | void _outsb(unsigned int port, const void * addr, unsigned long count) | ||
317 | { | ||
318 | const unsigned char *buf = addr; | ||
319 | unsigned char *portp; | ||
320 | |||
321 | if (port >= LAN_IOSTART && port < LAN_IOEND) { | ||
322 | portp = PORT2ADDR_NE(port); | ||
323 | while (count--) | ||
324 | _ne_outb(*buf++, portp); | ||
325 | #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) | ||
326 | } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { | ||
327 | portp = __port2addr_ata(port); | ||
328 | while (count--) | ||
329 | *(volatile unsigned char *)portp = *buf++; | ||
330 | #endif | ||
331 | #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) | ||
332 | } else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { | ||
333 | pcc_iowrite_byte(0, port, (void *)addr, sizeof(unsigned char), | ||
334 | count, 1); | ||
335 | #endif | ||
336 | } else { | ||
337 | portp = PORT2ADDR(port); | ||
338 | while (count--) | ||
339 | *(volatile unsigned char *)portp = *buf++; | ||
340 | } | ||
341 | } | ||
342 | |||
343 | void _outsw(unsigned int port, const void * addr, unsigned long count) | ||
344 | { | ||
345 | const unsigned short *buf = addr; | ||
346 | unsigned short *portp; | ||
347 | |||
348 | if (port >= LAN_IOSTART && port < LAN_IOEND) { | ||
349 | portp = PORT2ADDR_NE(port); | ||
350 | while (count--) | ||
351 | *(volatile unsigned short *)portp = *buf++; | ||
352 | #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) | ||
353 | } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { | ||
354 | portp = __port2addr_ata(port); | ||
355 | while (count--) | ||
356 | *(volatile unsigned short *)portp = *buf++; | ||
357 | #endif | ||
358 | #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) | ||
359 | } else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { | ||
360 | pcc_iowrite_word(9, port, (void *)addr, sizeof(unsigned short), | ||
361 | count, 1); | ||
362 | #endif | ||
363 | } else { | ||
364 | portp = PORT2ADDR(port); | ||
365 | while (count--) | ||
366 | *(volatile unsigned short *)portp = *buf++; | ||
367 | } | ||
368 | } | ||
369 | |||
370 | void _outsl(unsigned int port, const void * addr, unsigned long count) | ||
371 | { | ||
372 | const unsigned long *buf = addr; | ||
373 | unsigned char *portp; | ||
374 | |||
375 | portp = PORT2ADDR(port); | ||
376 | while (count--) | ||
377 | *(volatile unsigned long *)portp = *buf++; | ||
378 | } | ||