• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * ppc64 "iomap" interface implementation.
4  *
5  * (C) Copyright 2004 Linus Torvalds
6  */
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>
12 #include <asm/isa-bridge.h>
13 
14 /*
15  * Here comes the ppc64 implementation of the IOMAP
16  * interfaces.
17  */
ioread8(void __iomem * addr)18 unsigned int ioread8(void __iomem *addr)
19 {
20 	return readb(addr);
21 }
ioread16(void __iomem * addr)22 unsigned int ioread16(void __iomem *addr)
23 {
24 	return readw(addr);
25 }
ioread16be(void __iomem * addr)26 unsigned int ioread16be(void __iomem *addr)
27 {
28 	return readw_be(addr);
29 }
ioread32(void __iomem * addr)30 unsigned int ioread32(void __iomem *addr)
31 {
32 	return readl(addr);
33 }
ioread32be(void __iomem * addr)34 unsigned int ioread32be(void __iomem *addr)
35 {
36 	return readl_be(addr);
37 }
38 EXPORT_SYMBOL(ioread8);
39 EXPORT_SYMBOL(ioread16);
40 EXPORT_SYMBOL(ioread16be);
41 EXPORT_SYMBOL(ioread32);
42 EXPORT_SYMBOL(ioread32be);
43 #ifdef __powerpc64__
ioread64(void __iomem * addr)44 u64 ioread64(void __iomem *addr)
45 {
46 	return readq(addr);
47 }
ioread64be(void __iomem * addr)48 u64 ioread64be(void __iomem *addr)
49 {
50 	return readq_be(addr);
51 }
52 EXPORT_SYMBOL(ioread64);
53 EXPORT_SYMBOL(ioread64be);
54 #endif /* __powerpc64__ */
55 
iowrite8(u8 val,void __iomem * addr)56 void iowrite8(u8 val, void __iomem *addr)
57 {
58 	writeb(val, addr);
59 }
iowrite16(u16 val,void __iomem * addr)60 void iowrite16(u16 val, void __iomem *addr)
61 {
62 	writew(val, addr);
63 }
iowrite16be(u16 val,void __iomem * addr)64 void iowrite16be(u16 val, void __iomem *addr)
65 {
66 	writew_be(val, addr);
67 }
iowrite32(u32 val,void __iomem * addr)68 void iowrite32(u32 val, void __iomem *addr)
69 {
70 	writel(val, addr);
71 }
iowrite32be(u32 val,void __iomem * addr)72 void iowrite32be(u32 val, void __iomem *addr)
73 {
74 	writel_be(val, addr);
75 }
76 EXPORT_SYMBOL(iowrite8);
77 EXPORT_SYMBOL(iowrite16);
78 EXPORT_SYMBOL(iowrite16be);
79 EXPORT_SYMBOL(iowrite32);
80 EXPORT_SYMBOL(iowrite32be);
81 #ifdef __powerpc64__
iowrite64(u64 val,void __iomem * addr)82 void iowrite64(u64 val, void __iomem *addr)
83 {
84 	writeq(val, addr);
85 }
iowrite64be(u64 val,void __iomem * addr)86 void iowrite64be(u64 val, void __iomem *addr)
87 {
88 	writeq_be(val, addr);
89 }
90 EXPORT_SYMBOL(iowrite64);
91 EXPORT_SYMBOL(iowrite64be);
92 #endif /* __powerpc64__ */
93 
94 /*
95  * These are the "repeat read/write" functions. Note the
96  * non-CPU byte order. We do things in "IO byteorder"
97  * here.
98  *
99  * FIXME! We could make these do EEH handling if we really
100  * wanted. Not clear if we do.
101  */
ioread8_rep(void __iomem * addr,void * dst,unsigned long count)102 void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
103 {
104 	readsb(addr, dst, count);
105 }
ioread16_rep(void __iomem * addr,void * dst,unsigned long count)106 void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
107 {
108 	readsw(addr, dst, count);
109 }
ioread32_rep(void __iomem * addr,void * dst,unsigned long count)110 void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
111 {
112 	readsl(addr, dst, count);
113 }
114 EXPORT_SYMBOL(ioread8_rep);
115 EXPORT_SYMBOL(ioread16_rep);
116 EXPORT_SYMBOL(ioread32_rep);
117 
iowrite8_rep(void __iomem * addr,const void * src,unsigned long count)118 void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
119 {
120 	writesb(addr, src, count);
121 }
iowrite16_rep(void __iomem * addr,const void * src,unsigned long count)122 void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
123 {
124 	writesw(addr, src, count);
125 }
iowrite32_rep(void __iomem * addr,const void * src,unsigned long count)126 void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
127 {
128 	writesl(addr, src, count);
129 }
130 EXPORT_SYMBOL(iowrite8_rep);
131 EXPORT_SYMBOL(iowrite16_rep);
132 EXPORT_SYMBOL(iowrite32_rep);
133 
ioport_map(unsigned long port,unsigned int len)134 void __iomem *ioport_map(unsigned long port, unsigned int len)
135 {
136 	return (void __iomem *) (port + _IO_BASE);
137 }
138 
ioport_unmap(void __iomem * addr)139 void ioport_unmap(void __iomem *addr)
140 {
141 	/* Nothing to do */
142 }
143 EXPORT_SYMBOL(ioport_map);
144 EXPORT_SYMBOL(ioport_unmap);
145 
146 #ifdef CONFIG_PCI
pci_iounmap(struct pci_dev * dev,void __iomem * addr)147 void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
148 {
149 	if (isa_vaddr_is_ioport(addr))
150 		return;
151 	if (pcibios_vaddr_is_ioport(addr))
152 		return;
153 	iounmap(addr);
154 }
155 
156 EXPORT_SYMBOL(pci_iounmap);
157 #endif /* CONFIG_PCI */
158