aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-powerpc/io.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-powerpc/io.h')
-rw-r--r--include/asm-powerpc/io.h183
1 files changed, 84 insertions, 99 deletions
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index 212428db0d8b..46bae1cf385b 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -20,20 +20,11 @@ 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
29#include <asm-generic/iomap.h> 26#include <asm-generic/iomap.h>
30 27
31#define __ide_mm_insw(p, a, c) _insw_ns((volatile u16 __iomem *)(p), (a), (c))
32#define __ide_mm_insl(p, a, c) _insl_ns((volatile u32 __iomem *)(p), (a), (c))
33#define __ide_mm_outsw(p, a, c) _outsw_ns((volatile u16 __iomem *)(p), (a), (c))
34#define __ide_mm_outsl(p, a, c) _outsl_ns((volatile u32 __iomem *)(p), (a), (c))
35
36
37#define SIO_CONFIG_RA 0x398 28#define SIO_CONFIG_RA 0x398
38#define SIO_CONFIG_RD 0x399 29#define SIO_CONFIG_RD 0x399
39 30
@@ -43,42 +34,53 @@ extern unsigned long isa_io_base;
43extern unsigned long pci_io_base; 34extern unsigned long pci_io_base;
44 35
45#ifdef CONFIG_PPC_ISERIES 36#ifdef CONFIG_PPC_ISERIES
46/* __raw_* accessors aren't supported on iSeries */ 37
47#define __raw_readb(addr) { BUG(); 0; } 38extern int in_8(const volatile unsigned char __iomem *addr);
48#define __raw_readw(addr) { BUG(); 0; } 39extern void out_8(volatile unsigned char __iomem *addr, int val);
49#define __raw_readl(addr) { BUG(); 0; } 40extern int in_le16(const volatile unsigned short __iomem *addr);
50#define __raw_readq(addr) { BUG(); 0; } 41extern int in_be16(const volatile unsigned short __iomem *addr);
51#define __raw_writeb(v, addr) { BUG(); 0; } 42extern void out_le16(volatile unsigned short __iomem *addr, int val);
52#define __raw_writew(v, addr) { BUG(); 0; } 43extern void out_be16(volatile unsigned short __iomem *addr, int val);
53#define __raw_writel(v, addr) { BUG(); 0; } 44extern unsigned in_le32(const volatile unsigned __iomem *addr);
54#define __raw_writeq(v, addr) { BUG(); 0; } 45extern unsigned in_be32(const volatile unsigned __iomem *addr);
55#define readb(addr) iSeries_Read_Byte(addr) 46extern void out_le32(volatile unsigned __iomem *addr, int val);
56#define readw(addr) iSeries_Read_Word(addr) 47extern void out_be32(volatile unsigned __iomem *addr, int val);
57#define readl(addr) iSeries_Read_Long(addr) 48extern unsigned long in_le64(const volatile unsigned long __iomem *addr);
58#define writeb(data, addr) iSeries_Write_Byte((data),(addr)) 49extern unsigned long in_be64(const volatile unsigned long __iomem *addr);
59#define writew(data, addr) iSeries_Write_Word((data),(addr)) 50extern void out_le64(volatile unsigned long __iomem *addr, unsigned long val);
60#define writel(data, addr) iSeries_Write_Long((data),(addr)) 51extern void out_be64(volatile unsigned long __iomem *addr, unsigned long val);
61#define memset_io(a,b,c) iSeries_memset_io((a),(b),(c)) 52
62#define memcpy_fromio(a,b,c) iSeries_memcpy_fromio((a), (b), (c)) 53extern unsigned char __raw_readb(const volatile void __iomem *addr);
63#define memcpy_toio(a,b,c) iSeries_memcpy_toio((a), (b), (c)) 54extern unsigned short __raw_readw(const volatile void __iomem *addr);
64 55extern unsigned int __raw_readl(const volatile void __iomem *addr);
65#define inb(addr) readb(((void __iomem *)(long)(addr))) 56extern unsigned long __raw_readq(const volatile void __iomem *addr);
66#define inw(addr) readw(((void __iomem *)(long)(addr))) 57extern void __raw_writeb(unsigned char v, volatile void __iomem *addr);
67#define inl(addr) readl(((void __iomem *)(long)(addr))) 58extern void __raw_writew(unsigned short v, volatile void __iomem *addr);
68#define outb(data,addr) writeb(data,((void __iomem *)(long)(addr))) 59extern void __raw_writel(unsigned int v, volatile void __iomem *addr);
69#define outw(data,addr) writew(data,((void __iomem *)(long)(addr))) 60extern void __raw_writeq(unsigned long v, volatile void __iomem *addr);
70#define outl(data,addr) writel(data,((void __iomem *)(long)(addr))) 61
71/* 62extern void memset_io(volatile void __iomem *addr, int c, unsigned long n);
72 * The *_ns versions below don't do byte-swapping. 63extern void memcpy_fromio(void *dest, const volatile void __iomem *src,
73 * Neither do the standard versions now, these are just here 64 unsigned long n);
74 * for older code. 65extern void memcpy_toio(volatile void __iomem *dest, const void *src,
75 */ 66 unsigned long n);
76#define insb(port, buf, ns) _insb((u8 __iomem *)((port)+pci_io_base), (buf), (ns)) 67
77#define insw(port, buf, ns) _insw_ns((u8 __iomem *)((port)+pci_io_base), (buf), (ns)) 68#else /* CONFIG_PPC_ISERIES */
78#define insl(port, buf, nl) _insl_ns((u8 __iomem *)((port)+pci_io_base), (buf), (nl)) 69
79#define insw_ns(port, buf, ns) _insw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns)) 70#define in_8(addr) __in_8((addr))
80#define insl_ns(port, buf, nl) _insl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl)) 71#define out_8(addr, val) __out_8((addr), (val))
81#else 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))
82 84
83static inline unsigned char __raw_readb(const volatile void __iomem *addr) 85static inline unsigned char __raw_readb(const volatile void __iomem *addr)
84{ 86{
@@ -112,23 +114,11 @@ static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
112{ 114{
113 *(volatile unsigned long __force *)addr = v; 115 *(volatile unsigned long __force *)addr = v;
114} 116}
115#define readb(addr) eeh_readb(addr)
116#define readw(addr) eeh_readw(addr)
117#define readl(addr) eeh_readl(addr)
118#define readq(addr) eeh_readq(addr)
119#define writeb(data, addr) eeh_writeb((data), (addr))
120#define writew(data, addr) eeh_writew((data), (addr))
121#define writel(data, addr) eeh_writel((data), (addr))
122#define writeq(data, addr) eeh_writeq((data), (addr))
123#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))
124#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))
125#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))
126#define inb(port) eeh_inb((unsigned long)port) 120
127#define outb(val, port) eeh_outb(val, (unsigned long)port) 121#endif /* CONFIG_PPC_ISERIES */
128#define inw(port) eeh_inw((unsigned long)port)
129#define outw(val, port) eeh_outw(val, (unsigned long)port)
130#define inl(port) eeh_inl((unsigned long)port)
131#define outl(val, port) eeh_outl(val, (unsigned long)port)
132 122
133/* 123/*
134 * The insw/outsw/insl/outsl macros don't do byte-swapping. 124 * The insw/outsw/insl/outsl macros don't do byte-swapping.
@@ -138,30 +128,37 @@ static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
138#define insb(port, buf, ns) eeh_insb((port), (buf), (ns)) 128#define insb(port, buf, ns) eeh_insb((port), (buf), (ns))
139#define insw(port, buf, ns) eeh_insw_ns((port), (buf), (ns)) 129#define insw(port, buf, ns) eeh_insw_ns((port), (buf), (ns))
140#define insl(port, buf, nl) eeh_insl_ns((port), (buf), (nl)) 130#define insl(port, buf, nl) eeh_insl_ns((port), (buf), (nl))
141#define insw_ns(port, buf, ns) eeh_insw_ns((port), (buf), (ns))
142#define insl_ns(port, buf, nl) eeh_insl_ns((port), (buf), (nl))
143
144#endif
145 131
146#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))
147#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))
148#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))
149 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
150#define readb_relaxed(addr) readb(addr) 151#define readb_relaxed(addr) readb(addr)
151#define readw_relaxed(addr) readw(addr) 152#define readw_relaxed(addr) readw(addr)
152#define readl_relaxed(addr) readl(addr) 153#define readl_relaxed(addr) readl(addr)
153#define readq_relaxed(addr) readq(addr) 154#define readq_relaxed(addr) readq(addr)
154 155
155extern void _insb(volatile u8 __iomem *port, void *buf, int ns); 156extern void _insb(volatile u8 __iomem *port, void *buf, long count);
156extern void _outsb(volatile u8 __iomem *port, const void *buf, int ns); 157extern void _outsb(volatile u8 __iomem *port, const void *buf, long count);
157extern void _insw(volatile u16 __iomem *port, void *buf, int ns); 158extern void _insw_ns(volatile u16 __iomem *port, void *buf, long count);
158extern void _outsw(volatile u16 __iomem *port, const void *buf, int ns); 159extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count);
159extern void _insl(volatile u32 __iomem *port, void *buf, int nl); 160extern void _insl_ns(volatile u32 __iomem *port, void *buf, long count);
160extern void _outsl(volatile u32 __iomem *port, const void *buf, int nl); 161extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count);
161extern void _insw_ns(volatile u16 __iomem *port, void *buf, int ns);
162extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, int ns);
163extern void _insl_ns(volatile u32 __iomem *port, void *buf, int nl);
164extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, int nl);
165 162
166static inline void mmiowb(void) 163static inline void mmiowb(void)
167{ 164{
@@ -180,14 +177,6 @@ static inline void mmiowb(void)
180#define inl_p(port) inl(port) 177#define inl_p(port) inl(port)
181#define outl_p(val, port) (udelay(1), outl((val), (port))) 178#define outl_p(val, port) (udelay(1), outl((val), (port)))
182 179
183/*
184 * The *_ns versions below don't do byte-swapping.
185 * Neither do the standard versions now, these are just here
186 * for older code.
187 */
188#define outsw_ns(port, buf, ns) _outsw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns))
189#define outsl_ns(port, buf, nl) _outsl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl))
190
191 180
192#define IO_SPACE_LIMIT ~(0UL) 181#define IO_SPACE_LIMIT ~(0UL)
193 182
@@ -279,7 +268,7 @@ static inline void iosync(void)
279 * 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
280 * instead. 269 * instead.
281 */ 270 */
282static inline int in_8(const volatile unsigned char __iomem *addr) 271static inline int __in_8(const volatile unsigned char __iomem *addr)
283{ 272{
284 int ret; 273 int ret;
285 274
@@ -288,14 +277,14 @@ static inline int in_8(const volatile unsigned char __iomem *addr)
288 return ret; 277 return ret;
289} 278}
290 279
291static inline void out_8(volatile unsigned char __iomem *addr, int val) 280static inline void __out_8(volatile unsigned char __iomem *addr, int val)
292{ 281{
293 __asm__ __volatile__("sync; stb%U0%X0 %1,%0" 282 __asm__ __volatile__("sync; stb%U0%X0 %1,%0"
294 : "=m" (*addr) : "r" (val)); 283 : "=m" (*addr) : "r" (val));
295 get_paca()->io_sync = 1; 284 get_paca()->io_sync = 1;
296} 285}
297 286
298static inline int in_le16(const volatile unsigned short __iomem *addr) 287static inline int __in_le16(const volatile unsigned short __iomem *addr)
299{ 288{
300 int ret; 289 int ret;
301 290
@@ -304,7 +293,7 @@ static inline int in_le16(const volatile unsigned short __iomem *addr)
304 return ret; 293 return ret;
305} 294}
306 295
307static inline int in_be16(const volatile unsigned short __iomem *addr) 296static inline int __in_be16(const volatile unsigned short __iomem *addr)
308{ 297{
309 int ret; 298 int ret;
310 299
@@ -313,21 +302,21 @@ static inline int in_be16(const volatile unsigned short __iomem *addr)
313 return ret; 302 return ret;
314} 303}
315 304
316static inline void out_le16(volatile unsigned short __iomem *addr, int val) 305static inline void __out_le16(volatile unsigned short __iomem *addr, int val)
317{ 306{
318 __asm__ __volatile__("sync; sthbrx %1,0,%2" 307 __asm__ __volatile__("sync; sthbrx %1,0,%2"
319 : "=m" (*addr) : "r" (val), "r" (addr)); 308 : "=m" (*addr) : "r" (val), "r" (addr));
320 get_paca()->io_sync = 1; 309 get_paca()->io_sync = 1;
321} 310}
322 311
323static inline void out_be16(volatile unsigned short __iomem *addr, int val) 312static inline void __out_be16(volatile unsigned short __iomem *addr, int val)
324{ 313{
325 __asm__ __volatile__("sync; sth%U0%X0 %1,%0" 314 __asm__ __volatile__("sync; sth%U0%X0 %1,%0"
326 : "=m" (*addr) : "r" (val)); 315 : "=m" (*addr) : "r" (val));
327 get_paca()->io_sync = 1; 316 get_paca()->io_sync = 1;
328} 317}
329 318
330static inline unsigned in_le32(const volatile unsigned __iomem *addr) 319static inline unsigned __in_le32(const volatile unsigned __iomem *addr)
331{ 320{
332 unsigned ret; 321 unsigned ret;
333 322
@@ -336,7 +325,7 @@ static inline unsigned in_le32(const volatile unsigned __iomem *addr)
336 return ret; 325 return ret;
337} 326}
338 327
339static inline unsigned in_be32(const volatile unsigned __iomem *addr) 328static inline unsigned __in_be32(const volatile unsigned __iomem *addr)
340{ 329{
341 unsigned ret; 330 unsigned ret;
342 331
@@ -345,21 +334,21 @@ static inline unsigned in_be32(const volatile unsigned __iomem *addr)
345 return ret; 334 return ret;
346} 335}
347 336
348static inline void out_le32(volatile unsigned __iomem *addr, int val) 337static inline void __out_le32(volatile unsigned __iomem *addr, int val)
349{ 338{
350 __asm__ __volatile__("sync; stwbrx %1,0,%2" : "=m" (*addr) 339 __asm__ __volatile__("sync; stwbrx %1,0,%2" : "=m" (*addr)
351 : "r" (val), "r" (addr)); 340 : "r" (val), "r" (addr));
352 get_paca()->io_sync = 1; 341 get_paca()->io_sync = 1;
353} 342}
354 343
355static inline void out_be32(volatile unsigned __iomem *addr, int val) 344static inline void __out_be32(volatile unsigned __iomem *addr, int val)
356{ 345{
357 __asm__ __volatile__("sync; stw%U0%X0 %1,%0" 346 __asm__ __volatile__("sync; stw%U0%X0 %1,%0"
358 : "=m" (*addr) : "r" (val)); 347 : "=m" (*addr) : "r" (val));
359 get_paca()->io_sync = 1; 348 get_paca()->io_sync = 1;
360} 349}
361 350
362static inline unsigned long in_le64(const volatile unsigned long __iomem *addr) 351static inline unsigned long __in_le64(const volatile unsigned long __iomem *addr)
363{ 352{
364 unsigned long tmp, ret; 353 unsigned long tmp, ret;
365 354
@@ -379,7 +368,7 @@ static inline unsigned long in_le64(const volatile unsigned long __iomem *addr)
379 return ret; 368 return ret;
380} 369}
381 370
382static inline unsigned long in_be64(const volatile unsigned long __iomem *addr) 371static inline unsigned long __in_be64(const volatile unsigned long __iomem *addr)
383{ 372{
384 unsigned long ret; 373 unsigned long ret;
385 374
@@ -388,7 +377,7 @@ static inline unsigned long in_be64(const volatile unsigned long __iomem *addr)
388 return ret; 377 return ret;
389} 378}
390 379
391static inline void out_le64(volatile unsigned long __iomem *addr, unsigned long val) 380static inline void __out_le64(volatile unsigned long __iomem *addr, unsigned long val)
392{ 381{
393 unsigned long tmp; 382 unsigned long tmp;
394 383
@@ -406,15 +395,13 @@ static inline void out_le64(volatile unsigned long __iomem *addr, unsigned long
406 get_paca()->io_sync = 1; 395 get_paca()->io_sync = 1;
407} 396}
408 397
409static inline void out_be64(volatile unsigned long __iomem *addr, unsigned long val) 398static inline void __out_be64(volatile unsigned long __iomem *addr, unsigned long val)
410{ 399{
411 __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));
412 get_paca()->io_sync = 1; 401 get_paca()->io_sync = 1;
413} 402}
414 403
415#ifndef CONFIG_PPC_ISERIES
416#include <asm/eeh.h> 404#include <asm/eeh.h>
417#endif
418 405
419/** 406/**
420 * check_signature - find BIOS signatures 407 * check_signature - find BIOS signatures
@@ -430,7 +417,6 @@ static inline int check_signature(const volatile void __iomem * io_addr,
430 const unsigned char *signature, int length) 417 const unsigned char *signature, int length)
431{ 418{
432 int retval = 0; 419 int retval = 0;
433#ifndef CONFIG_PPC_ISERIES
434 do { 420 do {
435 if (readb(io_addr) != *signature) 421 if (readb(io_addr) != *signature)
436 goto out; 422 goto out;
@@ -440,7 +426,6 @@ static inline int check_signature(const volatile void __iomem * io_addr,
440 } while (length); 426 } while (length);
441 retval = 1; 427 retval = 1;
442out: 428out:
443#endif
444 return retval; 429 return retval;
445} 430}
446 431