WIP FPC-III support
[linux/fpc-iii.git] / arch / sh / kernel / iomap.c
blob0a0dff4e66dea4bf62cb35a567b59652f5dc364d
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * arch/sh/kernel/iomap.c
5 * Copyright (C) 2000 Niibe Yutaka
6 * Copyright (C) 2005 - 2007 Paul Mundt
7 */
8 #include <linux/module.h>
9 #include <linux/io.h>
11 unsigned int ioread8(const void __iomem *addr)
13 return readb(addr);
15 EXPORT_SYMBOL(ioread8);
17 unsigned int ioread16(const void __iomem *addr)
19 return readw(addr);
21 EXPORT_SYMBOL(ioread16);
23 unsigned int ioread16be(const void __iomem *addr)
25 return be16_to_cpu(__raw_readw(addr));
27 EXPORT_SYMBOL(ioread16be);
29 unsigned int ioread32(const void __iomem *addr)
31 return readl(addr);
33 EXPORT_SYMBOL(ioread32);
35 unsigned int ioread32be(const void __iomem *addr)
37 return be32_to_cpu(__raw_readl(addr));
39 EXPORT_SYMBOL(ioread32be);
41 void iowrite8(u8 val, void __iomem *addr)
43 writeb(val, addr);
45 EXPORT_SYMBOL(iowrite8);
47 void iowrite16(u16 val, void __iomem *addr)
49 writew(val, addr);
51 EXPORT_SYMBOL(iowrite16);
53 void iowrite16be(u16 val, void __iomem *addr)
55 __raw_writew(cpu_to_be16(val), addr);
57 EXPORT_SYMBOL(iowrite16be);
59 void iowrite32(u32 val, void __iomem *addr)
61 writel(val, addr);
63 EXPORT_SYMBOL(iowrite32);
65 void iowrite32be(u32 val, void __iomem *addr)
67 __raw_writel(cpu_to_be32(val), addr);
69 EXPORT_SYMBOL(iowrite32be);
72 * These are the "repeat MMIO read/write" functions.
73 * Note the "__raw" accesses, since we don't want to
74 * convert to CPU byte order. We write in "IO byte
75 * order" (we also don't have IO barriers).
77 static inline void mmio_insb(const void __iomem *addr, u8 *dst, int count)
79 while (--count >= 0) {
80 u8 data = __raw_readb(addr);
81 *dst = data;
82 dst++;
86 static inline void mmio_insw(const void __iomem *addr, u16 *dst, int count)
88 while (--count >= 0) {
89 u16 data = __raw_readw(addr);
90 *dst = data;
91 dst++;
95 static inline void mmio_insl(const void __iomem *addr, u32 *dst, int count)
97 while (--count >= 0) {
98 u32 data = __raw_readl(addr);
99 *dst = data;
100 dst++;
104 static inline void mmio_outsb(void __iomem *addr, const u8 *src, int count)
106 while (--count >= 0) {
107 __raw_writeb(*src, addr);
108 src++;
112 static inline void mmio_outsw(void __iomem *addr, const u16 *src, int count)
114 while (--count >= 0) {
115 __raw_writew(*src, addr);
116 src++;
120 static inline void mmio_outsl(void __iomem *addr, const u32 *src, int count)
122 while (--count >= 0) {
123 __raw_writel(*src, addr);
124 src++;
128 void ioread8_rep(const void __iomem *addr, void *dst, unsigned long count)
130 mmio_insb(addr, dst, count);
132 EXPORT_SYMBOL(ioread8_rep);
134 void ioread16_rep(const void __iomem *addr, void *dst, unsigned long count)
136 mmio_insw(addr, dst, count);
138 EXPORT_SYMBOL(ioread16_rep);
140 void ioread32_rep(const void __iomem *addr, void *dst, unsigned long count)
142 mmio_insl(addr, dst, count);
144 EXPORT_SYMBOL(ioread32_rep);
146 void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
148 mmio_outsb(addr, src, count);
150 EXPORT_SYMBOL(iowrite8_rep);
152 void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
154 mmio_outsw(addr, src, count);
156 EXPORT_SYMBOL(iowrite16_rep);
158 void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
160 mmio_outsl(addr, src, count);
162 EXPORT_SYMBOL(iowrite32_rep);