2 * arch/sh/kernel/iomap.c
4 * Copyright (C) 2000 Niibe Yutaka
5 * Copyright (C) 2005 - 2007 Paul Mundt
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
11 #include <linux/module.h>
14 unsigned int ioread8(void __iomem
*addr
)
18 EXPORT_SYMBOL(ioread8
);
20 unsigned int ioread16(void __iomem
*addr
)
24 EXPORT_SYMBOL(ioread16
);
26 unsigned int ioread16be(void __iomem
*addr
)
28 return be16_to_cpu(__raw_readw(addr
));
30 EXPORT_SYMBOL(ioread16be
);
32 unsigned int ioread32(void __iomem
*addr
)
36 EXPORT_SYMBOL(ioread32
);
38 unsigned int ioread32be(void __iomem
*addr
)
40 return be32_to_cpu(__raw_readl(addr
));
42 EXPORT_SYMBOL(ioread32be
);
44 void iowrite8(u8 val
, void __iomem
*addr
)
48 EXPORT_SYMBOL(iowrite8
);
50 void iowrite16(u16 val
, void __iomem
*addr
)
54 EXPORT_SYMBOL(iowrite16
);
56 void iowrite16be(u16 val
, void __iomem
*addr
)
58 __raw_writew(cpu_to_be16(val
), addr
);
60 EXPORT_SYMBOL(iowrite16be
);
62 void iowrite32(u32 val
, void __iomem
*addr
)
66 EXPORT_SYMBOL(iowrite32
);
68 void iowrite32be(u32 val
, void __iomem
*addr
)
70 __raw_writel(cpu_to_be32(val
), addr
);
72 EXPORT_SYMBOL(iowrite32be
);
75 * These are the "repeat MMIO read/write" functions.
76 * Note the "__raw" accesses, since we don't want to
77 * convert to CPU byte order. We write in "IO byte
78 * order" (we also don't have IO barriers).
80 static inline void mmio_insb(void __iomem
*addr
, u8
*dst
, int count
)
82 while (--count
>= 0) {
83 u8 data
= __raw_readb(addr
);
89 static inline void mmio_insw(void __iomem
*addr
, u16
*dst
, int count
)
91 while (--count
>= 0) {
92 u16 data
= __raw_readw(addr
);
98 static inline void mmio_insl(void __iomem
*addr
, u32
*dst
, int count
)
100 while (--count
>= 0) {
101 u32 data
= __raw_readl(addr
);
107 static inline void mmio_outsb(void __iomem
*addr
, const u8
*src
, int count
)
109 while (--count
>= 0) {
110 __raw_writeb(*src
, addr
);
115 static inline void mmio_outsw(void __iomem
*addr
, const u16
*src
, int count
)
117 while (--count
>= 0) {
118 __raw_writew(*src
, addr
);
123 static inline void mmio_outsl(void __iomem
*addr
, const u32
*src
, int count
)
125 while (--count
>= 0) {
126 __raw_writel(*src
, addr
);
131 void ioread8_rep(void __iomem
*addr
, void *dst
, unsigned long count
)
133 mmio_insb(addr
, dst
, count
);
135 EXPORT_SYMBOL(ioread8_rep
);
137 void ioread16_rep(void __iomem
*addr
, void *dst
, unsigned long count
)
139 mmio_insw(addr
, dst
, count
);
141 EXPORT_SYMBOL(ioread16_rep
);
143 void ioread32_rep(void __iomem
*addr
, void *dst
, unsigned long count
)
145 mmio_insl(addr
, dst
, count
);
147 EXPORT_SYMBOL(ioread32_rep
);
149 void iowrite8_rep(void __iomem
*addr
, const void *src
, unsigned long count
)
151 mmio_outsb(addr
, src
, count
);
153 EXPORT_SYMBOL(iowrite8_rep
);
155 void iowrite16_rep(void __iomem
*addr
, const void *src
, unsigned long count
)
157 mmio_outsw(addr
, src
, count
);
159 EXPORT_SYMBOL(iowrite16_rep
);
161 void iowrite32_rep(void __iomem
*addr
, const void *src
, unsigned long count
)
163 mmio_outsl(addr
, src
, count
);
165 EXPORT_SYMBOL(iowrite32_rep
);