[2.6 patch] make ocfs2_find_entry_el() static
[pv_ops_mirror.git] / arch / sh / boards / renesas / hs7751rvoip / io.c
blobbb9aa0d62852379d05aefa16a327650c2721d815
1 /*
2 * linux/arch/sh/boards/renesas/hs7751rvoip/io.c
4 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
5 * Based largely on io_se.c.
7 * I/O routine for Renesas Technology sales HS7751RVoIP
9 * Initial version only to support LAN access; some
10 * placeholder code from io_hs7751rvoip.c left in with the
11 * expectation of later SuperIO and PCMCIA access.
13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <linux/module.h>
16 #include <linux/pci.h>
17 #include <asm/io.h>
18 #include <asm/hs7751rvoip.h>
19 #include <asm/addrspace.h>
21 extern void *area6_io8_base; /* Area 6 8bit I/O Base address */
22 extern void *area5_io16_base; /* Area 5 16bit I/O Base address */
25 * The 7751R HS7751RVoIP uses the built-in PCI controller (PCIC)
26 * of the 7751R processor, and has a SuperIO accessible via the PCI.
27 * The board also includes a PCMCIA controller on its memory bus,
28 * like the other Solution Engine boards.
31 #define CODEC_IO_BASE 0x1000
32 #define CODEC_IOMAP(a) ((unsigned long)area6_io8_base + ((a) - CODEC_IO_BASE))
34 static inline unsigned long port2adr(unsigned int port)
36 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
37 if (port == 0x3f6)
38 return ((unsigned long)area5_io16_base + 0x0c);
39 else
40 return ((unsigned long)area5_io16_base + 0x800 +
41 ((port-0x1f0) << 1));
42 else
43 maybebadio((unsigned long)port);
44 return port;
47 /* The 7751R HS7751RVoIP seems to have everything hooked */
48 /* up pretty normally (nothing on high-bytes only...) so this */
49 /* shouldn't be needed */
50 static inline int shifted_port(unsigned long port)
52 /* For IDE registers, value is not shifted */
53 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
54 return 0;
55 else
56 return 1;
59 #if defined(CONFIG_HS7751RVOIP_CODEC)
60 #define codec_port(port) \
61 ((CODEC_IO_BASE <= (port)) && ((port) < (CODEC_IO_BASE + 0x20)))
62 #else
63 #define codec_port(port) (0)
64 #endif
67 * General outline: remap really low stuff [eventually] to SuperIO,
68 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
69 * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
70 * should be way beyond the window, and is used w/o translation for
71 * compatibility.
73 unsigned char hs7751rvoip_inb(unsigned long port)
75 if (PXSEG(port))
76 return ctrl_inb(port);
77 else if (codec_port(port))
78 return ctrl_inb(CODEC_IOMAP(port));
79 else if (is_pci_ioaddr(port) || shifted_port(port))
80 return ctrl_inb(pci_ioaddr(port));
81 else
82 return ctrl_inw(port2adr(port)) & 0xff;
85 unsigned char hs7751rvoip_inb_p(unsigned long port)
87 unsigned char v;
89 if (PXSEG(port))
90 v = ctrl_inb(port);
91 else if (codec_port(port))
92 v = ctrl_inb(CODEC_IOMAP(port));
93 else if (is_pci_ioaddr(port) || shifted_port(port))
94 v = ctrl_inb(pci_ioaddr(port));
95 else
96 v = ctrl_inw(port2adr(port)) & 0xff;
97 ctrl_delay();
98 return v;
101 unsigned short hs7751rvoip_inw(unsigned long port)
103 if (PXSEG(port))
104 return ctrl_inw(port);
105 else if (is_pci_ioaddr(port) || shifted_port(port))
106 return ctrl_inw(pci_ioaddr(port));
107 else
108 maybebadio(port);
109 return 0;
112 unsigned int hs7751rvoip_inl(unsigned long port)
114 if (PXSEG(port))
115 return ctrl_inl(port);
116 else if (is_pci_ioaddr(port) || shifted_port(port))
117 return ctrl_inl(pci_ioaddr(port));
118 else
119 maybebadio(port);
120 return 0;
123 void hs7751rvoip_outb(unsigned char value, unsigned long port)
126 if (PXSEG(port))
127 ctrl_outb(value, port);
128 else if (codec_port(port))
129 ctrl_outb(value, CODEC_IOMAP(port));
130 else if (is_pci_ioaddr(port) || shifted_port(port))
131 ctrl_outb(value, pci_ioaddr(port));
132 else
133 ctrl_outb(value, port2adr(port));
136 void hs7751rvoip_outb_p(unsigned char value, unsigned long port)
138 if (PXSEG(port))
139 ctrl_outb(value, port);
140 else if (codec_port(port))
141 ctrl_outb(value, CODEC_IOMAP(port));
142 else if (is_pci_ioaddr(port) || shifted_port(port))
143 ctrl_outb(value, pci_ioaddr(port));
144 else
145 ctrl_outw(value, port2adr(port));
147 ctrl_delay();
150 void hs7751rvoip_outw(unsigned short value, unsigned long port)
152 if (PXSEG(port))
153 ctrl_outw(value, port);
154 else if (is_pci_ioaddr(port) || shifted_port(port))
155 ctrl_outw(value, pci_ioaddr(port));
156 else
157 maybebadio(port);
160 void hs7751rvoip_outl(unsigned int value, unsigned long port)
162 if (PXSEG(port))
163 ctrl_outl(value, port);
164 else if (is_pci_ioaddr(port) || shifted_port(port))
165 ctrl_outl(value, pci_ioaddr(port));
166 else
167 maybebadio(port);
170 void hs7751rvoip_insb(unsigned long port, void *addr, unsigned long count)
172 u8 *buf = addr;
174 if (PXSEG(port))
175 while (count--)
176 *buf++ = ctrl_inb(port);
177 else if (codec_port(port))
178 while (count--)
179 *buf++ = ctrl_inb(CODEC_IOMAP(port));
180 else if (is_pci_ioaddr(port) || shifted_port(port)) {
181 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
183 while (count--)
184 *buf++ = *bp;
185 } else {
186 volatile u16 *p = (volatile u16 *)port2adr(port);
188 while (count--)
189 *buf++ = *p & 0xff;
193 void hs7751rvoip_insw(unsigned long port, void *addr, unsigned long count)
195 volatile u16 *p;
196 u16 *buf = addr;
198 if (PXSEG(port))
199 p = (volatile u16 *)port;
200 else if (is_pci_ioaddr(port) || shifted_port(port))
201 p = (volatile u16 *)pci_ioaddr(port);
202 else
203 p = (volatile u16 *)port2adr(port);
204 while (count--)
205 *buf++ = *p;
208 void hs7751rvoip_insl(unsigned long port, void *addr, unsigned long count)
211 if (is_pci_ioaddr(port) || shifted_port(port)) {
212 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
213 u32 *buf = addr;
215 while (count--)
216 *buf++ = *p;
217 } else
218 maybebadio(port);
221 void hs7751rvoip_outsb(unsigned long port, const void *addr, unsigned long count)
223 const u8 *buf = addr;
225 if (PXSEG(port))
226 while (count--)
227 ctrl_outb(*buf++, port);
228 else if (codec_port(port))
229 while (count--)
230 ctrl_outb(*buf++, CODEC_IOMAP(port));
231 else if (is_pci_ioaddr(port) || shifted_port(port)) {
232 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
234 while (count--)
235 *bp = *buf++;
236 } else {
237 volatile u16 *p = (volatile u16 *)port2adr(port);
239 while (count--)
240 *p = *buf++;
244 void hs7751rvoip_outsw(unsigned long port, const void *addr, unsigned long count)
246 volatile u16 *p;
247 const u16 *buf = addr;
249 if (PXSEG(port))
250 p = (volatile u16 *)port;
251 else if (is_pci_ioaddr(port) || shifted_port(port))
252 p = (volatile u16 *)pci_ioaddr(port);
253 else
254 p = (volatile u16 *)port2adr(port);
256 while (count--)
257 *p = *buf++;
260 void hs7751rvoip_outsl(unsigned long port, const void *addr, unsigned long count)
262 const u32 *buf = addr;
264 if (is_pci_ioaddr(port) || shifted_port(port)) {
265 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
267 while (count--)
268 *p = *buf++;
269 } else
270 maybebadio(port);
273 void __iomem *hs7751rvoip_ioport_map(unsigned long port, unsigned int size)
275 if (PXSEG(port))
276 return (void __iomem *)port;
277 else if (unlikely(codec_port(port) && (size == 1)))
278 return (void __iomem *)CODEC_IOMAP(port);
279 else if (is_pci_ioaddr(port))
280 return (void __iomem *)pci_ioaddr(port);
282 return (void __iomem *)port2adr(port);