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