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/config.h>
12 #include <linux/kernel.h>
13 #include <asm/mach/se73180.h>
16 #define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a)
19 unsigned long start, end;
21 struct iop *(*check) (struct iop * p, unsigned long port);
22 unsigned char (*inb) (struct iop * p, unsigned long port);
23 unsigned short (*inw) (struct iop * p, unsigned long port);
24 void (*outb) (struct iop * p, unsigned char value, unsigned long port);
25 void (*outw) (struct iop * p, unsigned short value, unsigned long port);
29 simple_check(struct iop *p, unsigned long port)
31 if ((p->start <= port) && (port <= p->end))
38 ide_check(struct iop *p, unsigned long port)
40 if (((0x1f0 <= port) && (port <= 0x1f7)) || (port == 0x3f7))
46 simple_inb(struct iop *p, unsigned long port)
48 return *(unsigned char *) (p->base + port);
52 simple_inw(struct iop *p, unsigned long port)
54 return *(unsigned short *) (p->base + port);
58 simple_outb(struct iop *p, unsigned char value, unsigned long port)
60 *(unsigned char *) (p->base + port) = value;
64 simple_outw(struct iop *p, unsigned short value, unsigned long port)
66 *(unsigned short *) (p->base + port) = value;
70 pcc_inb(struct iop *p, unsigned long port)
72 unsigned long addr = p->base + port + 0x40000;
77 v = *(volatile unsigned char *) addr;
82 pcc_outb(struct iop *p, unsigned char value, unsigned long port)
84 unsigned long addr = p->base + port + 0x40000;
88 *(volatile unsigned char *) addr = value;
92 bad_inb(struct iop *p, unsigned long port)
98 bad_outb(struct iop *p, unsigned char value, unsigned long port)
103 /* MSTLANEX01 LAN at 0xb400:0000 */
104 static struct iop laniop = {
108 .check = simple_check,
115 /* NE2000 pc card NIC */
116 static struct iop neiop = {
119 .base = 0xb0600000 + 0x80, /* soft 0x280 -> hard 0x300 */
120 .check = simple_check,
128 static struct iop cfiop = {
137 static __inline__ struct iop *
138 port2iop(unsigned long port)
141 #if defined(CONFIG_SMC91111)
142 else if (laniop.check(&laniop, port))
145 #if defined(CONFIG_NE2000)
146 else if (neiop.check(&neiop, port))
149 #if defined(CONFIG_IDE)
150 else if (cfiop.check(&cfiop, port))
154 return &neiop; /* fallback */
160 ctrl_inw(0xac000000);
161 ctrl_inw(0xac000000);
165 sh73180se_inb(unsigned long port)
167 struct iop *p = port2iop(port);
168 return (p->inb) (p, port);
172 sh73180se_inb_p(unsigned long port)
174 unsigned char v = sh73180se_inb(port);
180 sh73180se_inw(unsigned long port)
182 struct iop *p = port2iop(port);
183 return (p->inw) (p, port);
187 sh73180se_inl(unsigned long port)
193 sh73180se_outb(unsigned char value, unsigned long port)
195 struct iop *p = port2iop(port);
196 (p->outb) (p, value, port);
200 sh73180se_outb_p(unsigned char value, unsigned long port)
202 sh73180se_outb(value, port);
207 sh73180se_outw(unsigned short value, unsigned long port)
209 struct iop *p = port2iop(port);
210 (p->outw) (p, value, port);
214 sh73180se_outl(unsigned int value, unsigned long port)
220 sh73180se_insb(unsigned long port, void *addr, unsigned long count)
222 unsigned char *a = addr;
223 struct iop *p = port2iop(port);
225 *a++ = (p->inb) (p, port);
229 sh73180se_insw(unsigned long port, void *addr, unsigned long count)
231 unsigned short *a = addr;
232 struct iop *p = port2iop(port);
234 *a++ = (p->inw) (p, port);
238 sh73180se_insl(unsigned long port, void *addr, unsigned long count)
244 sh73180se_outsb(unsigned long port, const void *addr, unsigned long count)
246 unsigned char *a = (unsigned char *) addr;
247 struct iop *p = port2iop(port);
249 (p->outb) (p, *a++, port);
253 sh73180se_outsw(unsigned long port, const void *addr, unsigned long count)
255 unsigned short *a = (unsigned short *) addr;
256 struct iop *p = port2iop(port);
258 (p->outw) (p, *a++, port);
262 sh73180se_outsl(unsigned long port, const void *addr, unsigned long count)