diff options
Diffstat (limited to 'include/asm-powerpc/io.h')
-rw-r--r-- | include/asm-powerpc/io.h | 84 |
1 files changed, 61 insertions, 23 deletions
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h index afae0697e8c..77c7fa025e6 100644 --- a/include/asm-powerpc/io.h +++ b/include/asm-powerpc/io.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #define _ASM_POWERPC_IO_H | 2 | #define _ASM_POWERPC_IO_H |
3 | #ifdef __KERNEL__ | 3 | #ifdef __KERNEL__ |
4 | 4 | ||
5 | /* | 5 | /* |
6 | * This program is free software; you can redistribute it and/or | 6 | * This program is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU General Public License | 7 | * modify it under the terms of the GNU General Public License |
8 | * as published by the Free Software Foundation; either version | 8 | * as published by the Free Software Foundation; either version |
@@ -18,6 +18,9 @@ extern int check_legacy_ioport(unsigned long base_port); | |||
18 | #define _PNPWRP 0xa79 | 18 | #define _PNPWRP 0xa79 |
19 | #define PNPBIOS_BASE 0xf000 | 19 | #define PNPBIOS_BASE 0xf000 |
20 | 20 | ||
21 | #include <linux/device.h> | ||
22 | #include <linux/io.h> | ||
23 | |||
21 | #include <linux/compiler.h> | 24 | #include <linux/compiler.h> |
22 | #include <asm/page.h> | 25 | #include <asm/page.h> |
23 | #include <asm/byteorder.h> | 26 | #include <asm/byteorder.h> |
@@ -92,33 +95,60 @@ extern resource_size_t isa_mem_base; | |||
92 | #define IO_SET_SYNC_FLAG() | 95 | #define IO_SET_SYNC_FLAG() |
93 | #endif | 96 | #endif |
94 | 97 | ||
95 | #define DEF_MMIO_IN(name, type, insn) \ | 98 | /* gcc 4.0 and older doesn't have 'Z' constraint */ |
96 | static inline type name(const volatile type __iomem *addr) \ | 99 | #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0) |
100 | #define DEF_MMIO_IN_LE(name, size, insn) \ | ||
101 | static inline u##size name(const volatile u##size __iomem *addr) \ | ||
102 | { \ | ||
103 | u##size ret; \ | ||
104 | __asm__ __volatile__("sync;"#insn" %0,0,%1;twi 0,%0,0;isync" \ | ||
105 | : "=r" (ret) : "r" (addr), "m" (*addr) : "memory"); \ | ||
106 | return ret; \ | ||
107 | } | ||
108 | |||
109 | #define DEF_MMIO_OUT_LE(name, size, insn) \ | ||
110 | static inline void name(volatile u##size __iomem *addr, u##size val) \ | ||
111 | { \ | ||
112 | __asm__ __volatile__("sync;"#insn" %1,0,%2" \ | ||
113 | : "=m" (*addr) : "r" (val), "r" (addr) : "memory"); \ | ||
114 | IO_SET_SYNC_FLAG(); \ | ||
115 | } | ||
116 | #else /* newer gcc */ | ||
117 | #define DEF_MMIO_IN_LE(name, size, insn) \ | ||
118 | static inline u##size name(const volatile u##size __iomem *addr) \ | ||
97 | { \ | 119 | { \ |
98 | type ret; \ | 120 | u##size ret; \ |
99 | __asm__ __volatile__("sync;" insn ";twi 0,%0,0;isync" \ | 121 | __asm__ __volatile__("sync;"#insn" %0,%y1;twi 0,%0,0;isync" \ |
100 | : "=r" (ret) : "r" (addr), "m" (*addr)); \ | 122 | : "=r" (ret) : "Z" (*addr) : "memory"); \ |
101 | return ret; \ | 123 | return ret; \ |
102 | } | 124 | } |
103 | 125 | ||
104 | #define DEF_MMIO_OUT(name, type, insn) \ | 126 | #define DEF_MMIO_OUT_LE(name, size, insn) \ |
105 | static inline void name(volatile type __iomem *addr, type val) \ | 127 | static inline void name(volatile u##size __iomem *addr, u##size val) \ |
106 | { \ | 128 | { \ |
107 | __asm__ __volatile__("sync;" insn \ | 129 | __asm__ __volatile__("sync;"#insn" %1,%y0" \ |
108 | : "=m" (*addr) : "r" (val), "r" (addr)); \ | 130 | : "=Z" (*addr) : "r" (val) : "memory"); \ |
109 | IO_SET_SYNC_FLAG(); \ | 131 | IO_SET_SYNC_FLAG(); \ |
110 | } | 132 | } |
133 | #endif | ||
111 | 134 | ||
135 | #define DEF_MMIO_IN_BE(name, size, insn) \ | ||
136 | static inline u##size name(const volatile u##size __iomem *addr) \ | ||
137 | { \ | ||
138 | u##size ret; \ | ||
139 | __asm__ __volatile__("sync;"#insn"%U1%X1 %0,%1;twi 0,%0,0;isync"\ | ||
140 | : "=r" (ret) : "m" (*addr) : "memory"); \ | ||
141 | return ret; \ | ||
142 | } | ||
112 | 143 | ||
113 | #define DEF_MMIO_IN_BE(name, size, insn) \ | 144 | #define DEF_MMIO_OUT_BE(name, size, insn) \ |
114 | DEF_MMIO_IN(name, u##size, __stringify(insn)"%U2%X2 %0,%2") | 145 | static inline void name(volatile u##size __iomem *addr, u##size val) \ |
115 | #define DEF_MMIO_IN_LE(name, size, insn) \ | 146 | { \ |
116 | DEF_MMIO_IN(name, u##size, __stringify(insn)" %0,0,%1") | 147 | __asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \ |
148 | : "=m" (*addr) : "r" (val) : "memory"); \ | ||
149 | IO_SET_SYNC_FLAG(); \ | ||
150 | } | ||
117 | 151 | ||
118 | #define DEF_MMIO_OUT_BE(name, size, insn) \ | ||
119 | DEF_MMIO_OUT(name, u##size, __stringify(insn)"%U0%X0 %1,%0") | ||
120 | #define DEF_MMIO_OUT_LE(name, size, insn) \ | ||
121 | DEF_MMIO_OUT(name, u##size, __stringify(insn)" %1,0,%2") | ||
122 | 152 | ||
123 | DEF_MMIO_IN_BE(in_8, 8, lbz); | 153 | DEF_MMIO_IN_BE(in_8, 8, lbz); |
124 | DEF_MMIO_IN_BE(in_be16, 16, lhz); | 154 | DEF_MMIO_IN_BE(in_be16, 16, lhz); |
@@ -330,7 +360,8 @@ static inline unsigned int name(unsigned int port) \ | |||
330 | " .long 3b,5b\n" \ | 360 | " .long 3b,5b\n" \ |
331 | ".previous" \ | 361 | ".previous" \ |
332 | : "=&r" (x) \ | 362 | : "=&r" (x) \ |
333 | : "r" (port + _IO_BASE)); \ | 363 | : "r" (port + _IO_BASE) \ |
364 | : "memory"); \ | ||
334 | return x; \ | 365 | return x; \ |
335 | } | 366 | } |
336 | 367 | ||
@@ -347,7 +378,8 @@ static inline void name(unsigned int val, unsigned int port) \ | |||
347 | " .long 0b,2b\n" \ | 378 | " .long 0b,2b\n" \ |
348 | " .long 1b,2b\n" \ | 379 | " .long 1b,2b\n" \ |
349 | ".previous" \ | 380 | ".previous" \ |
350 | : : "r" (val), "r" (port + _IO_BASE)); \ | 381 | : : "r" (val), "r" (port + _IO_BASE) \ |
382 | : "memory"); \ | ||
351 | } | 383 | } |
352 | 384 | ||
353 | __do_in_asm(_rec_inb, "lbzx") | 385 | __do_in_asm(_rec_inb, "lbzx") |
@@ -585,7 +617,8 @@ static inline void iosync(void) | |||
585 | * and can be hooked by the platform via ppc_md | 617 | * and can be hooked by the platform via ppc_md |
586 | * | 618 | * |
587 | * * ioremap_flags allows to specify the page flags as an argument and can | 619 | * * ioremap_flags allows to specify the page flags as an argument and can |
588 | * also be hooked by the platform via ppc_md | 620 | * also be hooked by the platform via ppc_md. ioremap_prot is the exact |
621 | * same thing as ioremap_flags. | ||
589 | * | 622 | * |
590 | * * ioremap_nocache is identical to ioremap | 623 | * * ioremap_nocache is identical to ioremap |
591 | * | 624 | * |
@@ -607,6 +640,8 @@ extern void __iomem *ioremap(phys_addr_t address, unsigned long size); | |||
607 | extern void __iomem *ioremap_flags(phys_addr_t address, unsigned long size, | 640 | extern void __iomem *ioremap_flags(phys_addr_t address, unsigned long size, |
608 | unsigned long flags); | 641 | unsigned long flags); |
609 | #define ioremap_nocache(addr, size) ioremap((addr), (size)) | 642 | #define ioremap_nocache(addr, size) ioremap((addr), (size)) |
643 | #define ioremap_prot(addr, size, prot) ioremap_flags((addr), (size), (prot)) | ||
644 | |||
610 | extern void iounmap(volatile void __iomem *addr); | 645 | extern void iounmap(volatile void __iomem *addr); |
611 | 646 | ||
612 | extern void __iomem *__ioremap(phys_addr_t, unsigned long size, | 647 | extern void __iomem *__ioremap(phys_addr_t, unsigned long size, |
@@ -740,10 +775,13 @@ static inline void * bus_to_virt(unsigned long address) | |||
740 | #define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set) | 775 | #define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set) |
741 | 776 | ||
742 | #define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set) | 777 | #define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set) |
743 | #define clrsetbits_le16(addr, clear, set) clrsetbits(le32, addr, clear, set) | 778 | #define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set) |
744 | 779 | ||
745 | #define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set) | 780 | #define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set) |
746 | 781 | ||
782 | void __iomem *devm_ioremap_prot(struct device *dev, resource_size_t offset, | ||
783 | size_t size, unsigned long flags); | ||
784 | |||
747 | #endif /* __KERNEL__ */ | 785 | #endif /* __KERNEL__ */ |
748 | 786 | ||
749 | #endif /* _ASM_POWERPC_IO_H */ | 787 | #endif /* _ASM_POWERPC_IO_H */ |