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 <asm/rts7751r2d/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)
29 return (PA_AREA5_IO + 0x80c);
31 return (PA_AREA5_IO + 0x1000 + ((port-0x1f0) << 1));
33 maybebadio((unsigned long)port);
38 static inline unsigned long port88796l(unsigned int port, int flag)
43 addr = PA_AX88796L + ((port - AX88796L_IO_BASE) << 1);
45 addr = PA_AX88796L + ((port - AX88796L_IO_BASE) << 1) + 0x1000;
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)
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)))
66 #define CHECK_AX88796L_PORT(port) (0)
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
76 unsigned char rts7751r2d_inb(unsigned long port)
78 if (CHECK_AX88796L_PORT(port))
79 return (*(volatile unsigned short *)port88796l(port, 0)) & 0xff;
81 return *(volatile unsigned char *)port;
82 else if (is_pci_ioaddr(port) || shifted_port(port))
83 return *(volatile unsigned char *)pci_ioaddr(port);
85 return (*(volatile unsigned short *)port2adr(port) & 0xff);
88 unsigned char rts7751r2d_inb_p(unsigned long port)
92 if (CHECK_AX88796L_PORT(port))
93 v = (*(volatile unsigned short *)port88796l(port, 0)) & 0xff;
95 v = *(volatile unsigned char *)port;
96 else if (is_pci_ioaddr(port) || shifted_port(port))
97 v = *(volatile unsigned char *)pci_ioaddr(port);
99 v = (*(volatile unsigned short *)port2adr(port) & 0xff);
106 unsigned short rts7751r2d_inw(unsigned long port)
108 if (CHECK_AX88796L_PORT(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);
120 unsigned int rts7751r2d_inl(unsigned long port)
122 if (CHECK_AX88796L_PORT(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);
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;
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;
155 *(volatile unsigned short *)port2adr(port) = value;
160 void rts7751r2d_outw(unsigned short value, unsigned long port)
162 if (CHECK_AX88796L_PORT(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;
172 void rts7751r2d_outl(unsigned int value, unsigned long port)
174 if (CHECK_AX88796L_PORT(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;
184 void rts7751r2d_insb(unsigned long port, void *addr, unsigned long count)
186 unsigned long a = (unsigned long)addr;
190 if (CHECK_AX88796L_PORT(port)) {
191 p = (volatile unsigned short *)port88796l(port, 0);
193 ctrl_outb(*p & 0xff, a++);
194 } else if (PXSEG(port))
196 ctrl_outb(ctrl_inb(port), a++);
197 else if (is_pci_ioaddr(port) || shifted_port(port)) {
198 bp = (__u8 *)pci_ioaddr(port);
202 p = (volatile unsigned short *)port2adr(port);
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;
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);
220 p = (volatile unsigned short *)port2adr(port);
225 void rts7751r2d_insl(unsigned long port, void *addr, unsigned long count)
227 if (CHECK_AX88796L_PORT(port))
229 else if (is_pci_ioaddr(port) || shifted_port(port)) {
230 unsigned long a = (unsigned long)addr;
233 ctrl_outl(ctrl_inl(pci_ioaddr(port)), a);
240 void rts7751r2d_outsb(unsigned long port, const void *addr, unsigned long count)
242 unsigned long a = (unsigned long)addr;
246 if (CHECK_AX88796L_PORT(port)) {
247 p = (volatile unsigned short *)port88796l(port, 0);
250 } else if (PXSEG(port))
252 ctrl_outb(a++, port);
253 else if (is_pci_ioaddr(port) || shifted_port(port)) {
254 bp = (__u8 *)pci_ioaddr(port);
258 p = (volatile unsigned short *)port2adr(port);
264 void rts7751r2d_outsw(unsigned long port, const void *addr, unsigned long count)
266 unsigned long a = (unsigned long)addr;
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);
276 p = (volatile unsigned short *)port2adr(port);
284 void rts7751r2d_outsl(unsigned long port, const void *addr, unsigned long count)
286 if (CHECK_AX88796L_PORT(port))
288 else if (is_pci_ioaddr(port) || shifted_port(port)) {
289 unsigned long a = (unsigned long)addr;
292 ctrl_outl(ctrl_inl(a), pci_ioaddr(port));
299 unsigned long rts7751r2d_isa_port2addr(unsigned long offset)
301 return port2adr(offset);