2 * arch/sh/boards/se/73180/io.c
4 * Copyright (C) 2003 YOSHII Takashi <yoshii-takashi@hitachi-ul.co.jp>
5 * Based on arch/sh/boards/se/7300/io.c
7 * I/O routine for SH-Mobile3 73180 SolutionEngine.
11 #include <linux/kernel.h>
12 #include <asm/mach/se73180.h>
15 #define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a)
18 unsigned long start, end;
20 struct iop *(*check) (struct iop * p, unsigned long port);
21 unsigned char (*inb) (struct iop * p, unsigned long port);
22 unsigned short (*inw) (struct iop * p, unsigned long port);
23 void (*outb) (struct iop * p, unsigned char value, unsigned long port);
24 void (*outw) (struct iop * p, unsigned short value, unsigned long port);
28 simple_check(struct iop *p, unsigned long port)
30 if ((p->start <= port) && (port <= p->end))
37 ide_check(struct iop *p, unsigned long port)
39 if (((0x1f0 <= port) && (port <= 0x1f7)) || (port == 0x3f7))
45 simple_inb(struct iop *p, unsigned long port)
47 return *(unsigned char *) (p->base + port);
51 simple_inw(struct iop *p, unsigned long port)
53 return *(unsigned short *) (p->base + port);
57 simple_outb(struct iop *p, unsigned char value, unsigned long port)
59 *(unsigned char *) (p->base + port) = value;
63 simple_outw(struct iop *p, unsigned short value, unsigned long port)
65 *(unsigned short *) (p->base + port) = value;
69 pcc_inb(struct iop *p, unsigned long port)
71 unsigned long addr = p->base + port + 0x40000;
76 v = *(volatile unsigned char *) addr;
81 pcc_outb(struct iop *p, unsigned char value, unsigned long port)
83 unsigned long addr = p->base + port + 0x40000;
87 *(volatile unsigned char *) addr = value;
91 bad_inb(struct iop *p, unsigned long port)
97 bad_outb(struct iop *p, unsigned char value, unsigned long port)
102 /* MSTLANEX01 LAN at 0xb400:0000 */
103 static struct iop laniop = {
107 .check = simple_check,
114 /* NE2000 pc card NIC */
115 static struct iop neiop = {
118 .base = 0xb0600000 + 0x80, /* soft 0x280 -> hard 0x300 */
119 .check = simple_check,
127 static struct iop cfiop = {
136 static __inline__ struct iop *
137 port2iop(unsigned long port)
140 #if defined(CONFIG_SMC91111)
141 else if (laniop.check(&laniop, port))
144 #if defined(CONFIG_NE2000)
145 else if (neiop.check(&neiop, port))
148 #if defined(CONFIG_IDE)
149 else if (cfiop.check(&cfiop, port))
153 return &neiop; /* fallback */
159 ctrl_inw(0xac000000);
160 ctrl_inw(0xac000000);
164 sh73180se_inb(unsigned long port)
166 struct iop *p = port2iop(port);
167 return (p->inb) (p, port);
171 sh73180se_inb_p(unsigned long port)
173 unsigned char v = sh73180se_inb(port);
179 sh73180se_inw(unsigned long port)
181 struct iop *p = port2iop(port);
182 return (p->inw) (p, port);
186 sh73180se_inl(unsigned long port)
192 sh73180se_outb(unsigned char value, unsigned long port)
194 struct iop *p = port2iop(port);
195 (p->outb) (p, value, port);
199 sh73180se_outb_p(unsigned char value, unsigned long port)
201 sh73180se_outb(value, port);
206 sh73180se_outw(unsigned short value, unsigned long port)
208 struct iop *p = port2iop(port);
209 (p->outw) (p, value, port);
213 sh73180se_outl(unsigned int value, unsigned long port)
219 sh73180se_insb(unsigned long port, void *addr, unsigned long count)
221 unsigned char *a = addr;
222 struct iop *p = port2iop(port);
224 *a++ = (p->inb) (p, port);
228 sh73180se_insw(unsigned long port, void *addr, unsigned long count)
230 unsigned short *a = addr;
231 struct iop *p = port2iop(port);
233 *a++ = (p->inw) (p, port);
237 sh73180se_insl(unsigned long port, void *addr, unsigned long count)
243 sh73180se_outsb(unsigned long port, const void *addr, unsigned long count)
245 unsigned char *a = (unsigned char *) addr;
246 struct iop *p = port2iop(port);
248 (p->outb) (p, *a++, port);
252 sh73180se_outsw(unsigned long port, const void *addr, unsigned long count)
254 unsigned short *a = (unsigned short *) addr;
255 struct iop *p = port2iop(port);
257 (p->outw) (p, *a++, port);
261 sh73180se_outsl(unsigned long port, const void *addr, unsigned long count)