aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/alpha/Kconfig5
-rw-r--r--arch/alpha/kernel/pci-noop.c12
-rw-r--r--arch/alpha/kernel/pci.c26
-rw-r--r--arch/arm/Kconfig1
-rw-r--r--arch/arm/include/asm/io.h2
-rw-r--r--arch/arm/mm/iomap.c21
-rw-r--r--arch/cris/Kconfig5
-rw-r--r--arch/frv/Kconfig1
-rw-r--r--arch/frv/include/asm/io.h2
-rw-r--r--arch/frv/mb93090-mb00/Makefile2
-rw-r--r--arch/frv/mb93090-mb00/pci-iomap.c29
-rw-r--r--arch/hexagon/Kconfig4
-rw-r--r--arch/ia64/Kconfig5
-rw-r--r--arch/m68k/Kconfig4
-rw-r--r--arch/microblaze/Kconfig1
-rw-r--r--arch/microblaze/pci/iomap.c19
-rw-r--r--arch/mips/Kconfig1
-rw-r--r--arch/mips/lib/iomap-pci.c26
-rw-r--r--arch/mn10300/Kconfig1
-rw-r--r--arch/mn10300/include/asm/io.h17
-rw-r--r--arch/mn10300/unit-asb2305/Makefile2
-rw-r--r--arch/mn10300/unit-asb2305/pci-iomap.c31
-rw-r--r--arch/openrisc/Kconfig3
-rw-r--r--arch/parisc/Kconfig1
-rw-r--r--arch/parisc/lib/iomap.c23
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/powerpc/kernel/iomap.c19
-rw-r--r--arch/powerpc/platforms/Kconfig3
-rw-r--r--arch/score/Kconfig4
-rw-r--r--arch/sh/Kconfig4
-rw-r--r--arch/sh/drivers/pci/pci.c23
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/sparc/include/asm/io_32.h2
-rw-r--r--arch/sparc/include/asm/io_64.h2
-rw-r--r--arch/sparc/lib/iomap.c23
-rw-r--r--arch/tile/Kconfig1
-rw-r--r--arch/tile/include/asm/io.h3
-rw-r--r--arch/tile/include/asm/pci.h2
-rw-r--r--arch/tile/kernel/pci.c21
-rw-r--r--arch/unicore32/Kconfig4
-rw-r--r--arch/x86/Kconfig4
-rw-r--r--include/asm-generic/io.h4
-rw-r--r--include/asm-generic/iomap.h9
-rw-r--r--include/asm-generic/pci_iomap.h25
-rw-r--r--lib/Kconfig7
-rw-r--r--lib/Makefile1
-rw-r--r--lib/iomap.c38
-rw-r--r--lib/pci_iomap.c48
48 files changed, 124 insertions, 369 deletions
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 3d74801a4015..56a4df952fb0 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -70,10 +70,6 @@ config GENERIC_ISA_DMA
70 bool 70 bool
71 default y 71 default y
72 72
73config GENERIC_IOMAP
74 bool
75 default n
76
77source "init/Kconfig" 73source "init/Kconfig"
78source "kernel/Kconfig.freezer" 74source "kernel/Kconfig.freezer"
79 75
@@ -319,6 +315,7 @@ config ISA_DMA_API
319config PCI 315config PCI
320 bool 316 bool
321 depends on !ALPHA_JENSEN 317 depends on !ALPHA_JENSEN
318 select GENERIC_PCI_IOMAP
322 default y 319 default y
323 help 320 help
324 Find out whether you have a PCI motherboard. PCI is the name of a 321 Find out whether you have a PCI motherboard. PCI is the name of a
diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c
index 246100ef07c2..04eea4894ef3 100644
--- a/arch/alpha/kernel/pci-noop.c
+++ b/arch/alpha/kernel/pci-noop.c
@@ -185,15 +185,3 @@ struct dma_map_ops alpha_noop_ops = {
185 185
186struct dma_map_ops *dma_ops = &alpha_noop_ops; 186struct dma_map_ops *dma_ops = &alpha_noop_ops;
187EXPORT_SYMBOL(dma_ops); 187EXPORT_SYMBOL(dma_ops);
188
189void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
190{
191 return NULL;
192}
193
194void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
195{
196}
197
198EXPORT_SYMBOL(pci_iomap);
199EXPORT_SYMBOL(pci_iounmap);
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index c9ab94ee1ca8..f3cae275d3f5 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -508,30 +508,7 @@ sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
508 return -EOPNOTSUPP; 508 return -EOPNOTSUPP;
509} 509}
510 510
511/* Create an __iomem token from a PCI BAR. Copied from lib/iomap.c with 511/* Destroy an __iomem token. Not copied from lib/iomap.c. */
512 no changes, since we don't want the other things in that object file. */
513
514void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
515{
516 resource_size_t start = pci_resource_start(dev, bar);
517 resource_size_t len = pci_resource_len(dev, bar);
518 unsigned long flags = pci_resource_flags(dev, bar);
519
520 if (!len || !start)
521 return NULL;
522 if (maxlen && len > maxlen)
523 len = maxlen;
524 if (flags & IORESOURCE_IO)
525 return ioport_map(start, len);
526 if (flags & IORESOURCE_MEM) {
527 /* Not checking IORESOURCE_CACHEABLE because alpha does
528 not distinguish between ioremap and ioremap_nocache. */
529 return ioremap(start, len);
530 }
531 return NULL;
532}
533
534/* Destroy that token. Not copied from lib/iomap.c. */
535 512
536void pci_iounmap(struct pci_dev *dev, void __iomem * addr) 513void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
537{ 514{
@@ -539,7 +516,6 @@ void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
539 iounmap(addr); 516 iounmap(addr);
540} 517}
541 518
542EXPORT_SYMBOL(pci_iomap);
543EXPORT_SYMBOL(pci_iounmap); 519EXPORT_SYMBOL(pci_iounmap);
544 520
545/* FIXME: Some boxes have multiple ISA bridges! */ 521/* FIXME: Some boxes have multiple ISA bridges! */
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 98a6459cd398..24626b0419ee 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -31,6 +31,7 @@ config ARM
31 select HAVE_SPARSE_IRQ 31 select HAVE_SPARSE_IRQ
32 select GENERIC_IRQ_SHOW 32 select GENERIC_IRQ_SHOW
33 select CPU_PM if (SUSPEND || CPU_IDLE) 33 select CPU_PM if (SUSPEND || CPU_IDLE)
34 select GENERIC_PCI_IOMAP
34 help 35 help
35 The ARM series is a line of low-power-consumption RISC chip designs 36 The ARM series is a line of low-power-consumption RISC chip designs
36 licensed by ARM Ltd and targeted at embedded applications and 37 licensed by ARM Ltd and targeted at embedded applications and
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 065d100fa63e..9275828feb3d 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -27,6 +27,7 @@
27#include <asm/byteorder.h> 27#include <asm/byteorder.h>
28#include <asm/memory.h> 28#include <asm/memory.h>
29#include <asm/system.h> 29#include <asm/system.h>
30#include <asm-generic/pci_iomap.h>
30 31
31/* 32/*
32 * ISA I/O bus memory addresses are 1:1 with the physical address. 33 * ISA I/O bus memory addresses are 1:1 with the physical address.
@@ -306,7 +307,6 @@ extern void ioport_unmap(void __iomem *addr);
306 307
307struct pci_dev; 308struct pci_dev;
308 309
309extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen);
310extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr); 310extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
311 311
312/* 312/*
diff --git a/arch/arm/mm/iomap.c b/arch/arm/mm/iomap.c
index 430df1a5978d..e62956e12030 100644
--- a/arch/arm/mm/iomap.c
+++ b/arch/arm/mm/iomap.c
@@ -35,27 +35,6 @@ EXPORT_SYMBOL(pcibios_min_mem);
35unsigned int pci_flags = PCI_REASSIGN_ALL_RSRC; 35unsigned int pci_flags = PCI_REASSIGN_ALL_RSRC;
36EXPORT_SYMBOL(pci_flags); 36EXPORT_SYMBOL(pci_flags);
37 37
38void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
39{
40 resource_size_t start = pci_resource_start(dev, bar);
41 resource_size_t len = pci_resource_len(dev, bar);
42 unsigned long flags = pci_resource_flags(dev, bar);
43
44 if (!len || !start)
45 return NULL;
46 if (maxlen && len > maxlen)
47 len = maxlen;
48 if (flags & IORESOURCE_IO)
49 return ioport_map(start, len);
50 if (flags & IORESOURCE_MEM) {
51 if (flags & IORESOURCE_CACHEABLE)
52 return ioremap(start, len);
53 return ioremap_nocache(start, len);
54 }
55 return NULL;
56}
57EXPORT_SYMBOL(pci_iomap);
58
59void pci_iounmap(struct pci_dev *dev, void __iomem *addr) 38void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
60{ 39{
61 if ((unsigned long)addr >= VMALLOC_START && 40 if ((unsigned long)addr >= VMALLOC_START &&
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index 408b055c585f..b3abfb08aa5c 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -19,10 +19,6 @@ config GENERIC_CMOS_UPDATE
19config ARCH_USES_GETTIMEOFFSET 19config ARCH_USES_GETTIMEOFFSET
20 def_bool n 20 def_bool n
21 21
22config GENERIC_IOMAP
23 bool
24 default y
25
26config ARCH_HAS_ILOG2_U32 22config ARCH_HAS_ILOG2_U32
27 bool 23 bool
28 default n 24 default n
@@ -52,6 +48,7 @@ config CRIS
52 select HAVE_IDE 48 select HAVE_IDE
53 select HAVE_GENERIC_HARDIRQS 49 select HAVE_GENERIC_HARDIRQS
54 select GENERIC_IRQ_SHOW 50 select GENERIC_IRQ_SHOW
51 select GENERIC_IOMAP
55 52
56config HZ 53config HZ
57 int 54 int
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index c5e69abb4889..bbbf7927f238 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -317,6 +317,7 @@ config PCI
317 bool "Use PCI" 317 bool "Use PCI"
318 depends on MB93090_MB00 318 depends on MB93090_MB00
319 default y 319 default y
320 select GENERIC_PCI_IOMAP
320 help 321 help
321 Some FR-V systems (such as the MB93090-MB00 VDK) have PCI 322 Some FR-V systems (such as the MB93090-MB00 VDK) have PCI
322 onboard. If you have one of these boards and you wish to use the PCI 323 onboard. If you have one of these boards and you wish to use the PCI
diff --git a/arch/frv/include/asm/io.h b/arch/frv/include/asm/io.h
index ca7475e73b5e..8cb50a2fbcb2 100644
--- a/arch/frv/include/asm/io.h
+++ b/arch/frv/include/asm/io.h
@@ -21,6 +21,7 @@
21#include <asm/virtconvert.h> 21#include <asm/virtconvert.h>
22#include <asm/string.h> 22#include <asm/string.h>
23#include <asm/mb-regs.h> 23#include <asm/mb-regs.h>
24#include <asm-generic/pci_iomap.h>
24#include <linux/delay.h> 25#include <linux/delay.h>
25 26
26/* 27/*
@@ -370,7 +371,6 @@ static inline void iowrite32_rep(void __iomem *p, const void *src, unsigned long
370 371
371/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ 372/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
372struct pci_dev; 373struct pci_dev;
373extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
374static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p) 374static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
375{ 375{
376} 376}
diff --git a/arch/frv/mb93090-mb00/Makefile b/arch/frv/mb93090-mb00/Makefile
index b73b542f8f48..21f1df1b378a 100644
--- a/arch/frv/mb93090-mb00/Makefile
+++ b/arch/frv/mb93090-mb00/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5ifeq "$(CONFIG_PCI)" "y" 5ifeq "$(CONFIG_PCI)" "y"
6obj-y := pci-frv.o pci-irq.o pci-vdk.o pci-iomap.o 6obj-y := pci-frv.o pci-irq.o pci-vdk.o
7 7
8ifeq "$(CONFIG_MMU)" "y" 8ifeq "$(CONFIG_MMU)" "y"
9obj-y += pci-dma.o 9obj-y += pci-dma.o
diff --git a/arch/frv/mb93090-mb00/pci-iomap.c b/arch/frv/mb93090-mb00/pci-iomap.c
deleted file mode 100644
index 35f6df28351e..000000000000
--- a/arch/frv/mb93090-mb00/pci-iomap.c
+++ /dev/null
@@ -1,29 +0,0 @@
1/* pci-iomap.c: description
2 *
3 * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#include <linux/pci.h>
12#include <linux/module.h>
13
14void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
15{
16 resource_size_t start = pci_resource_start(dev, bar);
17 resource_size_t len = pci_resource_len(dev, bar);
18 unsigned long flags = pci_resource_flags(dev, bar);
19
20 if (!len || !start)
21 return NULL;
22
23 if ((flags & IORESOURCE_IO) || (flags & IORESOURCE_MEM))
24 return (void __iomem *) start;
25
26 return NULL;
27}
28
29EXPORT_SYMBOL(pci_iomap);
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index 02513c2dd5ec..9059e3905887 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -26,6 +26,7 @@ config HEXAGON
26 select HAVE_ARCH_KGDB 26 select HAVE_ARCH_KGDB
27 select HAVE_ARCH_TRACEHOOK 27 select HAVE_ARCH_TRACEHOOK
28 select NO_IOPORT 28 select NO_IOPORT
29 select GENERIC_IOMAP
29 # mostly generic routines, with some accelerated ones 30 # mostly generic routines, with some accelerated ones
30 ---help--- 31 ---help---
31 Qualcomm Hexagon is a processor architecture designed for high 32 Qualcomm Hexagon is a processor architecture designed for high
@@ -73,9 +74,6 @@ config GENERIC_CSUM
73config GENERIC_IRQ_PROBE 74config GENERIC_IRQ_PROBE
74 def_bool y 75 def_bool y
75 76
76config GENERIC_IOMAP
77 def_bool y
78
79#config ZONE_DMA 77#config ZONE_DMA
80# bool 78# bool
81# default y 79# default y
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 3b7a7c483785..bd7266903bf8 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -32,6 +32,7 @@ config IA64
32 select GENERIC_IRQ_SHOW 32 select GENERIC_IRQ_SHOW
33 select ARCH_WANT_OPTIONAL_GPIOLIB 33 select ARCH_WANT_OPTIONAL_GPIOLIB
34 select ARCH_HAVE_NMI_SAFE_CMPXCHG 34 select ARCH_HAVE_NMI_SAFE_CMPXCHG
35 select GENERIC_IOMAP
35 default y 36 default y
36 help 37 help
37 The Itanium Processor Family is Intel's 64-bit successor to 38 The Itanium Processor Family is Intel's 64-bit successor to
@@ -105,10 +106,6 @@ config EFI
105 bool 106 bool
106 default y 107 default y
107 108
108config GENERIC_IOMAP
109 bool
110 default y
111
112config ARCH_CLOCKSOURCE_DATA 109config ARCH_CLOCKSOURCE_DATA
113 def_bool y 110 def_bool y
114 111
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 81fdaa72c540..99c363617f27 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -37,9 +37,6 @@ config GENERIC_CALIBRATE_DELAY
37 bool 37 bool
38 default y 38 default y
39 39
40config GENERIC_IOMAP
41 def_bool MMU
42
43config GENERIC_CSUM 40config GENERIC_CSUM
44 bool 41 bool
45 42
@@ -81,6 +78,7 @@ source "kernel/Kconfig.freezer"
81config MMU 78config MMU
82 bool "MMU-based Paged Memory Management Support" 79 bool "MMU-based Paged Memory Management Support"
83 default y 80 default y
81 select GENERIC_IOMAP
84 help 82 help
85 Select if you want MMU-based virtualised addressing space 83 Select if you want MMU-based virtualised addressing space
86 support by paged memory management. If unsure, say 'Y'. 84 support by paged memory management. If unsure, say 'Y'.
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index e446bab2427b..f0eead74fff6 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -17,6 +17,7 @@ config MICROBLAZE
17 select HAVE_GENERIC_HARDIRQS 17 select HAVE_GENERIC_HARDIRQS
18 select GENERIC_IRQ_PROBE 18 select GENERIC_IRQ_PROBE
19 select GENERIC_IRQ_SHOW 19 select GENERIC_IRQ_SHOW
20 select GENERIC_PCI_IOMAP
20 21
21config SWAP 22config SWAP
22 def_bool n 23 def_bool n
diff --git a/arch/microblaze/pci/iomap.c b/arch/microblaze/pci/iomap.c
index 57acda852f5a..b07abbac0319 100644
--- a/arch/microblaze/pci/iomap.c
+++ b/arch/microblaze/pci/iomap.c
@@ -10,25 +10,6 @@
10#include <asm/io.h> 10#include <asm/io.h>
11#include <asm/pci-bridge.h> 11#include <asm/pci-bridge.h>
12 12
13void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
14{
15 resource_size_t start = pci_resource_start(dev, bar);
16 resource_size_t len = pci_resource_len(dev, bar);
17 unsigned long flags = pci_resource_flags(dev, bar);
18
19 if (!len)
20 return NULL;
21 if (max && len > max)
22 len = max;
23 if (flags & IORESOURCE_IO)
24 return ioport_map(start, len);
25 if (flags & IORESOURCE_MEM)
26 return ioremap(start, len);
27 /* What? */
28 return NULL;
29}
30EXPORT_SYMBOL(pci_iomap);
31
32void pci_iounmap(struct pci_dev *dev, void __iomem *addr) 13void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
33{ 14{
34 if (isa_vaddr_is_ioport(addr)) 15 if (isa_vaddr_is_ioport(addr))
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index c529cfe52c53..29d92187ff30 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2317,6 +2317,7 @@ config PCI
2317 bool "Support for PCI controller" 2317 bool "Support for PCI controller"
2318 depends on HW_HAS_PCI 2318 depends on HW_HAS_PCI
2319 select PCI_DOMAINS 2319 select PCI_DOMAINS
2320 select GENERIC_PCI_IOMAP
2320 help 2321 help
2321 Find out whether you have a PCI motherboard. PCI is the name of a 2322 Find out whether you have a PCI motherboard. PCI is the name of a
2322 bus system, i.e. the way the CPU talks to the other stuff inside 2323 bus system, i.e. the way the CPU talks to the other stuff inside
diff --git a/arch/mips/lib/iomap-pci.c b/arch/mips/lib/iomap-pci.c
index 2ab899c4b4ce..2635b1a96333 100644
--- a/arch/mips/lib/iomap-pci.c
+++ b/arch/mips/lib/iomap-pci.c
@@ -40,32 +40,6 @@ static void __iomem *ioport_map_pci(struct pci_dev *dev,
40 return (void __iomem *) (ctrl->io_map_base + port); 40 return (void __iomem *) (ctrl->io_map_base + port);
41} 41}
42 42
43/*
44 * Create a virtual mapping cookie for a PCI BAR (memory or IO)
45 */
46void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
47{
48 resource_size_t start = pci_resource_start(dev, bar);
49 resource_size_t len = pci_resource_len(dev, bar);
50 unsigned long flags = pci_resource_flags(dev, bar);
51
52 if (!len || !start)
53 return NULL;
54 if (maxlen && len > maxlen)
55 len = maxlen;
56 if (flags & IORESOURCE_IO)
57 return ioport_map_pci(dev, start, len);
58 if (flags & IORESOURCE_MEM) {
59 if (flags & IORESOURCE_CACHEABLE)
60 return ioremap(start, len);
61 return ioremap_nocache(start, len);
62 }
63 /* What? */
64 return NULL;
65}
66
67EXPORT_SYMBOL(pci_iomap);
68
69void pci_iounmap(struct pci_dev *dev, void __iomem * addr) 43void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
70{ 44{
71 iounmap(addr); 45 iounmap(addr);
diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
index 438db84a1f7c..8f1c40d5817e 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -252,6 +252,7 @@ config PCI
252 bool "Use PCI" 252 bool "Use PCI"
253 depends on MN10300_UNIT_ASB2305 253 depends on MN10300_UNIT_ASB2305
254 default y 254 default y
255 select GENERIC_PCI_IOMAP
255 help 256 help
256 Some systems (such as the ASB2305) have PCI onboard. If you have one 257 Some systems (such as the ASB2305) have PCI onboard. If you have one
257 of these boards and you wish to use the PCI facilities, say Y here. 258 of these boards and you wish to use the PCI facilities, say Y here.
diff --git a/arch/mn10300/include/asm/io.h b/arch/mn10300/include/asm/io.h
index 787255da744e..139df8c53de8 100644
--- a/arch/mn10300/include/asm/io.h
+++ b/arch/mn10300/include/asm/io.h
@@ -229,7 +229,6 @@ static inline void outsl(unsigned long addr, const void *buffer, int count)
229 229
230/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ 230/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
231struct pci_dev; 231struct pci_dev;
232extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
233static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p) 232static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
234{ 233{
235} 234}
@@ -251,15 +250,15 @@ static inline void *phys_to_virt(unsigned long address)
251/* 250/*
252 * Change "struct page" to physical address. 251 * Change "struct page" to physical address.
253 */ 252 */
254static inline void *__ioremap(unsigned long offset, unsigned long size, 253static inline void __iomem *__ioremap(unsigned long offset, unsigned long size,
255 unsigned long flags) 254 unsigned long flags)
256{ 255{
257 return (void *) offset; 256 return (void __iomem *) offset;
258} 257}
259 258
260static inline void *ioremap(unsigned long offset, unsigned long size) 259static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
261{ 260{
262 return (void *) offset; 261 return (void __iomem *) offset;
263} 262}
264 263
265/* 264/*
@@ -267,14 +266,14 @@ static inline void *ioremap(unsigned long offset, unsigned long size)
267 * area. it's useful if some control registers are in such an area and write 266 * area. it's useful if some control registers are in such an area and write
268 * combining or read caching is not desirable: 267 * combining or read caching is not desirable:
269 */ 268 */
270static inline void *ioremap_nocache(unsigned long offset, unsigned long size) 269static inline void __iomem *ioremap_nocache(unsigned long offset, unsigned long size)
271{ 270{
272 return (void *) (offset | 0x20000000); 271 return (void __iomem *) (offset | 0x20000000);
273} 272}
274 273
275#define ioremap_wc ioremap_nocache 274#define ioremap_wc ioremap_nocache
276 275
277static inline void iounmap(void *addr) 276static inline void iounmap(void __iomem *addr)
278{ 277{
279} 278}
280 279
diff --git a/arch/mn10300/unit-asb2305/Makefile b/arch/mn10300/unit-asb2305/Makefile
index 0551022225b3..cbc5abaa939a 100644
--- a/arch/mn10300/unit-asb2305/Makefile
+++ b/arch/mn10300/unit-asb2305/Makefile
@@ -5,4 +5,4 @@
5############################################################################### 5###############################################################################
6obj-y := unit-init.o leds.o 6obj-y := unit-init.o leds.o
7 7
8obj-$(CONFIG_PCI) += pci.o pci-asb2305.o pci-irq.o pci-iomap.o 8obj-$(CONFIG_PCI) += pci.o pci-asb2305.o pci-irq.o
diff --git a/arch/mn10300/unit-asb2305/pci-iomap.c b/arch/mn10300/unit-asb2305/pci-iomap.c
deleted file mode 100644
index c1a8d8f941fd..000000000000
--- a/arch/mn10300/unit-asb2305/pci-iomap.c
+++ /dev/null
@@ -1,31 +0,0 @@
1/* ASB2305 PCI I/O mapping handler
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11#include <linux/pci.h>
12#include <linux/module.h>
13
14/*
15 * Create a virtual mapping cookie for a PCI BAR (memory or IO)
16 */
17void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
18{
19 resource_size_t start = pci_resource_start(dev, bar);
20 resource_size_t len = pci_resource_len(dev, bar);
21 unsigned long flags = pci_resource_flags(dev, bar);
22
23 if (!len || !start)
24 return NULL;
25
26 if ((flags & IORESOURCE_IO) || (flags & IORESOURCE_MEM))
27 return (void __iomem *) start;
28
29 return NULL;
30}
31EXPORT_SYMBOL(pci_iomap);
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index e518a5a4cf4c..081a54f1a93d 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -38,9 +38,6 @@ config RWSEM_XCHGADD_ALGORITHM
38config GENERIC_HWEIGHT 38config GENERIC_HWEIGHT
39 def_bool y 39 def_bool y
40 40
41config GENERIC_IOMAP
42 def_bool y
43
44config NO_IOPORT 41config NO_IOPORT
45 def_bool y 42 def_bool y
46 43
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index fdfd8be29e95..242a1b7ac759 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -14,6 +14,7 @@ config PARISC
14 select GENERIC_ATOMIC64 if !64BIT 14 select GENERIC_ATOMIC64 if !64BIT
15 select HAVE_GENERIC_HARDIRQS 15 select HAVE_GENERIC_HARDIRQS
16 select GENERIC_IRQ_PROBE 16 select GENERIC_IRQ_PROBE
17 select GENERIC_PCI_IOMAP
17 select IRQ_PER_CPU 18 select IRQ_PER_CPU
18 select ARCH_HAVE_NMI_SAFE_CMPXCHG 19 select ARCH_HAVE_NMI_SAFE_CMPXCHG
19 20
diff --git a/arch/parisc/lib/iomap.c b/arch/parisc/lib/iomap.c
index 8f470c93b16d..fb8e10a4fb39 100644
--- a/arch/parisc/lib/iomap.c
+++ b/arch/parisc/lib/iomap.c
@@ -436,28 +436,6 @@ void ioport_unmap(void __iomem *addr)
436 } 436 }
437} 437}
438 438
439/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
440void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
441{
442 resource_size_t start = pci_resource_start(dev, bar);
443 resource_size_t len = pci_resource_len(dev, bar);
444 unsigned long flags = pci_resource_flags(dev, bar);
445
446 if (!len || !start)
447 return NULL;
448 if (maxlen && len > maxlen)
449 len = maxlen;
450 if (flags & IORESOURCE_IO)
451 return ioport_map(start, len);
452 if (flags & IORESOURCE_MEM) {
453 if (flags & IORESOURCE_CACHEABLE)
454 return ioremap(start, len);
455 return ioremap_nocache(start, len);
456 }
457 /* What? */
458 return NULL;
459}
460
461void pci_iounmap(struct pci_dev *dev, void __iomem * addr) 439void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
462{ 440{
463 if (!INDIRECT_ADDR(addr)) { 441 if (!INDIRECT_ADDR(addr)) {
@@ -483,5 +461,4 @@ EXPORT_SYMBOL(iowrite16_rep);
483EXPORT_SYMBOL(iowrite32_rep); 461EXPORT_SYMBOL(iowrite32_rep);
484EXPORT_SYMBOL(ioport_map); 462EXPORT_SYMBOL(ioport_map);
485EXPORT_SYMBOL(ioport_unmap); 463EXPORT_SYMBOL(ioport_unmap);
486EXPORT_SYMBOL(pci_iomap);
487EXPORT_SYMBOL(pci_iounmap); 464EXPORT_SYMBOL(pci_iounmap);
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 692ac7588e20..1919634a9b32 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -718,6 +718,7 @@ config PCI
718 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx 718 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx
719 default PCI_QSPAN if !4xx && !CPM2 && 8xx 719 default PCI_QSPAN if !4xx && !CPM2 && 8xx
720 select ARCH_SUPPORTS_MSI 720 select ARCH_SUPPORTS_MSI
721 select GENERIC_PCI_IOMAP
721 help 722 help
722 Find out whether your system includes a PCI bus. PCI is the name of 723 Find out whether your system includes a PCI bus. PCI is the name of
723 a bus system, i.e. the way the CPU talks to the other stuff inside 724 a bus system, i.e. the way the CPU talks to the other stuff inside
diff --git a/arch/powerpc/kernel/iomap.c b/arch/powerpc/kernel/iomap.c
index 262791807397..97a3715ac8bd 100644
--- a/arch/powerpc/kernel/iomap.c
+++ b/arch/powerpc/kernel/iomap.c
@@ -119,24 +119,6 @@ EXPORT_SYMBOL(ioport_map);
119EXPORT_SYMBOL(ioport_unmap); 119EXPORT_SYMBOL(ioport_unmap);
120 120
121#ifdef CONFIG_PCI 121#ifdef CONFIG_PCI
122void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
123{
124 resource_size_t start = pci_resource_start(dev, bar);
125 resource_size_t len = pci_resource_len(dev, bar);
126 unsigned long flags = pci_resource_flags(dev, bar);
127
128 if (!len)
129 return NULL;
130 if (max && len > max)
131 len = max;
132 if (flags & IORESOURCE_IO)
133 return ioport_map(start, len);
134 if (flags & IORESOURCE_MEM)
135 return ioremap(start, len);
136 /* What? */
137 return NULL;
138}
139
140void pci_iounmap(struct pci_dev *dev, void __iomem *addr) 122void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
141{ 123{
142 if (isa_vaddr_is_ioport(addr)) 124 if (isa_vaddr_is_ioport(addr))
@@ -146,6 +128,5 @@ void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
146 iounmap(addr); 128 iounmap(addr);
147} 129}
148 130
149EXPORT_SYMBOL(pci_iomap);
150EXPORT_SYMBOL(pci_iounmap); 131EXPORT_SYMBOL(pci_iounmap);
151#endif /* CONFIG_PCI */ 132#endif /* CONFIG_PCI */
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index 31e1adeaa92a..0cfb46d54b8c 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -175,9 +175,6 @@ config PPC_INDIRECT_MMIO
175config PPC_IO_WORKAROUNDS 175config PPC_IO_WORKAROUNDS
176 bool 176 bool
177 177
178config GENERIC_IOMAP
179 bool
180
181source "drivers/cpufreq/Kconfig" 178source "drivers/cpufreq/Kconfig"
182 179
183menu "CPU Frequency drivers" 180menu "CPU Frequency drivers"
diff --git a/arch/score/Kconfig b/arch/score/Kconfig
index 8b0c9464aa9d..3df65d39abc1 100644
--- a/arch/score/Kconfig
+++ b/arch/score/Kconfig
@@ -4,6 +4,7 @@ config SCORE
4 def_bool y 4 def_bool y
5 select HAVE_GENERIC_HARDIRQS 5 select HAVE_GENERIC_HARDIRQS
6 select GENERIC_IRQ_SHOW 6 select GENERIC_IRQ_SHOW
7 select GENERIC_IOMAP
7 select HAVE_MEMBLOCK 8 select HAVE_MEMBLOCK
8 select HAVE_MEMBLOCK_NODE_MAP 9 select HAVE_MEMBLOCK_NODE_MAP
9 select ARCH_DISCARD_MEMBLOCK 10 select ARCH_DISCARD_MEMBLOCK
@@ -36,9 +37,6 @@ endmenu
36config CPU_SCORE7 37config CPU_SCORE7
37 bool 38 bool
38 39
39config GENERIC_IOMAP
40 def_bool y
41
42config NO_DMA 40config NO_DMA
43 bool 41 bool
44 default y 42 default y
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 47a2f1c2cb0d..3c8db65c89e5 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -85,9 +85,6 @@ config GENERIC_GPIO
85config GENERIC_CALIBRATE_DELAY 85config GENERIC_CALIBRATE_DELAY
86 bool 86 bool
87 87
88config GENERIC_IOMAP
89 bool
90
91config GENERIC_CLOCKEVENTS 88config GENERIC_CLOCKEVENTS
92 def_bool y 89 def_bool y
93 90
@@ -861,6 +858,7 @@ config PCI
861 bool "PCI support" 858 bool "PCI support"
862 depends on SYS_SUPPORTS_PCI 859 depends on SYS_SUPPORTS_PCI
863 select PCI_DOMAINS 860 select PCI_DOMAINS
861 select GENERIC_PCI_IOMAP
864 help 862 help
865 Find out whether you have a PCI motherboard. PCI is the name of a 863 Find out whether you have a PCI motherboard. PCI is the name of a
866 bus system, i.e. the way the CPU talks to the other stuff inside 864 bus system, i.e. the way the CPU talks to the other stuff inside
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index c2691afe8f79..11aaf2fdec84 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -393,29 +393,6 @@ static void __iomem *ioport_map_pci(struct pci_dev *dev,
393 return (void __iomem *)(chan->io_map_base + port); 393 return (void __iomem *)(chan->io_map_base + port);
394} 394}
395 395
396void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
397{
398 resource_size_t start = pci_resource_start(dev, bar);
399 resource_size_t len = pci_resource_len(dev, bar);
400 unsigned long flags = pci_resource_flags(dev, bar);
401
402 if (unlikely(!len || !start))
403 return NULL;
404 if (maxlen && len > maxlen)
405 len = maxlen;
406
407 if (flags & IORESOURCE_IO)
408 return ioport_map_pci(dev, start, len);
409 if (flags & IORESOURCE_MEM) {
410 if (flags & IORESOURCE_CACHEABLE)
411 return ioremap(start, len);
412 return ioremap_nocache(start, len);
413 }
414
415 return NULL;
416}
417EXPORT_SYMBOL(pci_iomap);
418
419void pci_iounmap(struct pci_dev *dev, void __iomem *addr) 396void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
420{ 397{
421 iounmap(addr); 398 iounmap(addr);
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 868ea08dff0b..96657992a72e 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -28,6 +28,7 @@ config SPARC
28 select HAVE_GENERIC_HARDIRQS 28 select HAVE_GENERIC_HARDIRQS
29 select GENERIC_IRQ_SHOW 29 select GENERIC_IRQ_SHOW
30 select USE_GENERIC_SMP_HELPERS if SMP 30 select USE_GENERIC_SMP_HELPERS if SMP
31 select GENERIC_PCI_IOMAP
31 32
32config SPARC32 33config SPARC32
33 def_bool !64BIT 34 def_bool !64BIT
diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h
index c2ced21c9dc1..2006e5d359df 100644
--- a/arch/sparc/include/asm/io_32.h
+++ b/arch/sparc/include/asm/io_32.h
@@ -7,6 +7,7 @@
7 7
8#include <asm/page.h> /* IO address mapping routines need this */ 8#include <asm/page.h> /* IO address mapping routines need this */
9#include <asm/system.h> 9#include <asm/system.h>
10#include <asm-generic/pci_iomap.h>
10 11
11#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) 12#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
12 13
@@ -324,7 +325,6 @@ extern void ioport_unmap(void __iomem *);
324 325
325/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ 326/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
326struct pci_dev; 327struct pci_dev;
327extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
328extern void pci_iounmap(struct pci_dev *dev, void __iomem *); 328extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
329 329
330/* 330/*
diff --git a/arch/sparc/include/asm/io_64.h b/arch/sparc/include/asm/io_64.h
index 9c8965415f0a..9481e5a6fa90 100644
--- a/arch/sparc/include/asm/io_64.h
+++ b/arch/sparc/include/asm/io_64.h
@@ -8,6 +8,7 @@
8#include <asm/page.h> /* IO address mapping routines need this */ 8#include <asm/page.h> /* IO address mapping routines need this */
9#include <asm/system.h> 9#include <asm/system.h>
10#include <asm/asi.h> 10#include <asm/asi.h>
11#include <asm-generic/pci_iomap.h>
11 12
12/* PC crapola... */ 13/* PC crapola... */
13#define __SLOW_DOWN_IO do { } while (0) 14#define __SLOW_DOWN_IO do { } while (0)
@@ -514,7 +515,6 @@ extern void ioport_unmap(void __iomem *);
514 515
515/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ 516/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
516struct pci_dev; 517struct pci_dev;
517extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
518extern void pci_iounmap(struct pci_dev *dev, void __iomem *); 518extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
519 519
520static inline int sbus_can_dma_64bit(void) 520static inline int sbus_can_dma_64bit(void)
diff --git a/arch/sparc/lib/iomap.c b/arch/sparc/lib/iomap.c
index 9ef37e13a920..c4d42a50ebc0 100644
--- a/arch/sparc/lib/iomap.c
+++ b/arch/sparc/lib/iomap.c
@@ -18,31 +18,8 @@ void ioport_unmap(void __iomem *addr)
18EXPORT_SYMBOL(ioport_map); 18EXPORT_SYMBOL(ioport_map);
19EXPORT_SYMBOL(ioport_unmap); 19EXPORT_SYMBOL(ioport_unmap);
20 20
21/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
22void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
23{
24 resource_size_t start = pci_resource_start(dev, bar);
25 resource_size_t len = pci_resource_len(dev, bar);
26 unsigned long flags = pci_resource_flags(dev, bar);
27
28 if (!len || !start)
29 return NULL;
30 if (maxlen && len > maxlen)
31 len = maxlen;
32 if (flags & IORESOURCE_IO)
33 return ioport_map(start, len);
34 if (flags & IORESOURCE_MEM) {
35 if (flags & IORESOURCE_CACHEABLE)
36 return ioremap(start, len);
37 return ioremap_nocache(start, len);
38 }
39 /* What? */
40 return NULL;
41}
42
43void pci_iounmap(struct pci_dev *dev, void __iomem * addr) 21void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
44{ 22{
45 /* nothing to do */ 23 /* nothing to do */
46} 24}
47EXPORT_SYMBOL(pci_iomap);
48EXPORT_SYMBOL(pci_iounmap); 25EXPORT_SYMBOL(pci_iounmap);
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 70a0de46cd1b..11270ca22c0a 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -321,6 +321,7 @@ config PCI
321 bool "PCI support" 321 bool "PCI support"
322 default y 322 default y
323 select PCI_DOMAINS 323 select PCI_DOMAINS
324 select GENERIC_PCI_IOMAP
324 ---help--- 325 ---help---
325 Enable PCI root complex support, so PCIe endpoint devices can 326 Enable PCI root complex support, so PCIe endpoint devices can
326 be attached to the Tile chip. Many, but not all, PCI devices 327 be attached to the Tile chip. Many, but not all, PCI devices
diff --git a/arch/tile/include/asm/io.h b/arch/tile/include/asm/io.h
index c9ea1652af03..d2152deb1f3c 100644
--- a/arch/tile/include/asm/io.h
+++ b/arch/tile/include/asm/io.h
@@ -204,7 +204,8 @@ static inline long ioport_panic(void)
204 204
205static inline void __iomem *ioport_map(unsigned long port, unsigned int len) 205static inline void __iomem *ioport_map(unsigned long port, unsigned int len)
206{ 206{
207 return (void __iomem *) ioport_panic(); 207 pr_info("ioport_map: mapping IO resources is unsupported on tile.\n");
208 return NULL;
208} 209}
209 210
210static inline void ioport_unmap(void __iomem *addr) 211static inline void ioport_unmap(void __iomem *addr)
diff --git a/arch/tile/include/asm/pci.h b/arch/tile/include/asm/pci.h
index 7f03cefed1b9..1d25fea42e54 100644
--- a/arch/tile/include/asm/pci.h
+++ b/arch/tile/include/asm/pci.h
@@ -16,6 +16,7 @@
16#define _ASM_TILE_PCI_H 16#define _ASM_TILE_PCI_H
17 17
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <asm-generic/pci_iomap.h>
19 20
20/* 21/*
21 * Structure of a PCI controller (host bridge) 22 * Structure of a PCI controller (host bridge)
@@ -49,7 +50,6 @@ struct pci_controller {
49int __devinit tile_pci_init(void); 50int __devinit tile_pci_init(void);
50int __devinit pcibios_init(void); 51int __devinit pcibios_init(void);
51 52
52void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
53static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {} 53static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {}
54 54
55void __devinit pcibios_fixup_bus(struct pci_bus *bus); 55void __devinit pcibios_fixup_bus(struct pci_bus *bus);
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 9d610d3fb11e..25567934a21e 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -466,27 +466,6 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
466 return 0; 466 return 0;
467} 467}
468 468
469void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
470{
471 unsigned long start = pci_resource_start(dev, bar);
472 unsigned long len = pci_resource_len(dev, bar);
473 unsigned long flags = pci_resource_flags(dev, bar);
474
475 if (!len)
476 return NULL;
477 if (max && len > max)
478 len = max;
479
480 if (!(flags & IORESOURCE_MEM)) {
481 pr_info("PCI: Trying to map invalid resource %#lx\n", flags);
482 start = 0;
483 }
484
485 return (void __iomem *)start;
486}
487EXPORT_SYMBOL(pci_iomap);
488
489
490/**************************************************************** 469/****************************************************************
491 * 470 *
492 * Tile PCI config space read/write routines 471 * Tile PCI config space read/write routines
diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index 942ed6174f1d..eeb8054c7cd8 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -12,6 +12,7 @@ config UNICORE32
12 select GENERIC_IRQ_PROBE 12 select GENERIC_IRQ_PROBE
13 select GENERIC_IRQ_SHOW 13 select GENERIC_IRQ_SHOW
14 select ARCH_WANT_FRAME_POINTERS 14 select ARCH_WANT_FRAME_POINTERS
15 select GENERIC_IOMAP
15 help 16 help
16 UniCore-32 is 32-bit Instruction Set Architecture, 17 UniCore-32 is 32-bit Instruction Set Architecture,
17 including a series of low-power-consumption RISC chip 18 including a series of low-power-consumption RISC chip
@@ -30,9 +31,6 @@ config GENERIC_CLOCKEVENTS
30config GENERIC_CSUM 31config GENERIC_CSUM
31 def_bool y 32 def_bool y
32 33
33config GENERIC_IOMAP
34 def_bool y
35
36config NO_IOPORT 34config NO_IOPORT
37 bool 35 bool
38 36
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d6ddc0bfe36a..1a31254ceb83 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -78,6 +78,7 @@ config X86
78 select HAVE_BPF_JIT if (X86_64 && NET) 78 select HAVE_BPF_JIT if (X86_64 && NET)
79 select CLKEVT_I8253 79 select CLKEVT_I8253
80 select ARCH_HAVE_NMI_SAFE_CMPXCHG 80 select ARCH_HAVE_NMI_SAFE_CMPXCHG
81 select GENERIC_IOMAP
81 82
82config INSTRUCTION_DECODER 83config INSTRUCTION_DECODER
83 def_bool (KPROBES || PERF_EVENTS) 84 def_bool (KPROBES || PERF_EVENTS)
@@ -143,9 +144,6 @@ config NEED_SG_DMA_LENGTH
143config GENERIC_ISA_DMA 144config GENERIC_ISA_DMA
144 def_bool ISA_DMA_API 145 def_bool ISA_DMA_API
145 146
146config GENERIC_IOMAP
147 def_bool y
148
149config GENERIC_BUG 147config GENERIC_BUG
150 def_bool y 148 def_bool y
151 depends on BUG 149 depends on BUG
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index c2cf2eda0626..448303bdb85f 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -19,6 +19,8 @@
19#include <asm-generic/iomap.h> 19#include <asm-generic/iomap.h>
20#endif 20#endif
21 21
22#include <asm-generic/pci_iomap.h>
23
22#ifndef mmiowb 24#ifndef mmiowb
23#define mmiowb() do {} while (0) 25#define mmiowb() do {} while (0)
24#endif 26#endif
@@ -283,9 +285,7 @@ static inline void writesb(const void __iomem *addr, const void *buf, int len)
283#define __io_virt(x) ((void __force *) (x)) 285#define __io_virt(x) ((void __force *) (x))
284 286
285#ifndef CONFIG_GENERIC_IOMAP 287#ifndef CONFIG_GENERIC_IOMAP
286/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
287struct pci_dev; 288struct pci_dev;
288extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
289static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p) 289static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
290{ 290{
291} 291}
diff --git a/include/asm-generic/iomap.h b/include/asm-generic/iomap.h
index 98dcd76ce836..8a3d4fde2604 100644
--- a/include/asm-generic/iomap.h
+++ b/include/asm-generic/iomap.h
@@ -67,18 +67,15 @@ extern void ioport_unmap(void __iomem *);
67#endif 67#endif
68 68
69#ifdef CONFIG_PCI 69#ifdef CONFIG_PCI
70/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ 70/* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */
71struct pci_dev; 71struct pci_dev;
72extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
73extern void pci_iounmap(struct pci_dev *dev, void __iomem *); 72extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
74#else 73#else
75struct pci_dev; 74struct pci_dev;
76static inline void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
77{
78 return NULL;
79}
80static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) 75static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
81{ } 76{ }
82#endif 77#endif
83 78
79#include <asm-generic/pci_iomap.h>
80
84#endif 81#endif
diff --git a/include/asm-generic/pci_iomap.h b/include/asm-generic/pci_iomap.h
new file mode 100644
index 000000000000..8de4b73e19e2
--- /dev/null
+++ b/include/asm-generic/pci_iomap.h
@@ -0,0 +1,25 @@
1/* Generic I/O port emulation, based on MN10300 code
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11#ifndef __ASM_GENERIC_PCI_IOMAP_H
12#define __ASM_GENERIC_PCI_IOMAP_H
13
14struct pci_dev;
15#ifdef CONFIG_PCI
16/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
17extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
18#else
19static inline void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
20{
21 return NULL;
22}
23#endif
24
25#endif /* __ASM_GENERIC_IO_H */
diff --git a/lib/Kconfig b/lib/Kconfig
index f34be6417d71..7f6b8bca8c25 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -19,6 +19,13 @@ config RATIONAL
19config GENERIC_FIND_FIRST_BIT 19config GENERIC_FIND_FIRST_BIT
20 bool 20 bool
21 21
22config GENERIC_PCI_IOMAP
23 bool
24
25config GENERIC_IOMAP
26 bool
27 select GENERIC_PCI_IOMAP
28
22config CRC_CCITT 29config CRC_CCITT
23 tristate "CRC-CCITT functions" 30 tristate "CRC-CCITT functions"
24 help 31 help
diff --git a/lib/Makefile b/lib/Makefile
index c0ffaaff6534..884ed376164d 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -33,6 +33,7 @@ endif
33 33
34lib-$(CONFIG_HOTPLUG) += kobject_uevent.o 34lib-$(CONFIG_HOTPLUG) += kobject_uevent.o
35obj-$(CONFIG_GENERIC_IOMAP) += iomap.o 35obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
36obj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o
36obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o 37obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
37obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o 38obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
38obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o 39obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
diff --git a/lib/iomap.c b/lib/iomap.c
index 5dbcb4b2d864..ada922a808e6 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -242,45 +242,11 @@ EXPORT_SYMBOL(ioport_unmap);
242#endif /* CONFIG_HAS_IOPORT */ 242#endif /* CONFIG_HAS_IOPORT */
243 243
244#ifdef CONFIG_PCI 244#ifdef CONFIG_PCI
245/** 245/* Hide the details if this is a MMIO or PIO address space and just do what
246 * pci_iomap - create a virtual mapping cookie for a PCI BAR 246 * you expect in the correct way. */
247 * @dev: PCI device that owns the BAR
248 * @bar: BAR number
249 * @maxlen: length of the memory to map
250 *
251 * Using this function you will get a __iomem address to your device BAR.
252 * You can access it using ioread*() and iowrite*(). These functions hide
253 * the details if this is a MMIO or PIO address space and will just do what
254 * you expect from them in the correct way.
255 *
256 * @maxlen specifies the maximum length to map. If you want to get access to
257 * the complete BAR without checking for its length first, pass %0 here.
258 * */
259void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
260{
261 resource_size_t start = pci_resource_start(dev, bar);
262 resource_size_t len = pci_resource_len(dev, bar);
263 unsigned long flags = pci_resource_flags(dev, bar);
264
265 if (!len || !start)
266 return NULL;
267 if (maxlen && len > maxlen)
268 len = maxlen;
269 if (flags & IORESOURCE_IO)
270 return ioport_map(start, len);
271 if (flags & IORESOURCE_MEM) {
272 if (flags & IORESOURCE_CACHEABLE)
273 return ioremap(start, len);
274 return ioremap_nocache(start, len);
275 }
276 /* What? */
277 return NULL;
278}
279
280void pci_iounmap(struct pci_dev *dev, void __iomem * addr) 247void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
281{ 248{
282 IO_COND(addr, /* nothing */, iounmap(addr)); 249 IO_COND(addr, /* nothing */, iounmap(addr));
283} 250}
284EXPORT_SYMBOL(pci_iomap);
285EXPORT_SYMBOL(pci_iounmap); 251EXPORT_SYMBOL(pci_iounmap);
286#endif /* CONFIG_PCI */ 252#endif /* CONFIG_PCI */
diff --git a/lib/pci_iomap.c b/lib/pci_iomap.c
new file mode 100644
index 000000000000..4b0fdc22e688
--- /dev/null
+++ b/lib/pci_iomap.c
@@ -0,0 +1,48 @@
1/*
2 * Implement the default iomap interfaces
3 *
4 * (C) Copyright 2004 Linus Torvalds
5 */
6#include <linux/pci.h>
7#include <linux/io.h>
8
9#include <linux/export.h>
10
11#ifdef CONFIG_PCI
12/**
13 * pci_iomap - create a virtual mapping cookie for a PCI BAR
14 * @dev: PCI device that owns the BAR
15 * @bar: BAR number
16 * @maxlen: length of the memory to map
17 *
18 * Using this function you will get a __iomem address to your device BAR.
19 * You can access it using ioread*() and iowrite*(). These functions hide
20 * the details if this is a MMIO or PIO address space and will just do what
21 * you expect from them in the correct way.
22 *
23 * @maxlen specifies the maximum length to map. If you want to get access to
24 * the complete BAR without checking for its length first, pass %0 here.
25 * */
26void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
27{
28 resource_size_t start = pci_resource_start(dev, bar);
29 resource_size_t len = pci_resource_len(dev, bar);
30 unsigned long flags = pci_resource_flags(dev, bar);
31
32 if (!len || !start)
33 return NULL;
34 if (maxlen && len > maxlen)
35 len = maxlen;
36 if (flags & IORESOURCE_IO)
37 return ioport_map(start, len);
38 if (flags & IORESOURCE_MEM) {
39 if (flags & IORESOURCE_CACHEABLE)
40 return ioremap(start, len);
41 return ioremap_nocache(start, len);
42 }
43 /* What? */
44 return NULL;
45}
46
47EXPORT_SYMBOL(pci_iomap);
48#endif /* CONFIG_PCI */