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
14 #define PORT2ADDR(port) _port2addr(port)
16 static inline void *_port2addr(unsigned long port)
18 return (void *)(port | NONCACHE_OFFSET);
21 static inline void *_port2addr_ne(unsigned long port)
23 return (void *)((port<<1) + NONCACHE_OFFSET + 0x02000000);
26 static inline void delay(void)
28 __asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory");
35 #define PORT2ADDR_NE(port) _port2addr_ne(port)
37 static inline unsigned char _ne_inb(void *portp)
39 return *(volatile unsigned char *)(portp+1);
42 static inline unsigned short _ne_inw(void *portp)
46 tmp = *(unsigned short *)(portp) & 0xff;
47 tmp |= *(unsigned short *)(portp+2) << 8;
51 static inline void _ne_insb(void *portp, void *addr, unsigned long count)
53 unsigned char *buf = addr;
55 *buf++ = *(volatile unsigned char *)(portp+1);
58 static inline void _ne_outb(unsigned char b, void *portp)
60 *(volatile unsigned char *)(portp+1) = b;
63 static inline void _ne_outw(unsigned short w, void *portp)
65 *(volatile unsigned short *)portp = (w >> 8);
66 *(volatile unsigned short *)(portp+2) = (w & 0xff);
69 unsigned char _inb(unsigned long port)
71 if (port >= 0x300 && port < 0x320)
72 return _ne_inb(PORT2ADDR_NE(port));
74 return *(volatile unsigned char *)PORT2ADDR(port);
77 unsigned short _inw(unsigned long port)
79 if (port >= 0x300 && port < 0x320)
80 return _ne_inw(PORT2ADDR_NE(port));
82 return *(volatile unsigned short *)PORT2ADDR(port);
85 unsigned long _inl(unsigned long port)
87 return *(volatile unsigned long *)PORT2ADDR(port);
90 unsigned char _inb_p(unsigned long port)
92 unsigned char v = _inb(port);
97 unsigned short _inw_p(unsigned long port)
99 unsigned short v = _inw(port);
104 unsigned long _inl_p(unsigned long port)
106 unsigned long v = _inl(port);
111 void _outb(unsigned char b, unsigned long port)
113 if (port >= 0x300 && port < 0x320)
114 _ne_outb(b, PORT2ADDR_NE(port));
116 *(volatile unsigned char *)PORT2ADDR(port) = b;
119 void _outw(unsigned short w, unsigned long port)
121 if (port >= 0x300 && port < 0x320)
122 _ne_outw(w, PORT2ADDR_NE(port));
124 *(volatile unsigned short *)PORT2ADDR(port) = w;
127 void _outl(unsigned long l, unsigned long port)
129 *(volatile unsigned long *)PORT2ADDR(port) = l;
132 void _outb_p(unsigned char b, unsigned long port)
138 void _outw_p(unsigned short w, unsigned long port)
144 void _outl_p(unsigned long l, unsigned long port)
150 void _insb(unsigned int port, void *addr, unsigned long count)
152 if (port >= 0x300 && port < 0x320)
153 _ne_insb(PORT2ADDR_NE(port), addr, count);
155 unsigned char *buf = addr;
156 unsigned char *portp = PORT2ADDR(port);
158 *buf++ = *(volatile unsigned char *)portp;
162 void _insw(unsigned int port, void *addr, unsigned long count)
164 unsigned short *buf = addr;
165 unsigned short *portp;
167 if (port >= 0x300 && port < 0x320) {
168 portp = PORT2ADDR_NE(port);
170 *buf++ = _ne_inw(portp);
172 portp = PORT2ADDR(port);
174 *buf++ = *(volatile unsigned short *)portp;
178 void _insl(unsigned int port, void *addr, unsigned long count)
180 unsigned long *buf = addr;
181 unsigned long *portp;
183 portp = PORT2ADDR(port);
185 *buf++ = *(volatile unsigned long *)portp;
188 void _outsb(unsigned int port, const void *addr, unsigned long count)
190 const unsigned char *buf = addr;
191 unsigned char *portp;
193 if (port >= 0x300 && port < 0x320) {
194 portp = PORT2ADDR_NE(port);
196 _ne_outb(*buf++, portp);
198 portp = PORT2ADDR(port);
200 *(volatile unsigned char *)portp = *buf++;
204 void _outsw(unsigned int port, const void *addr, unsigned long count)
206 const unsigned short *buf = addr;
207 unsigned short *portp;
209 if (port >= 0x300 && port < 0x320) {
210 portp = PORT2ADDR_NE(port);
212 _ne_outw(*buf++, portp);
214 portp = PORT2ADDR(port);
216 *(volatile unsigned short *)portp = *buf++;
220 void _outsl(unsigned int port, const void *addr, unsigned long count)
222 const unsigned long *buf = addr;
223 unsigned char *portp;
225 portp = PORT2ADDR(port);
227 *(volatile unsigned long *)portp = *buf++;