2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* ppc64 "iomap" interface implementation.
|
|
|
|
*
|
|
|
|
* (C) Copyright 2004 Linus Torvalds
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Here comes the ppc64 implementation of the IOMAP
|
|
|
|
* interfaces.
|
|
|
|
*/
|
2007-01-26 10:52:27 +03:00
|
|
|
unsigned int ioread8(void __iomem *addr)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
return readb(addr);
|
|
|
|
}
|
2007-01-26 10:52:27 +03:00
|
|
|
unsigned int ioread16(void __iomem *addr)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
return readw(addr);
|
|
|
|
}
|
2007-01-26 10:52:27 +03:00
|
|
|
unsigned int ioread16be(void __iomem *addr)
|
2005-08-21 05:48:47 +04:00
|
|
|
{
|
|
|
|
return in_be16(addr);
|
|
|
|
}
|
2007-01-26 10:52:27 +03:00
|
|
|
unsigned int ioread32(void __iomem *addr)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
return readl(addr);
|
|
|
|
}
|
2007-01-26 10:52:27 +03:00
|
|
|
unsigned int ioread32be(void __iomem *addr)
|
2005-08-21 05:48:47 +04:00
|
|
|
{
|
|
|
|
return in_be32(addr);
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
EXPORT_SYMBOL(ioread8);
|
|
|
|
EXPORT_SYMBOL(ioread16);
|
2005-08-21 05:48:47 +04:00
|
|
|
EXPORT_SYMBOL(ioread16be);
|
2005-04-17 02:20:36 +04:00
|
|
|
EXPORT_SYMBOL(ioread32);
|
2005-08-21 05:48:47 +04:00
|
|
|
EXPORT_SYMBOL(ioread32be);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-01-26 10:52:27 +03:00
|
|
|
void iowrite8(u8 val, void __iomem *addr)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
writeb(val, addr);
|
|
|
|
}
|
2007-01-26 10:52:27 +03:00
|
|
|
void iowrite16(u16 val, void __iomem *addr)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
writew(val, addr);
|
|
|
|
}
|
2007-01-26 10:52:27 +03:00
|
|
|
void iowrite16be(u16 val, void __iomem *addr)
|
2005-08-21 05:48:47 +04:00
|
|
|
{
|
|
|
|
out_be16(addr, val);
|
|
|
|
}
|
2007-01-26 10:52:27 +03:00
|
|
|
void iowrite32(u32 val, void __iomem *addr)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
writel(val, addr);
|
|
|
|
}
|
2007-01-26 10:52:27 +03:00
|
|
|
void iowrite32be(u32 val, void __iomem *addr)
|
2005-08-21 05:48:47 +04:00
|
|
|
{
|
|
|
|
out_be32(addr, val);
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
EXPORT_SYMBOL(iowrite8);
|
|
|
|
EXPORT_SYMBOL(iowrite16);
|
2005-08-21 05:48:47 +04:00
|
|
|
EXPORT_SYMBOL(iowrite16be);
|
2005-04-17 02:20:36 +04:00
|
|
|
EXPORT_SYMBOL(iowrite32);
|
2005-08-21 05:48:47 +04:00
|
|
|
EXPORT_SYMBOL(iowrite32be);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* These are the "repeat read/write" functions. Note the
|
|
|
|
* non-CPU byte order. We do things in "IO byteorder"
|
|
|
|
* here.
|
|
|
|
*
|
|
|
|
* FIXME! We could make these do EEH handling if we really
|
|
|
|
* wanted. Not clear if we do.
|
|
|
|
*/
|
|
|
|
void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
|
|
|
|
{
|
2005-09-09 19:50:43 +04:00
|
|
|
_insb((u8 __iomem *) addr, dst, count);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
|
|
|
|
{
|
2005-09-09 19:50:43 +04:00
|
|
|
_insw_ns((u16 __iomem *) addr, dst, count);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
|
|
|
|
{
|
2005-09-09 19:50:43 +04:00
|
|
|
_insl_ns((u32 __iomem *) addr, dst, count);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ioread8_rep);
|
|
|
|
EXPORT_SYMBOL(ioread16_rep);
|
|
|
|
EXPORT_SYMBOL(ioread32_rep);
|
|
|
|
|
|
|
|
void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
|
|
|
|
{
|
2005-09-09 19:50:43 +04:00
|
|
|
_outsb((u8 __iomem *) addr, src, count);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
|
|
|
|
{
|
2005-09-09 19:50:43 +04:00
|
|
|
_outsw_ns((u16 __iomem *) addr, src, count);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
|
|
|
|
{
|
2005-09-09 19:50:43 +04:00
|
|
|
_outsl_ns((u32 __iomem *) addr, src, count);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(iowrite8_rep);
|
|
|
|
EXPORT_SYMBOL(iowrite16_rep);
|
|
|
|
EXPORT_SYMBOL(iowrite32_rep);
|
|
|
|
|
|
|
|
void __iomem *ioport_map(unsigned long port, unsigned int len)
|
|
|
|
{
|
2006-11-13 01:27:39 +03:00
|
|
|
return (void __iomem *) (port + _IO_BASE);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ioport_unmap(void __iomem *addr)
|
|
|
|
{
|
|
|
|
/* Nothing to do */
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ioport_map);
|
|
|
|
EXPORT_SYMBOL(ioport_unmap);
|
|
|
|
|
|
|
|
void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
|
|
|
|
{
|
|
|
|
unsigned long start = pci_resource_start(dev, bar);
|
|
|
|
unsigned long len = pci_resource_len(dev, bar);
|
|
|
|
unsigned long flags = pci_resource_flags(dev, bar);
|
|
|
|
|
|
|
|
if (!len)
|
|
|
|
return NULL;
|
|
|
|
if (max && len > max)
|
|
|
|
len = max;
|
|
|
|
if (flags & IORESOURCE_IO)
|
|
|
|
return ioport_map(start, len);
|
|
|
|
if (flags & IORESOURCE_MEM)
|
|
|
|
return ioremap(start, len);
|
|
|
|
/* What? */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
|
|
|
|
{
|
|
|
|
/* Nothing to do */
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(pci_iomap);
|
|
|
|
EXPORT_SYMBOL(pci_iounmap);
|