diff options
Diffstat (limited to 'arch/sh/boards/renesas/rts7751r2d/io.c')
-rw-r--r-- | arch/sh/boards/renesas/rts7751r2d/io.c | 191 |
1 files changed, 84 insertions, 107 deletions
diff --git a/arch/sh/boards/renesas/rts7751r2d/io.c b/arch/sh/boards/renesas/rts7751r2d/io.c index 123abbbc91e0..135aa0b5e62d 100644 --- a/arch/sh/boards/renesas/rts7751r2d/io.c +++ b/arch/sh/boards/renesas/rts7751r2d/io.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/arch/sh/kernel/io_rts7751r2d.c | ||
3 | * | ||
4 | * Copyright (C) 2001 Ian da Silva, Jeremy Siegel | 2 | * Copyright (C) 2001 Ian da Silva, Jeremy Siegel |
5 | * Based largely on io_se.c. | 3 | * Based largely on io_se.c. |
6 | * | 4 | * |
@@ -10,17 +8,13 @@ | |||
10 | * placeholder code from io_rts7751r2d.c left in with the | 8 | * placeholder code from io_rts7751r2d.c left in with the |
11 | * expectation of later SuperIO and PCMCIA access. | 9 | * expectation of later SuperIO and PCMCIA access. |
12 | */ | 10 | */ |
13 | |||
14 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
15 | #include <linux/types.h> | 12 | #include <linux/types.h> |
16 | #include <asm/io.h> | 13 | #include <linux/pci.h> |
17 | #include <asm/rts7751r2d/rts7751r2d.h> | 14 | #include <asm/rts7751r2d/rts7751r2d.h> |
15 | #include <asm/io.h> | ||
18 | #include <asm/addrspace.h> | 16 | #include <asm/addrspace.h> |
19 | 17 | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/pci.h> | ||
22 | #include "../../../drivers/pci/pci-sh7751.h" | ||
23 | |||
24 | /* | 18 | /* |
25 | * The 7751R RTS7751R2D uses the built-in PCI controller (PCIC) | 19 | * The 7751R RTS7751R2D uses the built-in PCI controller (PCIC) |
26 | * of the 7751R processor, and has a SuperIO accessible via the PCI. | 20 | * of the 7751R processor, and has a SuperIO accessible via the PCI. |
@@ -28,22 +22,6 @@ | |||
28 | * like the other Solution Engine boards. | 22 | * like the other Solution Engine boards. |
29 | */ | 23 | */ |
30 | 24 | ||
31 | #define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR) | ||
32 | #define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR) | ||
33 | #define PCI_IO_AREA SH7751_PCI_IO_BASE | ||
34 | #define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE | ||
35 | |||
36 | #define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK)) | ||
37 | |||
38 | #define maybebadio(name,port) \ | ||
39 | printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \ | ||
40 | #name, (port), (__u32) __builtin_return_address(0)) | ||
41 | |||
42 | static inline void delay(void) | ||
43 | { | ||
44 | ctrl_inw(0xa0000000); | ||
45 | } | ||
46 | |||
47 | static inline unsigned long port2adr(unsigned int port) | 25 | static inline unsigned long port2adr(unsigned int port) |
48 | { | 26 | { |
49 | if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6) | 27 | if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6) |
@@ -52,7 +30,7 @@ static inline unsigned long port2adr(unsigned int port) | |||
52 | else | 30 | else |
53 | return (PA_AREA5_IO + 0x1000 + ((port-0x1f0) << 1)); | 31 | return (PA_AREA5_IO + 0x1000 + ((port-0x1f0) << 1)); |
54 | else | 32 | else |
55 | maybebadio(port2adr, (unsigned long)port); | 33 | maybebadio((unsigned long)port); |
56 | 34 | ||
57 | return port; | 35 | return port; |
58 | } | 36 | } |
@@ -81,17 +59,6 @@ static inline int shifted_port(unsigned long port) | |||
81 | return 1; | 59 | return 1; |
82 | } | 60 | } |
83 | 61 | ||
84 | /* In case someone configures the kernel w/o PCI support: in that */ | ||
85 | /* scenario, don't ever bother to check for PCI-window addresses */ | ||
86 | |||
87 | /* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */ | ||
88 | #if defined(CONFIG_PCI) | ||
89 | #define CHECK_SH7751_PCIIO(port) \ | ||
90 | ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE))) | ||
91 | #else | ||
92 | #define CHECK_SH7751_PCIIO(port) (0) | ||
93 | #endif | ||
94 | |||
95 | #if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE) | 62 | #if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE) |
96 | #define CHECK_AX88796L_PORT(port) \ | 63 | #define CHECK_AX88796L_PORT(port) \ |
97 | ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20))) | 64 | ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20))) |
@@ -112,8 +79,8 @@ unsigned char rts7751r2d_inb(unsigned long port) | |||
112 | return (*(volatile unsigned short *)port88796l(port, 0)) & 0xff; | 79 | return (*(volatile unsigned short *)port88796l(port, 0)) & 0xff; |
113 | else if (PXSEG(port)) | 80 | else if (PXSEG(port)) |
114 | return *(volatile unsigned char *)port; | 81 | return *(volatile unsigned char *)port; |
115 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 82 | else if (is_pci_ioaddr(port) || shifted_port(port)) |
116 | return *(volatile unsigned char *)PCI_IOMAP(port); | 83 | return *(volatile unsigned char *)pci_ioaddr(port); |
117 | else | 84 | else |
118 | return (*(volatile unsigned short *)port2adr(port) & 0xff); | 85 | return (*(volatile unsigned short *)port2adr(port) & 0xff); |
119 | } | 86 | } |
@@ -126,11 +93,12 @@ unsigned char rts7751r2d_inb_p(unsigned long port) | |||
126 | v = (*(volatile unsigned short *)port88796l(port, 0)) & 0xff; | 93 | v = (*(volatile unsigned short *)port88796l(port, 0)) & 0xff; |
127 | else if (PXSEG(port)) | 94 | else if (PXSEG(port)) |
128 | v = *(volatile unsigned char *)port; | 95 | v = *(volatile unsigned char *)port; |
129 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 96 | else if (is_pci_ioaddr(port) || shifted_port(port)) |
130 | v = *(volatile unsigned char *)PCI_IOMAP(port); | 97 | v = *(volatile unsigned char *)pci_ioaddr(port); |
131 | else | 98 | else |
132 | v = (*(volatile unsigned short *)port2adr(port) & 0xff); | 99 | v = (*(volatile unsigned short *)port2adr(port) & 0xff); |
133 | delay(); | 100 | |
101 | ctrl_delay(); | ||
134 | 102 | ||
135 | return v; | 103 | return v; |
136 | } | 104 | } |
@@ -138,13 +106,13 @@ unsigned char rts7751r2d_inb_p(unsigned long port) | |||
138 | unsigned short rts7751r2d_inw(unsigned long port) | 106 | unsigned short rts7751r2d_inw(unsigned long port) |
139 | { | 107 | { |
140 | if (CHECK_AX88796L_PORT(port)) | 108 | if (CHECK_AX88796L_PORT(port)) |
141 | maybebadio(inw, port); | 109 | maybebadio(port); |
142 | else if (PXSEG(port)) | 110 | else if (PXSEG(port)) |
143 | return *(volatile unsigned short *)port; | 111 | return *(volatile unsigned short *)port; |
144 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 112 | else if (is_pci_ioaddr(port) || shifted_port(port)) |
145 | return *(volatile unsigned short *)PCI_IOMAP(port); | 113 | return *(volatile unsigned short *)pci_ioaddr(port); |
146 | else | 114 | else |
147 | maybebadio(inw, port); | 115 | maybebadio(port); |
148 | 116 | ||
149 | return 0; | 117 | return 0; |
150 | } | 118 | } |
@@ -152,13 +120,13 @@ unsigned short rts7751r2d_inw(unsigned long port) | |||
152 | unsigned int rts7751r2d_inl(unsigned long port) | 120 | unsigned int rts7751r2d_inl(unsigned long port) |
153 | { | 121 | { |
154 | if (CHECK_AX88796L_PORT(port)) | 122 | if (CHECK_AX88796L_PORT(port)) |
155 | maybebadio(inl, port); | 123 | maybebadio(port); |
156 | else if (PXSEG(port)) | 124 | else if (PXSEG(port)) |
157 | return *(volatile unsigned long *)port; | 125 | return *(volatile unsigned long *)port; |
158 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 126 | else if (is_pci_ioaddr(port) || shifted_port(port)) |
159 | return *(volatile unsigned long *)PCI_IOMAP(port); | 127 | return *(volatile unsigned long *)pci_ioaddr(port); |
160 | else | 128 | else |
161 | maybebadio(inl, port); | 129 | maybebadio(port); |
162 | 130 | ||
163 | return 0; | 131 | return 0; |
164 | } | 132 | } |
@@ -169,8 +137,8 @@ void rts7751r2d_outb(unsigned char value, unsigned long port) | |||
169 | *((volatile unsigned short *)port88796l(port, 0)) = value; | 137 | *((volatile unsigned short *)port88796l(port, 0)) = value; |
170 | else if (PXSEG(port)) | 138 | else if (PXSEG(port)) |
171 | *(volatile unsigned char *)port = value; | 139 | *(volatile unsigned char *)port = value; |
172 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 140 | else if (is_pci_ioaddr(port) || shifted_port(port)) |
173 | *(volatile unsigned char *)PCI_IOMAP(port) = value; | 141 | *(volatile unsigned char *)pci_ioaddr(port) = value; |
174 | else | 142 | else |
175 | *(volatile unsigned short *)port2adr(port) = value; | 143 | *(volatile unsigned short *)port2adr(port) = value; |
176 | } | 144 | } |
@@ -181,143 +149,152 @@ void rts7751r2d_outb_p(unsigned char value, unsigned long port) | |||
181 | *((volatile unsigned short *)port88796l(port, 0)) = value; | 149 | *((volatile unsigned short *)port88796l(port, 0)) = value; |
182 | else if (PXSEG(port)) | 150 | else if (PXSEG(port)) |
183 | *(volatile unsigned char *)port = value; | 151 | *(volatile unsigned char *)port = value; |
184 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 152 | else if (is_pci_ioaddr(port) || shifted_port(port)) |
185 | *(volatile unsigned char *)PCI_IOMAP(port) = value; | 153 | *(volatile unsigned char *)pci_ioaddr(port) = value; |
186 | else | 154 | else |
187 | *(volatile unsigned short *)port2adr(port) = value; | 155 | *(volatile unsigned short *)port2adr(port) = value; |
188 | delay(); | 156 | |
157 | ctrl_delay(); | ||
189 | } | 158 | } |
190 | 159 | ||
191 | void rts7751r2d_outw(unsigned short value, unsigned long port) | 160 | void rts7751r2d_outw(unsigned short value, unsigned long port) |
192 | { | 161 | { |
193 | if (CHECK_AX88796L_PORT(port)) | 162 | if (CHECK_AX88796L_PORT(port)) |
194 | maybebadio(outw, port); | 163 | maybebadio(port); |
195 | else if (PXSEG(port)) | 164 | else if (PXSEG(port)) |
196 | *(volatile unsigned short *)port = value; | 165 | *(volatile unsigned short *)port = value; |
197 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 166 | else if (is_pci_ioaddr(port) || shifted_port(port)) |
198 | *(volatile unsigned short *)PCI_IOMAP(port) = value; | 167 | *(volatile unsigned short *)pci_ioaddr(port) = value; |
199 | else | 168 | else |
200 | maybebadio(outw, port); | 169 | maybebadio(port); |
201 | } | 170 | } |
202 | 171 | ||
203 | void rts7751r2d_outl(unsigned int value, unsigned long port) | 172 | void rts7751r2d_outl(unsigned int value, unsigned long port) |
204 | { | 173 | { |
205 | if (CHECK_AX88796L_PORT(port)) | 174 | if (CHECK_AX88796L_PORT(port)) |
206 | maybebadio(outl, port); | 175 | maybebadio(port); |
207 | else if (PXSEG(port)) | 176 | else if (PXSEG(port)) |
208 | *(volatile unsigned long *)port = value; | 177 | *(volatile unsigned long *)port = value; |
209 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 178 | else if (is_pci_ioaddr(port) || shifted_port(port)) |
210 | *(volatile unsigned long *)PCI_IOMAP(port) = value; | 179 | *(volatile unsigned long *)pci_ioaddr(port) = value; |
211 | else | 180 | else |
212 | maybebadio(outl, port); | 181 | maybebadio(port); |
213 | } | 182 | } |
214 | 183 | ||
215 | void rts7751r2d_insb(unsigned long port, void *addr, unsigned long count) | 184 | void rts7751r2d_insb(unsigned long port, void *addr, unsigned long count) |
216 | { | 185 | { |
186 | unsigned long a = (unsigned long)addr; | ||
217 | volatile __u8 *bp; | 187 | volatile __u8 *bp; |
218 | volatile __u16 *p; | 188 | volatile __u16 *p; |
219 | unsigned char *s = addr; | ||
220 | 189 | ||
221 | if (CHECK_AX88796L_PORT(port)) { | 190 | if (CHECK_AX88796L_PORT(port)) { |
222 | p = (volatile unsigned short *)port88796l(port, 0); | 191 | p = (volatile unsigned short *)port88796l(port, 0); |
223 | while (count--) *s++ = *p & 0xff; | 192 | while (count--) |
193 | ctrl_outb(*p & 0xff, a++); | ||
224 | } else if (PXSEG(port)) | 194 | } else if (PXSEG(port)) |
225 | while (count--) *s++ = *(volatile unsigned char *)port; | 195 | while (count--) |
226 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { | 196 | ctrl_outb(ctrl_inb(port), a++); |
227 | bp = (__u8 *)PCI_IOMAP(port); | 197 | else if (is_pci_ioaddr(port) || shifted_port(port)) { |
228 | while (count--) *s++ = *bp; | 198 | bp = (__u8 *)pci_ioaddr(port); |
199 | while (count--) | ||
200 | ctrl_outb(*bp, a++); | ||
229 | } else { | 201 | } else { |
230 | p = (volatile unsigned short *)port2adr(port); | 202 | p = (volatile unsigned short *)port2adr(port); |
231 | while (count--) *s++ = *p & 0xff; | 203 | while (count--) |
204 | ctrl_outb(*p & 0xff, a++); | ||
232 | } | 205 | } |
233 | } | 206 | } |
234 | 207 | ||
235 | void rts7751r2d_insw(unsigned long port, void *addr, unsigned long count) | 208 | void rts7751r2d_insw(unsigned long port, void *addr, unsigned long count) |
236 | { | 209 | { |
210 | unsigned long a = (unsigned long)addr; | ||
237 | volatile __u16 *p; | 211 | volatile __u16 *p; |
238 | __u16 *s = addr; | ||
239 | 212 | ||
240 | if (CHECK_AX88796L_PORT(port)) | 213 | if (CHECK_AX88796L_PORT(port)) |
241 | p = (volatile unsigned short *)port88796l(port, 1); | 214 | p = (volatile unsigned short *)port88796l(port, 1); |
242 | else if (PXSEG(port)) | 215 | else if (PXSEG(port)) |
243 | p = (volatile unsigned short *)port; | 216 | p = (volatile unsigned short *)port; |
244 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 217 | else if (is_pci_ioaddr(port) || shifted_port(port)) |
245 | p = (volatile unsigned short *)PCI_IOMAP(port); | 218 | p = (volatile unsigned short *)pci_ioaddr(port); |
246 | else | 219 | else |
247 | p = (volatile unsigned short *)port2adr(port); | 220 | p = (volatile unsigned short *)port2adr(port); |
248 | while (count--) *s++ = *p; | 221 | while (count--) |
222 | ctrl_outw(*p, a++); | ||
249 | } | 223 | } |
250 | 224 | ||
251 | void rts7751r2d_insl(unsigned long port, void *addr, unsigned long count) | 225 | void rts7751r2d_insl(unsigned long port, void *addr, unsigned long count) |
252 | { | 226 | { |
253 | if (CHECK_AX88796L_PORT(port)) | 227 | if (CHECK_AX88796L_PORT(port)) |
254 | maybebadio(insl, port); | 228 | maybebadio(port); |
255 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { | 229 | else if (is_pci_ioaddr(port) || shifted_port(port)) { |
256 | volatile __u32 *p = (__u32 *)PCI_IOMAP(port); | 230 | unsigned long a = (unsigned long)addr; |
257 | __u32 *s = addr; | 231 | |
258 | 232 | while (count--) { | |
259 | while (count--) *s++ = *p; | 233 | ctrl_outl(ctrl_inl(pci_ioaddr(port)), a); |
234 | a += 4; | ||
235 | } | ||
260 | } else | 236 | } else |
261 | maybebadio(insl, port); | 237 | maybebadio(port); |
262 | } | 238 | } |
263 | 239 | ||
264 | void rts7751r2d_outsb(unsigned long port, const void *addr, unsigned long count) | 240 | void rts7751r2d_outsb(unsigned long port, const void *addr, unsigned long count) |
265 | { | 241 | { |
242 | unsigned long a = (unsigned long)addr; | ||
266 | volatile __u8 *bp; | 243 | volatile __u8 *bp; |
267 | volatile __u16 *p; | 244 | volatile __u16 *p; |
268 | const __u8 *s = addr; | ||
269 | 245 | ||
270 | if (CHECK_AX88796L_PORT(port)) { | 246 | if (CHECK_AX88796L_PORT(port)) { |
271 | p = (volatile unsigned short *)port88796l(port, 0); | 247 | p = (volatile unsigned short *)port88796l(port, 0); |
272 | while (count--) *p = *s++; | 248 | while (count--) |
249 | *p = ctrl_inb(a++); | ||
273 | } else if (PXSEG(port)) | 250 | } else if (PXSEG(port)) |
274 | while (count--) *(volatile unsigned char *)port = *s++; | 251 | while (count--) |
275 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { | 252 | ctrl_outb(a++, port); |
276 | bp = (__u8 *)PCI_IOMAP(port); | 253 | else if (is_pci_ioaddr(port) || shifted_port(port)) { |
277 | while (count--) *bp = *s++; | 254 | bp = (__u8 *)pci_ioaddr(port); |
255 | while (count--) | ||
256 | *bp = ctrl_inb(a++); | ||
278 | } else { | 257 | } else { |
279 | p = (volatile unsigned short *)port2adr(port); | 258 | p = (volatile unsigned short *)port2adr(port); |
280 | while (count--) *p = *s++; | 259 | while (count--) |
260 | *p = ctrl_inb(a++); | ||
281 | } | 261 | } |
282 | } | 262 | } |
283 | 263 | ||
284 | void rts7751r2d_outsw(unsigned long port, const void *addr, unsigned long count) | 264 | void rts7751r2d_outsw(unsigned long port, const void *addr, unsigned long count) |
285 | { | 265 | { |
266 | unsigned long a = (unsigned long)addr; | ||
286 | volatile __u16 *p; | 267 | volatile __u16 *p; |
287 | const __u16 *s = addr; | ||
288 | 268 | ||
289 | if (CHECK_AX88796L_PORT(port)) | 269 | if (CHECK_AX88796L_PORT(port)) |
290 | p = (volatile unsigned short *)port88796l(port, 1); | 270 | p = (volatile unsigned short *)port88796l(port, 1); |
291 | else if (PXSEG(port)) | 271 | else if (PXSEG(port)) |
292 | p = (volatile unsigned short *)port; | 272 | p = (volatile unsigned short *)port; |
293 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 273 | else if (is_pci_ioaddr(port) || shifted_port(port)) |
294 | p = (volatile unsigned short *)PCI_IOMAP(port); | 274 | p = (volatile unsigned short *)pci_ioaddr(port); |
295 | else | 275 | else |
296 | p = (volatile unsigned short *)port2adr(port); | 276 | p = (volatile unsigned short *)port2adr(port); |
297 | while (count--) *p = *s++; | 277 | |
278 | while (count--) { | ||
279 | ctrl_outw(*p, a); | ||
280 | a += 2; | ||
281 | } | ||
298 | } | 282 | } |
299 | 283 | ||
300 | void rts7751r2d_outsl(unsigned long port, const void *addr, unsigned long count) | 284 | void rts7751r2d_outsl(unsigned long port, const void *addr, unsigned long count) |
301 | { | 285 | { |
302 | if (CHECK_AX88796L_PORT(port)) | 286 | if (CHECK_AX88796L_PORT(port)) |
303 | maybebadio(outsl, port); | 287 | maybebadio(port); |
304 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { | 288 | else if (is_pci_ioaddr(port) || shifted_port(port)) { |
305 | volatile __u32 *p = (__u32 *)PCI_IOMAP(port); | 289 | unsigned long a = (unsigned long)addr; |
306 | const __u32 *s = addr; | 290 | |
307 | 291 | while (count--) { | |
308 | while (count--) *p = *s++; | 292 | ctrl_outl(ctrl_inl(a), pci_ioaddr(port)); |
293 | a += 4; | ||
294 | } | ||
309 | } else | 295 | } else |
310 | maybebadio(outsl, port); | 296 | maybebadio(port); |
311 | } | ||
312 | |||
313 | void *rts7751r2d_ioremap(unsigned long offset, unsigned long size) | ||
314 | { | ||
315 | if (offset >= 0xfd000000) | ||
316 | return (void *)offset; | ||
317 | else | ||
318 | return (void *)P2SEGADDR(offset); | ||
319 | } | 297 | } |
320 | EXPORT_SYMBOL(rts7751r2d_ioremap); | ||
321 | 298 | ||
322 | unsigned long rts7751r2d_isa_port2addr(unsigned long offset) | 299 | unsigned long rts7751r2d_isa_port2addr(unsigned long offset) |
323 | { | 300 | { |