diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2006-09-21 04:00:00 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-09-22 01:19:58 -0400 |
commit | caf81329c39b5c48f6cc0d78fa159b5a587e37f9 (patch) | |
tree | 7cf6afe7a14e2a9d1cc962895b61d8cb24e71793 /include/asm-powerpc/io.h | |
parent | 7da8a2e5c1fd2ee513fdeac8d13c4f3623838fd0 (diff) |
[POWERPC] Merge iSeries i/o operations with the rest
This patch changes the io operations so that they are out of line if
CONFIG_PPC_ISERIES is set and includes a firmware feature check in
that case.
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'include/asm-powerpc/io.h')
-rw-r--r-- | include/asm-powerpc/io.h | 148 |
1 files changed, 77 insertions, 71 deletions
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h index 174fb89d5eda..46bae1cf385b 100644 --- a/include/asm-powerpc/io.h +++ b/include/asm-powerpc/io.h | |||
@@ -20,9 +20,6 @@ extern int check_legacy_ioport(unsigned long base_port); | |||
20 | #include <asm/page.h> | 20 | #include <asm/page.h> |
21 | #include <asm/byteorder.h> | 21 | #include <asm/byteorder.h> |
22 | #include <asm/paca.h> | 22 | #include <asm/paca.h> |
23 | #ifdef CONFIG_PPC_ISERIES | ||
24 | #include <asm/iseries/iseries_io.h> | ||
25 | #endif | ||
26 | #include <asm/synch.h> | 23 | #include <asm/synch.h> |
27 | #include <asm/delay.h> | 24 | #include <asm/delay.h> |
28 | 25 | ||
@@ -37,41 +34,53 @@ extern unsigned long isa_io_base; | |||
37 | extern unsigned long pci_io_base; | 34 | extern unsigned long pci_io_base; |
38 | 35 | ||
39 | #ifdef CONFIG_PPC_ISERIES | 36 | #ifdef CONFIG_PPC_ISERIES |
40 | /* __raw_* accessors aren't supported on iSeries */ | ||
41 | #define __raw_readb(addr) { BUG(); 0; } | ||
42 | #define __raw_readw(addr) { BUG(); 0; } | ||
43 | #define __raw_readl(addr) { BUG(); 0; } | ||
44 | #define __raw_readq(addr) { BUG(); 0; } | ||
45 | #define __raw_writeb(v, addr) { BUG(); 0; } | ||
46 | #define __raw_writew(v, addr) { BUG(); 0; } | ||
47 | #define __raw_writel(v, addr) { BUG(); 0; } | ||
48 | #define __raw_writeq(v, addr) { BUG(); 0; } | ||
49 | #define readb(addr) iSeries_Read_Byte(addr) | ||
50 | #define readw(addr) iSeries_Read_Word(addr) | ||
51 | #define readl(addr) iSeries_Read_Long(addr) | ||
52 | #define writeb(data, addr) iSeries_Write_Byte((data),(addr)) | ||
53 | #define writew(data, addr) iSeries_Write_Word((data),(addr)) | ||
54 | #define writel(data, addr) iSeries_Write_Long((data),(addr)) | ||
55 | #define memset_io(a,b,c) iSeries_memset_io((a),(b),(c)) | ||
56 | #define memcpy_fromio(a,b,c) iSeries_memcpy_fromio((a), (b), (c)) | ||
57 | #define memcpy_toio(a,b,c) iSeries_memcpy_toio((a), (b), (c)) | ||
58 | |||
59 | #define inb(addr) readb(((void __iomem *)(long)(addr))) | ||
60 | #define inw(addr) readw(((void __iomem *)(long)(addr))) | ||
61 | #define inl(addr) readl(((void __iomem *)(long)(addr))) | ||
62 | #define outb(data,addr) writeb(data,((void __iomem *)(long)(addr))) | ||
63 | #define outw(data,addr) writew(data,((void __iomem *)(long)(addr))) | ||
64 | #define outl(data,addr) writel(data,((void __iomem *)(long)(addr))) | ||
65 | /* | ||
66 | * The *_ns versions below don't do byte-swapping. | ||
67 | * Neither do the standard versions now, these are just here | ||
68 | * for older code. | ||
69 | */ | ||
70 | #define insb(port, buf, ns) _insb((u8 __iomem *)((port)+pci_io_base), (buf), (ns)) | ||
71 | #define insw(port, buf, ns) _insw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns)) | ||
72 | #define insl(port, buf, nl) _insl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl)) | ||
73 | 37 | ||
74 | #else | 38 | extern int in_8(const volatile unsigned char __iomem *addr); |
39 | extern void out_8(volatile unsigned char __iomem *addr, int val); | ||
40 | extern int in_le16(const volatile unsigned short __iomem *addr); | ||
41 | extern int in_be16(const volatile unsigned short __iomem *addr); | ||
42 | extern void out_le16(volatile unsigned short __iomem *addr, int val); | ||
43 | extern void out_be16(volatile unsigned short __iomem *addr, int val); | ||
44 | extern unsigned in_le32(const volatile unsigned __iomem *addr); | ||
45 | extern unsigned in_be32(const volatile unsigned __iomem *addr); | ||
46 | extern void out_le32(volatile unsigned __iomem *addr, int val); | ||
47 | extern void out_be32(volatile unsigned __iomem *addr, int val); | ||
48 | extern unsigned long in_le64(const volatile unsigned long __iomem *addr); | ||
49 | extern unsigned long in_be64(const volatile unsigned long __iomem *addr); | ||
50 | extern void out_le64(volatile unsigned long __iomem *addr, unsigned long val); | ||
51 | extern void out_be64(volatile unsigned long __iomem *addr, unsigned long val); | ||
52 | |||
53 | extern unsigned char __raw_readb(const volatile void __iomem *addr); | ||
54 | extern unsigned short __raw_readw(const volatile void __iomem *addr); | ||
55 | extern unsigned int __raw_readl(const volatile void __iomem *addr); | ||
56 | extern unsigned long __raw_readq(const volatile void __iomem *addr); | ||
57 | extern void __raw_writeb(unsigned char v, volatile void __iomem *addr); | ||
58 | extern void __raw_writew(unsigned short v, volatile void __iomem *addr); | ||
59 | extern void __raw_writel(unsigned int v, volatile void __iomem *addr); | ||
60 | extern void __raw_writeq(unsigned long v, volatile void __iomem *addr); | ||
61 | |||
62 | extern void memset_io(volatile void __iomem *addr, int c, unsigned long n); | ||
63 | extern void memcpy_fromio(void *dest, const volatile void __iomem *src, | ||
64 | unsigned long n); | ||
65 | extern void memcpy_toio(volatile void __iomem *dest, const void *src, | ||
66 | unsigned long n); | ||
67 | |||
68 | #else /* CONFIG_PPC_ISERIES */ | ||
69 | |||
70 | #define in_8(addr) __in_8((addr)) | ||
71 | #define out_8(addr, val) __out_8((addr), (val)) | ||
72 | #define in_le16(addr) __in_le16((addr)) | ||
73 | #define in_be16(addr) __in_be16((addr)) | ||
74 | #define out_le16(addr, val) __out_le16((addr), (val)) | ||
75 | #define out_be16(addr, val) __out_be16((addr), (val)) | ||
76 | #define in_le32(addr) __in_le32((addr)) | ||
77 | #define in_be32(addr) __in_be32((addr)) | ||
78 | #define out_le32(addr, val) __out_le32((addr), (val)) | ||
79 | #define out_be32(addr, val) __out_be32((addr), (val)) | ||
80 | #define in_le64(addr) __in_le64((addr)) | ||
81 | #define in_be64(addr) __in_be64((addr)) | ||
82 | #define out_le64(addr, val) __out_le64((addr), (val)) | ||
83 | #define out_be64(addr, val) __out_be64((addr), (val)) | ||
75 | 84 | ||
76 | static inline unsigned char __raw_readb(const volatile void __iomem *addr) | 85 | static inline unsigned char __raw_readb(const volatile void __iomem *addr) |
77 | { | 86 | { |
@@ -105,23 +114,11 @@ static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr) | |||
105 | { | 114 | { |
106 | *(volatile unsigned long __force *)addr = v; | 115 | *(volatile unsigned long __force *)addr = v; |
107 | } | 116 | } |
108 | #define readb(addr) eeh_readb(addr) | ||
109 | #define readw(addr) eeh_readw(addr) | ||
110 | #define readl(addr) eeh_readl(addr) | ||
111 | #define readq(addr) eeh_readq(addr) | ||
112 | #define writeb(data, addr) eeh_writeb((data), (addr)) | ||
113 | #define writew(data, addr) eeh_writew((data), (addr)) | ||
114 | #define writel(data, addr) eeh_writel((data), (addr)) | ||
115 | #define writeq(data, addr) eeh_writeq((data), (addr)) | ||
116 | #define memset_io(a,b,c) eeh_memset_io((a),(b),(c)) | 117 | #define memset_io(a,b,c) eeh_memset_io((a),(b),(c)) |
117 | #define memcpy_fromio(a,b,c) eeh_memcpy_fromio((a),(b),(c)) | 118 | #define memcpy_fromio(a,b,c) eeh_memcpy_fromio((a),(b),(c)) |
118 | #define memcpy_toio(a,b,c) eeh_memcpy_toio((a),(b),(c)) | 119 | #define memcpy_toio(a,b,c) eeh_memcpy_toio((a),(b),(c)) |
119 | #define inb(port) eeh_inb((unsigned long)port) | 120 | |
120 | #define outb(val, port) eeh_outb(val, (unsigned long)port) | 121 | #endif /* CONFIG_PPC_ISERIES */ |
121 | #define inw(port) eeh_inw((unsigned long)port) | ||
122 | #define outw(val, port) eeh_outw(val, (unsigned long)port) | ||
123 | #define inl(port) eeh_inl((unsigned long)port) | ||
124 | #define outl(val, port) eeh_outl(val, (unsigned long)port) | ||
125 | 122 | ||
126 | /* | 123 | /* |
127 | * The insw/outsw/insl/outsl macros don't do byte-swapping. | 124 | * The insw/outsw/insl/outsl macros don't do byte-swapping. |
@@ -132,12 +129,25 @@ static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr) | |||
132 | #define insw(port, buf, ns) eeh_insw_ns((port), (buf), (ns)) | 129 | #define insw(port, buf, ns) eeh_insw_ns((port), (buf), (ns)) |
133 | #define insl(port, buf, nl) eeh_insl_ns((port), (buf), (nl)) | 130 | #define insl(port, buf, nl) eeh_insl_ns((port), (buf), (nl)) |
134 | 131 | ||
135 | #endif | ||
136 | |||
137 | #define outsb(port, buf, ns) _outsb((u8 __iomem *)((port)+pci_io_base), (buf), (ns)) | 132 | #define outsb(port, buf, ns) _outsb((u8 __iomem *)((port)+pci_io_base), (buf), (ns)) |
138 | #define outsw(port, buf, ns) _outsw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns)) | 133 | #define outsw(port, buf, ns) _outsw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns)) |
139 | #define outsl(port, buf, nl) _outsl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl)) | 134 | #define outsl(port, buf, nl) _outsl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl)) |
140 | 135 | ||
136 | #define readb(addr) eeh_readb(addr) | ||
137 | #define readw(addr) eeh_readw(addr) | ||
138 | #define readl(addr) eeh_readl(addr) | ||
139 | #define readq(addr) eeh_readq(addr) | ||
140 | #define writeb(data, addr) eeh_writeb((data), (addr)) | ||
141 | #define writew(data, addr) eeh_writew((data), (addr)) | ||
142 | #define writel(data, addr) eeh_writel((data), (addr)) | ||
143 | #define writeq(data, addr) eeh_writeq((data), (addr)) | ||
144 | #define inb(port) eeh_inb((unsigned long)port) | ||
145 | #define outb(val, port) eeh_outb(val, (unsigned long)port) | ||
146 | #define inw(port) eeh_inw((unsigned long)port) | ||
147 | #define outw(val, port) eeh_outw(val, (unsigned long)port) | ||
148 | #define inl(port) eeh_inl((unsigned long)port) | ||
149 | #define outl(val, port) eeh_outl(val, (unsigned long)port) | ||
150 | |||
141 | #define readb_relaxed(addr) readb(addr) | 151 | #define readb_relaxed(addr) readb(addr) |
142 | #define readw_relaxed(addr) readw(addr) | 152 | #define readw_relaxed(addr) readw(addr) |
143 | #define readl_relaxed(addr) readl(addr) | 153 | #define readl_relaxed(addr) readl(addr) |
@@ -258,7 +268,7 @@ static inline void iosync(void) | |||
258 | * and should not be used directly by device drivers. Use inb/readb | 268 | * and should not be used directly by device drivers. Use inb/readb |
259 | * instead. | 269 | * instead. |
260 | */ | 270 | */ |
261 | static inline int in_8(const volatile unsigned char __iomem *addr) | 271 | static inline int __in_8(const volatile unsigned char __iomem *addr) |
262 | { | 272 | { |
263 | int ret; | 273 | int ret; |
264 | 274 | ||
@@ -267,14 +277,14 @@ static inline int in_8(const volatile unsigned char __iomem *addr) | |||
267 | return ret; | 277 | return ret; |
268 | } | 278 | } |
269 | 279 | ||
270 | static inline void out_8(volatile unsigned char __iomem *addr, int val) | 280 | static inline void __out_8(volatile unsigned char __iomem *addr, int val) |
271 | { | 281 | { |
272 | __asm__ __volatile__("sync; stb%U0%X0 %1,%0" | 282 | __asm__ __volatile__("sync; stb%U0%X0 %1,%0" |
273 | : "=m" (*addr) : "r" (val)); | 283 | : "=m" (*addr) : "r" (val)); |
274 | get_paca()->io_sync = 1; | 284 | get_paca()->io_sync = 1; |
275 | } | 285 | } |
276 | 286 | ||
277 | static inline int in_le16(const volatile unsigned short __iomem *addr) | 287 | static inline int __in_le16(const volatile unsigned short __iomem *addr) |
278 | { | 288 | { |
279 | int ret; | 289 | int ret; |
280 | 290 | ||
@@ -283,7 +293,7 @@ static inline int in_le16(const volatile unsigned short __iomem *addr) | |||
283 | return ret; | 293 | return ret; |
284 | } | 294 | } |
285 | 295 | ||
286 | static inline int in_be16(const volatile unsigned short __iomem *addr) | 296 | static inline int __in_be16(const volatile unsigned short __iomem *addr) |
287 | { | 297 | { |
288 | int ret; | 298 | int ret; |
289 | 299 | ||
@@ -292,21 +302,21 @@ static inline int in_be16(const volatile unsigned short __iomem *addr) | |||
292 | return ret; | 302 | return ret; |
293 | } | 303 | } |
294 | 304 | ||
295 | static inline void out_le16(volatile unsigned short __iomem *addr, int val) | 305 | static inline void __out_le16(volatile unsigned short __iomem *addr, int val) |
296 | { | 306 | { |
297 | __asm__ __volatile__("sync; sthbrx %1,0,%2" | 307 | __asm__ __volatile__("sync; sthbrx %1,0,%2" |
298 | : "=m" (*addr) : "r" (val), "r" (addr)); | 308 | : "=m" (*addr) : "r" (val), "r" (addr)); |
299 | get_paca()->io_sync = 1; | 309 | get_paca()->io_sync = 1; |
300 | } | 310 | } |
301 | 311 | ||
302 | static inline void out_be16(volatile unsigned short __iomem *addr, int val) | 312 | static inline void __out_be16(volatile unsigned short __iomem *addr, int val) |
303 | { | 313 | { |
304 | __asm__ __volatile__("sync; sth%U0%X0 %1,%0" | 314 | __asm__ __volatile__("sync; sth%U0%X0 %1,%0" |
305 | : "=m" (*addr) : "r" (val)); | 315 | : "=m" (*addr) : "r" (val)); |
306 | get_paca()->io_sync = 1; | 316 | get_paca()->io_sync = 1; |
307 | } | 317 | } |
308 | 318 | ||
309 | static inline unsigned in_le32(const volatile unsigned __iomem *addr) | 319 | static inline unsigned __in_le32(const volatile unsigned __iomem *addr) |
310 | { | 320 | { |
311 | unsigned ret; | 321 | unsigned ret; |
312 | 322 | ||
@@ -315,7 +325,7 @@ static inline unsigned in_le32(const volatile unsigned __iomem *addr) | |||
315 | return ret; | 325 | return ret; |
316 | } | 326 | } |
317 | 327 | ||
318 | static inline unsigned in_be32(const volatile unsigned __iomem *addr) | 328 | static inline unsigned __in_be32(const volatile unsigned __iomem *addr) |
319 | { | 329 | { |
320 | unsigned ret; | 330 | unsigned ret; |
321 | 331 | ||
@@ -324,21 +334,21 @@ static inline unsigned in_be32(const volatile unsigned __iomem *addr) | |||
324 | return ret; | 334 | return ret; |
325 | } | 335 | } |
326 | 336 | ||
327 | static inline void out_le32(volatile unsigned __iomem *addr, int val) | 337 | static inline void __out_le32(volatile unsigned __iomem *addr, int val) |
328 | { | 338 | { |
329 | __asm__ __volatile__("sync; stwbrx %1,0,%2" : "=m" (*addr) | 339 | __asm__ __volatile__("sync; stwbrx %1,0,%2" : "=m" (*addr) |
330 | : "r" (val), "r" (addr)); | 340 | : "r" (val), "r" (addr)); |
331 | get_paca()->io_sync = 1; | 341 | get_paca()->io_sync = 1; |
332 | } | 342 | } |
333 | 343 | ||
334 | static inline void out_be32(volatile unsigned __iomem *addr, int val) | 344 | static inline void __out_be32(volatile unsigned __iomem *addr, int val) |
335 | { | 345 | { |
336 | __asm__ __volatile__("sync; stw%U0%X0 %1,%0" | 346 | __asm__ __volatile__("sync; stw%U0%X0 %1,%0" |
337 | : "=m" (*addr) : "r" (val)); | 347 | : "=m" (*addr) : "r" (val)); |
338 | get_paca()->io_sync = 1; | 348 | get_paca()->io_sync = 1; |
339 | } | 349 | } |
340 | 350 | ||
341 | static inline unsigned long in_le64(const volatile unsigned long __iomem *addr) | 351 | static inline unsigned long __in_le64(const volatile unsigned long __iomem *addr) |
342 | { | 352 | { |
343 | unsigned long tmp, ret; | 353 | unsigned long tmp, ret; |
344 | 354 | ||
@@ -358,7 +368,7 @@ static inline unsigned long in_le64(const volatile unsigned long __iomem *addr) | |||
358 | return ret; | 368 | return ret; |
359 | } | 369 | } |
360 | 370 | ||
361 | static inline unsigned long in_be64(const volatile unsigned long __iomem *addr) | 371 | static inline unsigned long __in_be64(const volatile unsigned long __iomem *addr) |
362 | { | 372 | { |
363 | unsigned long ret; | 373 | unsigned long ret; |
364 | 374 | ||
@@ -367,7 +377,7 @@ static inline unsigned long in_be64(const volatile unsigned long __iomem *addr) | |||
367 | return ret; | 377 | return ret; |
368 | } | 378 | } |
369 | 379 | ||
370 | static inline void out_le64(volatile unsigned long __iomem *addr, unsigned long val) | 380 | static inline void __out_le64(volatile unsigned long __iomem *addr, unsigned long val) |
371 | { | 381 | { |
372 | unsigned long tmp; | 382 | unsigned long tmp; |
373 | 383 | ||
@@ -385,15 +395,13 @@ static inline void out_le64(volatile unsigned long __iomem *addr, unsigned long | |||
385 | get_paca()->io_sync = 1; | 395 | get_paca()->io_sync = 1; |
386 | } | 396 | } |
387 | 397 | ||
388 | static inline void out_be64(volatile unsigned long __iomem *addr, unsigned long val) | 398 | static inline void __out_be64(volatile unsigned long __iomem *addr, unsigned long val) |
389 | { | 399 | { |
390 | __asm__ __volatile__("sync; std%U0%X0 %1,%0" : "=m" (*addr) : "r" (val)); | 400 | __asm__ __volatile__("sync; std%U0%X0 %1,%0" : "=m" (*addr) : "r" (val)); |
391 | get_paca()->io_sync = 1; | 401 | get_paca()->io_sync = 1; |
392 | } | 402 | } |
393 | 403 | ||
394 | #ifndef CONFIG_PPC_ISERIES | ||
395 | #include <asm/eeh.h> | 404 | #include <asm/eeh.h> |
396 | #endif | ||
397 | 405 | ||
398 | /** | 406 | /** |
399 | * check_signature - find BIOS signatures | 407 | * check_signature - find BIOS signatures |
@@ -409,7 +417,6 @@ static inline int check_signature(const volatile void __iomem * io_addr, | |||
409 | const unsigned char *signature, int length) | 417 | const unsigned char *signature, int length) |
410 | { | 418 | { |
411 | int retval = 0; | 419 | int retval = 0; |
412 | #ifndef CONFIG_PPC_ISERIES | ||
413 | do { | 420 | do { |
414 | if (readb(io_addr) != *signature) | 421 | if (readb(io_addr) != *signature) |
415 | goto out; | 422 | goto out; |
@@ -419,7 +426,6 @@ static inline int check_signature(const volatile void __iomem * io_addr, | |||
419 | } while (length); | 426 | } while (length); |
420 | retval = 1; | 427 | retval = 1; |
421 | out: | 428 | out: |
422 | #endif | ||
423 | return retval; | 429 | return retval; |
424 | } | 430 | } |
425 | 431 | ||