diff options
author | Paul Mundt <lethal@linux-sh.org> | 2006-09-27 02:41:24 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2006-09-27 02:41:24 -0400 |
commit | 373e68b5472d421cbd2703e7a77caf053f78c005 (patch) | |
tree | 6fed51fdf1b89f80a1ec9ea4aab285c1af649945 /arch/sh/boards/renesas/hs7751rvoip/io.c | |
parent | f647d33f879d258de4ab2559975bd6eebda2033e (diff) |
sh: Board updates for I/O routine rework.
This updates the various boards for some of the recent I/O routine
updates.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/boards/renesas/hs7751rvoip/io.c')
-rw-r--r-- | arch/sh/boards/renesas/hs7751rvoip/io.c | 159 |
1 files changed, 91 insertions, 68 deletions
diff --git a/arch/sh/boards/renesas/hs7751rvoip/io.c b/arch/sh/boards/renesas/hs7751rvoip/io.c index edecf107fc13..ecdce7ef6a34 100644 --- a/arch/sh/boards/renesas/hs7751rvoip/io.c +++ b/arch/sh/boards/renesas/hs7751rvoip/io.c | |||
@@ -21,10 +21,8 @@ | |||
21 | #include <linux/pci.h> | 21 | #include <linux/pci.h> |
22 | #include "../../../drivers/pci/pci-sh7751.h" | 22 | #include "../../../drivers/pci/pci-sh7751.h" |
23 | 23 | ||
24 | extern void *area5_io8_base; /* Area 5 8bit I/O Base address */ | ||
25 | extern void *area6_io8_base; /* Area 6 8bit I/O Base address */ | 24 | extern void *area6_io8_base; /* Area 6 8bit I/O Base address */ |
26 | extern void *area5_io16_base; /* Area 5 16bit I/O Base address */ | 25 | extern void *area5_io16_base; /* Area 5 16bit I/O Base address */ |
27 | extern void *area6_io16_base; /* Area 6 16bit I/O Base address */ | ||
28 | 26 | ||
29 | /* | 27 | /* |
30 | * The 7751R HS7751RVoIP uses the built-in PCI controller (PCIC) | 28 | * The 7751R HS7751RVoIP uses the built-in PCI controller (PCIC) |
@@ -37,16 +35,10 @@ extern void *area6_io16_base; /* Area 6 16bit I/O Base address */ | |||
37 | #define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR) | 35 | #define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR) |
38 | #define PCI_IO_AREA SH7751_PCI_IO_BASE | 36 | #define PCI_IO_AREA SH7751_PCI_IO_BASE |
39 | #define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE | 37 | #define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE |
40 | |||
41 | #define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK)) | 38 | #define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK)) |
42 | 39 | ||
43 | #if defined(CONFIG_HS7751RVOIP_CODEC) | ||
44 | #define CODEC_IO_BASE 0x1000 | 40 | #define CODEC_IO_BASE 0x1000 |
45 | #endif | 41 | #define CODEC_IOMAP(a) ((unsigned long)area6_io8_base + ((a) - CODEC_IO_BASE)) |
46 | |||
47 | #define maybebadio(name,port) \ | ||
48 | printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \ | ||
49 | #name, (port), (__u32) __builtin_return_address(0)) | ||
50 | 42 | ||
51 | static inline void delay(void) | 43 | static inline void delay(void) |
52 | { | 44 | { |
@@ -61,7 +53,7 @@ static inline unsigned long port2adr(unsigned int port) | |||
61 | else | 53 | else |
62 | return ((unsigned long)area5_io16_base + 0x800 + ((port-0x1f0) << 1)); | 54 | return ((unsigned long)area5_io16_base + 0x800 + ((port-0x1f0) << 1)); |
63 | else | 55 | else |
64 | maybebadio(port2adr, (unsigned long)port); | 56 | maybebadio((unsigned long)port); |
65 | return port; | 57 | return port; |
66 | } | 58 | } |
67 | 59 | ||
@@ -109,15 +101,15 @@ codec_port(unsigned long port) | |||
109 | unsigned char hs7751rvoip_inb(unsigned long port) | 101 | unsigned char hs7751rvoip_inb(unsigned long port) |
110 | { | 102 | { |
111 | if (PXSEG(port)) | 103 | if (PXSEG(port)) |
112 | return *(volatile unsigned char *)port; | 104 | return ctrl_inb(port); |
113 | #if defined(CONFIG_HS7751RVOIP_CODEC) | 105 | #if defined(CONFIG_HS7751RVOIP_CODEC) |
114 | else if (codec_port(port)) | 106 | else if (codec_port(port)) |
115 | return *(volatile unsigned char *)((unsigned long)area6_io8_base+(port-CODEC_IO_BASE)); | 107 | return ctrl_inb(CODEC_IOMAP(port)); |
116 | #endif | 108 | #endif |
117 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 109 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) |
118 | return *(volatile unsigned char *)PCI_IOMAP(port); | 110 | return ctrl_inb(PCI_IOMAP(port)); |
119 | else | 111 | else |
120 | return (*(volatile unsigned short *)port2adr(port) & 0xff); | 112 | return ctrl_inw(port2adr(port)) & 0xff; |
121 | } | 113 | } |
122 | 114 | ||
123 | unsigned char hs7751rvoip_inb_p(unsigned long port) | 115 | unsigned char hs7751rvoip_inb_p(unsigned long port) |
@@ -125,15 +117,15 @@ unsigned char hs7751rvoip_inb_p(unsigned long port) | |||
125 | unsigned char v; | 117 | unsigned char v; |
126 | 118 | ||
127 | if (PXSEG(port)) | 119 | if (PXSEG(port)) |
128 | v = *(volatile unsigned char *)port; | 120 | v = ctrl_inb(port); |
129 | #if defined(CONFIG_HS7751RVOIP_CODEC) | 121 | #if defined(CONFIG_HS7751RVOIP_CODEC) |
130 | else if (codec_port(port)) | 122 | else if (codec_port(port)) |
131 | v = *(volatile unsigned char *)((unsigned long)area6_io8_base+(port-CODEC_IO_BASE)); | 123 | v = ctrl_inb(CODEC_IOMAP(port)); |
132 | #endif | 124 | #endif |
133 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 125 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) |
134 | v = *(volatile unsigned char *)PCI_IOMAP(port); | 126 | v = ctrl_inb(PCI_IOMAP(port)); |
135 | else | 127 | else |
136 | v = (*(volatile unsigned short *)port2adr(port) & 0xff); | 128 | v = ctrl_inw(port2adr(port)) & 0xff; |
137 | delay(); | 129 | delay(); |
138 | return v; | 130 | return v; |
139 | } | 131 | } |
@@ -141,22 +133,22 @@ unsigned char hs7751rvoip_inb_p(unsigned long port) | |||
141 | unsigned short hs7751rvoip_inw(unsigned long port) | 133 | unsigned short hs7751rvoip_inw(unsigned long port) |
142 | { | 134 | { |
143 | if (PXSEG(port)) | 135 | if (PXSEG(port)) |
144 | return *(volatile unsigned short *)port; | 136 | return ctrl_inw(port); |
145 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 137 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) |
146 | return *(volatile unsigned short *)PCI_IOMAP(port); | 138 | return ctrl_inw(PCI_IOMAP(port)); |
147 | else | 139 | else |
148 | maybebadio(inw, port); | 140 | maybebadio(port); |
149 | return 0; | 141 | return 0; |
150 | } | 142 | } |
151 | 143 | ||
152 | unsigned int hs7751rvoip_inl(unsigned long port) | 144 | unsigned int hs7751rvoip_inl(unsigned long port) |
153 | { | 145 | { |
154 | if (PXSEG(port)) | 146 | if (PXSEG(port)) |
155 | return *(volatile unsigned long *)port; | 147 | return ctrl_inl(port); |
156 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 148 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) |
157 | return *(volatile unsigned long *)PCI_IOMAP(port); | 149 | return ctrl_inl(PCI_IOMAP(port)); |
158 | else | 150 | else |
159 | maybebadio(inl, port); | 151 | maybebadio(port); |
160 | return 0; | 152 | return 0; |
161 | } | 153 | } |
162 | 154 | ||
@@ -164,137 +156,168 @@ void hs7751rvoip_outb(unsigned char value, unsigned long port) | |||
164 | { | 156 | { |
165 | 157 | ||
166 | if (PXSEG(port)) | 158 | if (PXSEG(port)) |
167 | *(volatile unsigned char *)port = value; | 159 | ctrl_outb(value, port); |
168 | #if defined(CONFIG_HS7751RVOIP_CODEC) | 160 | #if defined(CONFIG_HS7751RVOIP_CODEC) |
169 | else if (codec_port(port)) | 161 | else if (codec_port(port)) |
170 | *(volatile unsigned char *)((unsigned long)area6_io8_base+(port-CODEC_IO_BASE)) = value; | 162 | ctrl_outb(value, CODEC_IOMAP(port)); |
171 | #endif | 163 | #endif |
172 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 164 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) |
173 | *(unsigned char *)PCI_IOMAP(port) = value; | 165 | ctrl_outb(value, PCI_IOMAP(port)); |
174 | else | 166 | else |
175 | *(volatile unsigned short *)port2adr(port) = value; | 167 | ctrl_outb(value, port2adr(port)); |
176 | } | 168 | } |
177 | 169 | ||
178 | void hs7751rvoip_outb_p(unsigned char value, unsigned long port) | 170 | void hs7751rvoip_outb_p(unsigned char value, unsigned long port) |
179 | { | 171 | { |
180 | if (PXSEG(port)) | 172 | if (PXSEG(port)) |
181 | *(volatile unsigned char *)port = value; | 173 | ctrl_outb(value, port); |
182 | #if defined(CONFIG_HS7751RVOIP_CODEC) | 174 | #if defined(CONFIG_HS7751RVOIP_CODEC) |
183 | else if (codec_port(port)) | 175 | else if (codec_port(port)) |
184 | *(volatile unsigned char *)((unsigned long)area6_io8_base+(port-CODEC_IO_BASE)) = value; | 176 | ctrl_outb(value, CODEC_IOMAP(port)); |
185 | #endif | 177 | #endif |
186 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 178 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) |
187 | *(unsigned char *)PCI_IOMAP(port) = value; | 179 | ctrl_outb(value, PCI_IOMAP(port)); |
188 | else | 180 | else |
189 | *(volatile unsigned short *)port2adr(port) = value; | 181 | ctrl_outw(value, port2adr(port)); |
182 | |||
190 | delay(); | 183 | delay(); |
191 | } | 184 | } |
192 | 185 | ||
193 | void hs7751rvoip_outw(unsigned short value, unsigned long port) | 186 | void hs7751rvoip_outw(unsigned short value, unsigned long port) |
194 | { | 187 | { |
195 | if (PXSEG(port)) | 188 | if (PXSEG(port)) |
196 | *(volatile unsigned short *)port = value; | 189 | ctrl_outw(value, port); |
197 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 190 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) |
198 | *(unsigned short *)PCI_IOMAP(port) = value; | 191 | ctrl_outw(value, PCI_IOMAP(port)); |
199 | else | 192 | else |
200 | maybebadio(outw, port); | 193 | maybebadio(port); |
201 | } | 194 | } |
202 | 195 | ||
203 | void hs7751rvoip_outl(unsigned int value, unsigned long port) | 196 | void hs7751rvoip_outl(unsigned int value, unsigned long port) |
204 | { | 197 | { |
205 | if (PXSEG(port)) | 198 | if (PXSEG(port)) |
206 | *(volatile unsigned long *)port = value; | 199 | ctrl_outl(value, port); |
207 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 200 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) |
208 | *((unsigned long *)PCI_IOMAP(port)) = value; | 201 | ctrl_outl(value, PCI_IOMAP(port)); |
209 | else | 202 | else |
210 | maybebadio(outl, port); | 203 | maybebadio(port); |
211 | } | 204 | } |
212 | 205 | ||
213 | void hs7751rvoip_insb(unsigned long port, void *addr, unsigned long count) | 206 | void hs7751rvoip_insb(unsigned long port, void *addr, unsigned long count) |
214 | { | 207 | { |
208 | u8 *buf = addr; | ||
209 | |||
215 | if (PXSEG(port)) | 210 | if (PXSEG(port)) |
216 | while (count--) *((unsigned char *) addr)++ = *(volatile unsigned char *)port; | 211 | while (count--) |
212 | *buf++ = ctrl_inb(port); | ||
217 | #if defined(CONFIG_HS7751RVOIP_CODEC) | 213 | #if defined(CONFIG_HS7751RVOIP_CODEC) |
218 | else if (codec_port(port)) | 214 | else if (codec_port(port)) |
219 | while (count--) *((unsigned char *) addr)++ = *(volatile unsigned char *)((unsigned long)area6_io8_base+(port-CODEC_IO_BASE)); | 215 | while (count--) |
216 | *buf++ = ctrl_inb(CODEC_IOMAP(port)); | ||
220 | #endif | 217 | #endif |
221 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { | 218 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { |
222 | volatile __u8 *bp = (__u8 *)PCI_IOMAP(port); | 219 | volatile u8 *bp = (volatile u8 *)PCI_IOMAP(port); |
223 | 220 | ||
224 | while (count--) *((volatile unsigned char *) addr)++ = *bp; | 221 | while (count--) |
222 | *buf++ = *bp; | ||
225 | } else { | 223 | } else { |
226 | volatile __u16 *p = (volatile unsigned short *)port2adr(port); | 224 | volatile u16 *p = (volatile u16 *)port2adr(port); |
227 | 225 | ||
228 | while (count--) *((unsigned char *) addr)++ = *p & 0xff; | 226 | while (count--) |
227 | *buf++ = *p & 0xff; | ||
229 | } | 228 | } |
230 | } | 229 | } |
231 | 230 | ||
232 | void hs7751rvoip_insw(unsigned long port, void *addr, unsigned long count) | 231 | void hs7751rvoip_insw(unsigned long port, void *addr, unsigned long count) |
233 | { | 232 | { |
234 | volatile __u16 *p; | 233 | volatile u16 *p; |
234 | u16 *buf = addr; | ||
235 | 235 | ||
236 | if (PXSEG(port)) | 236 | if (PXSEG(port)) |
237 | p = (volatile unsigned short *)port; | 237 | p = (volatile u16 *)port; |
238 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 238 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) |
239 | p = (volatile unsigned short *)PCI_IOMAP(port); | 239 | p = (volatile u16 *)PCI_IOMAP(port); |
240 | else | 240 | else |
241 | p = (volatile unsigned short *)port2adr(port); | 241 | p = (volatile u16 *)port2adr(port); |
242 | while (count--) *((__u16 *) addr)++ = *p; | 242 | while (count--) |
243 | *buf++ = *p; | ||
243 | } | 244 | } |
244 | 245 | ||
245 | void hs7751rvoip_insl(unsigned long port, void *addr, unsigned long count) | 246 | void hs7751rvoip_insl(unsigned long port, void *addr, unsigned long count) |
246 | { | 247 | { |
248 | |||
247 | if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { | 249 | if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { |
248 | volatile __u32 *p = (__u32 *)PCI_IOMAP(port); | 250 | volatile u32 *p = (volatile u32 *)PCI_IOMAP(port); |
251 | u32 *buf = addr; | ||
249 | 252 | ||
250 | while (count--) *((__u32 *) addr)++ = *p; | 253 | while (count--) |
254 | *buf++ = *p; | ||
251 | } else | 255 | } else |
252 | maybebadio(insl, port); | 256 | maybebadio(port); |
253 | } | 257 | } |
254 | 258 | ||
255 | void hs7751rvoip_outsb(unsigned long port, const void *addr, unsigned long count) | 259 | void hs7751rvoip_outsb(unsigned long port, const void *addr, unsigned long count) |
256 | { | 260 | { |
261 | const u8 *buf = addr; | ||
262 | |||
257 | if (PXSEG(port)) | 263 | if (PXSEG(port)) |
258 | while (count--) *(volatile unsigned char *)port = *((unsigned char *) addr)++; | 264 | while (count--) |
265 | ctrl_outb(*buf++, port); | ||
259 | #if defined(CONFIG_HS7751RVOIP_CODEC) | 266 | #if defined(CONFIG_HS7751RVOIP_CODEC) |
260 | else if (codec_port(port)) | 267 | else if (codec_port(port)) |
261 | while (count--) *(volatile unsigned char *)((unsigned long)area6_io8_base+(port-CODEC_IO_BASE)) = *((unsigned char *) addr)++; | 268 | while (count--) |
269 | ctrl_outb(*buf++, CODEC_IOMAP(port)); | ||
262 | #endif | 270 | #endif |
263 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { | 271 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { |
264 | volatile __u8 *bp = (__u8 *)PCI_IOMAP(port); | 272 | volatile u8 *bp = (volatile u8 *)PCI_IOMAP(port); |
265 | 273 | ||
266 | while (count--) *bp = *((volatile unsigned char *) addr)++; | 274 | while (count--) |
275 | *bp = *buf++; | ||
267 | } else { | 276 | } else { |
268 | volatile __u16 *p = (volatile unsigned short *)port2adr(port); | 277 | volatile u16 *p = (volatile u16 *)port2adr(port); |
269 | 278 | ||
270 | while (count--) *p = *((unsigned char *) addr)++; | 279 | while (count--) |
280 | *p = *buf++; | ||
271 | } | 281 | } |
272 | } | 282 | } |
273 | 283 | ||
274 | void hs7751rvoip_outsw(unsigned long port, const void *addr, unsigned long count) | 284 | void hs7751rvoip_outsw(unsigned long port, const void *addr, unsigned long count) |
275 | { | 285 | { |
276 | volatile __u16 *p; | 286 | volatile u16 *p; |
287 | const u16 *buf = addr; | ||
277 | 288 | ||
278 | if (PXSEG(port)) | 289 | if (PXSEG(port)) |
279 | p = (volatile unsigned short *)port; | 290 | p = (volatile u16 *)port; |
280 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) | 291 | else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) |
281 | p = (volatile unsigned short *)PCI_IOMAP(port); | 292 | p = (volatile u16 *)PCI_IOMAP(port); |
282 | else | 293 | else |
283 | p = (volatile unsigned short *)port2adr(port); | 294 | p = (volatile u16 *)port2adr(port); |
284 | while (count--) *p = *((__u16 *) addr)++; | 295 | |
296 | while (count--) | ||
297 | *p = *buf++; | ||
285 | } | 298 | } |
286 | 299 | ||
287 | void hs7751rvoip_outsl(unsigned long port, const void *addr, unsigned long count) | 300 | void hs7751rvoip_outsl(unsigned long port, const void *addr, unsigned long count) |
288 | { | 301 | { |
302 | const u32 *buf = addr; | ||
303 | |||
289 | if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { | 304 | if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { |
290 | volatile __u32 *p = (__u32 *)PCI_IOMAP(port); | 305 | volatile u32 *p = (volatile u32 *)PCI_IOMAP(port); |
291 | 306 | ||
292 | while (count--) *p = *((__u32 *) addr)++; | 307 | while (count--) |
308 | *p = *buf++; | ||
293 | } else | 309 | } else |
294 | maybebadio(outsl, port); | 310 | maybebadio(port); |
295 | } | 311 | } |
296 | 312 | ||
297 | unsigned long hs7751rvoip_isa_port2addr(unsigned long offset) | 313 | void __iomem *hs7751rvoip_ioport_map(unsigned long port, unsigned int size) |
298 | { | 314 | { |
299 | return port2adr(offset); | 315 | if (PXSEG(port)) |
316 | return (void __iomem *)port; | ||
317 | else if (unlikely(codec_port(port) && (size == 1))) | ||
318 | return (void __iomem *)CODEC_IOMAP(port); | ||
319 | else if (CHECK_SH7751_PCIIO(port)) | ||
320 | return (void __iomem *)PCI_IOMAP(port); | ||
321 | |||
322 | return (void __iomem *)port2adr(port); | ||
300 | } | 323 | } |