13 #include <asm/byteorder.h>
15 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
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)
22 #define M32R_PCC_IOSTART1 0x2000
23 #define M32R_PCC_IOEND1 (M32R_PCC_IOSTART1 + M32R_PCC_IOMAP_SIZE - 1)
25 extern void pcc_ioread(
int,
unsigned long,
void *,
size_t,
size_t,
int);
26 extern void pcc_iowrite(
int,
unsigned long,
void *,
size_t,
size_t,
int);
29 #define PORT2ADDR(port) _port2addr(port)
31 static inline void *_port2addr(
unsigned long port)
36 static inline void *_port2addr_ne(
unsigned long port)
41 static inline void delay(
void)
43 __asm__ __volatile__ (
"push r0; \n\t pop r0;" : : :
"memory");
50 #define PORT2ADDR_NE(port) _port2addr_ne(port)
52 static inline unsigned char _ne_inb(
void *portp)
54 return (
unsigned char) *(
volatile unsigned short *)portp;
57 static inline unsigned short _ne_inw(
void *portp)
61 tmp = *(
volatile unsigned short *)portp;
65 static inline void _ne_outb(
unsigned char b,
void *portp)
67 *(
volatile unsigned short *)portp = (
unsigned short)
b;
70 static inline void _ne_outw(
unsigned short w,
void *portp)
75 unsigned char _inb(
unsigned long port)
77 if (port >= 0x300 && port < 0x320)
80 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
81 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
85 }
else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
92 return *(
volatile unsigned char *)
PORT2ADDR(port);
95 unsigned short _inw(
unsigned long port)
97 if (port >= 0x300 && port < 0x320)
100 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
101 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
105 }
else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
111 return *(
volatile unsigned short *)
PORT2ADDR(port);
114 unsigned long _inl(
unsigned long port)
116 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
117 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
121 }
else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
127 return *(
volatile unsigned long *)
PORT2ADDR(port);
132 unsigned char v =
_inb(port);
137 unsigned short _inw_p(
unsigned long port)
139 unsigned short v =
_inw(port);
146 unsigned long v =
_inl(port);
151 void _outb(
unsigned char b,
unsigned long port)
153 if (port >= 0x300 && port < 0x320)
156 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
157 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
159 }
else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
163 *(
volatile unsigned char *)
PORT2ADDR(port) =
b;
166 void _outw(
unsigned short w,
unsigned long port)
168 if (port >= 0x300 && port < 0x320)
171 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
172 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
174 }
else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
178 *(
volatile unsigned short *)
PORT2ADDR(port) =
w;
181 void _outl(
unsigned long l,
unsigned long port)
183 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
184 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
186 }
else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
190 *(
volatile unsigned long *)
PORT2ADDR(port) =
l;
193 void _outb_p(
unsigned char b,
unsigned long port)
199 void _outw_p(
unsigned short w,
unsigned long port)
214 unsigned short *portp;
216 if (port >= 0x300 && port < 0x320){
219 *buf++ = *(
volatile unsigned char *)portp;
220 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
221 }
else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
222 pcc_ioread(0, port, (
void *)addr,
sizeof(
unsigned char),
224 }
else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
225 pcc_ioread(1, port, (
void *)addr,
sizeof(
unsigned char),
231 *buf++ = *(
volatile unsigned char *)portp;
238 unsigned short *portp;
240 if (port >= 0x300 && port < 0x320) {
243 *buf++ = _ne_inw(portp);
244 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
245 }
else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
246 pcc_ioread(0, port, (
void *)addr,
sizeof(
unsigned short),
248 }
else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
249 pcc_ioread(1, port, (
void *)addr,
sizeof(
unsigned short),
255 *buf++ = *(
volatile unsigned short *)portp;
262 unsigned long *portp;
266 *buf++ = *(
volatile unsigned long *)portp;
271 const unsigned char *
buf =
addr;
272 unsigned char *portp;
274 if (port >= 0x300 && port < 0x320) {
277 _ne_outb(*buf++, portp);
278 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
279 }
else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
280 pcc_iowrite(0, port, (
void *)addr,
sizeof(
unsigned char),
282 }
else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
283 pcc_iowrite(1, port, (
void *)addr,
sizeof(
unsigned char),
289 *(
volatile unsigned char *)portp = *buf++;
295 const unsigned short *
buf =
addr;
296 unsigned short *portp;
298 if (port >= 0x300 && port < 0x320) {
301 _ne_outw(*buf++, portp);
302 #if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
303 }
else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
304 pcc_iowrite(0, port, (
void *)addr,
sizeof(
unsigned short),
306 }
else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
307 pcc_iowrite(1, port, (
void *)addr,
sizeof(
unsigned short),
313 *(
volatile unsigned short *)portp = *buf++;
319 const unsigned long *
buf =
addr;
320 unsigned char *portp;
324 *(
volatile unsigned long *)portp = *buf++;