Add linux-next specific files for 20110831
[linux-2.6/next.git] / arch / powerpc / kernel / iomap.c
blob262791807397375612e29860ae64e5d86ee6cc6a
1 /*
2 * ppc64 "iomap" interface implementation.
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>
14 * Here comes the ppc64 implementation of the IOMAP
15 * interfaces.
17 unsigned int ioread8(void __iomem *addr)
19 return readb(addr);
21 unsigned int ioread16(void __iomem *addr)
23 return readw(addr);
25 unsigned int ioread16be(void __iomem *addr)
27 return in_be16(addr);
29 unsigned int ioread32(void __iomem *addr)
31 return readl(addr);
33 unsigned int ioread32be(void __iomem *addr)
35 return in_be32(addr);
37 EXPORT_SYMBOL(ioread8);
38 EXPORT_SYMBOL(ioread16);
39 EXPORT_SYMBOL(ioread16be);
40 EXPORT_SYMBOL(ioread32);
41 EXPORT_SYMBOL(ioread32be);
43 void iowrite8(u8 val, void __iomem *addr)
45 writeb(val, addr);
47 void iowrite16(u16 val, void __iomem *addr)
49 writew(val, addr);
51 void iowrite16be(u16 val, void __iomem *addr)
53 out_be16(addr, val);
55 void iowrite32(u32 val, void __iomem *addr)
57 writel(val, addr);
59 void iowrite32be(u32 val, void __iomem *addr)
61 out_be32(addr, val);
63 EXPORT_SYMBOL(iowrite8);
64 EXPORT_SYMBOL(iowrite16);
65 EXPORT_SYMBOL(iowrite16be);
66 EXPORT_SYMBOL(iowrite32);
67 EXPORT_SYMBOL(iowrite32be);
70 * These are the "repeat read/write" functions. Note the
71 * non-CPU byte order. We do things in "IO byteorder"
72 * here.
74 * FIXME! We could make these do EEH handling if we really
75 * wanted. Not clear if we do.
77 void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
79 _insb((u8 __iomem *) addr, dst, count);
81 void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
83 _insw_ns((u16 __iomem *) addr, dst, count);
85 void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
87 _insl_ns((u32 __iomem *) addr, dst, count);
89 EXPORT_SYMBOL(ioread8_rep);
90 EXPORT_SYMBOL(ioread16_rep);
91 EXPORT_SYMBOL(ioread32_rep);
93 void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
95 _outsb((u8 __iomem *) addr, src, count);
97 void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
99 _outsw_ns((u16 __iomem *) addr, src, count);
101 void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
103 _outsl_ns((u32 __iomem *) addr, src, count);
105 EXPORT_SYMBOL(iowrite8_rep);
106 EXPORT_SYMBOL(iowrite16_rep);
107 EXPORT_SYMBOL(iowrite32_rep);
109 void __iomem *ioport_map(unsigned long port, unsigned int len)
111 return (void __iomem *) (port + _IO_BASE);
114 void ioport_unmap(void __iomem *addr)
116 /* Nothing to do */
118 EXPORT_SYMBOL(ioport_map);
119 EXPORT_SYMBOL(ioport_unmap);
121 #ifdef CONFIG_PCI
122 void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
124 resource_size_t start = pci_resource_start(dev, bar);
125 resource_size_t len = pci_resource_len(dev, bar);
126 unsigned long flags = pci_resource_flags(dev, bar);
128 if (!len)
129 return NULL;
130 if (max && len > max)
131 len = max;
132 if (flags & IORESOURCE_IO)
133 return ioport_map(start, len);
134 if (flags & IORESOURCE_MEM)
135 return ioremap(start, len);
136 /* What? */
137 return NULL;
140 void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
142 if (isa_vaddr_is_ioport(addr))
143 return;
144 if (pcibios_vaddr_is_ioport(addr))
145 return;
146 iounmap(addr);
149 EXPORT_SYMBOL(pci_iomap);
150 EXPORT_SYMBOL(pci_iounmap);
151 #endif /* CONFIG_PCI */