linux/arch/powerpc/kernel/iomap.c
<<
>>
Prefs
   1/*
   2 * ppc64 "iomap" interface implementation.
   3 *
   4 * (C) Copyright 2004 Linus Torvalds
   5 */
   6#include <linux/init.h>
   7#include <linux/pci.h>
   8#include <linux/mm.h>
   9#include <linux/export.h>
  10#include <asm/io.h>
  11#include <asm/pci-bridge.h>
  12
  13/*
  14 * Here comes the ppc64 implementation of the IOMAP 
  15 * interfaces.
  16 */
  17unsigned int ioread8(void __iomem *addr)
  18{
  19        return readb(addr);
  20}
  21unsigned int ioread16(void __iomem *addr)
  22{
  23        return readw(addr);
  24}
  25unsigned int ioread16be(void __iomem *addr)
  26{
  27        return in_be16(addr);
  28}
  29unsigned int ioread32(void __iomem *addr)
  30{
  31        return readl(addr);
  32}
  33unsigned int ioread32be(void __iomem *addr)
  34{
  35        return in_be32(addr);
  36}
  37EXPORT_SYMBOL(ioread8);
  38EXPORT_SYMBOL(ioread16);
  39EXPORT_SYMBOL(ioread16be);
  40EXPORT_SYMBOL(ioread32);
  41EXPORT_SYMBOL(ioread32be);
  42
  43void iowrite8(u8 val, void __iomem *addr)
  44{
  45        writeb(val, addr);
  46}
  47void iowrite16(u16 val, void __iomem *addr)
  48{
  49        writew(val, addr);
  50}
  51void iowrite16be(u16 val, void __iomem *addr)
  52{
  53        out_be16(addr, val);
  54}
  55void iowrite32(u32 val, void __iomem *addr)
  56{
  57        writel(val, addr);
  58}
  59void iowrite32be(u32 val, void __iomem *addr)
  60{
  61        out_be32(addr, val);
  62}
  63EXPORT_SYMBOL(iowrite8);
  64EXPORT_SYMBOL(iowrite16);
  65EXPORT_SYMBOL(iowrite16be);
  66EXPORT_SYMBOL(iowrite32);
  67EXPORT_SYMBOL(iowrite32be);
  68
  69/*
  70 * These are the "repeat read/write" functions. Note the
  71 * non-CPU byte order. We do things in "IO byteorder"
  72 * here.
  73 *
  74 * FIXME! We could make these do EEH handling if we really
  75 * wanted. Not clear if we do.
  76 */
  77void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
  78{
  79        _insb((u8 __iomem *) addr, dst, count);
  80}
  81void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
  82{
  83        _insw_ns((u16 __iomem *) addr, dst, count);
  84}
  85void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
  86{
  87        _insl_ns((u32 __iomem *) addr, dst, count);
  88}
  89EXPORT_SYMBOL(ioread8_rep);
  90EXPORT_SYMBOL(ioread16_rep);
  91EXPORT_SYMBOL(ioread32_rep);
  92
  93void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
  94{
  95        _outsb((u8 __iomem *) addr, src, count);
  96}
  97void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
  98{
  99        _outsw_ns((u16 __iomem *) addr, src, count);
 100}
 101void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
 102{
 103        _outsl_ns((u32 __iomem *) addr, src, count);
 104}
 105EXPORT_SYMBOL(iowrite8_rep);
 106EXPORT_SYMBOL(iowrite16_rep);
 107EXPORT_SYMBOL(iowrite32_rep);
 108
 109void __iomem *ioport_map(unsigned long port, unsigned int len)
 110{
 111        return (void __iomem *) (port + _IO_BASE);
 112}
 113
 114void ioport_unmap(void __iomem *addr)
 115{
 116        /* Nothing to do */
 117}
 118EXPORT_SYMBOL(ioport_map);
 119EXPORT_SYMBOL(ioport_unmap);
 120
 121#ifdef CONFIG_PCI
 122void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
 123{
 124        if (isa_vaddr_is_ioport(addr))
 125                return;
 126        if (pcibios_vaddr_is_ioport(addr))
 127                return;
 128        iounmap(addr);
 129}
 130
 131EXPORT_SYMBOL(pci_iounmap);
 132#endif /* CONFIG_PCI */
 133