usb: option: add Huawei E353 controlling interfaces
[zen-stable.git] / arch / m32r / platforms / oaks32r / io.c
blob364a3b2e8907d50e57bc86e1462ded25e6157652
1 /*
2 * linux/arch/m32r/platforms/oaks32r/io.c
4 * Typical I/O routines for OAKS32R board.
6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Mamoru Sakugawa
8 */
10 #include <asm/m32r.h>
11 #include <asm/page.h>
12 #include <asm/io.h>
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");
32 * NIC I/O function
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)
44 unsigned short tmp;
46 tmp = *(unsigned short *)(portp) & 0xff;
47 tmp |= *(unsigned short *)(portp+2) << 8;
48 return tmp;
51 static inline void _ne_insb(void *portp, void *addr, unsigned long count)
53 unsigned char *buf = addr;
54 while (count--)
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);
93 delay();
94 return (v);
97 unsigned short _inw_p(unsigned long port)
99 unsigned short v = _inw(port);
100 delay();
101 return (v);
104 unsigned long _inl_p(unsigned long port)
106 unsigned long v = _inl(port);
107 delay();
108 return (v);
111 void _outb(unsigned char b, unsigned long port)
113 if (port >= 0x300 && port < 0x320)
114 _ne_outb(b, PORT2ADDR_NE(port));
115 else
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));
123 else
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)
134 _outb(b, port);
135 delay();
138 void _outw_p(unsigned short w, unsigned long port)
140 _outw(w, port);
141 delay();
144 void _outl_p(unsigned long l, unsigned long port)
146 _outl(l, port);
147 delay();
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);
154 else {
155 unsigned char *buf = addr;
156 unsigned char *portp = PORT2ADDR(port);
157 while (count--)
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);
169 while (count--)
170 *buf++ = _ne_inw(portp);
171 } else {
172 portp = PORT2ADDR(port);
173 while (count--)
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);
184 while (count--)
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);
195 while (count--)
196 _ne_outb(*buf++, portp);
197 } else {
198 portp = PORT2ADDR(port);
199 while (count--)
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);
211 while (count--)
212 _ne_outw(*buf++, portp);
213 } else {
214 portp = PORT2ADDR(port);
215 while (count--)
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);
226 while (count--)
227 *(volatile unsigned long *)portp = *buf++;