sh: Kill off dead bigsur and ec3104 boards.
[linux-2.6/cjktty.git] / arch / sh / boards / renesas / rts7751r2d / io.c
blobf2507a804979a35f0b3a2bedb696986c06d1a689
1 /*
2 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
3 * Based largely on io_se.c.
5 * I/O routine for Renesas Technology sales RTS7751R2D.
7 * Initial version only to support LAN access; some
8 * placeholder code from io_rts7751r2d.c left in with the
9 * expectation of later SuperIO and PCMCIA access.
11 #include <linux/kernel.h>
12 #include <linux/types.h>
13 #include <linux/pci.h>
14 #include <linux/io.h>
15 #include <asm/rts7751r2d.h>
16 #include <asm/addrspace.h>
19 * The 7751R RTS7751R2D uses the built-in PCI controller (PCIC)
20 * of the 7751R processor, and has a SuperIO accessible via the PCI.
21 * The board also includes a PCMCIA controller on its memory bus,
22 * like the other Solution Engine boards.
25 static inline unsigned long port2adr(unsigned int port)
27 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
28 if (port == 0x3f6)
29 return (PA_AREA5_IO + 0x80c);
30 else
31 return (PA_AREA5_IO + 0x1000 + ((port-0x1f0) << 1));
32 else
33 maybebadio((unsigned long)port);
35 return port;
38 static inline unsigned long port88796l(unsigned int port, int flag)
40 unsigned long addr;
42 if (flag)
43 addr = PA_AX88796L + ((port - AX88796L_IO_BASE) << 1);
44 else
45 addr = PA_AX88796L + ((port - AX88796L_IO_BASE) << 1) + 0x1000;
47 return addr;
50 /* The 7751R RTS7751R2D seems to have everything hooked */
51 /* up pretty normally (nothing on high-bytes only...) so this */
52 /* shouldn't be needed */
53 static inline int shifted_port(unsigned long port)
55 /* For IDE registers, value is not shifted */
56 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
57 return 0;
58 else
59 return 1;
62 #if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE)
63 #define CHECK_AX88796L_PORT(port) \
64 ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20)))
65 #else
66 #define CHECK_AX88796L_PORT(port) (0)
67 #endif
70 * General outline: remap really low stuff [eventually] to SuperIO,
71 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
72 * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
73 * should be way beyond the window, and is used w/o translation for
74 * compatibility.
76 unsigned char rts7751r2d_inb(unsigned long port)
78 if (CHECK_AX88796L_PORT(port))
79 return (*(volatile unsigned short *)port88796l(port, 0)) & 0xff;
80 else if (PXSEG(port))
81 return *(volatile unsigned char *)port;
82 else if (is_pci_ioaddr(port) || shifted_port(port))
83 return *(volatile unsigned char *)pci_ioaddr(port);
84 else
85 return (*(volatile unsigned short *)port2adr(port) & 0xff);
88 unsigned char rts7751r2d_inb_p(unsigned long port)
90 unsigned char v;
92 if (CHECK_AX88796L_PORT(port))
93 v = (*(volatile unsigned short *)port88796l(port, 0)) & 0xff;
94 else if (PXSEG(port))
95 v = *(volatile unsigned char *)port;
96 else if (is_pci_ioaddr(port) || shifted_port(port))
97 v = *(volatile unsigned char *)pci_ioaddr(port);
98 else
99 v = (*(volatile unsigned short *)port2adr(port) & 0xff);
101 ctrl_delay();
103 return v;
106 unsigned short rts7751r2d_inw(unsigned long port)
108 if (CHECK_AX88796L_PORT(port))
109 maybebadio(port);
110 else if (PXSEG(port))
111 return *(volatile unsigned short *)port;
112 else if (is_pci_ioaddr(port) || shifted_port(port))
113 return *(volatile unsigned short *)pci_ioaddr(port);
114 else
115 maybebadio(port);
117 return 0;
120 unsigned int rts7751r2d_inl(unsigned long port)
122 if (CHECK_AX88796L_PORT(port))
123 maybebadio(port);
124 else if (PXSEG(port))
125 return *(volatile unsigned long *)port;
126 else if (is_pci_ioaddr(port) || shifted_port(port))
127 return *(volatile unsigned long *)pci_ioaddr(port);
128 else
129 maybebadio(port);
131 return 0;
134 void rts7751r2d_outb(unsigned char value, unsigned long port)
136 if (CHECK_AX88796L_PORT(port))
137 *((volatile unsigned short *)port88796l(port, 0)) = value;
138 else if (PXSEG(port))
139 *(volatile unsigned char *)port = value;
140 else if (is_pci_ioaddr(port) || shifted_port(port))
141 *(volatile unsigned char *)pci_ioaddr(port) = value;
142 else
143 *(volatile unsigned short *)port2adr(port) = value;
146 void rts7751r2d_outb_p(unsigned char value, unsigned long port)
148 if (CHECK_AX88796L_PORT(port))
149 *((volatile unsigned short *)port88796l(port, 0)) = value;
150 else if (PXSEG(port))
151 *(volatile unsigned char *)port = value;
152 else if (is_pci_ioaddr(port) || shifted_port(port))
153 *(volatile unsigned char *)pci_ioaddr(port) = value;
154 else
155 *(volatile unsigned short *)port2adr(port) = value;
157 ctrl_delay();
160 void rts7751r2d_outw(unsigned short value, unsigned long port)
162 if (CHECK_AX88796L_PORT(port))
163 maybebadio(port);
164 else if (PXSEG(port))
165 *(volatile unsigned short *)port = value;
166 else if (is_pci_ioaddr(port) || shifted_port(port))
167 *(volatile unsigned short *)pci_ioaddr(port) = value;
168 else
169 maybebadio(port);
172 void rts7751r2d_outl(unsigned int value, unsigned long port)
174 if (CHECK_AX88796L_PORT(port))
175 maybebadio(port);
176 else if (PXSEG(port))
177 *(volatile unsigned long *)port = value;
178 else if (is_pci_ioaddr(port) || shifted_port(port))
179 *(volatile unsigned long *)pci_ioaddr(port) = value;
180 else
181 maybebadio(port);
184 void rts7751r2d_insb(unsigned long port, void *addr, unsigned long count)
186 unsigned long a = (unsigned long)addr;
187 volatile __u8 *bp;
188 volatile __u16 *p;
190 if (CHECK_AX88796L_PORT(port)) {
191 p = (volatile unsigned short *)port88796l(port, 0);
192 while (count--)
193 ctrl_outb(*p & 0xff, a++);
194 } else if (PXSEG(port))
195 while (count--)
196 ctrl_outb(ctrl_inb(port), a++);
197 else if (is_pci_ioaddr(port) || shifted_port(port)) {
198 bp = (__u8 *)pci_ioaddr(port);
199 while (count--)
200 ctrl_outb(*bp, a++);
201 } else {
202 p = (volatile unsigned short *)port2adr(port);
203 while (count--)
204 ctrl_outb(*p & 0xff, a++);
208 void rts7751r2d_insw(unsigned long port, void *addr, unsigned long count)
210 unsigned long a = (unsigned long)addr;
211 volatile __u16 *p;
213 if (CHECK_AX88796L_PORT(port))
214 p = (volatile unsigned short *)port88796l(port, 1);
215 else if (PXSEG(port))
216 p = (volatile unsigned short *)port;
217 else if (is_pci_ioaddr(port) || shifted_port(port))
218 p = (volatile unsigned short *)pci_ioaddr(port);
219 else
220 p = (volatile unsigned short *)port2adr(port);
221 while (count--)
222 ctrl_outw(*p, a++);
225 void rts7751r2d_insl(unsigned long port, void *addr, unsigned long count)
227 if (CHECK_AX88796L_PORT(port))
228 maybebadio(port);
229 else if (is_pci_ioaddr(port) || shifted_port(port)) {
230 unsigned long a = (unsigned long)addr;
232 while (count--) {
233 ctrl_outl(ctrl_inl(pci_ioaddr(port)), a);
234 a += 4;
236 } else
237 maybebadio(port);
240 void rts7751r2d_outsb(unsigned long port, const void *addr, unsigned long count)
242 unsigned long a = (unsigned long)addr;
243 volatile __u8 *bp;
244 volatile __u16 *p;
246 if (CHECK_AX88796L_PORT(port)) {
247 p = (volatile unsigned short *)port88796l(port, 0);
248 while (count--)
249 *p = ctrl_inb(a++);
250 } else if (PXSEG(port))
251 while (count--)
252 ctrl_outb(a++, port);
253 else if (is_pci_ioaddr(port) || shifted_port(port)) {
254 bp = (__u8 *)pci_ioaddr(port);
255 while (count--)
256 *bp = ctrl_inb(a++);
257 } else {
258 p = (volatile unsigned short *)port2adr(port);
259 while (count--)
260 *p = ctrl_inb(a++);
264 void rts7751r2d_outsw(unsigned long port, const void *addr, unsigned long count)
266 unsigned long a = (unsigned long)addr;
267 volatile __u16 *p;
269 if (CHECK_AX88796L_PORT(port))
270 p = (volatile unsigned short *)port88796l(port, 1);
271 else if (PXSEG(port))
272 p = (volatile unsigned short *)port;
273 else if (is_pci_ioaddr(port) || shifted_port(port))
274 p = (volatile unsigned short *)pci_ioaddr(port);
275 else
276 p = (volatile unsigned short *)port2adr(port);
278 while (count--) {
279 ctrl_outw(*p, a);
280 a += 2;
284 void rts7751r2d_outsl(unsigned long port, const void *addr, unsigned long count)
286 if (CHECK_AX88796L_PORT(port))
287 maybebadio(port);
288 else if (is_pci_ioaddr(port) || shifted_port(port)) {
289 unsigned long a = (unsigned long)addr;
291 while (count--) {
292 ctrl_outl(ctrl_inl(a), pci_ioaddr(port));
293 a += 4;
295 } else
296 maybebadio(port);
299 unsigned long rts7751r2d_isa_port2addr(unsigned long offset)
301 return port2adr(offset);