Skip to content

Commit 645b302

Browse files
committed
ARM: pxa/sa1100: move I/O space to PCI_IOBASE
PXA and StrongARM1100 traditionally map their I/O space 1:1 into virtual memory, using a per-bus io_offset that matches the base address of the ioremap mapping. In order for PXA to work in a multiplatform config, this needs to change so I/O space starts at PCI_IOBASE (0xfee00000). Since the pcmcia soc_common support is shared with StrongARM1100, both have to change at the same time. The affected machines are: - Anything with a PCMCIA slot now uses pci_remap_iospace, which is made available to PCMCIA configurations as well, rather than just PCI. The first PCMCIA slot now starts at port number 0x10000. - The Zeus and Viper platforms have PC/104-style ISA buses, which have a static mapping for both I/O and memory space at 0xf1000000, which can no longer work. It does not appear to have any in-tree users, so moving it to port number 0 makes them behave like a traditional PC. - SA1100 does support ISA slots in theory, but all machines that originally enabled this appear to have been removed from the tree ages ago, and the I/O space is never mapped anywhere. - The Nanoengine machine has support for PCI slots, but looks like this never included I/O space, the resources only define the location for memory and config space. With this, the definitions of __io() and IO_SPACE_LIMIT can be simplified, as the only remaining cases are the generic PCI_IOBASE and the custom inb()/outb() macros on RiscPC. S3C24xx still has a custom inb()/outb() in this here, but this is already removed in another branch. Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 5414bea commit 645b302

File tree

6 files changed

+39
-33
lines changed

6 files changed

+39
-33
lines changed

arch/arm/include/asm/io.h

+4-23
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static inline void __iomem *__typesafe_io(unsigned long addr)
174174
#define PCI_IO_VIRT_BASE 0xfee00000
175175
#define PCI_IOBASE ((void __iomem *)PCI_IO_VIRT_BASE)
176176

177-
#if defined(CONFIG_PCI)
177+
#if defined(CONFIG_PCI) || IS_ENABLED(CONFIG_PCMCIA)
178178
void pci_ioremap_set_mem_type(int mem_type);
179179
#else
180180
static inline void pci_ioremap_set_mem_type(int mem_type) {}
@@ -200,32 +200,13 @@ void __iomem *pci_remap_cfgspace(resource_size_t res_cookie, size_t size);
200200
*/
201201
#ifdef CONFIG_NEED_MACH_IO_H
202202
#include <mach/io.h>
203-
#elif defined(CONFIG_PCI)
204-
#define IO_SPACE_LIMIT ((resource_size_t)0xfffff)
205-
#define __io(a) __typesafe_io(PCI_IO_VIRT_BASE + ((a) & IO_SPACE_LIMIT))
206203
#else
207-
#define __io(a) __typesafe_io((a) & IO_SPACE_LIMIT)
208-
#endif
209-
210-
/*
211-
* This is the limit of PC card/PCI/ISA IO space, which is by default
212-
* 64K if we have PC card, PCI or ISA support. Otherwise, default to
213-
* zero to prevent ISA/PCI drivers claiming IO space (and potentially
214-
* oopsing.)
215-
*
216-
* Only set this larger if you really need inb() et.al. to operate over
217-
* a larger address space. Note that SOC_COMMON ioremaps each sockets
218-
* IO space area, and so inb() et.al. must be defined to operate as per
219-
* readb() et.al. on such platforms.
220-
*/
221-
#ifndef IO_SPACE_LIMIT
222-
#if defined(CONFIG_PCMCIA_SOC_COMMON) || defined(CONFIG_PCMCIA_SOC_COMMON_MODULE)
223-
#define IO_SPACE_LIMIT ((resource_size_t)0xffffffff)
224-
#elif defined(CONFIG_PCI) || defined(CONFIG_ISA) || defined(CONFIG_PCCARD)
225-
#define IO_SPACE_LIMIT ((resource_size_t)0xffff)
204+
#if IS_ENABLED(CONFIG_PCMCIA) || defined(CONFIG_PCI)
205+
#define IO_SPACE_LIMIT ((resource_size_t)0xfffff)
226206
#else
227207
#define IO_SPACE_LIMIT ((resource_size_t)0)
228208
#endif
209+
#define __io(a) __typesafe_io(PCI_IO_VIRT_BASE + ((a) & IO_SPACE_LIMIT))
229210
#endif
230211

