blob: 71c9fde2fd9072517af4062168d720c2c3153b57 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/sh/kernel/io.c
3 *
4 * Copyright (C) 2000 Stuart Menefy
Paul Mundtb66c1a32006-01-16 22:14:15 -08005 * Copyright (C) 2005 Paul Mundt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * Provide real functions which expand to whatever the header file defined.
8 * Also definitions of machine independent IO functions.
Paul Mundtb66c1a32006-01-16 22:14:15 -08009 *
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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/module.h>
Paul Mundtb66c1a32006-01-16 22:14:15 -080015#include <asm/machvec.h>
16#include <asm/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18/*
19 * Copy data from IO memory space to "real" memory space.
20 * This needs to be optimized.
21 */
Paul Mundtb66c1a32006-01-16 22:14:15 -080022void memcpy_fromio(void *to, volatile void __iomem *from, unsigned long count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023{
24 char *p = to;
25 while (count) {
26 count--;
Paul Mundtb66c1a32006-01-16 22:14:15 -080027 *p = readb((void __iomem *)from);
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 p++;
29 from++;
30 }
31}
Paul Mundtb66c1a32006-01-16 22:14:15 -080032EXPORT_SYMBOL(memcpy_fromio);
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034/*
35 * Copy data from "real" memory space to IO memory space.
36 * This needs to be optimized.
37 */
Paul Mundtb66c1a32006-01-16 22:14:15 -080038void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039{
40 const char *p = from;
41 while (count) {
42 count--;
Paul Mundtb66c1a32006-01-16 22:14:15 -080043 writeb(*p, (void __iomem *)to);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 p++;
45 to++;
46 }
47}
Paul Mundtb66c1a32006-01-16 22:14:15 -080048EXPORT_SYMBOL(memcpy_toio);
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050/*
51 * "memset" on IO memory space.
52 * This needs to be optimized.
53 */
Paul Mundtb66c1a32006-01-16 22:14:15 -080054void memset_io(volatile void __iomem *dst, int c, unsigned long count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055{
56 while (count) {
57 count--;
Paul Mundtb66c1a32006-01-16 22:14:15 -080058 writeb(c, (void __iomem *)dst);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 dst++;
60 }
61}
Linus Torvalds1da177e2005-04-16 15:20:36 -070062EXPORT_SYMBOL(memset_io);
63
Paul Mundtb66c1a32006-01-16 22:14:15 -080064void __iomem *ioport_map(unsigned long port, unsigned int nr)
65{
66 return sh_mv.mv_ioport_map(port, nr);
67}
68EXPORT_SYMBOL(ioport_map);
69
70void ioport_unmap(void __iomem *addr)
71{
72 sh_mv.mv_ioport_unmap(addr);
73}
74EXPORT_SYMBOL(ioport_unmap);