aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Burton <paul.burton@mips.com>2018-08-29 17:54:00 -0400
committerPaul Burton <paul.burton@mips.com>2018-08-30 12:41:16 -0400
commitb962aeb022051915c26dcaba97d3ed0883bef9f5 (patch)
treec9ae12a1d25d7988dd937badb7ed11a057ac45b6
parente245767abf2797f1581f94e48db7f6184e14ebed (diff)
MIPS: Use GENERIC_IOMAP
MIPS has a copy of lib/iomap.c with minor alterations, none of which are necessary given appropriate definitions of PIO_OFFSET, PIO_MASK & PIO_RESERVED. Provide such definitions, select GENERIC_IOMAP & remove arch/mips/lib/iomap.c to cut back on the needless duplication. The one change this does make is to our mmio_{in,out}s[bwl] functions, which began to deviate from their generic counterparts with commit 0845bb721ebb ("MIPS: iomap: Use __mem_{read,write}{b,w,l} for MMIO"). I suspect that this commit was incorrect, and that the SEAD-3 platform should have instead selected CONFIG_SWAP_IO_SPACE. Since the SEAD-3 platform code is now gone & the board is instead supported by the generic platform (CONFIG_MIPS_GENERIC) which selects CONFIG_SWAP_IO_SPACE anyway, this shouldn't be a problem any more. Signed-off-by: Paul Burton <paul.burton@mips.com> Patchwork: https://patchwork.linux-mips.org/patch/20342/ Cc: linux-mips@linux-mips.org
-rw-r--r--arch/mips/Kconfig2
-rw-r--r--arch/mips/include/asm/io.h15
-rw-r--r--arch/mips/lib/Makefile2
-rw-r--r--arch/mips/lib/iomap-pci.c7
-rw-r--r--arch/mips/lib/iomap.c227
5 files changed, 12 insertions, 241 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 35511999156a..1a119fd7324d 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -21,6 +21,7 @@ config MIPS
21 select GENERIC_CLOCKEVENTS 21 select GENERIC_CLOCKEVENTS
22 select GENERIC_CMOS_UPDATE 22 select GENERIC_CMOS_UPDATE
23 select GENERIC_CPU_AUTOPROBE 23 select GENERIC_CPU_AUTOPROBE
24 select GENERIC_IOMAP
24 select GENERIC_IRQ_PROBE 25 select GENERIC_IRQ_PROBE
25 select GENERIC_IRQ_SHOW 26 select GENERIC_IRQ_SHOW
26 select GENERIC_LIB_ASHLDI3 27 select GENERIC_LIB_ASHLDI3
@@ -28,7 +29,6 @@ config MIPS
28 select GENERIC_LIB_CMPDI2 29 select GENERIC_LIB_CMPDI2
29 select GENERIC_LIB_LSHRDI3 30 select GENERIC_LIB_LSHRDI3
30 select GENERIC_LIB_UCMPDI2 31 select GENERIC_LIB_UCMPDI2
31 select GENERIC_PCI_IOMAP
32 select GENERIC_SCHED_CLOCK if !CAVIUM_OCTEON_SOC 32 select GENERIC_SCHED_CLOCK if !CAVIUM_OCTEON_SOC
33 select GENERIC_SMP_IDLE_THREAD 33 select GENERIC_SMP_IDLE_THREAD
34 select GENERIC_TIME_VSYSCALL 34 select GENERIC_TIME_VSYSCALL
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index 54c730aed327..bbbeede9fea1 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -80,6 +80,16 @@ static inline void set_io_port_base(unsigned long base)
80} 80}
81 81
82/* 82/*
83 * Provide the necessary definitions for generic iomap. We make use of
84 * mips_io_port_base for iomap(), but we don't reserve any low addresses for
85 * use with I/O ports.
86 */
87#define HAVE_ARCH_PIO_SIZE
88#define PIO_OFFSET mips_io_port_base
89#define PIO_MASK IO_SPACE_LIMIT
90#define PIO_RESERVED 0x0UL
91
92/*
83 * Thanks to James van Artsdalen for a better timing-fix than 93 * Thanks to James van Artsdalen for a better timing-fix than
84 * the two short jumps: using outb's to a nonexistent port seems 94 * the two short jumps: using outb's to a nonexistent port seems
85 * to guarantee better timings even on fast machines. 95 * to guarantee better timings even on fast machines.
@@ -172,11 +182,6 @@ static inline void *isa_bus_to_virt(unsigned long address)
172extern void __iomem * __ioremap(phys_addr_t offset, phys_addr_t size, unsigned long flags); 182extern void __iomem * __ioremap(phys_addr_t offset, phys_addr_t size, unsigned long flags);
173extern void __iounmap(const volatile void __iomem *addr); 183extern void __iounmap(const volatile void __iomem *addr);
174 184
175#ifndef CONFIG_PCI
176struct pci_dev;
177static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {}
178#endif
179
180static inline void __iomem * __ioremap_mode(phys_addr_t offset, unsigned long size, 185static inline void __iomem * __ioremap_mode(phys_addr_t offset, unsigned long size,
181 unsigned long flags) 186 unsigned long flags)
182{ 187{
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index 6537e022ef62..479f50559c83 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -7,7 +7,7 @@ lib-y += bitops.o csum_partial.o delay.o memcpy.o memset.o \
7 mips-atomic.o strncpy_user.o \ 7 mips-atomic.o strncpy_user.o \
8 strnlen_user.o uncached.o 8 strnlen_user.o uncached.o
9 9
10obj-y += iomap.o iomap_copy.o 10obj-y += iomap_copy.o
11obj-$(CONFIG_PCI) += iomap-pci.o 11obj-$(CONFIG_PCI) += iomap-pci.o
12lib-$(CONFIG_GENERIC_CSUM) := $(filter-out csum_partial.o, $(lib-y)) 12lib-$(CONFIG_GENERIC_CSUM) := $(filter-out csum_partial.o, $(lib-y))
13 13
diff --git a/arch/mips/lib/iomap-pci.c b/arch/mips/lib/iomap-pci.c
index 4850509c5534..210f5a95ecb1 100644
--- a/arch/mips/lib/iomap-pci.c
+++ b/arch/mips/lib/iomap-pci.c
@@ -44,10 +44,3 @@ void __iomem *__pci_ioport_map(struct pci_dev *dev,
44} 44}
45 45
46#endif /* CONFIG_PCI_DRIVERS_LEGACY */ 46#endif /* CONFIG_PCI_DRIVERS_LEGACY */
47
48void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
49{
50 iounmap(addr);
51}
52
53EXPORT_SYMBOL(pci_iounmap);
diff --git a/arch/mips/lib/iomap.c b/arch/mips/lib/iomap.c
deleted file mode 100644
index 9b31653f318c..000000000000
--- a/arch/mips/lib/iomap.c
+++ /dev/null
@@ -1,227 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Implement the default iomap interfaces
4 *
5 * (C) Copyright 2004 Linus Torvalds
6 * (C) Copyright 2006 Ralf Baechle <ralf@linux-mips.org>
7 * (C) Copyright 2007 MIPS Technologies, Inc.
8 * written by Ralf Baechle <ralf@linux-mips.org>
9 */
10#include <linux/export.h>
11#include <asm/io.h>
12
13/*
14 * Read/write from/to an (offsettable) iomem cookie. It might be a PIO
15 * access or a MMIO access, these functions don't care. The info is
16 * encoded in the hardware mapping set up by the mapping functions
17 * (or the cookie itself, depending on implementation and hw).
18 *
19 * The generic routines don't assume any hardware mappings, and just
20 * encode the PIO/MMIO as part of the cookie. They coldly assume that
21 * the MMIO IO mappings are not in the low address range.
22 *
23 * Architectures for which this is not true can't use this generic
24 * implementation and should do their own copy.
25 */
26
27#define PIO_MASK 0x0ffffUL
28
29unsigned int ioread8(void __iomem *addr)
30{
31 return readb(addr);
32}
33
34EXPORT_SYMBOL(ioread8);
35
36unsigned int ioread16(void __iomem *addr)
37{
38 return readw(addr);
39}
40
41EXPORT_SYMBOL(ioread16);
42
43unsigned int ioread16be(void __iomem *addr)
44{
45 return be16_to_cpu(__raw_readw(addr));
46}
47
48EXPORT_SYMBOL(ioread16be);
49
50unsigned int ioread32(void __iomem *addr)
51{
52 return readl(addr);
53}
54
55EXPORT_SYMBOL(ioread32);
56
57unsigned int ioread32be(void __iomem *addr)
58{
59 return be32_to_cpu(__raw_readl(addr));
60}
61
62EXPORT_SYMBOL(ioread32be);
63
64void iowrite8(u8 val, void __iomem *addr)
65{
66 writeb(val, addr);
67}
68
69EXPORT_SYMBOL(iowrite8);
70
71void iowrite16(u16 val, void __iomem *addr)
72{
73 writew(val, addr);
74}
75
76EXPORT_SYMBOL(iowrite16);
77
78void iowrite16be(u16 val, void __iomem *addr)
79{
80 __raw_writew(cpu_to_be16(val), addr);
81}
82
83EXPORT_SYMBOL(iowrite16be);
84
85void iowrite32(u32 val, void __iomem *addr)
86{
87 writel(val, addr);
88}
89
90EXPORT_SYMBOL(iowrite32);
91
92void iowrite32be(u32 val, void __iomem *addr)
93{
94 __raw_writel(cpu_to_be32(val), addr);
95}
96
97EXPORT_SYMBOL(iowrite32be);
98
99/*
100 * These are the "repeat MMIO read/write" functions.
101 * Note the "__mem" accesses, since we want to convert
102 * to CPU byte order if the host bus happens to not match the
103 * endianness of PCI/ISA (see mach-generic/mangle-port.h).
104 */
105static inline void mmio_insb(void __iomem *addr, u8 *dst, int count)
106{
107 while (--count >= 0) {
108 u8 data = __mem_readb(addr);
109 *dst = data;
110 dst++;
111 }
112}
113
114static inline void mmio_insw(void __iomem *addr, u16 *dst, int count)
115{
116 while (--count >= 0) {
117 u16 data = __mem_readw(addr);
118 *dst = data;
119 dst++;
120 }
121}
122
123static inline void mmio_insl(void __iomem *addr, u32 *dst, int count)
124{
125 while (--count >= 0) {
126 u32 data = __mem_readl(addr);
127 *dst = data;
128 dst++;
129 }
130}
131
132static inline void mmio_outsb(void __iomem *addr, const u8 *src, int count)
133{
134 while (--count >= 0) {
135 __mem_writeb(*src, addr);
136 src++;
137 }
138}
139
140static inline void mmio_outsw(void __iomem *addr, const u16 *src, int count)
141{
142 while (--count >= 0) {
143 __mem_writew(*src, addr);
144 src++;
145 }
146}
147
148static inline void mmio_outsl(void __iomem *addr, const u32 *src, int count)
149{
150 while (--count >= 0) {
151 __mem_writel(*src, addr);
152 src++;
153 }
154}
155
156void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
157{
158 mmio_insb(addr, dst, count);
159}
160
161EXPORT_SYMBOL(ioread8_rep);
162
163void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
164{
165 mmio_insw(addr, dst, count);
166}
167
168EXPORT_SYMBOL(ioread16_rep);
169
170void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
171{
172 mmio_insl(addr, dst, count);
173}
174
175EXPORT_SYMBOL(ioread32_rep);
176
177void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
178{
179 mmio_outsb(addr, src, count);
180}
181
182EXPORT_SYMBOL(iowrite8_rep);
183
184void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
185{
186 mmio_outsw(addr, src, count);
187}
188
189EXPORT_SYMBOL(iowrite16_rep);
190
191void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
192{
193 mmio_outsl(addr, src, count);
194}
195
196EXPORT_SYMBOL(iowrite32_rep);
197
198/*
199 * Create a virtual mapping cookie for an IO port range
200 *
201 * This uses the same mapping are as the in/out family which has to be setup
202 * by the platform initialization code.
203 *
204 * Just to make matters somewhat more interesting on MIPS systems with
205 * multiple host bridge each will have it's own ioport address space.
206 */
207static void __iomem *ioport_map_legacy(unsigned long port, unsigned int nr)
208{
209 return (void __iomem *) (mips_io_port_base + port);
210}
211
212void __iomem *ioport_map(unsigned long port, unsigned int nr)
213{
214 if (port > PIO_MASK)
215 return NULL;
216
217 return ioport_map_legacy(port, nr);
218}
219
220EXPORT_SYMBOL(ioport_map);
221
222void ioport_unmap(void __iomem *addr)
223{
224 /* Nothing to do */
225}
226
227EXPORT_SYMBOL(ioport_unmap);