17 #include <asm/byteorder.h>
19 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
20 #include <linux/types.h>
22 #define M32R_PCC_IOMAP_SIZE 0x1000
24 #define M32R_PCC_IOSTART0 0x1000
25 #define M32R_PCC_IOEND0 (M32R_PCC_IOSTART0 + M32R_PCC_IOMAP_SIZE - 1)
27 extern void pcc_ioread_byte(
int,
unsigned long,
void *,
size_t,
size_t,
int);
28 extern void pcc_ioread_word(
int,
unsigned long,
void *,
size_t,
size_t,
int);
29 extern void pcc_iowrite_byte(
int,
unsigned long,
void *,
size_t,
size_t,
int);
30 extern void pcc_iowrite_word(
int,
unsigned long,
void *,
size_t,
size_t,
int);
33 #define PORT2ADDR(port) _port2addr(port)
34 #define PORT2ADDR_USB(port) _port2addr_usb(port)
36 static inline void *_port2addr(
unsigned long port)
41 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
42 static inline void *__port2addr_ata(
unsigned long port)
56 default:
return (
void *)&dummy_reg;
66 #define LAN_IOSTART (0x300 | NONCACHE_OFFSET)
67 #define LAN_IOEND (0x320 | NONCACHE_OFFSET)
68 static inline void *_port2addr_ne(
unsigned long port)
70 return (
void *)(port + 0x10000000);
72 static inline void *_port2addr_usb(
unsigned long port)
77 static inline void delay(
void)
79 __asm__ __volatile__ (
"push r0; \n\t pop r0;" : : :
"memory");
86 #define PORT2ADDR_NE(port) _port2addr_ne(port)
88 static inline unsigned char _ne_inb(
void *portp)
90 return *(
volatile unsigned char *)portp;
93 static inline unsigned short _ne_inw(
void *portp)
95 return (
unsigned short)
le16_to_cpu(*(
volatile unsigned short *)portp);
98 static inline void _ne_insb(
void *portp,
void *
addr,
unsigned long count)
100 unsigned char *
buf = (
unsigned char *)addr;
103 *buf++ = _ne_inb(portp);
106 static inline void _ne_outb(
unsigned char b,
void *portp)
108 *(
volatile unsigned char *)portp = b;
111 static inline void _ne_outw(
unsigned short w,
void *portp)
113 *(
volatile unsigned short *)portp =
cpu_to_le16(w);
116 unsigned char _inb(
unsigned long port)
121 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
122 else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
123 return *(
volatile unsigned char *)__port2addr_ata(port);
126 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
127 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
134 return *(
volatile unsigned char *)
PORT2ADDR(port);
137 unsigned short _inw(
unsigned long port)
141 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
142 else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
143 return *(
volatile unsigned short *)__port2addr_ata(port);
146 #if defined(CONFIG_USB)
147 else if(port >= 0x340 && port < 0x3a0)
150 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
151 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
157 return *(
volatile unsigned short *)
PORT2ADDR(port);
160 unsigned long _inl(
unsigned long port)
162 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
163 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
169 return *(
volatile unsigned long *)
PORT2ADDR(port);
174 unsigned char v =
_inb(port);
179 unsigned short _inw_p(
unsigned long port)
181 unsigned short v =
_inw(port);
188 unsigned long v =
_inl(port);
193 void _outb(
unsigned char b,
unsigned long port)
198 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
199 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
200 *(
volatile unsigned char *)__port2addr_ata(port) =
b;
203 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
204 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
208 *(
volatile unsigned char *)
PORT2ADDR(port) =
b;
211 void _outw(
unsigned short w,
unsigned long port)
216 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
217 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
218 *(
volatile unsigned short *)__port2addr_ata(port) =
w;
221 #if defined(CONFIG_USB)
222 if(port >= 0x340 && port < 0x3a0)
226 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
227 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
231 *(
volatile unsigned short *)
PORT2ADDR(port) =
w;
234 void _outl(
unsigned long l,
unsigned long port)
236 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
237 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
241 *(
volatile unsigned long *)
PORT2ADDR(port) =
l;
250 void _outw_p(
unsigned short w,
unsigned long port)
262 void _insb(
unsigned int port,
void *addr,
unsigned long count)
266 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
267 else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
268 unsigned char *buf =
addr;
269 unsigned char *portp = __port2addr_ata(port);
271 *buf++ = *(
volatile unsigned char *)portp;
274 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
275 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
281 unsigned char *buf =
addr;
284 *buf++ = *(
volatile unsigned char *)portp;
288 void _insw(
unsigned int port,
void *addr,
unsigned long count)
290 unsigned short *buf =
addr;
291 unsigned short *portp;
300 *buf++ = *(
volatile unsigned short *)portp;
301 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
302 }
else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
306 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
307 }
else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
308 portp = __port2addr_ata(port);
310 *buf++ = *(
volatile unsigned short *)portp;
315 *buf++ = *(
volatile unsigned short *)portp;
319 void _insl(
unsigned int port,
void *addr,
unsigned long count)
321 unsigned long *buf =
addr;
322 unsigned long *portp;
326 *buf++ = *(
volatile unsigned long *)portp;
329 void _outsb(
unsigned int port,
const void *addr,
unsigned long count)
331 const unsigned char *buf =
addr;
332 unsigned char *portp;
337 _ne_outb(*buf++, portp);
338 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
339 }
else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
340 portp = __port2addr_ata(port);
342 *(
volatile unsigned char *)portp = *buf++;
344 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
345 }
else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
352 *(
volatile unsigned char *)portp = *buf++;
356 void _outsw(
unsigned int port,
const void *addr,
unsigned long count)
358 const unsigned short *buf =
addr;
359 unsigned short *portp;
368 *(
volatile unsigned short *)portp = *buf++;
369 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
370 }
else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
371 portp = __port2addr_ata(port);
373 *(
volatile unsigned short *)portp = *buf++;
375 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
376 }
else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
383 *(
volatile unsigned short *)portp = *buf++;
387 void _outsl(
unsigned int port,
const void *addr,
unsigned long count)
389 const unsigned long *buf =
addr;
390 unsigned char *portp;
394 *(
volatile unsigned long *)portp = *buf++;