2 * arch/sh/boards/se/7343/io.c
4 * I/O routine for SH-Mobile3AS 7343 SolutionEngine.
8 #include <linux/config.h>
9 #include <linux/kernel.h>
11 #include <asm/mach/se7343.h>
13 #define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a)
16 unsigned long start, end;
18 struct iop *(*check) (struct iop * p, unsigned long port);
19 unsigned char (*inb) (struct iop * p, unsigned long port);
20 unsigned short (*inw) (struct iop * p, unsigned long port);
21 void (*outb) (struct iop * p, unsigned char value, unsigned long port);
22 void (*outw) (struct iop * p, unsigned short value, unsigned long port);
26 simple_check(struct iop *p, unsigned long port)
35 if ((p->start <= port) && (port <= p->end))
42 ide_check(struct iop *p, unsigned long port)
44 if (((0x1f0 <= port) && (port <= 0x1f7)) || (port == 0x3f7))
50 simple_inb(struct iop *p, unsigned long port)
52 return *(unsigned char *) (p->base + port);
56 simple_inw(struct iop *p, unsigned long port)
58 return *(unsigned short *) (p->base + port);
62 simple_outb(struct iop *p, unsigned char value, unsigned long port)
64 *(unsigned char *) (p->base + port) = value;
68 simple_outw(struct iop *p, unsigned short value, unsigned long port)
70 *(unsigned short *) (p->base + port) = value;
74 pcc_inb(struct iop *p, unsigned long port)
76 unsigned long addr = p->base + port + 0x40000;
81 v = *(volatile unsigned char *) addr;
86 pcc_outb(struct iop *p, unsigned char value, unsigned long port)
88 unsigned long addr = p->base + port + 0x40000;
92 *(volatile unsigned char *) addr = value;
96 bad_inb(struct iop *p, unsigned long port)
102 bad_outb(struct iop *p, unsigned char value, unsigned long port)
108 /* MSTLANEX01 LAN at 0xb400:0000 */
109 static struct iop laniop = {
113 .check = simple_check,
122 /* NE2000 pc card NIC */
123 static struct iop neiop = {
126 .base = 0xb0600000 + 0x80, /* soft 0x280 -> hard 0x300 */
127 .check = simple_check,
137 static struct iop cfiop = {
147 static __inline__ struct iop *
148 port2iop(unsigned long port)
151 #if defined(CONFIG_SMC91X)
152 else if (laniop.check(&laniop, port))
155 #if defined(CONFIG_NE2000)
156 else if (neiop.check(&neiop, port))
159 #if defined(CONFIG_IDE)
160 else if (cfiop.check(&cfiop, port))
170 ctrl_inw(0xac000000);
171 ctrl_inw(0xac000000);
175 sh7343se_inb(unsigned long port)
177 struct iop *p = port2iop(port);
178 return (p->inb) (p, port);
182 sh7343se_inb_p(unsigned long port)
184 unsigned char v = sh7343se_inb(port);
190 sh7343se_inw(unsigned long port)
192 struct iop *p = port2iop(port);
193 return (p->inw) (p, port);
197 sh7343se_inl(unsigned long port)
203 sh7343se_outb(unsigned char value, unsigned long port)
205 struct iop *p = port2iop(port);
206 (p->outb) (p, value, port);
210 sh7343se_outb_p(unsigned char value, unsigned long port)
212 sh7343se_outb(value, port);
217 sh7343se_outw(unsigned short value, unsigned long port)
219 struct iop *p = port2iop(port);
220 (p->outw) (p, value, port);
224 sh7343se_outl(unsigned int value, unsigned long port)
230 sh7343se_insb(unsigned long port, void *addr, unsigned long count)
232 unsigned char *a = addr;
233 struct iop *p = port2iop(port);
235 *a++ = (p->inb) (p, port);
239 sh7343se_insw(unsigned long port, void *addr, unsigned long count)
241 unsigned short *a = addr;
242 struct iop *p = port2iop(port);
244 *a++ = (p->inw) (p, port);
248 sh7343se_insl(unsigned long port, void *addr, unsigned long count)
254 sh7343se_outsb(unsigned long port, const void *addr, unsigned long count)
256 unsigned char *a = (unsigned char *) addr;
257 struct iop *p = port2iop(port);
259 (p->outb) (p, *a++, port);
263 sh7343se_outsw(unsigned long port, const void *addr, unsigned long count)
265 unsigned short *a = (unsigned short *) addr;
266 struct iop *p = port2iop(port);
268 (p->outw) (p, *a++, port);
272 sh7343se_outsl(unsigned long port, const void *addr, unsigned long count)