Linux 4.13.16
[linux/fpc-iii.git] / arch / powerpc / kernel / iomap.c
bloba1854d1ded8b3d72041a1ddfff2dc97c05bb5cec
1 /*
2 * ppc64 "iomap" interface implementation.
4 * (C) Copyright 2004 Linus Torvalds
5 */
6 #include <linux/pci.h>
7 #include <linux/mm.h>
8 #include <linux/export.h>
9 #include <asm/io.h>
10 #include <asm/pci-bridge.h>
11 #include <asm/isa-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 readw_be(addr);
29 unsigned int ioread32(void __iomem *addr)
31 return readl(addr);
33 unsigned int ioread32be(void __iomem *addr)
35 return readl_be(addr);
37 EXPORT_SYMBOL(ioread8);
38 EXPORT_SYMBOL(ioread16);
39 EXPORT_SYMBOL(ioread16be);
40 EXPORT_SYMBOL(ioread32);
41 EXPORT_SYMBOL(ioread32be);
42 #ifdef __powerpc64__
43 u64 ioread64(void __iomem *addr)
45 return readq(addr);
47 u64 ioread64be(void __iomem *addr)
49 return readq_be(addr);
51 EXPORT_SYMBOL(ioread64);
52 EXPORT_SYMBOL(ioread64be);
53 #endif /* __powerpc64__ */
55 void iowrite8(u8 val, void __iomem *addr)
57 writeb(val, addr);
59 void iowrite16(u16 val, void __iomem *addr)
61 writew(val, addr);
63 void iowrite16be(u16 val, void __iomem *addr)
65 writew_be(val, addr);
67 void iowrite32(u32 val, void __iomem *addr)
69 writel(val, addr);
71 void iowrite32be(u32 val, void __iomem *addr)
73 writel_be(val, addr);
75 EXPORT_SYMBOL(iowrite8);
76 EXPORT_SYMBOL(iowrite16);
77 EXPORT_SYMBOL(iowrite16be);
78 EXPORT_SYMBOL(iowrite32);
79 EXPORT_SYMBOL(iowrite32be);
80 #ifdef __powerpc64__
81 void iowrite64(u64 val, void __iomem *addr)
83 writeq(val, addr);
85 void iowrite64be(u64 val, void __iomem *addr)
87 writeq_be(val, addr);
89 EXPORT_SYMBOL(iowrite64);
90 EXPORT_SYMBOL(iowrite64be);
91 #endif /* __powerpc64__ */
94 * These are the "repeat read/write" functions. Note the
95 * non-CPU byte order. We do things in "IO byteorder"
96 * here.
98 * FIXME! We could make these do EEH handling if we really
99 * wanted. Not clear if we do.
101 void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
103 readsb(addr, dst, count);
105 void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
107 readsw(addr, dst, count);
109 void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
111 readsl(addr, dst, count);
113 EXPORT_SYMBOL(ioread8_rep);
114 EXPORT_SYMBOL(ioread16_rep);
115 EXPORT_SYMBOL(ioread32_rep);
117 void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
119 writesb(addr, src, count);
121 void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
123 writesw(addr, src, count);
125 void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
127 writesl(addr, src, count);
129 EXPORT_SYMBOL(iowrite8_rep);
130 EXPORT_SYMBOL(iowrite16_rep);
131 EXPORT_SYMBOL(iowrite32_rep);
133 void __iomem *ioport_map(unsigned long port, unsigned int len)
135 return (void __iomem *) (port + _IO_BASE);
138 void ioport_unmap(void __iomem *addr)
140 /* Nothing to do */
142 EXPORT_SYMBOL(ioport_map);
143 EXPORT_SYMBOL(ioport_unmap);
145 #ifdef CONFIG_PCI
146 void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
148 if (isa_vaddr_is_ioport(addr))
149 return;
150 if (pcibios_vaddr_is_ioport(addr))
151 return;
152 iounmap(addr);
155 EXPORT_SYMBOL(pci_iounmap);
156 #endif /* CONFIG_PCI */