13 #include <asm/byteorder.h>
15 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
16 #include <linux/types.h>
18 #define M32R_PCC_IOMAP_SIZE 0x1000
20 #define M32R_PCC_IOSTART0 0x1000
21 #define M32R_PCC_IOEND0 (M32R_PCC_IOSTART0 + M32R_PCC_IOMAP_SIZE - 1)
23 extern void pcc_ioread_byte(
int,
unsigned long,
void *,
size_t,
size_t,
int);
24 extern void pcc_ioread_word(
int,
unsigned long,
void *,
size_t,
size_t,
int);
25 extern void pcc_iowrite_byte(
int,
unsigned long,
void *,
size_t,
size_t,
int);
26 extern void pcc_iowrite_word(
int,
unsigned long,
void *,
size_t,
size_t,
int);
29 #define PORT2ADDR(port) _port2addr(port)
30 #define PORT2ADDR_NE(port) _port2addr_ne(port)
31 #define PORT2ADDR_USB(port) _port2addr_usb(port)
33 static inline void *_port2addr(
unsigned long port)
38 #if defined(CONFIG_IDE)
39 static inline void *__port2addr_ata(
unsigned long port)
74 default:
return (
void *)&dummy_reg;
79 #define LAN_IOSTART (0x300 | NONCACHE_OFFSET)
80 #define LAN_IOEND (0x320 | NONCACHE_OFFSET)
81 static inline void *_port2addr_ne(
unsigned long port)
83 return (
void *)(port + 0x10000000);
86 static inline void *_port2addr_usb(
unsigned long port)
90 static inline void delay(
void)
92 __asm__ __volatile__ (
"push r0; \n\t pop r0;" : : :
"memory");
99 static inline unsigned char _ne_inb(
void *portp)
101 return (
unsigned char) *(
volatile unsigned char *)portp;
104 static inline unsigned short _ne_inw(
void *portp)
106 return (
unsigned short)
le16_to_cpu(*(
volatile unsigned short *)portp);
109 static inline void _ne_insb(
void *portp,
void *
addr,
unsigned long count)
114 *buf++ = *(
volatile unsigned char *)portp;
117 static inline void _ne_outb(
unsigned char b,
void *portp)
119 *(
volatile unsigned char *)portp = (
unsigned char)
b;
122 static inline void _ne_outw(
unsigned short w,
void *portp)
124 *(
volatile unsigned short *)portp =
cpu_to_le16(w);
127 unsigned char _inb(
unsigned long port)
131 #if defined(CONFIG_IDE)
132 else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
133 ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
134 return *(
volatile unsigned char *)__port2addr_ata(port);
137 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
138 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
144 return *(
volatile unsigned char *)
PORT2ADDR(port);
147 unsigned short _inw(
unsigned long port)
151 #if defined(CONFIG_IDE)
152 else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
153 ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
154 return *(
volatile unsigned short *)__port2addr_ata(port);
157 #if defined(CONFIG_USB)
158 else if (port >= 0x340 && port < 0x3a0)
162 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
163 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
169 return *(
volatile unsigned short *)
PORT2ADDR(port);
172 unsigned long _inl(
unsigned long port)
174 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
175 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
181 return *(
volatile unsigned long *)
PORT2ADDR(port);
186 unsigned char v =
_inb(port);
191 unsigned short _inw_p(
unsigned long port)
193 unsigned short v =
_inw(port);
200 unsigned long v =
_inl(port);
205 void _outb(
unsigned char b,
unsigned long port)
210 #if defined(CONFIG_IDE)
211 if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
212 ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
213 *(
volatile unsigned char *)__port2addr_ata(port) =
b;
216 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
217 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
221 *(
volatile unsigned char *)
PORT2ADDR(port) =
b;
224 void _outw(
unsigned short w,
unsigned long port)
229 #if defined(CONFIG_IDE)
230 if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
231 ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
232 *(
volatile unsigned short *)__port2addr_ata(port) =
w;
235 #if defined(CONFIG_USB)
236 if (port >= 0x340 && port < 0x3a0)
240 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
241 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
245 *(
volatile unsigned short *)
PORT2ADDR(port) =
w;
248 void _outl(
unsigned long l,
unsigned long port)
250 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
251 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
255 *(
volatile unsigned long *)
PORT2ADDR(port) =
l;
258 void _outb_p(
unsigned char b,
unsigned long port)
264 void _outw_p(
unsigned short w,
unsigned long port)
276 void _insb(
unsigned int port,
void * addr,
unsigned long count)
280 #if defined(CONFIG_IDE)
281 else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
282 ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
283 unsigned char *buf =
addr;
284 unsigned char *portp = __port2addr_ata(port);
286 *buf++ = *(
volatile unsigned char *)portp;
289 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
290 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
296 unsigned char *buf =
addr;
299 *buf++ = *(
volatile unsigned char *)portp;
303 void _insw(
unsigned int port,
void * addr,
unsigned long count)
305 unsigned short *buf =
addr;
306 unsigned short *portp;
311 *buf++ = *(
volatile unsigned short *)portp;
312 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
313 }
else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
317 #if defined(CONFIG_IDE)
318 }
else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
319 ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
320 portp = __port2addr_ata(port);
322 *buf++ = *(
volatile unsigned short *)portp;
327 *buf++ = *(
volatile unsigned short *)portp;
331 void _insl(
unsigned int port,
void * addr,
unsigned long count)
333 unsigned long *buf =
addr;
334 unsigned long *portp;
338 *buf++ = *(
volatile unsigned long *)portp;
341 void _outsb(
unsigned int port,
const void * addr,
unsigned long count)
343 const unsigned char *buf =
addr;
344 unsigned char *portp;
349 _ne_outb(*buf++, portp);
350 #if defined(CONFIG_IDE)
351 }
else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
352 ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
353 portp = __port2addr_ata(port);
355 *(
volatile unsigned char *)portp = *buf++;
357 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
358 }
else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
365 *(
volatile unsigned char *)portp = *buf++;
369 void _outsw(
unsigned int port,
const void * addr,
unsigned long count)
371 const unsigned short *buf =
addr;
372 unsigned short *portp;
377 *(
volatile unsigned short *)portp = *buf++;
378 #if defined(CONFIG_IDE)
379 }
else if ( ((port >= 0x170 && port <=0x177) || port == 0x376) ||
380 ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) ){
381 portp = __port2addr_ata(port);
383 *(
volatile unsigned short *)portp = *buf++;
385 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
386 }
else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
393 *(
volatile unsigned short *)portp = *buf++;
397 void _outsl(
unsigned int port,
const void * addr,
unsigned long count)
399 const unsigned long *buf =
addr;
400 unsigned char *portp;
404 *(
volatile unsigned long *)portp = *buf++;