io.c 1.9 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>
M
Magnus Damm 已提交
15
#include <linux/pci.h>
16 17
#include <asm/machvec.h>
#include <asm/io.h>
L
Linus Torvalds 已提交
18 19 20 21 22

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

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

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

D
David McKay 已提交
65 66
#ifndef CONFIG_GENERIC_IOMAP

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

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

	return __ioport_map(port, nr);
76 77 78 79 80 81 82 83
}
EXPORT_SYMBOL(ioport_map);

void ioport_unmap(void __iomem *addr)
{
	sh_mv.mv_ioport_unmap(addr);
}
EXPORT_SYMBOL(ioport_unmap);
D
David McKay 已提交
84 85

#endif /* CONFIG_GENERIC_IOMAP */