2 * arch/sh/boards/se/7343/io.c
4 * I/O routine for SH-Mobile3AS 7343 SolutionEngine.
7 #include <linux/kernel.h>
9 #include <mach-se/mach/se7343.h>
11 #define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a)
14 unsigned long start, end;
16 struct iop *(*check) (struct iop * p, unsigned long port);
17 unsigned char (*inb) (struct iop * p, unsigned long port);
18 unsigned short (*inw) (struct iop * p, unsigned long port);
19 void (*outb) (struct iop * p, unsigned char value, unsigned long port);
20 void (*outw) (struct iop * p, unsigned short value, unsigned long port);
24 simple_check(struct iop *p, unsigned long port)
33 if ((p->start <= port) && (port <= p->end))
40 ide_check(struct iop *p, unsigned long port)
42 if (((0x1f0 <= port) && (port <= 0x1f7)) || (port == 0x3f7))
48 simple_inb(struct iop *p, unsigned long port)
50 return *(unsigned char *) (p->base + port);
54 simple_inw(struct iop *p, unsigned long port)
56 return *(unsigned short *) (p->base + port);
60 simple_outb(struct iop *p, unsigned char value, unsigned long port)
62 *(unsigned char *) (p->base + port) = value;
66 simple_outw(struct iop *p, unsigned short value, unsigned long port)
68 *(unsigned short *) (p->base + port) = value;
72 pcc_inb(struct iop *p, unsigned long port)
74 unsigned long addr = p->base + port + 0x40000;
79 v = *(volatile unsigned char *) addr;
84 pcc_outb(struct iop *p, unsigned char value, unsigned long port)
86 unsigned long addr = p->base + port + 0x40000;
90 *(volatile unsigned char *) addr = value;
94 bad_inb(struct iop *p, unsigned long port)
100 bad_outb(struct iop *p, unsigned char value, unsigned long port)
106 /* MSTLANEX01 LAN at 0xb400:0000 */
107 static struct iop laniop = {
111 .check = simple_check,
120 /* NE2000 pc card NIC */
121 static struct iop neiop = {
124 .base = 0xb0600000 + 0x80, /* soft 0x280 -> hard 0x300 */
125 .check = simple_check,
135 static struct iop cfiop = {
145 static __inline__ struct iop *
146 port2iop(unsigned long port)
149 #if defined(CONFIG_SMC91X)
150 else if (laniop.check(&laniop, port))
153 #if defined(CONFIG_NE2000)
154 else if (neiop.check(&neiop, port))
157 #if defined(CONFIG_IDE)
158 else if (cfiop.check(&cfiop, port))
168 ctrl_inw(0xac000000);
169 ctrl_inw(0xac000000);
173 sh7343se_inb(unsigned long port)
175 struct iop *p = port2iop(port);
176 return (p->inb) (p, port);
180 sh7343se_inb_p(unsigned long port)
182 unsigned char v = sh7343se_inb(port);
188 sh7343se_inw(unsigned long port)
190 struct iop *p = port2iop(port);
191 return (p->inw) (p, port);
195 sh7343se_inl(unsigned long port)
201 sh7343se_outb(unsigned char value, unsigned long port)
203 struct iop *p = port2iop(port);
204 (p->outb) (p, value, port);
208 sh7343se_outb_p(unsigned char value, unsigned long port)
210 sh7343se_outb(value, port);
215 sh7343se_outw(unsigned short value, unsigned long port)
217 struct iop *p = port2iop(port);
218 (p->outw) (p, value, port);
222 sh7343se_outl(unsigned int value, unsigned long port)
228 sh7343se_insb(unsigned long port, void *addr, unsigned long count)
230 unsigned char *a = addr;
231 struct iop *p = port2iop(port);
233 *a++ = (p->inb) (p, port);
237 sh7343se_insw(unsigned long port, void *addr, unsigned long count)
239 unsigned short *a = addr;
240 struct iop *p = port2iop(port);
242 *a++ = (p->inw) (p, port);
246 sh7343se_insl(unsigned long port, void *addr, unsigned long count)
252 sh7343se_outsb(unsigned long port, const void *addr, unsigned long count)
254 unsigned char *a = (unsigned char *) addr;
255 struct iop *p = port2iop(port);
257 (p->outb) (p, *a++, port);
261 sh7343se_outsw(unsigned long port, const void *addr, unsigned long count)
263 unsigned short *a = (unsigned short *) addr;
264 struct iop *p = port2iop(port);
266 (p->outw) (p, *a++, port);
270 sh7343se_outsl(unsigned long port, const void *addr, unsigned long count)