aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m32r/kernel
diff options
context:
space:
mode:
authorHirokazu Takata <takata@linux-m32r.org>2005-06-21 20:16:10 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 22:07:30 -0400
commit2368086344c3d67b0f4aecac39d620fb9b8795c3 (patch)
treeaa55003e311abf6049acd23f5ff7f8bfd24eca4c /arch/m32r/kernel
parentd4c477ca5448f19afaaf6c0cfd655009ea9e614d (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')
-rw-r--r--arch/m32r/kernel/Makefile2
-rw-r--r--arch/m32r/kernel/io_m32700ut.c92
-rw-r--r--arch/m32r/kernel/io_mappi.c74
-rw-r--r--arch/m32r/kernel/io_mappi2.c92
-rw-r--r--arch/m32r/kernel/io_mappi3.c378
-rw-r--r--arch/m32r/kernel/io_oaks32r.c36
-rw-r--r--arch/m32r/kernel/io_opsput.c79
-rw-r--r--arch/m32r/kernel/io_usrv.c51
-rw-r--r--arch/m32r/kernel/setup.c2
-rw-r--r--arch/m32r/kernel/setup_mappi2.c6
-rw-r--r--arch/m32r/kernel/setup_mappi3.c208
11 files changed, 644 insertions, 376 deletions
diff --git a/arch/m32r/kernel/Makefile b/arch/m32r/kernel/Makefile
index cfd690bf6d8a..6c6b6c376638 100644
--- a/arch/m32r/kernel/Makefile
+++ b/arch/m32r/kernel/Makefile
@@ -10,6 +10,7 @@ obj-y := process.o entry.o traps.o align.o irq.o setup.o time.o \
10obj-$(CONFIG_SMP) += smp.o smpboot.o 10obj-$(CONFIG_SMP) += smp.o smpboot.o
11obj-$(CONFIG_PLAT_MAPPI) += setup_mappi.o io_mappi.o 11obj-$(CONFIG_PLAT_MAPPI) += setup_mappi.o io_mappi.o
12obj-$(CONFIG_PLAT_MAPPI2) += setup_mappi2.o io_mappi2.o 12obj-$(CONFIG_PLAT_MAPPI2) += setup_mappi2.o io_mappi2.o
13obj-$(CONFIG_PLAT_MAPPI3) += setup_mappi3.o io_mappi3.o
13obj-$(CONFIG_PLAT_USRV) += setup_usrv.o io_usrv.o 14obj-$(CONFIG_PLAT_USRV) += setup_usrv.o io_usrv.o
14obj-$(CONFIG_PLAT_M32700UT) += setup_m32700ut.o io_m32700ut.o 15obj-$(CONFIG_PLAT_M32700UT) += setup_m32700ut.o io_m32700ut.o
15obj-$(CONFIG_PLAT_OPSPUT) += setup_opsput.o io_opsput.o 16obj-$(CONFIG_PLAT_OPSPUT) += setup_opsput.o io_opsput.o
@@ -17,4 +18,3 @@ obj-$(CONFIG_MODULES) += module.o
17obj-$(CONFIG_PLAT_OAKS32R) += setup_oaks32r.o io_oaks32r.o 18obj-$(CONFIG_PLAT_OAKS32R) += setup_oaks32r.o io_oaks32r.o
18 19
19EXTRA_AFLAGS := -traditional 20EXTRA_AFLAGS := -traditional
20
diff --git a/arch/m32r/kernel/io_m32700ut.c b/arch/m32r/kernel/io_m32700ut.c
index 371ba904e968..e545b065f7e9 100644
--- a/arch/m32r/kernel/io_m32700ut.c
+++ b/arch/m32r/kernel/io_m32700ut.c
@@ -3,8 +3,8 @@
3 * 3 *
4 * Typical I/O routines for M32700UT board. 4 * Typical I/O routines for M32700UT board.
5 * 5 *
6 * Copyright (c) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata, 6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Takeo Takahashi 7 * Hitoshi Yamamoto, Takeo Takahashi
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General 9 * This file is subject to the terms and conditions of the GNU General
10 * Public License. See the file "COPYING" in the main directory of this 10 * Public License. See the file "COPYING" in the main directory of this
@@ -172,64 +172,21 @@ unsigned long _inl(unsigned long port)
172 172
173unsigned char _inb_p(unsigned long port) 173unsigned char _inb_p(unsigned long port)
174{ 174{
175 unsigned char v; 175 unsigned char v = _inb(port);
176
177 if (port >= LAN_IOSTART && port < LAN_IOEND)
178 v = _ne_inb(PORT2ADDR_NE(port));
179 else
180#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
181 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
182 return *(volatile unsigned char *)__port2addr_ata(port);
183 } else
184#endif
185#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
186 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
187 unsigned char b;
188 pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
189 return b;
190 } else
191#endif
192 v = *(volatile unsigned char *)PORT2ADDR(port);
193
194 delay(); 176 delay();
195 return (v); 177 return (v);
196} 178}
197 179
198unsigned short _inw_p(unsigned long port) 180unsigned short _inw_p(unsigned long port)
199{ 181{
200 unsigned short v; 182 unsigned short v = _inw(port);
201
202 if (port >= LAN_IOSTART && port < LAN_IOEND)
203 v = _ne_inw(PORT2ADDR_NE(port));
204 else
205#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
206 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
207 return *(volatile unsigned short *)__port2addr_ata(port);
208 } else
209#endif
210#if defined(CONFIG_USB)
211 if(port >= 0x340 && port < 0x3a0)
212 return *(volatile unsigned short *)PORT2ADDR_USB(port);
213 else
214#endif
215#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
216 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
217 unsigned short w;
218 pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
219 return w;
220 } else
221#endif
222 v = *(volatile unsigned short *)PORT2ADDR(port);
223
224 delay(); 183 delay();
225 return (v); 184 return (v);
226} 185}
227 186
228unsigned long _inl_p(unsigned long port) 187unsigned long _inl_p(unsigned long port)
229{ 188{
230 unsigned long v; 189 unsigned long v = _inl(port);
231
232 v = *(volatile unsigned long *)PORT2ADDR(port);
233 delay(); 190 delay();
234 return (v); 191 return (v);
235} 192}
@@ -287,52 +244,19 @@ void _outl(unsigned long l, unsigned long port)
287 244
288void _outb_p(unsigned char b, unsigned long port) 245void _outb_p(unsigned char b, unsigned long port)
289{ 246{
290 if (port >= LAN_IOSTART && port < LAN_IOEND) 247 _outb(b, port);
291 _ne_outb(b, PORT2ADDR_NE(port));
292 else
293#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
294 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
295 *(volatile unsigned char *)__port2addr_ata(port) = b;
296 } else
297#endif
298#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
299 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
300 pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
301 } else
302#endif
303 *(volatile unsigned char *)PORT2ADDR(port) = b;
304
305 delay(); 248 delay();
306} 249}
307 250
308void _outw_p(unsigned short w, unsigned long port) 251void _outw_p(unsigned short w, unsigned long port)
309{ 252{
310 if (port >= LAN_IOSTART && port < LAN_IOEND) 253 _outw(w, port);
311 _ne_outw(w, PORT2ADDR_NE(port));
312 else
313#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
314 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
315 *(volatile unsigned short *)__port2addr_ata(port) = w;
316 } else
317#endif
318#if defined(CONFIG_USB)
319 if(port >= 0x340 && port < 0x3a0)
320 *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
321 else
322#endif
323#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
324 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
325 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
326 } else
327#endif
328 *(volatile unsigned short *)PORT2ADDR(port) = w;
329
330 delay(); 254 delay();
331} 255}
332 256
333void _outl_p(unsigned long l, unsigned long port) 257void _outl_p(unsigned long l, unsigned long port)
334{ 258{
335 *(volatile unsigned long *)PORT2ADDR(port) = l; 259 _outl(l, port);
336 delay(); 260 delay();
337} 261}
338 262
diff --git a/arch/m32r/kernel/io_mappi.c b/arch/m32r/kernel/io_mappi.c
index 85688ffb52f9..78033165fb5c 100644
--- a/arch/m32r/kernel/io_mappi.c
+++ b/arch/m32r/kernel/io_mappi.c
@@ -3,8 +3,8 @@
3 * 3 *
4 * Typical I/O routines for Mappi board. 4 * Typical I/O routines for Mappi board.
5 * 5 *
6 * Copyright (c) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata, 6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto 7 * Hitoshi Yamamoto
8 */ 8 */
9 9
10#include <linux/config.h> 10#include <linux/config.h>
@@ -130,57 +130,21 @@ unsigned long _inl(unsigned long port)
130 130
131unsigned char _inb_p(unsigned long port) 131unsigned char _inb_p(unsigned long port)
132{ 132{
133 unsigned char v; 133 unsigned char v = _inb(port);
134
135 if (port >= 0x300 && port < 0x320)
136 v = _ne_inb(PORT2ADDR_NE(port));
137 else
138#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
139 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
140 unsigned char b;
141 pcc_ioread(0, port, &b, sizeof(b), 1, 0);
142 return b;
143 } else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
144 unsigned char b;
145 pcc_ioread(1, port, &b, sizeof(b), 1, 0);
146 return b;
147 } else
148#endif
149 v = *(volatile unsigned char *)PORT2ADDR(port);
150
151 delay(); 134 delay();
152 return (v); 135 return (v);
153} 136}
154 137
155unsigned short _inw_p(unsigned long port) 138unsigned short _inw_p(unsigned long port)
156{ 139{
157 unsigned short v; 140 unsigned short v = _inw(port);
158
159 if (port >= 0x300 && port < 0x320)
160 v = _ne_inw(PORT2ADDR_NE(port));
161 else
162#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
163 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
164 unsigned short w;
165 pcc_ioread(0, port, &w, sizeof(w), 1, 0);
166 return w;
167 } else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
168 unsigned short w;
169 pcc_ioread(1, port, &w, sizeof(w), 1, 0);
170 return w;
171 } else
172#endif
173 v = *(volatile unsigned short *)PORT2ADDR(port);
174
175 delay(); 141 delay();
176 return (v); 142 return (v);
177} 143}
178 144
179unsigned long _inl_p(unsigned long port) 145unsigned long _inl_p(unsigned long port)
180{ 146{
181 unsigned long v; 147 unsigned long v = _inl(port);
182
183 v = *(volatile unsigned long *)PORT2ADDR(port);
184 delay(); 148 delay();
185 return (v); 149 return (v);
186} 150}
@@ -229,41 +193,19 @@ void _outl(unsigned long l, unsigned long port)
229 193
230void _outb_p(unsigned char b, unsigned long port) 194void _outb_p(unsigned char b, unsigned long port)
231{ 195{
232 if (port >= 0x300 && port < 0x320) 196 _outb(b, port);
233 _ne_outb(b, PORT2ADDR_NE(port));
234 else
235#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
236 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
237 pcc_iowrite(0, port, &b, sizeof(b), 1, 0);
238 } else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
239 pcc_iowrite(1, port, &b, sizeof(b), 1, 0);
240 } else
241#endif
242 *(volatile unsigned char *)PORT2ADDR(port) = b;
243
244 delay(); 197 delay();
245} 198}
246 199
247void _outw_p(unsigned short w, unsigned long port) 200void _outw_p(unsigned short w, unsigned long port)
248{ 201{
249 if (port >= 0x300 && port < 0x320) 202 _outw(w, port);
250 _ne_outw(w, PORT2ADDR_NE(port));
251 else
252#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
253 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
254 pcc_iowrite(0, port, &w, sizeof(w), 1, 0);
255 } else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
256 pcc_iowrite(1, port, &w, sizeof(w), 1, 0);
257 } else
258#endif
259 *(volatile unsigned short *)PORT2ADDR(port) = w;
260
261 delay(); 203 delay();
262} 204}
263 205
264void _outl_p(unsigned long l, unsigned long port) 206void _outl_p(unsigned long l, unsigned long port)
265{ 207{
266 *(volatile unsigned long *)PORT2ADDR(port) = l; 208 _outl(l, port);
267 delay(); 209 delay();
268} 210}
269 211
diff --git a/arch/m32r/kernel/io_mappi2.c b/arch/m32r/kernel/io_mappi2.c
index 4182cd4f97c8..5c03504bf653 100644
--- a/arch/m32r/kernel/io_mappi2.c
+++ b/arch/m32r/kernel/io_mappi2.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Typical I/O routines for Mappi2 board. 4 * Typical I/O routines for Mappi2 board.
5 * 5 *
6 * Copyright (c) 2001-2003 Hiroyuki Kondo, Hirokazu Takata, 6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Mamoru Sakugawa 7 * Hitoshi Yamamoto, Mamoru Sakugawa
8 */ 8 */
9 9
@@ -25,7 +25,7 @@ extern void pcc_ioread_byte(int, unsigned long, void *, size_t, size_t, int);
25extern void pcc_ioread_word(int, unsigned long, void *, size_t, size_t, int); 25extern void pcc_ioread_word(int, unsigned long, void *, size_t, size_t, int);
26extern void pcc_iowrite_byte(int, unsigned long, void *, size_t, size_t, int); 26extern void pcc_iowrite_byte(int, unsigned long, void *, size_t, size_t, int);
27extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int); 27extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int);
28#endif /* CONFIG_PCMCIA && CONFIG_MAPPI2_CFC */ 28#endif /* CONFIG_PCMCIA && CONFIG_M32R_CFC */
29 29
30#define PORT2ADDR(port) _port2addr(port) 30#define PORT2ADDR(port) _port2addr(port)
31#define PORT2ADDR_NE(port) _port2addr_ne(port) 31#define PORT2ADDR_NE(port) _port2addr_ne(port)
@@ -169,64 +169,21 @@ unsigned long _inl(unsigned long port)
169 169
170unsigned char _inb_p(unsigned long port) 170unsigned char _inb_p(unsigned long port)
171{ 171{
172 unsigned char v; 172 unsigned char v = _inb(port);
173
174 if (port >= LAN_IOSTART && port < LAN_IOEND)
175 v = _ne_inb(PORT2ADDR_NE(port));
176 else
177#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
178 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
179 return *(volatile unsigned char *)__port2addr_ata(port);
180 } else
181#endif
182#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
183 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
184 unsigned char b;
185 pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
186 return b;
187 } else
188#endif
189 v = *(volatile unsigned char *)PORT2ADDR(port);
190
191 delay(); 173 delay();
192 return (v); 174 return (v);
193} 175}
194 176
195unsigned short _inw_p(unsigned long port) 177unsigned short _inw_p(unsigned long port)
196{ 178{
197 unsigned short v; 179 unsigned short v = _inw(port);
198
199 if (port >= LAN_IOSTART && port < LAN_IOEND)
200 v = _ne_inw(PORT2ADDR_NE(port));
201 else
202#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
203 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
204 return *(volatile unsigned short *)__port2addr_ata(port);
205 } else
206#endif
207#if defined(CONFIG_USB)
208 if (port >= 0x340 && port < 0x3a0)
209 v = *(volatile unsigned short *)PORT2ADDR_USB(port);
210 else
211#endif
212#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
213 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
214 unsigned short w;
215 pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
216 return w;
217 } else
218#endif
219 v = *(volatile unsigned short *)PORT2ADDR(port);
220
221 delay(); 180 delay();
222 return (v); 181 return (v);
223} 182}
224 183
225unsigned long _inl_p(unsigned long port) 184unsigned long _inl_p(unsigned long port)
226{ 185{
227 unsigned long v; 186 unsigned long v = _inl(port);
228
229 v = *(volatile unsigned long *)PORT2ADDR(port);
230 delay(); 187 delay();
231 return (v); 188 return (v);
232} 189}
@@ -284,52 +241,19 @@ void _outl(unsigned long l, unsigned long port)
284 241
285void _outb_p(unsigned char b, unsigned long port) 242void _outb_p(unsigned char b, unsigned long port)
286{ 243{
287 if (port >= LAN_IOSTART && port < LAN_IOEND) 244 _outb(b, port);
288 _ne_outb(b, PORT2ADDR_NE(port));
289 else
290#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
291 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
292 *(volatile unsigned char *)__port2addr_ata(port) = b;
293 } else
294#endif
295#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
296 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
297 pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
298 } else
299#endif
300 *(volatile unsigned char *)PORT2ADDR(port) = b;
301
302 delay(); 245 delay();
303} 246}
304 247
305void _outw_p(unsigned short w, unsigned long port) 248void _outw_p(unsigned short w, unsigned long port)
306{ 249{
307 if (port >= LAN_IOSTART && port < LAN_IOEND) 250 _outw(w, port);
308 _ne_outw(w, PORT2ADDR_NE(port));
309 else
310#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
311 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
312 *(volatile unsigned short *)__port2addr_ata(port) = w;
313 } else
314#endif
315#if defined(CONFIG_USB)
316 if (port >= 0x340 && port < 0x3a0)
317 *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
318 else
319#endif
320#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
321 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
322 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
323 } else
324#endif
325 *(volatile unsigned short *)PORT2ADDR(port) = w;
326
327 delay(); 251 delay();
328} 252}
329 253
330void _outl_p(unsigned long l, unsigned long port) 254void _outl_p(unsigned long l, unsigned long port)
331{ 255{
332 *(volatile unsigned long *)PORT2ADDR(port) = l; 256 _outl(l, port);
333 delay(); 257 delay();
334} 258}
335 259
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
24extern void pcc_ioread_byte(int, unsigned long, void *, size_t, size_t, int);
25extern void pcc_ioread_word(int, unsigned long, void *, size_t, size_t, int);
26extern void pcc_iowrite_byte(int, unsigned long, void *, size_t, size_t, int);
27extern 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
34static 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)
43static 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
62static inline void *_port2addr_ne(unsigned long port)
63{
64 return (void *)(port + NONCACHE_OFFSET + 0x10000000);
65}
66
67static inline void *_port2addr_usb(unsigned long port)
68{
69 return (void *)(port + NONCACHE_OFFSET + 0x12000000);
70}
71static 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
80static inline unsigned char _ne_inb(void *portp)
81{
82 return (unsigned char) *(volatile unsigned char *)portp;
83}
84
85static inline unsigned short _ne_inw(void *portp)
86{
87 return (unsigned short)le16_to_cpu(*(volatile unsigned short *)portp);
88}
89
90static 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
98static inline void _ne_outb(unsigned char b, void *portp)
99{
100 *(volatile unsigned char *)portp = (unsigned char)b;
101}
102
103static inline void _ne_outw(unsigned short w, void *portp)
104{
105 *(volatile unsigned short *)portp = cpu_to_le16(w);
106}
107
108unsigned 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
127unsigned 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
151unsigned 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
163unsigned char _inb_p(unsigned long port)
164{
165 unsigned char v = _inb(port);
166 delay();
167 return (v);
168}
169
170unsigned short _inw_p(unsigned long port)
171{
172 unsigned short v = _inw(port);
173 delay();
174 return (v);
175}
176
177unsigned long _inl_p(unsigned long port)
178{
179 unsigned long v = _inl(port);
180 delay();
181 return (v);
182}
183
184void _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
202void _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
225void _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
235void _outb_p(unsigned char b, unsigned long port)
236{
237 _outb(b, port);
238 delay();
239}
240
241void _outw_p(unsigned short w, unsigned long port)
242{
243 _outw(w, port);
244 delay();
245}
246
247void _outl_p(unsigned long l, unsigned long port)
248{
249 _outl(l, port);
250 delay();
251}
252
253void _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
279void _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
306void _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
316void _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
343void _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
370void _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}
diff --git a/arch/m32r/kernel/io_oaks32r.c b/arch/m32r/kernel/io_oaks32r.c
index 286964794d51..9997dddd24d7 100644
--- a/arch/m32r/kernel/io_oaks32r.c
+++ b/arch/m32r/kernel/io_oaks32r.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Typical I/O routines for OAKS32R board. 4 * Typical I/O routines for OAKS32R board.
5 * 5 *
6 * Copyright (c) 2001-2004 Hiroyuki Kondo, Hirokazu Takata, 6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Mamoru Sakugawa 7 * Hitoshi Yamamoto, Mamoru Sakugawa
8 */ 8 */
9 9
@@ -90,35 +90,21 @@ unsigned long _inl(unsigned long port)
90 90
91unsigned char _inb_p(unsigned long port) 91unsigned char _inb_p(unsigned long port)
92{ 92{
93 unsigned char v; 93 unsigned char v = _inb(port);
94
95 if (port >= 0x300 && port < 0x320)
96 v = _ne_inb(PORT2ADDR_NE(port));
97 else
98 v = *(volatile unsigned char *)PORT2ADDR(port);
99
100 delay(); 94 delay();
101 return (v); 95 return (v);
102} 96}
103 97
104unsigned short _inw_p(unsigned long port) 98unsigned short _inw_p(unsigned long port)
105{ 99{
106 unsigned short v; 100 unsigned short v = _inw(port);
107
108 if (port >= 0x300 && port < 0x320)
109 v = _ne_inw(PORT2ADDR_NE(port));
110 else
111 v = *(volatile unsigned short *)PORT2ADDR(port);
112
113 delay(); 101 delay();
114 return (v); 102 return (v);
115} 103}
116 104
117unsigned long _inl_p(unsigned long port) 105unsigned long _inl_p(unsigned long port)
118{ 106{
119 unsigned long v; 107 unsigned long v = _inl(port);
120
121 v = *(volatile unsigned long *)PORT2ADDR(port);
122 delay(); 108 delay();
123 return (v); 109 return (v);
124} 110}
@@ -146,27 +132,19 @@ void _outl(unsigned long l, unsigned long port)
146 132
147void _outb_p(unsigned char b, unsigned long port) 133void _outb_p(unsigned char b, unsigned long port)
148{ 134{
149 if (port >= 0x300 && port < 0x320) 135 _outb(b, port);
150 _ne_outb(b, PORT2ADDR_NE(port));
151 else
152 *(volatile unsigned char *)PORT2ADDR(port) = b;
153
154 delay(); 136 delay();
155} 137}
156 138
157void _outw_p(unsigned short w, unsigned long port) 139void _outw_p(unsigned short w, unsigned long port)
158{ 140{
159 if (port >= 0x300 && port < 0x320) 141 _outw(w, port);
160 _ne_outw(w, PORT2ADDR_NE(port));
161 else
162 *(volatile unsigned short *)PORT2ADDR(port) = w;
163
164 delay(); 142 delay();
165} 143}
166 144
167void _outl_p(unsigned long l, unsigned long port) 145void _outl_p(unsigned long l, unsigned long port)
168{ 146{
169 *(volatile unsigned long *)PORT2ADDR(port) = l; 147 _outl(l, port);
170 delay(); 148 delay();
171} 149}
172 150
diff --git a/arch/m32r/kernel/io_opsput.c b/arch/m32r/kernel/io_opsput.c
index aaf42f9f76da..e34951e8156f 100644
--- a/arch/m32r/kernel/io_opsput.c
+++ b/arch/m32r/kernel/io_opsput.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * linux/arch/m32r/kernel/io_mappi.c 2 * linux/arch/m32r/kernel/io_opsput.c
3 * 3 *
4 * Typical I/O routines for OPSPUT board. 4 * Typical I/O routines for OPSPUT board.
5 * 5 *
6 * Copyright (c) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata, 6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Takeo Takahashi 7 * Hitoshi Yamamoto, Takeo Takahashi
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General 9 * This file is subject to the terms and conditions of the GNU General
10 * Public License. See the file "COPYING" in the main directory of this 10 * Public License. See the file "COPYING" in the main directory of this
@@ -98,7 +98,6 @@ unsigned char _inb(unsigned long port)
98{ 98{
99 if (port >= LAN_IOSTART && port < LAN_IOEND) 99 if (port >= LAN_IOSTART && port < LAN_IOEND)
100 return _ne_inb(PORT2ADDR_NE(port)); 100 return _ne_inb(PORT2ADDR_NE(port));
101
102#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) 101#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
103 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { 102 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
104 unsigned char b; 103 unsigned char b;
@@ -118,7 +117,6 @@ unsigned short _inw(unsigned long port)
118 else if(port >= 0x340 && port < 0x3a0) 117 else if(port >= 0x340 && port < 0x3a0)
119 return *(volatile unsigned short *)PORT2ADDR_USB(port); 118 return *(volatile unsigned short *)PORT2ADDR_USB(port);
120#endif 119#endif
121
122#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) 120#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
123 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { 121 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
124 unsigned short w; 122 unsigned short w;
@@ -143,55 +141,21 @@ unsigned long _inl(unsigned long port)
143 141
144unsigned char _inb_p(unsigned long port) 142unsigned char _inb_p(unsigned long port)
145{ 143{
146 unsigned char v; 144 unsigned char v = _inb(port);
147
148 if (port >= LAN_IOSTART && port < LAN_IOEND)
149 v = _ne_inb(PORT2ADDR_NE(port));
150 else
151#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
152 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
153 unsigned char b;
154 pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
155 return b;
156 } else
157#endif
158 v = *(volatile unsigned char *)PORT2ADDR(port);
159
160 delay(); 145 delay();
161 return (v); 146 return (v);
162} 147}
163 148
164unsigned short _inw_p(unsigned long port) 149unsigned short _inw_p(unsigned long port)
165{ 150{
166 unsigned short v; 151 unsigned short v = _inw(port);
167
168 if (port >= LAN_IOSTART && port < LAN_IOEND)
169 v = _ne_inw(PORT2ADDR_NE(port));
170 else
171#if defined(CONFIG_USB)
172 if(port >= 0x340 && port < 0x3a0)
173 return *(volatile unsigned short *)PORT2ADDR_USB(port);
174 else
175#endif
176
177#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
178 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
179 unsigned short w;
180 pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
181 return w;
182 } else
183#endif
184 v = *(volatile unsigned short *)PORT2ADDR(port);
185
186 delay(); 152 delay();
187 return (v); 153 return (v);
188} 154}
189 155
190unsigned long _inl_p(unsigned long port) 156unsigned long _inl_p(unsigned long port)
191{ 157{
192 unsigned long v; 158 unsigned long v = _inl(port);
193
194 v = *(volatile unsigned long *)PORT2ADDR(port);
195 delay(); 159 delay();
196 return (v); 160 return (v);
197} 161}
@@ -219,7 +183,6 @@ void _outw(unsigned short w, unsigned long port)
219 *(volatile unsigned short *)PORT2ADDR_USB(port) = w; 183 *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
220 else 184 else
221#endif 185#endif
222
223#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) 186#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
224 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { 187 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
225 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0); 188 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
@@ -240,43 +203,19 @@ void _outl(unsigned long l, unsigned long port)
240 203
241void _outb_p(unsigned char b, unsigned long port) 204void _outb_p(unsigned char b, unsigned long port)
242{ 205{
243 if (port >= LAN_IOSTART && port < LAN_IOEND) 206 _outb(b, port);
244 _ne_outb(b, PORT2ADDR_NE(port));
245 else
246#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
247 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
248 pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
249 } else
250#endif
251 *(volatile unsigned char *)PORT2ADDR(port) = b;
252
253 delay(); 207 delay();
254} 208}
255 209
256void _outw_p(unsigned short w, unsigned long port) 210void _outw_p(unsigned short w, unsigned long port)
257{ 211{
258 if (port >= LAN_IOSTART && port < LAN_IOEND) 212 _outw(w, port);
259 _ne_outw(w, PORT2ADDR_NE(port));
260 else
261#if defined(CONFIG_USB)
262 if(port >= 0x340 && port < 0x3a0)
263 *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
264 else
265#endif
266
267#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
268 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
269 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
270 } else
271#endif
272 *(volatile unsigned short *)PORT2ADDR(port) = w;
273
274 delay(); 213 delay();
275} 214}
276 215
277void _outl_p(unsigned long l, unsigned long port) 216void _outl_p(unsigned long l, unsigned long port)
278{ 217{
279 *(volatile unsigned long *)PORT2ADDR(port) = l; 218 _outl(l, port);
280 delay(); 219 delay();
281} 220}
282 221
diff --git a/arch/m32r/kernel/io_usrv.c b/arch/m32r/kernel/io_usrv.c
index 27928a0b99ed..9eb161dcc104 100644
--- a/arch/m32r/kernel/io_usrv.c
+++ b/arch/m32r/kernel/io_usrv.c
@@ -3,8 +3,8 @@
3 * 3 *
4 * Typical I/O routines for uServer board. 4 * Typical I/O routines for uServer board.
5 * 5 *
6 * Copyright (c) 2001 - 2003 Hiroyuki Kondo, Hirokazu Takata, 6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Takeo Takahashi 7 * Hitoshi Yamamoto, Takeo Takahashi
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General 9 * This file is subject to the terms and conditions of the GNU General
10 * Public License. See the file "COPYING" in the main directory of this 10 * Public License. See the file "COPYING" in the main directory of this
@@ -39,7 +39,7 @@ extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int);
39 39
40#define PORT2ADDR(port) _port2addr(port) 40#define PORT2ADDR(port) _port2addr(port)
41 41
42static __inline__ void *_port2addr(unsigned long port) 42static inline void *_port2addr(unsigned long port)
43{ 43{
44#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) 44#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
45 if (port >= UART0_IOSTART && port <= UART0_IOEND) 45 if (port >= UART0_IOSTART && port <= UART0_IOEND)
@@ -50,7 +50,7 @@ static __inline__ void *_port2addr(unsigned long port)
50 return (void *)(port + NONCACHE_OFFSET); 50 return (void *)(port + NONCACHE_OFFSET);
51} 51}
52 52
53static __inline__ void delay(void) 53static inline void delay(void)
54{ 54{
55 __asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory"); 55 __asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory");
56} 56}
@@ -87,39 +87,22 @@ unsigned long _inl(unsigned long port)
87 87
88unsigned char _inb_p(unsigned long port) 88unsigned char _inb_p(unsigned long port)
89{ 89{
90 unsigned char b; 90 unsigned char v = _inb(port);
91 91 delay();
92 if (port >= CFC_IOSTART && port <= CFC_IOEND) { 92 return v;
93 pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
94 return b;
95 } else {
96 b = *(volatile unsigned char *)PORT2ADDR(port);
97 delay();
98 return b;
99 }
100} 93}
101 94
102unsigned short _inw_p(unsigned long port) 95unsigned short _inw_p(unsigned long port)
103{ 96{
104 unsigned short w; 97 unsigned short v = _inw(port);
105 98 delay();
106 if (port >= CFC_IOSTART && port <= CFC_IOEND) { 99 return v;
107 pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
108 return w;
109 } else {
110 w = *(volatile unsigned short *)PORT2ADDR(port);
111 delay();
112 return w;
113 }
114} 100}
115 101
116unsigned long _inl_p(unsigned long port) 102unsigned long _inl_p(unsigned long port)
117{ 103{
118 unsigned long v; 104 unsigned long v = _inl(port);
119
120 v = *(volatile unsigned long *)PORT2ADDR(port);
121 delay(); 105 delay();
122
123 return v; 106 return v;
124} 107}
125 108
@@ -149,25 +132,19 @@ void _outl(unsigned long l, unsigned long port)
149 132
150void _outb_p(unsigned char b, unsigned long port) 133void _outb_p(unsigned char b, unsigned long port)
151{ 134{
152 if (port >= CFC_IOSTART && port <= CFC_IOEND) 135 _outb(b, port);
153 pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
154 else
155 *(volatile unsigned char *)PORT2ADDR(port) = b;
156 delay(); 136 delay();
157} 137}
158 138
159void _outw_p(unsigned short w, unsigned long port) 139void _outw_p(unsigned short w, unsigned long port)
160{ 140{
161 if (port >= CFC_IOSTART && port <= CFC_IOEND) 141 _outw(w, port);
162 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
163 else
164 *(volatile unsigned short *)PORT2ADDR(port) = w;
165 delay(); 142 delay();
166} 143}
167 144
168void _outl_p(unsigned long l, unsigned long port) 145void _outl_p(unsigned long l, unsigned long port)
169{ 146{
170 *(volatile unsigned long *)PORT2ADDR(port) = l; 147 _outl(l, port);
171 delay(); 148 delay();
172} 149}
173 150
diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c
index 4826cd6e40e8..ec5674727e7f 100644
--- a/arch/m32r/kernel/setup.c
+++ b/arch/m32r/kernel/setup.c
@@ -330,6 +330,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
330 seq_printf(m, "Machine\t\t: Mappi Evaluation board\n"); 330 seq_printf(m, "Machine\t\t: Mappi Evaluation board\n");
331#elif CONFIG_PLAT_MAPPI2 331#elif CONFIG_PLAT_MAPPI2
332 seq_printf(m, "Machine\t\t: Mappi-II Evaluation board\n"); 332 seq_printf(m, "Machine\t\t: Mappi-II Evaluation board\n");
333#elif CONFIG_PLAT_MAPPI3
334 seq_printf(m, "Machine\t\t: Mappi-III Evaluation board\n");
333#elif CONFIG_PLAT_M32700UT 335#elif CONFIG_PLAT_M32700UT
334 seq_printf(m, "Machine\t\t: M32700UT Evaluation board\n"); 336 seq_printf(m, "Machine\t\t: M32700UT Evaluation board\n");
335#elif CONFIG_PLAT_OPSPUT 337#elif CONFIG_PLAT_OPSPUT
diff --git a/arch/m32r/kernel/setup_mappi2.c b/arch/m32r/kernel/setup_mappi2.c
index 1904d465a507..248fc658dbd5 100644
--- a/arch/m32r/kernel/setup_mappi2.c
+++ b/arch/m32r/kernel/setup_mappi2.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/m32r/kernel/setup_mappi.c 2 * linux/arch/m32r/kernel/setup_mappi2.c
3 * 3 *
4 * Setup routines for Renesas MAPPI-II(M3A-ZA36) Board 4 * Setup routines for Renesas MAPPI-II(M3A-ZA36) Board
5 * 5 *
@@ -156,7 +156,6 @@ void __init init_IRQ(void)
156 irq_desc[PLD_IRQ_CFIREQ].handler = &mappi2_irq_type; 156 irq_desc[PLD_IRQ_CFIREQ].handler = &mappi2_irq_type;
157 irq_desc[PLD_IRQ_CFIREQ].action = 0; 157 irq_desc[PLD_IRQ_CFIREQ].action = 0;
158 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */ 158 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */
159// icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00;
160 icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01; 159 icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
161 disable_mappi2_irq(PLD_IRQ_CFIREQ); 160 disable_mappi2_irq(PLD_IRQ_CFIREQ);
162 161
@@ -167,7 +166,6 @@ void __init init_IRQ(void)
167 irq_desc[PLD_IRQ_CFC_INSERT].action = 0; 166 irq_desc[PLD_IRQ_CFC_INSERT].action = 0;
168 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */ 167 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */
169 icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00; 168 icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00;
170// icu_data[PLD_IRQ_CFC_INSERT].icucr = 0;
171 disable_mappi2_irq(PLD_IRQ_CFC_INSERT); 169 disable_mappi2_irq(PLD_IRQ_CFC_INSERT);
172 170
173 /* ICUCR42: CFC Eject */ 171 /* ICUCR42: CFC Eject */
@@ -176,9 +174,7 @@ void __init init_IRQ(void)
176 irq_desc[PLD_IRQ_CFC_EJECT].action = 0; 174 irq_desc[PLD_IRQ_CFC_EJECT].action = 0;
177 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */ 175 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */
178 icu_data[PLD_IRQ_CFC_EJECT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 176 icu_data[PLD_IRQ_CFC_EJECT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
179// icu_data[PLD_IRQ_CFC_EJECT].icucr = 0;
180 disable_mappi2_irq(PLD_IRQ_CFC_EJECT); 177 disable_mappi2_irq(PLD_IRQ_CFC_EJECT);
181
182#endif /* CONFIG_MAPPI2_CFC */ 178#endif /* CONFIG_MAPPI2_CFC */
183} 179}
184 180
diff --git a/arch/m32r/kernel/setup_mappi3.c b/arch/m32r/kernel/setup_mappi3.c
new file mode 100644
index 000000000000..72b5b7609cea
--- /dev/null
+++ b/arch/m32r/kernel/setup_mappi3.c
@@ -0,0 +1,208 @@
1/*
2 * linux/arch/m32r/kernel/setup_mappi3.c
3 *
4 * Setup routines for Renesas MAPPI-III(M3A-2170) 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 <linux/irq.h>
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/device.h>
15
16#include <asm/system.h>
17#include <asm/m32r.h>
18#include <asm/io.h>
19
20#define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
21
22#ifndef CONFIG_SMP
23typedef struct {
24 unsigned long icucr; /* ICU Control Register */
25} icu_data_t;
26#endif /* CONFIG_SMP */
27
28icu_data_t icu_data[NR_IRQS];
29
30static void disable_mappi3_irq(unsigned int irq)
31{
32 unsigned long port, data;
33
34 if ((irq == 0) ||(irq >= NR_IRQS)) {
35 printk("bad irq 0x%08x\n", irq);
36 return;
37 }
38 port = irq2port(irq);
39 data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
40 outl(data, port);
41}
42
43static void enable_mappi3_irq(unsigned int irq)
44{
45 unsigned long port, data;
46
47 if ((irq == 0) ||(irq >= NR_IRQS)) {
48 printk("bad irq 0x%08x\n", irq);
49 return;
50 }
51 port = irq2port(irq);
52 data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
53 outl(data, port);
54}
55
56static void mask_and_ack_mappi3(unsigned int irq)
57{
58 disable_mappi3_irq(irq);
59}
60
61static void end_mappi3_irq(unsigned int irq)
62{
63 enable_mappi3_irq(irq);
64}
65
66static unsigned int startup_mappi3_irq(unsigned int irq)
67{
68 enable_mappi3_irq(irq);
69 return (0);
70}
71
72static void shutdown_mappi3_irq(unsigned int irq)
73{
74 unsigned long port;
75
76 port = irq2port(irq);
77 outl(M32R_ICUCR_ILEVEL7, port);
78}
79
80static struct hw_interrupt_type mappi3_irq_type =
81{
82 "MAPPI3-IRQ",
83 startup_mappi3_irq,
84 shutdown_mappi3_irq,
85 enable_mappi3_irq,
86 disable_mappi3_irq,
87 mask_and_ack_mappi3,
88 end_mappi3_irq
89};
90
91void __init init_IRQ(void)
92{
93#if defined(CONFIG_SMC91X)
94 /* INT0 : LAN controller (SMC91111) */
95 irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED;
96 irq_desc[M32R_IRQ_INT0].handler = &mappi3_irq_type;
97 irq_desc[M32R_IRQ_INT0].action = 0;
98 irq_desc[M32R_IRQ_INT0].depth = 1;
99 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
100 disable_mappi3_irq(M32R_IRQ_INT0);
101#endif /* CONFIG_SMC91X */
102
103 /* MFT2 : system timer */
104 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
105 irq_desc[M32R_IRQ_MFT2].handler = &mappi3_irq_type;
106 irq_desc[M32R_IRQ_MFT2].action = 0;
107 irq_desc[M32R_IRQ_MFT2].depth = 1;
108 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
109 disable_mappi3_irq(M32R_IRQ_MFT2);
110
111#ifdef CONFIG_SERIAL_M32R_SIO
112 /* SIO0_R : uart receive data */
113 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
114 irq_desc[M32R_IRQ_SIO0_R].handler = &mappi3_irq_type;
115 irq_desc[M32R_IRQ_SIO0_R].action = 0;
116 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
117 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
118 disable_mappi3_irq(M32R_IRQ_SIO0_R);
119
120 /* SIO0_S : uart send data */
121 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
122 irq_desc[M32R_IRQ_SIO0_S].handler = &mappi3_irq_type;
123 irq_desc[M32R_IRQ_SIO0_S].action = 0;
124 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
125 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
126 disable_mappi3_irq(M32R_IRQ_SIO0_S);
127 /* SIO1_R : uart receive data */
128 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
129 irq_desc[M32R_IRQ_SIO1_R].handler = &mappi3_irq_type;
130 irq_desc[M32R_IRQ_SIO1_R].action = 0;
131 irq_desc[M32R_IRQ_SIO1_R].depth = 1;
132 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
133 disable_mappi3_irq(M32R_IRQ_SIO1_R);
134
135 /* SIO1_S : uart send data */
136 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
137 irq_desc[M32R_IRQ_SIO1_S].handler = &mappi3_irq_type;
138 irq_desc[M32R_IRQ_SIO1_S].action = 0;
139 irq_desc[M32R_IRQ_SIO1_S].depth = 1;
140 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
141 disable_mappi3_irq(M32R_IRQ_SIO1_S);
142#endif /* CONFIG_M32R_USE_DBG_CONSOLE */
143
144#if defined(CONFIG_USB)
145 /* INT1 : USB Host controller interrupt */
146 irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED;
147 irq_desc[M32R_IRQ_INT1].handler = &mappi3_irq_type;
148 irq_desc[M32R_IRQ_INT1].action = 0;
149 irq_desc[M32R_IRQ_INT1].depth = 1;
150 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_ISMOD01;
151 disable_mappi3_irq(M32R_IRQ_INT1);
152#endif /* CONFIG_USB */
153
154 /* ICUCR40: CFC IREQ */
155 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
156 irq_desc[PLD_IRQ_CFIREQ].handler = &mappi3_irq_type;
157 irq_desc[PLD_IRQ_CFIREQ].action = 0;
158 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */
159 icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
160 disable_mappi3_irq(PLD_IRQ_CFIREQ);
161
162#if defined(CONFIG_M32R_CFC)
163 /* ICUCR41: CFC Insert */
164 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED;
165 irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi3_irq_type;
166 irq_desc[PLD_IRQ_CFC_INSERT].action = 0;
167 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */
168 icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00;
169 disable_mappi3_irq(PLD_IRQ_CFC_INSERT);
170
171 /* ICUCR42: CFC Eject */
172 irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED;
173 irq_desc[PLD_IRQ_CFC_EJECT].handler = &mappi3_irq_type;
174 irq_desc[PLD_IRQ_CFC_EJECT].action = 0;
175 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */
176 icu_data[PLD_IRQ_CFC_EJECT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
177 disable_mappi3_irq(PLD_IRQ_CFC_EJECT);
178#endif /* CONFIG_M32R_CFC */
179}
180
181#define LAN_IOSTART 0x300
182#define LAN_IOEND 0x320
183static struct resource smc91x_resources[] = {
184 [0] = {
185 .start = (LAN_IOSTART),
186 .end = (LAN_IOEND),
187 .flags = IORESOURCE_MEM,
188 },
189 [1] = {
190 .start = M32R_IRQ_INT0,
191 .end = M32R_IRQ_INT0,
192 .flags = IORESOURCE_IRQ,
193 }
194};
195
196static struct platform_device smc91x_device = {
197 .name = "smc91x",
198 .id = 0,
199 .num_resources = ARRAY_SIZE(smc91x_resources),
200 .resource = smc91x_resources,
201};
202
203static int __init platform_init(void)
204{
205 platform_device_register(&smc91x_device);
206 return 0;
207}
208arch_initcall(platform_init);