]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] ppc32: Add "native" iomap interfaces
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Sat, 16 Oct 2004 08:03:01 +0000 (01:03 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 16 Oct 2004 08:03:01 +0000 (01:03 -0700)
This patch adds proper ppc32 "iomap" interfaces.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/ppc/Kconfig
arch/ppc/kernel/pci.c
arch/ppc/mm/pgtable.c
include/asm-ppc/io.h

index 81d55092fde022b6cc67bf970bde0a92f73e71c3..46139ac9756386a5376cf2d9d1c721f3ac7a4d25 100644 (file)
@@ -35,10 +35,6 @@ config GENERIC_NVRAM
        bool
        default y
 
-config GENERIC_IOMAP
-       bool
-       default y
-
 source "init/Kconfig"
 
 menu "Processor"
index d51e3de8de125c5f9d3a47643036986a1a451bc8..08cdddee7ac199cf34ec5cfda87bae0df9b18fa8 100644 (file)
@@ -1709,6 +1709,32 @@ pci_init_resource(struct resource *res, unsigned long start, unsigned long end,
        res->child = NULL;
 }
 
+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 (void __iomem *) start;
+       /* What? */
+       return NULL;
+}
+
+void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
+{
+       /* Nothing to do */
+}
+EXPORT_SYMBOL(pci_iomap);
+EXPORT_SYMBOL(pci_iounmap);
+
+
 /*
  * Null PCI config access functions, for the case when we can't
  * find a hose.
index c16d4cce4677a3fe866381d8e48e3bca1c747652..30482852c9c25e82190dd534518d7be36eb237f8 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
@@ -271,6 +272,18 @@ void iounmap(void *addr)
                vunmap((void *) (PAGE_MASK & (unsigned long)addr));
 }
 
+void __iomem *ioport_map(unsigned long port, unsigned int len)
+{
+       return (void __iomem *) (port + _IO_BASE);
+}
+
+void ioport_unmap(void __iomem *addr)
+{
+       /* Nothing to do */
+}
+EXPORT_SYMBOL(ioport_map);
+EXPORT_SYMBOL(ioport_unmap);
+
 int
 map_page(unsigned long va, phys_addr_t pa, int flags)
 {
index 748856f5955ab7c6b7a8351710d756f9234b7bfb..5abdd426b04f4aa10dd951cb8351996da10fee3f 100644 (file)
@@ -398,6 +398,79 @@ static inline int isa_check_signature(unsigned long io_addr,
        return 0;
 }
 
+/*
+ * Here comes the ppc implementation of the IOMAP 
+ * interfaces.
+ */
+static inline unsigned int ioread8(void __iomem *addr)
+{
+       return readb(addr);
+}
+
+static inline unsigned int ioread16(void __iomem *addr)
+{
+       return readw(addr);
+}
+
+static inline unsigned int ioread32(void __iomem *addr)
+{
+       return readl(addr);
+}
+
+static inline void iowrite8(u8 val, void __iomem *addr)
+{
+       writeb(val, addr);
+}
+
+static inline void iowrite16(u16 val, void __iomem *addr)
+{
+       writew(val, addr);
+}
+
+static inline void iowrite32(u32 val, void __iomem *addr)
+{
+       writel(val, addr);
+}
+
+static inline void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
+{
+       _insb((u8 __force *) addr, dst, count);
+}
+
+static inline void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
+{
+       _insw_ns((u16 __force *) addr, dst, count);
+}
+
+static inline void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
+{
+       _insl_ns((u32 __force *) addr, dst, count);
+}
+
+static inline void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
+{
+       _outsb((u8 __force *) addr, src, count);
+}
+
+static inline void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
+{
+       _outsw_ns((u16 __force *) addr, src, count);
+}
+
+static inline void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
+{
+       _outsl_ns((u32 __force *) addr, src, count);
+}
+
+/* Create a virtual mapping cookie for an IO port range */
+extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
+extern void ioport_unmap(void __iomem *);
+
+/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
+struct pci_dev;
+extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
+extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
+
 #endif /* _PPC_IO_H */
 
 #ifdef CONFIG_8260_PCI9