14 #include <asm/byteorder.h>
16 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
17 #include <linux/types.h>
19 #define M32R_PCC_IOMAP_SIZE 0x1000
21 #define M32R_PCC_IOSTART0 0x1000
22 #define M32R_PCC_IOEND0 (M32R_PCC_IOSTART0 + M32R_PCC_IOMAP_SIZE - 1)
24 extern void pcc_ioread_byte(
int,
unsigned long,
void *,
size_t,
size_t,
int);
25 extern void pcc_ioread_word(
int,
unsigned long,
void *,
size_t,
size_t,
int);
26 extern void pcc_iowrite_byte(
int,
unsigned long,
void *,
size_t,
size_t,
int);
27 extern void pcc_iowrite_word(
int,
unsigned long,
void *,
size_t,
size_t,
int);
30 #define PORT2ADDR(port) _port2addr(port)
32 static inline void *_port2addr(
unsigned long port)
37 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
38 static inline void *__port2addr_ata(
unsigned long port)
52 default:
return (
void *)&dummy_reg;
62 #define LAN_IOSTART (0x300 | NONCACHE_OFFSET)
63 #define LAN_IOEND (0x320 | NONCACHE_OFFSET)
64 static inline void *_port2addr_ne(
unsigned long port)
69 static inline void delay(
void)
71 __asm__ __volatile__ (
"push r0; \n\t pop r0;" : : :
"memory");
78 #define PORT2ADDR_NE(port) _port2addr_ne(port)
80 static inline unsigned char _ne_inb(
void *portp)
82 return *(
volatile unsigned char *)portp;
85 static inline unsigned short _ne_inw(
void *portp)
87 return (
unsigned short)
le16_to_cpu(*(
volatile unsigned short *)portp);
90 static inline void _ne_insb(
void *portp,
void *
addr,
unsigned long count)
92 unsigned char *
buf = (
unsigned char *)addr;
95 *buf++ = _ne_inb(portp);
98 static inline void _ne_outb(
unsigned char b,
void *portp)
100 *(
volatile unsigned char *)portp = b;
103 static inline void _ne_outw(
unsigned short w,
void *portp)
105 *(
volatile unsigned short *)portp =
cpu_to_le16(w);
108 unsigned char _inb(
unsigned long port)
113 return *(
volatile unsigned char *)
PORT2ADDR(port);
116 unsigned short _inw(
unsigned long port)
121 return *(
volatile unsigned short *)
PORT2ADDR(port);
124 unsigned long _inl(
unsigned long port)
126 return *(
volatile unsigned long *)
PORT2ADDR(port);
131 unsigned char v =
_inb(port);
136 unsigned short _inw_p(
unsigned long port)
138 unsigned short v =
_inw(port);
145 unsigned long v =
_inl(port);
150 void _outb(
unsigned char b,
unsigned long port)
155 *(
volatile unsigned char *)
PORT2ADDR(port) =
b;
158 void _outw(
unsigned short w,
unsigned long port)
163 *(
volatile unsigned short *)
PORT2ADDR(port) =
w;
166 void _outl(
unsigned long l,
unsigned long port)
168 *(
volatile unsigned long *)
PORT2ADDR(port) =
l;
177 void _outw_p(
unsigned short w,
unsigned long port)
189 void _insb(
unsigned int port,
void *addr,
unsigned long count)
194 unsigned char *buf =
addr;
197 *buf++ = *(
volatile unsigned char *)portp;
201 void _insw(
unsigned int port,
void *addr,
unsigned long count)
203 unsigned short *buf =
addr;
204 unsigned short *portp;
213 *buf++ = *(
volatile unsigned short *)portp;
214 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
215 }
else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
219 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
220 }
else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
221 portp = __port2addr_ata(port);
223 *buf++ = *(
volatile unsigned short *)portp;
228 *buf++ = *(
volatile unsigned short *)portp;
232 void _insl(
unsigned int port,
void *addr,
unsigned long count)
234 unsigned long *buf =
addr;
235 unsigned long *portp;
239 *buf++ = *(
volatile unsigned long *)portp;
242 void _outsb(
unsigned int port,
const void *addr,
unsigned long count)
244 const unsigned char *buf =
addr;
245 unsigned char *portp;
250 _ne_outb(*buf++, portp);
254 *(
volatile unsigned char *)portp = *buf++;
258 void _outsw(
unsigned int port,
const void *addr,
unsigned long count)
260 const unsigned short *buf =
addr;
261 unsigned short *portp;
270 *(
volatile unsigned short *)portp = *buf++;
271 #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
272 }
else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
273 portp = __port2addr_ata(port);
275 *(
volatile unsigned short *)portp = *buf++;
277 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
278 }
else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
285 *(
volatile unsigned short *)portp = *buf++;
289 void _outsl(
unsigned int port,
const void *addr,
unsigned long count)
291 const unsigned long *buf =
addr;
292 unsigned char *portp;
296 *(
volatile unsigned long *)portp = *buf++;