[PATCH] Avoid console spam with ext3 aborted journal.
[linux-2.6/verdex.git] / arch / m32r / kernel / io_oaks32r.c
blob286964794d5158bc58e666c0cbf8664a92781db4
1 /*
2 * linux/arch/m32r/kernel/io_oaks32r.c
4 * Typical I/O routines for OAKS32R board.
6 * Copyright (c) 2001-2004 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Mamoru Sakugawa
8 */
10 #include <linux/config.h>
11 #include <asm/m32r.h>
12 #include <asm/page.h>
13 #include <asm/io.h>
15 #define PORT2ADDR(port) _port2addr(port)
17 static inline void *_port2addr(unsigned long port)
19 return (void *)(port + NONCACHE_OFFSET);
22 static inline void *_port2addr_ne(unsigned long port)
24 return (void *)((port<<1) + NONCACHE_OFFSET + 0x02000000);
27 static inline void delay(void)
29 __asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory");
33 * NIC I/O function
36 #define PORT2ADDR_NE(port) _port2addr_ne(port)
38 static inline unsigned char _ne_inb(void *portp)
40 return *(volatile unsigned char *)(portp+1);
43 static inline unsigned short _ne_inw(void *portp)
45 unsigned short tmp;
47 tmp = *(unsigned short *)(portp) & 0xff;
48 tmp |= *(unsigned short *)(portp+2) << 8;
49 return tmp;
52 static inline void _ne_insb(void *portp, void *addr, unsigned long count)
54 unsigned char *buf = addr;
55 while (count--)
56 *buf++ = *(volatile unsigned char *)(portp+1);
59 static inline void _ne_outb(unsigned char b, void *portp)
61 *(volatile unsigned char *)(portp+1) = b;
64 static inline void _ne_outw(unsigned short w, void *portp)
66 *(volatile unsigned short *)portp = (w >> 8);
67 *(volatile unsigned short *)(portp+2) = (w & 0xff);
70 unsigned char _inb(unsigned long port)
72 if (port >= 0x300 && port < 0x320)
73 return _ne_inb(PORT2ADDR_NE(port));
75 return *(volatile unsigned char *)PORT2ADDR(port);
78 unsigned short _inw(unsigned long port)
80 if (port >= 0x300 && port < 0x320)
81 return _ne_inw(PORT2ADDR_NE(port));
83 return *(volatile unsigned short *)PORT2ADDR(port);
86 unsigned long _inl(unsigned long port)
88 return *(volatile unsigned long *)PORT2ADDR(port);
91 unsigned char _inb_p(unsigned long port)
93 unsigned char v;
95 if (port >= 0x300 && port < 0x320)
96 v = _ne_inb(PORT2ADDR_NE(port));
97 else
98 v = *(volatile unsigned char *)PORT2ADDR(port);
100 delay();
101 return (v);
104 unsigned short _inw_p(unsigned long port)
106 unsigned short v;
108 if (port >= 0x300 && port < 0x320)
109 v = _ne_inw(PORT2ADDR_NE(port));
110 else
111 v = *(volatile unsigned short *)PORT2ADDR(port);
113 delay();
114 return (v);
117 unsigned long _inl_p(unsigned long port)
119 unsigned long v;
121 v = *(volatile unsigned long *)PORT2ADDR(port);
122 delay();
123 return (v);
126 void _outb(unsigned char b, unsigned long port)
128 if (port >= 0x300 && port < 0x320)
129 _ne_outb(b, PORT2ADDR_NE(port));
130 else
131 *(volatile unsigned char *)PORT2ADDR(port) = b;
134 void _outw(unsigned short w, unsigned long port)
136 if (port >= 0x300 && port < 0x320)
137 _ne_outw(w, PORT2ADDR_NE(port));
138 else
139 *(volatile unsigned short *)PORT2ADDR(port) = w;
142 void _outl(unsigned long l, unsigned long port)
144 *(volatile unsigned long *)PORT2ADDR(port) = l;
147 void _outb_p(unsigned char b, unsigned long port)
149 if (port >= 0x300 && port < 0x320)
150 _ne_outb(b, PORT2ADDR_NE(port));
151 else
152 *(volatile unsigned char *)PORT2ADDR(port) = b;
154 delay();
157 void _outw_p(unsigned short w, unsigned long port)
159 if (port >= 0x300 && port < 0x320)
160 _ne_outw(w, PORT2ADDR_NE(port));
161 else
162 *(volatile unsigned short *)PORT2ADDR(port) = w;
164 delay();
167 void _outl_p(unsigned long l, unsigned long port)
169 *(volatile unsigned long *)PORT2ADDR(port) = l;
170 delay();
173 void _insb(unsigned int port, void *addr, unsigned long count)
175 if (port >= 0x300 && port < 0x320)
176 _ne_insb(PORT2ADDR_NE(port), addr, count);
177 else {
178 unsigned char *buf = addr;
179 unsigned char *portp = PORT2ADDR(port);
180 while (count--)
181 *buf++ = *(volatile unsigned char *)portp;
185 void _insw(unsigned int port, void *addr, unsigned long count)
187 unsigned short *buf = addr;
188 unsigned short *portp;
190 if (port >= 0x300 && port < 0x320) {
191 portp = PORT2ADDR_NE(port);
192 while (count--)
193 *buf++ = _ne_inw(portp);
194 } else {
195 portp = PORT2ADDR(port);
196 while (count--)
197 *buf++ = *(volatile unsigned short *)portp;
201 void _insl(unsigned int port, void *addr, unsigned long count)
203 unsigned long *buf = addr;
204 unsigned long *portp;
206 portp = PORT2ADDR(port);
207 while (count--)
208 *buf++ = *(volatile unsigned long *)portp;
211 void _outsb(unsigned int port, const void *addr, unsigned long count)
213 const unsigned char *buf = addr;
214 unsigned char *portp;
216 if (port >= 0x300 && port < 0x320) {
217 portp = PORT2ADDR_NE(port);
218 while (count--)
219 _ne_outb(*buf++, portp);
220 } else {
221 portp = PORT2ADDR(port);
222 while (count--)
223 *(volatile unsigned char *)portp = *buf++;
227 void _outsw(unsigned int port, const void *addr, unsigned long count)
229 const unsigned short *buf = addr;
230 unsigned short *portp;
232 if (port >= 0x300 && port < 0x320) {
233 portp = PORT2ADDR_NE(port);
234 while (count--)
235 _ne_outw(*buf++, portp);
236 } else {
237 portp = PORT2ADDR(port);
238 while (count--)
239 *(volatile unsigned short *)portp = *buf++;
243 void _outsl(unsigned int port, const void *addr, unsigned long count)
245 const unsigned long *buf = addr;
246 unsigned char *portp;
248 portp = PORT2ADDR(port);
249 while (count--)
250 *(volatile unsigned long *)portp = *buf++;