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