io.c 1.8 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4
/*
 * linux/arch/sh/kernel/io.c
 *
 * Copyright (C) 2000  Stuart Menefy
5
 * Copyright (C) 2005  Paul Mundt
L
Linus Torvalds 已提交
6 7 8
 *
 * Provide real functions which expand to whatever the header file defined.
 * Also definitions of machine independent IO functions.
9 10 11 12
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
L
Linus Torvalds 已提交
13 14
 */
#include <linux/module.h>
15 16
#include <asm/machvec.h>
#include <asm/io.h>
L
Linus Torvalds 已提交
17 18 19 20 21

/*
 * Copy data from IO memory space to "real" memory space.
 * This needs to be optimized.
 */
P
Paul Mundt 已提交
22
void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned long count)
L
Linus Torvalds 已提交
23
{
P
Paul Mundt 已提交
24
	unsigned char *p = to;
L
Linus Torvalds 已提交
25 26
        while (count) {
                count--;
P
Paul Mundt 已提交
27
                *p = readb(from);
L
Linus Torvalds 已提交
28 29 30 31
                p++;
                from++;
        }
}
32 33
EXPORT_SYMBOL(memcpy_fromio);

L
Linus Torvalds 已提交
34 35 36 37
/*
 * Copy data from "real" memory space to IO memory space.
 * This needs to be optimized.
 */
38
void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count)
L
Linus Torvalds 已提交
39
{
P
Paul Mundt 已提交
40
	const unsigned char *p = from;
L
Linus Torvalds 已提交
41 42
        while (count) {
                count--;
P
Paul Mundt 已提交
43
                writeb(*p, to);
L
Linus Torvalds 已提交
44 45 46 47
                p++;
                to++;
        }
}
48 49
EXPORT_SYMBOL(memcpy_toio);

L
Linus Torvalds 已提交
50 51 52 53
/*
 * "memset" on IO memory space.
 * This needs to be optimized.
 */
54
void memset_io(volatile void __iomem *dst, int c, unsigned long count)
L
Linus Torvalds 已提交
55 56 57
{
        while (count) {
                count--;
P
Paul Mundt 已提交
58
                writeb(c, dst);
L
Linus Torvalds 已提交
59 60 61 62 63
                dst++;
        }
}
EXPORT_SYMBOL(memset_io);

64 65
void __iomem *ioport_map(unsigned long port, unsigned int nr)
{
M
Magnus Damm 已提交
66 67 68 69 70 71 72
	void __iomem *ret;

	ret = __ioport_map_trapped(port, nr);
	if (ret)
		return ret;

	return __ioport_map(port, nr);
73 74 75 76 77 78 79 80
}
EXPORT_SYMBOL(ioport_map);

void ioport_unmap(void __iomem *addr)
{
	sh_mv.mv_ioport_unmap(addr);
}
EXPORT_SYMBOL(ioport_unmap);