aboutsummaryrefslogtreecommitdiffstats
path: root/lib/iomap.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/iomap.c')
-rw-r--r--lib/iomap.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/iomap.c b/lib/iomap.c
index 55689c5d3379..d6ccdd85df53 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -50,6 +50,16 @@
50 } \ 50 } \
51} while (0) 51} while (0)
52 52
53#ifndef pio_read16be
54#define pio_read16be(port) swab16(inw(port))
55#define pio_read32be(port) swab32(inl(port))
56#endif
57
58#ifndef mmio_read16be
59#define mmio_read16be(addr) be16_to_cpu(__raw_readw(addr))
60#define mmio_read32be(addr) be32_to_cpu(__raw_readl(addr))
61#endif
62
53unsigned int fastcall ioread8(void __iomem *addr) 63unsigned int fastcall ioread8(void __iomem *addr)
54{ 64{
55 IO_COND(addr, return inb(port), return readb(addr)); 65 IO_COND(addr, return inb(port), return readb(addr));
@@ -60,7 +70,7 @@ unsigned int fastcall ioread16(void __iomem *addr)
60} 70}
61unsigned int fastcall ioread16be(void __iomem *addr) 71unsigned int fastcall ioread16be(void __iomem *addr)
62{ 72{
63 IO_COND(addr, return inw(port), return be16_to_cpu(__raw_readw(addr))); 73 IO_COND(addr, return pio_read16be(port), return mmio_read16be(addr));
64} 74}
65unsigned int fastcall ioread32(void __iomem *addr) 75unsigned int fastcall ioread32(void __iomem *addr)
66{ 76{
@@ -68,7 +78,7 @@ unsigned int fastcall ioread32(void __iomem *addr)
68} 78}
69unsigned int fastcall ioread32be(void __iomem *addr) 79unsigned int fastcall ioread32be(void __iomem *addr)
70{ 80{
71 IO_COND(addr, return inl(port), return be32_to_cpu(__raw_readl(addr))); 81 IO_COND(addr, return pio_read32be(port), return mmio_read32be(addr));
72} 82}
73EXPORT_SYMBOL(ioread8); 83EXPORT_SYMBOL(ioread8);
74EXPORT_SYMBOL(ioread16); 84EXPORT_SYMBOL(ioread16);
@@ -76,6 +86,16 @@ EXPORT_SYMBOL(ioread16be);
76EXPORT_SYMBOL(ioread32); 86EXPORT_SYMBOL(ioread32);
77EXPORT_SYMBOL(ioread32be); 87EXPORT_SYMBOL(ioread32be);
78 88
89#ifndef pio_write16be
90#define pio_write16be(val,port) outw(swab16(val),port)
91#define pio_write32be(val,port) outl(swab32(val),port)
92#endif
93
94#ifndef mmio_write16be
95#define mmio_write16be(val,port) __raw_writew(be16_to_cpu(val),port)
96#define mmio_write32be(val,port) __raw_writel(be32_to_cpu(val),port)
97#endif
98
79void fastcall iowrite8(u8 val, void __iomem *addr) 99void fastcall iowrite8(u8 val, void __iomem *addr)
80{ 100{
81 IO_COND(addr, outb(val,port), writeb(val, addr)); 101 IO_COND(addr, outb(val,port), writeb(val, addr));
@@ -86,7 +106,7 @@ void fastcall iowrite16(u16 val, void __iomem *addr)
86} 106}
87void fastcall iowrite16be(u16 val, void __iomem *addr) 107void fastcall iowrite16be(u16 val, void __iomem *addr)
88{ 108{
89 IO_COND(addr, outw(val,port), __raw_writew(cpu_to_be16(val), addr)); 109 IO_COND(addr, pio_write16be(val,port), mmio_write16be(val, addr));
90} 110}
91void fastcall iowrite32(u32 val, void __iomem *addr) 111void fastcall iowrite32(u32 val, void __iomem *addr)
92{ 112{
@@ -94,7 +114,7 @@ void fastcall iowrite32(u32 val, void __iomem *addr)
94} 114}
95void fastcall iowrite32be(u32 val, void __iomem *addr) 115void fastcall iowrite32be(u32 val, void __iomem *addr)
96{ 116{
97 IO_COND(addr, outl(val,port), __raw_writel(cpu_to_be32(val), addr)); 117 IO_COND(addr, pio_write32be(val,port), mmio_write32be(val, addr));
98} 118}
99EXPORT_SYMBOL(iowrite8); 119EXPORT_SYMBOL(iowrite8);
100EXPORT_SYMBOL(iowrite16); 120EXPORT_SYMBOL(iowrite16);
@@ -108,6 +128,7 @@ EXPORT_SYMBOL(iowrite32be);
108 * convert to CPU byte order. We write in "IO byte 128 * convert to CPU byte order. We write in "IO byte
109 * order" (we also don't have IO barriers). 129 * order" (we also don't have IO barriers).
110 */ 130 */
131#ifndef mmio_insb
111static inline void mmio_insb(void __iomem *addr, u8 *dst, int count) 132static inline void mmio_insb(void __iomem *addr, u8 *dst, int count)
112{ 133{
113 while (--count >= 0) { 134 while (--count >= 0) {
@@ -132,7 +153,9 @@ static inline void mmio_insl(void __iomem *addr, u32 *dst, int count)
132 dst++; 153 dst++;
133 } 154 }
134} 155}
156#endif
135 157
158#ifndef mmio_outsb
136static inline void mmio_outsb(void __iomem *addr, const u8 *src, int count) 159static inline void mmio_outsb(void __iomem *addr, const u8 *src, int count)
137{ 160{
138 while (--count >= 0) { 161 while (--count >= 0) {
@@ -154,6 +177,7 @@ static inline void mmio_outsl(void __iomem *addr, const u32 *src, int count)
154 src++; 177 src++;
155 } 178 }
156} 179}
180#endif
157 181
158void fastcall ioread8_rep(void __iomem *addr, void *dst, unsigned long count) 182void fastcall ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
159{ 183{