2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* linux/arch/sh/kernel/io.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000 Stuart Menefy
|
2006-01-17 09:14:15 +03:00
|
|
|
* Copyright (C) 2005 Paul Mundt
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
|
|
|
* Provide real functions which expand to whatever the header file defined.
|
|
|
|
* Also definitions of machine independent IO functions.
|
2006-01-17 09:14:15 +03:00
|
|
|
*
|
|
|
|
* 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.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
2008-02-19 15:35:31 +03:00
|
|
|
#include <linux/pci.h>
|
2006-01-17 09:14:15 +03:00
|
|
|
#include <asm/machvec.h>
|
|
|
|
#include <asm/io.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy data from IO memory space to "real" memory space.
|
|
|
|
* This needs to be optimized.
|
|
|
|
*/
|
2008-10-04 00:25:52 +04:00
|
|
|
void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned long count)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2008-10-04 00:25:52 +04:00
|
|
|
unsigned char *p = to;
|
2005-04-17 02:20:36 +04:00
|
|
|
while (count) {
|
|
|
|
count--;
|
2008-10-04 00:25:52 +04:00
|
|
|
*p = readb(from);
|
2005-04-17 02:20:36 +04:00
|
|
|
p++;
|
|
|
|
from++;
|
|
|
|
}
|
|
|
|
}
|
2006-01-17 09:14:15 +03:00
|
|
|
EXPORT_SYMBOL(memcpy_fromio);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Copy data from "real" memory space to IO memory space.
|
|
|
|
* This needs to be optimized.
|
|
|
|
*/
|
2006-01-17 09:14:15 +03:00
|
|
|
void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2008-10-04 00:25:52 +04:00
|
|
|
const unsigned char *p = from;
|
2005-04-17 02:20:36 +04:00
|
|
|
while (count) {
|
|
|
|
count--;
|
2008-10-04 00:25:52 +04:00
|
|
|
writeb(*p, to);
|
2005-04-17 02:20:36 +04:00
|
|
|
p++;
|
|
|
|
to++;
|
|
|
|
}
|
|
|
|
}
|
2006-01-17 09:14:15 +03:00
|
|
|
EXPORT_SYMBOL(memcpy_toio);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* "memset" on IO memory space.
|
|
|
|
* This needs to be optimized.
|
|
|
|
*/
|
2006-01-17 09:14:15 +03:00
|
|
|
void memset_io(volatile void __iomem *dst, int c, unsigned long count)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
while (count) {
|
|
|
|
count--;
|
2008-10-04 00:25:52 +04:00
|
|
|
writeb(c, dst);
|
2005-04-17 02:20:36 +04:00
|
|
|
dst++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(memset_io);
|
|
|
|
|
2006-01-17 09:14:15 +03:00
|
|
|
void __iomem *ioport_map(unsigned long port, unsigned int nr)
|
|
|
|
{
|
2008-02-07 14:18:21 +03:00
|
|
|
void __iomem *ret;
|
|
|
|
|
|
|
|
ret = __ioport_map_trapped(port, nr);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2008-02-19 15:35:31 +03:00
|
|
|
ret = __get_pci_io_base(port, nr);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2008-02-07 14:18:21 +03:00
|
|
|
return __ioport_map(port, nr);
|
2006-01-17 09:14:15 +03:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ioport_map);
|
|
|
|
|
|
|
|
void ioport_unmap(void __iomem *addr)
|
|
|
|
{
|
|
|
|
sh_mv.mv_ioport_unmap(addr);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ioport_unmap);
|