2 * linux/arch/sh/boards/se/7300/io.c
4 * Copyright (C) 2003 YOSHII Takashi <yoshii-takashi@hitachi-ul.co.jp>
7 #include <linux/config.h>
8 #include <linux/kernel.h>
9 #include <asm/se7300/se7300.h>
12 #define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a)
15 unsigned long start, end;
17 struct iop *(*check) (struct iop * p, unsigned long port);
18 unsigned char (*inb) (struct iop * p, unsigned long port);
19 unsigned short (*inw) (struct iop * p, unsigned long port);
20 void (*outb) (struct iop * p, unsigned char value, unsigned long port);
21 void (*outw) (struct iop * p, unsigned short value, unsigned long port);
25 simple_check(struct iop *p, unsigned long port)
27 if ((p->start <= port) && (port <= p->end))
34 ide_check(struct iop *p, unsigned long port)
36 if (((0x1f0 <= port) && (port <= 0x1f7)) || (port == 0x3f7))
42 simple_inb(struct iop *p, unsigned long port)
44 return *(unsigned char *) (p->base + port);
48 simple_inw(struct iop *p, unsigned long port)
50 return *(unsigned short *) (p->base + port);
54 simple_outb(struct iop *p, unsigned char value, unsigned long port)
56 *(unsigned char *) (p->base + port) = value;
60 simple_outw(struct iop *p, unsigned short value, unsigned long port)
62 *(unsigned short *) (p->base + port) = value;
66 pcc_inb(struct iop *p, unsigned long port)
68 unsigned long addr = p->base + port + 0x40000;
73 v = *(volatile unsigned char *) addr;
78 pcc_outb(struct iop *p, unsigned char value, unsigned long port)
80 unsigned long addr = p->base + port + 0x40000;
84 *(volatile unsigned char *) addr = value;
88 bad_inb(struct iop *p, unsigned long port)
94 bad_outb(struct iop *p, unsigned char value, unsigned long port)
99 /* MSTLANEX01 LAN at 0xb400:0000 */
100 static struct iop laniop = {
104 .check = simple_check,
111 /* NE2000 pc card NIC */
112 static struct iop neiop = {
115 .base = 0xb0600000 + 0x80, /* soft 0x280 -> hard 0x300 */
116 .check = simple_check,
124 static struct iop cfiop = {
133 static __inline__ struct iop *
134 port2iop(unsigned long port)
137 #if defined(CONFIG_SMC91111)
138 else if (laniop.check(&laniop, port))
141 #if defined(CONFIG_NE2000)
142 else if (neiop.check(&neiop, port))
145 #if defined(CONFIG_IDE)
146 else if (cfiop.check(&cfiop, port))
150 return &neiop; /* fallback */
156 ctrl_inw(0xac000000);
157 ctrl_inw(0xac000000);
161 sh7300se_inb(unsigned long port)
163 struct iop *p = port2iop(port);
164 return (p->inb) (p, port);
168 sh7300se_inb_p(unsigned long port)
170 unsigned char v = sh7300se_inb(port);
176 sh7300se_inw(unsigned long port)
178 struct iop *p = port2iop(port);
179 return (p->inw) (p, port);
183 sh7300se_inl(unsigned long port)
189 sh7300se_outb(unsigned char value, unsigned long port)
191 struct iop *p = port2iop(port);
192 (p->outb) (p, value, port);
196 sh7300se_outb_p(unsigned char value, unsigned long port)
198 sh7300se_outb(value, port);
203 sh7300se_outw(unsigned short value, unsigned long port)
205 struct iop *p = port2iop(port);
206 (p->outw) (p, value, port);
210 sh7300se_outl(unsigned int value, unsigned long port)
216 sh7300se_insb(unsigned long port, void *addr, unsigned long count)
218 unsigned char *a = addr;
219 struct iop *p = port2iop(port);
221 *a++ = (p->inb) (p, port);
225 sh7300se_insw(unsigned long port, void *addr, unsigned long count)
227 unsigned short *a = addr;
228 struct iop *p = port2iop(port);
230 *a++ = (p->inw) (p, port);
234 sh7300se_insl(unsigned long port, void *addr, unsigned long count)
240 sh7300se_outsb(unsigned long port, const void *addr, unsigned long count)
242 unsigned char *a = (unsigned char *) addr;
243 struct iop *p = port2iop(port);
245 (p->outb) (p, *a++, port);
249 sh7300se_outsw(unsigned long port, const void *addr, unsigned long count)
251 unsigned short *a = (unsigned short *) addr;
252 struct iop *p = port2iop(port);
254 (p->outw) (p, *a++, port);
258 sh7300se_outsl(unsigned long port, const void *addr, unsigned long count)