]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - arch/sh/kernel/io.c
d0ca9684b781ec79b9cce855d135ea624cd450fb
[mirror_ubuntu-zesty-kernel.git] / arch / sh / kernel / io.c
1 /*
2 * linux/arch/sh/kernel/io.c
3 *
4 * Copyright (C) 2000 Stuart Menefy
5 * Copyright (C) 2005 Paul Mundt
6 *
7 * Provide real functions which expand to whatever the header file defined.
8 * Also definitions of machine independent IO functions.
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
13 */
14 #include <linux/module.h>
15 #include <linux/pci.h>
16 #include <asm/machvec.h>
17 #include <asm/io.h>
18
19 /*
20 * Copy data from IO memory space to "real" memory space.
21 * This needs to be optimized.
22 */
23 void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned long count)
24 {
25 unsigned char *p = to;
26 while (count) {
27 count--;
28 *p = readb(from);
29 p++;
30 from++;
31 }
32 }
33 EXPORT_SYMBOL(memcpy_fromio);
34
35 /*
36 * Copy data from "real" memory space to IO memory space.
37 * This needs to be optimized.
38 */
39 void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count)
40 {
41 const unsigned char *p = from;
42 while (count) {
43 count--;
44 writeb(*p, to);
45 p++;
46 to++;
47 }
48 }
49 EXPORT_SYMBOL(memcpy_toio);
50
51 /*
52 * "memset" on IO memory space.
53 * This needs to be optimized.
54 */
55 void memset_io(volatile void __iomem *dst, int c, unsigned long count)
56 {
57 while (count) {
58 count--;
59 writeb(c, dst);
60 dst++;
61 }
62 }
63 EXPORT_SYMBOL(memset_io);
64
65 #ifndef CONFIG_GENERIC_IOMAP
66
67 void __iomem *ioport_map(unsigned long port, unsigned int nr)
68 {
69 void __iomem *ret;
70
71 ret = __ioport_map_trapped(port, nr);
72 if (ret)
73 return ret;
74
75 return __ioport_map(port, nr);
76 }
77 EXPORT_SYMBOL(ioport_map);
78
79 void ioport_unmap(void __iomem *addr)
80 {
81 sh_mv.mv_ioport_unmap(addr);
82 }
83 EXPORT_SYMBOL(ioport_unmap);
84
85 #endif /* CONFIG_GENERIC_IOMAP */