231212
/*

arch/arm/mach-pxa/viper.c

+12
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,18 @@ static struct map_desc viper_io_desc[] __initdata = {
998998
.length = 0x00800000,
999999
.type = MT_DEVICE,
10001000
},
1001+
{
1002+
/*
1003+
* ISA I/O space mapping:
1004+
* - ports 0x0000-0x0fff are PC/104
1005+
* - ports 0x10000-0x10fff are PCMCIA slot 1
1006+
* - ports 0x11000-0x11fff are PC/104
1007+
*/
1008+
.virtual = PCI_IO_VIRT_BASE,
1009+
.pfn = __phys_to_pfn(0x30000000),
1010+
.length = 0x1000,
1011+
.type = MT_DEVICE,
1012+
},
10011013
};
10021014

10031015
static void __init viper_map_io(void)

arch/arm/mach-pxa/zeus.c

+12
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,18 @@ static struct map_desc zeus_io_desc[] __initdata = {
929929
.length = 0x00800000,
930930
.type = MT_DEVICE,
931931
},
932+
{
933+
/*
934+
* ISA I/O space mapping:
935+
* - ports 0x0000-0x0fff are PC/104
936+
* - ports 0x10000-0x10fff are PCMCIA slot 1
937+
* - ports 0x11000-0x11fff are PC/104
938+
*/
939+
.virtual = PCI_IO_VIRT_BASE,
940+
.pfn = __phys_to_pfn(ZEUS_PC104IO_PHYS),
941+
.length = 0x1000,
942+
.type = MT_DEVICE,
943+
},
932944
};
933945

934946
static void __init zeus_map_io(void)

arch/arm/mm/ioremap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ void iounmap(volatile void __iomem *cookie)
455455
}
456456
EXPORT_SYMBOL(iounmap);
457457

458-
#ifdef CONFIG_PCI
458+
#if defined(CONFIG_PCI) || IS_ENABLED(CONFIG_PCMCIA)
459459
static int pci_ioremap_mem_type = MT_DEVICE;
460460

461461
void pci_ioremap_set_mem_type(int mem_type)

drivers/pcmcia/soc_common.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include <linux/regulator/consumer.h>
4747
#include <linux/spinlock.h>
4848
#include <linux/timer.h>
49+
#include <linux/pci.h>
4950

5051
#include "soc_common.h"
5152

@@ -782,8 +783,7 @@ void soc_pcmcia_remove_one(struct soc_pcmcia_socket *skt)
782783
/* should not be required; violates some lowlevel drivers */
783784
soc_common_pcmcia_config_skt(skt, &dead_socket);
784785

785-
iounmap(skt->virt_io);
786-
skt->virt_io = NULL;
786+
iounmap(PCI_IOBASE + skt->res_io_io.start);
787787
release_resource(&skt->res_attr);
788788
release_resource(&skt->res_mem);
789789
release_resource(&skt->res_io);
@@ -816,11 +816,12 @@ int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt)
816816
if (ret)
817817
goto out_err_4;
818818

819-
skt->virt_io = ioremap(skt->res_io.start, 0x10000);
820-
if (skt->virt_io == NULL) {
821-
ret = -ENOMEM;
819+
skt->res_io_io = (struct resource)
820+
DEFINE_RES_IO_NAMED(skt->nr * 0x1000 + 0x10000, 0x1000,
821+
"PCMCIA I/O");
822+
ret = pci_remap_iospace(&skt->res_io_io, skt->res_io.start);
823+
if (ret)
822824
goto out_err_5;
823-
}
824825

825826
/*
826827
* We initialize default socket timing here, because
@@ -838,7 +839,7 @@ int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt)
838839
skt->socket.resource_ops = &pccard_static_ops;
839840
skt->socket.irq_mask = 0;
840841
skt->socket.map_size = PAGE_SIZE;
841-
skt->socket.io_offset = (unsigned long)skt->virt_io;
842+
skt->socket.io_offset = (unsigned long)skt->res_io_io.start;
842843

843844
skt->status = soc_common_pcmcia_skt_state(skt);
844845

@@ -872,7 +873,7 @@ int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt)
872873
out_err_7:
873874
soc_pcmcia_hw_shutdown(skt);
874875
out_err_6:
875-
iounmap(skt->virt_io);
876+
iounmap(PCI_IOBASE + skt->res_io_io.start);
876877
out_err_5:
877878
release_resource(&skt->res_attr);
878879
out_err_4:

include/pcmcia/soc_common.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ struct soc_pcmcia_socket {
4646

4747
struct resource res_skt;
4848
struct resource res_io;
49+
struct resource res_io_io;
4950
struct resource res_mem;
5051
struct resource res_attr;
51-
void __iomem *virt_io;
5252

5353
struct {
5454
int gpio;

0 commit comments

Comments
 (0)