Merge git://git.infradead.org/mtd-2.6
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / sh / kernel / io.c
CommitLineData
1da177e4
LT
1/*
2 * linux/arch/sh/kernel/io.c
3 *
4 * Copyright (C) 2000 Stuart Menefy
b66c1a39 5 * Copyright (C) 2005 Paul Mundt
1da177e4
LT
6 *
7 * Provide real functions which expand to whatever the header file defined.
8 * Also definitions of machine independent IO functions.
b66c1a39
PM
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.
1da177e4 13 */
1da177e4 14#include <linux/module.h>
b66c1a39
PM
15#include <asm/machvec.h>
16#include <asm/io.h>
1da177e4
LT
17
18/*
19 * Copy data from IO memory space to "real" memory space.
20 * This needs to be optimized.
21 */
14866543 22void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned long count)
1da177e4 23{
14866543 24 unsigned char *p = to;
1da177e4
LT
25 while (count) {
26 count--;
14866543 27 *p = readb(from);
1da177e4
LT
28 p++;
29 from++;
30 }
31}
b66c1a39
PM
32EXPORT_SYMBOL(memcpy_fromio);
33
1da177e4
LT
34/*
35 * Copy data from "real" memory space to IO memory space.
36 * This needs to be optimized.
37 */
b66c1a39 38void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count)
1da177e4 39{
14866543 40 const unsigned char *p = from;
1da177e4
LT
41 while (count) {
42 count--;
14866543 43 writeb(*p, to);
1da177e4
LT
44 p++;
45 to++;
46 }
47}
b66c1a39
PM
48EXPORT_SYMBOL(memcpy_toio);
49
1da177e4
LT
50/*
51 * "memset" on IO memory space.
52 * This needs to be optimized.
53 */
b66c1a39 54void memset_io(volatile void __iomem *dst, int c, unsigned long count)
1da177e4
LT
55{
56 while (count) {
57 count--;
14866543 58 writeb(c, dst);
1da177e4
LT
59 dst++;
60 }
61}
1da177e4
LT
62EXPORT_SYMBOL(memset_io);
63
b66c1a39
PM
64void __iomem *ioport_map(unsigned long port, unsigned int nr)
65{
e7cc9a73
MD
66 void __iomem *ret;
67
68 ret = __ioport_map_trapped(port, nr);
69 if (ret)
70 return ret;
71
72 return __ioport_map(port, nr);
b66c1a39
PM
73}
74EXPORT_SYMBOL(ioport_map);
75
76void ioport_unmap(void __iomem *addr)
77{
78 sh_mv.mv_ioport_unmap(addr);
79}
80EXPORT_SYMBOL(ioport_unmap);