xref: /openbmc/linux/arch/arm/kernel/io.c (revision 9ac8d3fb)
1 #include <linux/module.h>
2 #include <linux/types.h>
3 #include <linux/io.h>
4 
5 /*
6  * Copy data from IO memory space to "real" memory space.
7  * This needs to be optimized.
8  */
9 void _memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
10 {
11 	unsigned char *t = to;
12 	while (count) {
13 		count--;
14 		*t = readb(from);
15 		t++;
16 		from++;
17 	}
18 }
19 
20 /*
21  * Copy data from "real" memory space to IO memory space.
22  * This needs to be optimized.
23  */
24 void _memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
25 {
26 	const unsigned char *f = from;
27 	while (count) {
28 		count--;
29 		writeb(*f, to);
30 		f++;
31 		to++;
32 	}
33 }
34 
35 /*
36  * "memset" on IO memory space.
37  * This needs to be optimized.
38  */
39 void _memset_io(volatile void __iomem *dst, int c, size_t count)
40 {
41 	while (count) {
42 		count--;
43 		writeb(c, dst);
44 		dst++;
45 	}
46 }
47 
48 EXPORT_SYMBOL(_memcpy_fromio);
49 EXPORT_SYMBOL(_memcpy_toio);
50 EXPORT_SYMBOL(_memset_io);
51