This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / arch / ppc64 / kernel / iomap.c
1 #include <linux/init.h>
2 #include <linux/pci.h>
3 #include <linux/mm.h>
4 #include <asm/io.h>
5
6 /*
7  * Here comes the ppc64 implementation of the IOMAP 
8  * interfaces.
9  */
10 unsigned int fastcall ioread8(void __iomem *addr)
11 {
12         return readb(addr);
13 }
14 unsigned int fastcall ioread16(void __iomem *addr)
15 {
16         return readw(addr);
17 }
18 unsigned int fastcall ioread32(void __iomem *addr)
19 {
20         return readl(addr);
21 }
22 EXPORT_SYMBOL(ioread8);
23 EXPORT_SYMBOL(ioread16);
24 EXPORT_SYMBOL(ioread32);
25
26 void fastcall iowrite8(u8 val, void __iomem *addr)
27 {
28         writeb(val, addr);
29 }
30 void fastcall iowrite16(u16 val, void __iomem *addr)
31 {
32         writew(val, addr);
33 }
34 void fastcall iowrite32(u32 val, void __iomem *addr)
35 {
36         writel(val, addr);
37 }
38 EXPORT_SYMBOL(iowrite8);
39 EXPORT_SYMBOL(iowrite16);
40 EXPORT_SYMBOL(iowrite32);
41
42 /*
43  * These are the "repeat read/write" functions. Note the
44  * non-CPU byte order. We do things in "IO byteorder"
45  * here.
46  *
47  * FIXME! We could make these do EEH handling if we really
48  * wanted. Not clear if we do.
49  */
50 void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
51 {
52         _insb((u8 __force *) addr, dst, count);
53 }
54 void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
55 {
56         _insw_ns((u16 __force *) addr, dst, count);
57 }
58 void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
59 {
60         _insl_ns((u32 __force *) addr, dst, count);
61 }
62 EXPORT_SYMBOL(ioread8_rep);
63 EXPORT_SYMBOL(ioread16_rep);
64 EXPORT_SYMBOL(ioread32_rep);
65
66 void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
67 {
68         _outsb((u8 __force *) addr, src, count);
69 }
70 void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
71 {
72         _outsw_ns((u16 __force *) addr, src, count);
73 }
74 void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
75 {
76         _outsl_ns((u32 __force *) addr, src, count);
77 }
78 EXPORT_SYMBOL(iowrite8_rep);
79 EXPORT_SYMBOL(iowrite16_rep);
80 EXPORT_SYMBOL(iowrite32_rep);
81
82 void __iomem *ioport_map(unsigned long port, unsigned int len)
83 {
84         if (!_IO_IS_VALID(port))
85                 return NULL;
86         return (void __iomem *) (port+pci_io_base);
87 }
88
89 void ioport_unmap(void __iomem *addr)
90 {
91         /* Nothing to do */
92 }
93 EXPORT_SYMBOL(ioport_map);
94 EXPORT_SYMBOL(ioport_unmap);
95
96 void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
97 {
98         unsigned long start = pci_resource_start(dev, bar);
99         unsigned long len = pci_resource_len(dev, bar);
100         unsigned long flags = pci_resource_flags(dev, bar);
101
102         if (!len)
103                 return NULL;
104         if (max && len > max)
105                 len = max;
106         if (flags & IORESOURCE_IO)
107                 return ioport_map(start, len);
108         if (flags & IORESOURCE_MEM)
109                 return (void __iomem *) start;
110         /* What? */
111         return NULL;
112 }
113
114 void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
115 {
116         /* Nothing to do */
117 }
118 EXPORT_SYMBOL(pci_iomap);
119 EXPORT_SYMBOL(pci_iounmap);