[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / sh / kernel / io_generic.c
bloba911b0149d1fc37161e4452e8a10981afb062eea
1 /* $Id: io_generic.c,v 1.2 2003/05/04 19:29:53 lethal Exp $
3 * linux/arch/sh/kernel/io_generic.c
5 * Copyright (C) 2000 Niibe Yutaka
7 * Generic I/O routine. These can be used where a machine specific version
8 * is not required.
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
16 #include <asm/io.h>
17 #include <asm/machvec.h>
18 #include <linux/module.h>
20 #if defined(CONFIG_CPU_SH3)
21 /* I'm not sure SH7709 has this kind of bug */
22 #define SH3_PCMCIA_BUG_WORKAROUND 1
23 #define DUMMY_READ_AREA6 0xba000000
24 #endif
26 #define PORT2ADDR(x) (sh_mv.mv_isa_port2addr(x))
28 unsigned long generic_io_base;
30 static inline void delay(void)
32 ctrl_inw(0xa0000000);
35 unsigned char generic_inb(unsigned long port)
37 return *(volatile unsigned char*)PORT2ADDR(port);
40 unsigned short generic_inw(unsigned long port)
42 return *(volatile unsigned short*)PORT2ADDR(port);
45 unsigned int generic_inl(unsigned long port)
47 return *(volatile unsigned long*)PORT2ADDR(port);
50 unsigned char generic_inb_p(unsigned long port)
52 unsigned long v = *(volatile unsigned char*)PORT2ADDR(port);
54 delay();
55 return v;
58 unsigned short generic_inw_p(unsigned long port)
60 unsigned long v = *(volatile unsigned short*)PORT2ADDR(port);
62 delay();
63 return v;
66 unsigned int generic_inl_p(unsigned long port)
68 unsigned long v = *(volatile unsigned long*)PORT2ADDR(port);
70 delay();
71 return v;
75 * insb/w/l all read a series of bytes/words/longs from a fixed port
76 * address. However as the port address doesn't change we only need to
77 * convert the port address to real address once.
80 void generic_insb(unsigned long port, void *buffer, unsigned long count)
82 volatile unsigned char *port_addr;
83 unsigned char *buf=buffer;
85 port_addr = (volatile unsigned char *)PORT2ADDR(port);
87 while(count--)
88 *buf++ = *port_addr;
91 void generic_insw(unsigned long port, void *buffer, unsigned long count)
93 volatile unsigned short *port_addr;
94 unsigned short *buf=buffer;
96 port_addr = (volatile unsigned short *)PORT2ADDR(port);
98 while(count--)
99 *buf++ = *port_addr;
100 #ifdef SH3_PCMCIA_BUG_WORKAROUND
101 ctrl_inb (DUMMY_READ_AREA6);
102 #endif
105 void generic_insl(unsigned long port, void *buffer, unsigned long count)
107 volatile unsigned long *port_addr;
108 unsigned long *buf=buffer;
110 port_addr = (volatile unsigned long *)PORT2ADDR(port);
112 while(count--)
113 *buf++ = *port_addr;
114 #ifdef SH3_PCMCIA_BUG_WORKAROUND
115 ctrl_inb (DUMMY_READ_AREA6);
116 #endif
119 void generic_outb(unsigned char b, unsigned long port)
121 *(volatile unsigned char*)PORT2ADDR(port) = b;
124 void generic_outw(unsigned short b, unsigned long port)
126 *(volatile unsigned short*)PORT2ADDR(port) = b;
129 void generic_outl(unsigned int b, unsigned long port)
131 *(volatile unsigned long*)PORT2ADDR(port) = b;
134 void generic_outb_p(unsigned char b, unsigned long port)
136 *(volatile unsigned char*)PORT2ADDR(port) = b;
137 delay();
140 void generic_outw_p(unsigned short b, unsigned long port)
142 *(volatile unsigned short*)PORT2ADDR(port) = b;
143 delay();
146 void generic_outl_p(unsigned int b, unsigned long port)
148 *(volatile unsigned long*)PORT2ADDR(port) = b;
149 delay();
153 * outsb/w/l all write a series of bytes/words/longs to a fixed port
154 * address. However as the port address doesn't change we only need to
155 * convert the port address to real address once.
158 void generic_outsb(unsigned long port, const void *buffer, unsigned long count)
160 volatile unsigned char *port_addr;
161 const unsigned char *buf=buffer;
163 port_addr = (volatile unsigned char *)PORT2ADDR(port);
165 while(count--)
166 *port_addr = *buf++;
169 void generic_outsw(unsigned long port, const void *buffer, unsigned long count)
171 volatile unsigned short *port_addr;
172 const unsigned short *buf=buffer;
174 port_addr = (volatile unsigned short *)PORT2ADDR(port);
176 while(count--)
177 *port_addr = *buf++;
179 #ifdef SH3_PCMCIA_BUG_WORKAROUND
180 ctrl_inb (DUMMY_READ_AREA6);
181 #endif
184 void generic_outsl(unsigned long port, const void *buffer, unsigned long count)
186 volatile unsigned long *port_addr;
187 const unsigned long *buf=buffer;
189 port_addr = (volatile unsigned long *)PORT2ADDR(port);
191 while(count--)
192 *port_addr = *buf++;
194 #ifdef SH3_PCMCIA_BUG_WORKAROUND
195 ctrl_inb (DUMMY_READ_AREA6);
196 #endif
199 unsigned char generic_readb(unsigned long addr)
201 return *(volatile unsigned char*)addr;
204 unsigned short generic_readw(unsigned long addr)
206 return *(volatile unsigned short*)addr;
209 unsigned int generic_readl(unsigned long addr)
211 return *(volatile unsigned long*)addr;
214 void generic_writeb(unsigned char b, unsigned long addr)
216 *(volatile unsigned char*)addr = b;
219 void generic_writew(unsigned short b, unsigned long addr)
221 *(volatile unsigned short*)addr = b;
224 void generic_writel(unsigned int b, unsigned long addr)
226 *(volatile unsigned long*)addr = b;
229 void * generic_ioremap(unsigned long offset, unsigned long size)
231 return (void *) P2SEGADDR(offset);
233 EXPORT_SYMBOL(generic_ioremap);
235 void generic_iounmap(void *addr)
238 EXPORT_SYMBOL(generic_iounmap);
240 unsigned long generic_isa_port2addr(unsigned long offset)
242 return offset + generic_io_base;