2 * linux/arch/m32r/kernel/io_oaks32r.c
4 * Typical I/O routines for OAKS32R board.
6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Mamoru Sakugawa
10 #include <linux/config.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");
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)
47 tmp = *(unsigned short *)(portp) & 0xff;
48 tmp |= *(unsigned short *)(portp+2) << 8;
52 static inline void _ne_insb(void *portp, void *addr, unsigned long count)
54 unsigned char *buf = addr;
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 = _inb(port);
98 unsigned short _inw_p(unsigned long port)
100 unsigned short v = _inw(port);
105 unsigned long _inl_p(unsigned long port)
107 unsigned long v = _inl(port);
112 void _outb(unsigned char b, unsigned long port)
114 if (port >= 0x300 && port < 0x320)
115 _ne_outb(b, PORT2ADDR_NE(port));
117 *(volatile unsigned char *)PORT2ADDR(port) = b;
120 void _outw(unsigned short w, unsigned long port)
122 if (port >= 0x300 && port < 0x320)
123 _ne_outw(w, PORT2ADDR_NE(port));
125 *(volatile unsigned short *)PORT2ADDR(port) = w;
128 void _outl(unsigned long l, unsigned long port)
130 *(volatile unsigned long *)PORT2ADDR(port) = l;
133 void _outb_p(unsigned char b, unsigned long port)
139 void _outw_p(unsigned short w, unsigned long port)
145 void _outl_p(unsigned long l, unsigned long port)
151 void _insb(unsigned int port, void *addr, unsigned long count)
153 if (port >= 0x300 && port < 0x320)
154 _ne_insb(PORT2ADDR_NE(port), addr, count);
156 unsigned char *buf = addr;
157 unsigned char *portp = PORT2ADDR(port);
159 *buf++ = *(volatile unsigned char *)portp;
163 void _insw(unsigned int port, void *addr, unsigned long count)
165 unsigned short *buf = addr;
166 unsigned short *portp;
168 if (port >= 0x300 && port < 0x320) {
169 portp = PORT2ADDR_NE(port);
171 *buf++ = _ne_inw(portp);
173 portp = PORT2ADDR(port);
175 *buf++ = *(volatile unsigned short *)portp;
179 void _insl(unsigned int port, void *addr, unsigned long count)
181 unsigned long *buf = addr;
182 unsigned long *portp;
184 portp = PORT2ADDR(port);
186 *buf++ = *(volatile unsigned long *)portp;
189 void _outsb(unsigned int port, const void *addr, unsigned long count)
191 const unsigned char *buf = addr;
192 unsigned char *portp;
194 if (port >= 0x300 && port < 0x320) {
195 portp = PORT2ADDR_NE(port);
197 _ne_outb(*buf++, portp);
199 portp = PORT2ADDR(port);
201 *(volatile unsigned char *)portp = *buf++;
205 void _outsw(unsigned int port, const void *addr, unsigned long count)
207 const unsigned short *buf = addr;
208 unsigned short *portp;
210 if (port >= 0x300 && port < 0x320) {
211 portp = PORT2ADDR_NE(port);
213 _ne_outw(*buf++, portp);
215 portp = PORT2ADDR(port);
217 *(volatile unsigned short *)portp = *buf++;
221 void _outsl(unsigned int port, const void *addr, unsigned long count)
223 const unsigned long *buf = addr;
224 unsigned char *portp;
226 portp = PORT2ADDR(port);
228 *(volatile unsigned long *)portp = *buf++;