2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* ppc64 "iomap" interface implementation.
|
|
|
|
*
|
|
|
|
* (C) Copyright 2004 Linus Torvalds
|
|
|
|
*/
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/mm.h>
|
2011-07-29 13:19:31 +07:00
|
|
|
#include <linux/export.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/io.h>
|
2007-07-26 11:07:13 +07:00
|
|
|
#include <asm/pci-bridge.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Here comes the ppc64 implementation of the IOMAP
|
|
|
|
* interfaces.
|
|
|
|
*/
|
2007-01-26 14:52:27 +07:00
|
|
|
unsigned int ioread8(void __iomem *addr)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
return readb(addr);
|
|
|
|
}
|
2007-01-26 14:52:27 +07:00
|
|
|
unsigned int ioread16(void __iomem *addr)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
return readw(addr);
|
|
|
|
}
|
2007-01-26 14:52:27 +07:00
|
|
|
unsigned int ioread16be(void __iomem *addr)
|
2005-08-21 08:48:47 +07:00
|
|
|
{
|
2014-06-23 07:56:22 +07:00
|
|
|
return readw_be(addr);
|
2005-08-21 08:48:47 +07:00
|
|
|
}
|
2007-01-26 14:52:27 +07:00
|
|
|
unsigned int ioread32(void __iomem *addr)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
return readl(addr);
|
|
|
|
}
|
2007-01-26 14:52:27 +07:00
|
|
|
unsigned int ioread32be(void __iomem *addr)
|
2005-08-21 08:48:47 +07:00
|
|
|
{
|
2014-06-23 07:56:22 +07:00
|
|
|
return readl_be(addr);
|
2005-08-21 08:48:47 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
EXPORT_SYMBOL(ioread8);
|
|
|
|
EXPORT_SYMBOL(ioread16);
|
2005-08-21 08:48:47 +07:00
|
|
|
EXPORT_SYMBOL(ioread16be);
|
2005-04-17 05:20:36 +07:00
|
|
|
EXPORT_SYMBOL(ioread32);
|
2005-08-21 08:48:47 +07:00
|
|
|
EXPORT_SYMBOL(ioread32be);
|
2016-05-19 22:11:10 +07:00
|
|
|
#ifdef __powerpc64__
|
|
|
|
u64 ioread64(void __iomem *addr)
|
|
|
|
{
|
|
|
|
return readq(addr);
|
|
|
|
}
|
|
|
|
u64 ioread64be(void __iomem *addr)
|
|
|
|
{
|
|
|
|
return readq_be(addr);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ioread64);
|
|
|
|
EXPORT_SYMBOL(ioread64be);
|
|
|
|
#endif /* __powerpc64__ */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-01-26 14:52:27 +07:00
|
|
|
void iowrite8(u8 val, void __iomem *addr)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
writeb(val, addr);
|
|
|
|
}
|
2007-01-26 14:52:27 +07:00
|
|
|
void iowrite16(u16 val, void __iomem *addr)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
writew(val, addr);
|
|
|
|
}
|
2007-01-26 14:52:27 +07:00
|
|
|
void iowrite16be(u16 val, void __iomem *addr)
|
2005-08-21 08:48:47 +07:00
|
|
|
{
|
2014-06-23 07:56:22 +07:00
|
|
|
writew_be(val, addr);
|
2005-08-21 08:48:47 +07:00
|
|
|
}
|
2007-01-26 14:52:27 +07:00
|
|
|
void iowrite32(u32 val, void __iomem *addr)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
writel(val, addr);
|
|
|
|
}
|
2007-01-26 14:52:27 +07:00
|
|
|
void iowrite32be(u32 val, void __iomem *addr)
|
2005-08-21 08:48:47 +07:00
|
|
|
{
|
2014-06-23 07:56:22 +07:00
|
|
|
writel_be(val, addr);
|
2005-08-21 08:48:47 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
EXPORT_SYMBOL(iowrite8);
|
|
|
|
EXPORT_SYMBOL(iowrite16);
|
2005-08-21 08:48:47 +07:00
|
|
|
EXPORT_SYMBOL(iowrite16be);
|
2005-04-17 05:20:36 +07:00
|
|
|
EXPORT_SYMBOL(iowrite32);
|
2005-08-21 08:48:47 +07:00
|
|
|
EXPORT_SYMBOL(iowrite32be);
|
2016-05-19 22:11:10 +07:00
|
|
|
#ifdef __powerpc64__
|
|
|
|
void iowrite64(u64 val, void __iomem *addr)
|
|
|
|
{
|
|
|
|
writeq(val, addr);
|
|
|
|
}
|
|
|
|
void iowrite64be(u64 val, void __iomem *addr)
|
|
|
|
{
|
|
|
|
writeq_be(val, addr);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(iowrite64);
|
|
|
|
EXPORT_SYMBOL(iowrite64be);
|
|
|
|
#endif /* __powerpc64__ */
|
2005-04-17 05:20:36 +07: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)
|
|
|
|
{
|
2014-06-23 07:56:22 +07:00
|
|
|
readsb(addr, dst, count);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
|
|
|
|
{
|
2014-06-23 07:56:22 +07:00
|
|
|
readsw(addr, dst, count);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
|
|
|
|
{
|
2014-06-23 07:56:22 +07:00
|
|
|
readsl(addr, dst, count);
|
2005-04-17 05:20:36 +07: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)
|
|
|
|
{
|
2014-06-23 07:56:22 +07:00
|
|
|
writesb(addr, src, count);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
|
|
|
|
{
|
2014-06-23 07:56:22 +07:00
|
|
|
writesw(addr, src, count);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
|
|
|
|
{
|
2014-06-23 07:56:22 +07:00
|
|
|
writesl(addr, src, count);
|
2005-04-17 05:20:36 +07: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 05:27:39 +07:00
|
|
|
return (void __iomem *) (port + _IO_BASE);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void ioport_unmap(void __iomem *addr)
|
|
|
|
{
|
|
|
|
/* Nothing to do */
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ioport_map);
|
|
|
|
EXPORT_SYMBOL(ioport_unmap);
|
|
|
|
|
2011-08-05 13:01:20 +07:00
|
|
|
#ifdef CONFIG_PCI
|
2005-04-17 05:20:36 +07:00
|
|
|
void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
|
|
|
|
{
|
2007-07-26 11:07:13 +07:00
|
|
|
if (isa_vaddr_is_ioport(addr))
|
|
|
|
return;
|
|
|
|
if (pcibios_vaddr_is_ioport(addr))
|
|
|
|
return;
|
|
|
|
iounmap(addr);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2007-07-26 11:07:13 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
EXPORT_SYMBOL(pci_iounmap);
|
2011-08-10 22:15:44 +07:00
|
|
|
#endif /* CONFIG_PCI */
|