diff options
author | Magnus Damm <magnus.damm@gmail.com> | 2008-02-19 07:35:31 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-04-16 03:00:14 -0400 |
commit | 8ce0143b11cdc519b8e1fd94a262b654ef0bc3ab (patch) | |
tree | 912403b5b8b853ca1479e95590ac2fd057de0030 | |
parent | ef339f241b08a16af58897e6288ba200e0c7a8c7 (diff) |
sh: pci io port base address code
Adds a __get_pci_io_base() function which is used to match a port range
against struct pci_channel. This allows us to detect if a port range is
assigned to pci or happens to be legacy port io. While at it, remove unused
cpu-specific cruft.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r-- | arch/sh/drivers/pci/ops-rts7751r2d.c | 1 | ||||
-rw-r--r-- | arch/sh/include/asm/pci.h | 47 | ||||
-rw-r--r-- | arch/sh/kernel/io.c | 5 |
3 files changed, 25 insertions, 28 deletions
diff --git a/arch/sh/drivers/pci/ops-rts7751r2d.c b/arch/sh/drivers/pci/ops-rts7751r2d.c index fe5a231b8669..58ed1d58cffb 100644 --- a/arch/sh/drivers/pci/ops-rts7751r2d.c +++ b/arch/sh/drivers/pci/ops-rts7751r2d.c | |||
@@ -68,7 +68,6 @@ static struct sh4_pci_address_map sh7751_pci_map = { | |||
68 | 68 | ||
69 | int __init pcibios_init_platform(void) | 69 | int __init pcibios_init_platform(void) |
70 | { | 70 | { |
71 | __set_io_port_base(SH7751_PCI_IO_BASE); | ||
72 | return sh7751_pcic_init(&board_pci_channels[0], &sh7751_pci_map); | 71 | return sh7751_pcic_init(&board_pci_channels[0], &sh7751_pci_map); |
73 | } | 72 | } |
74 | 73 | ||
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h index ccf5c5ff62ff..bb2c2fcddc9e 100644 --- a/arch/sh/include/asm/pci.h +++ b/arch/sh/include/asm/pci.h | |||
@@ -38,33 +38,6 @@ extern struct pci_channel board_pci_channels[]; | |||
38 | #define PCIBIOS_MIN_IO __PCI_CHAN(bus)->io_resource->start | 38 | #define PCIBIOS_MIN_IO __PCI_CHAN(bus)->io_resource->start |
39 | #define PCIBIOS_MIN_MEM __PCI_CHAN(bus)->mem_resource->start | 39 | #define PCIBIOS_MIN_MEM __PCI_CHAN(bus)->mem_resource->start |
40 | 40 | ||
41 | /* | ||
42 | * I/O routine helpers | ||
43 | */ | ||
44 | #if defined(CONFIG_CPU_SUBTYPE_SH7780) || defined(CONFIG_CPU_SUBTYPE_SH7785) | ||
45 | #define PCI_IO_AREA 0xFE400000 | ||
46 | #define PCI_IO_SIZE 0x00400000 | ||
47 | #elif defined(CONFIG_CPU_SH5) | ||
48 | extern unsigned long PCI_IO_AREA; | ||
49 | #define PCI_IO_SIZE 0x00010000 | ||
50 | #else | ||
51 | #define PCI_IO_AREA 0xFE240000 | ||
52 | #define PCI_IO_SIZE 0x00040000 | ||
53 | #endif | ||
54 | |||
55 | #define PCI_MEM_SIZE 0x01000000 | ||
56 | |||
57 | #define SH4_PCIIOBR_MASK 0xFFFC0000 | ||
58 | #define pci_ioaddr(addr) (PCI_IO_AREA + (addr & ~SH4_PCIIOBR_MASK)) | ||
59 | |||
60 | #if defined(CONFIG_PCI) | ||
61 | #define is_pci_ioaddr(port) \ | ||
62 | (((port) >= PCIBIOS_MIN_IO) && \ | ||
63 | ((port) < (PCIBIOS_MIN_IO + PCI_IO_SIZE))) | ||
64 | #else | ||
65 | #define is_pci_ioaddr(port) (0) | ||
66 | #endif | ||
67 | |||
68 | struct pci_dev; | 41 | struct pci_dev; |
69 | 42 | ||
70 | extern void pcibios_set_master(struct pci_dev *dev); | 43 | extern void pcibios_set_master(struct pci_dev *dev); |
@@ -137,11 +110,31 @@ static inline int __is_pci_memory(unsigned long phys_addr, unsigned long size) | |||
137 | } | 110 | } |
138 | return 0; | 111 | return 0; |
139 | } | 112 | } |
113 | |||
114 | static inline void __iomem *__get_pci_io_base(unsigned long port, | ||
115 | unsigned long size) | ||
116 | { | ||
117 | struct pci_channel *p; | ||
118 | struct resource *res; | ||
119 | |||
120 | for (p = board_pci_channels; p->init; p++) { | ||
121 | res = p->io_resource; | ||
122 | if (p->enabled && (port >= res->start) && | ||
123 | (port + size) <= (res->end + 1)) | ||
124 | return (void __iomem *)(p->io_base + port); | ||
125 | } | ||
126 | return NULL; | ||
127 | } | ||
140 | #else | 128 | #else |
141 | static inline int __is_pci_memory(unsigned long phys_addr, unsigned long size) | 129 | static inline int __is_pci_memory(unsigned long phys_addr, unsigned long size) |
142 | { | 130 | { |
143 | return 0; | 131 | return 0; |
144 | } | 132 | } |
133 | static inline void __iomem *__get_pci_io_base(unsigned long port, | ||
134 | unsigned long size) | ||
135 | { | ||
136 | return NULL; | ||
137 | } | ||
145 | #endif | 138 | #endif |
146 | 139 | ||
147 | /* Board-specific fixup routines. */ | 140 | /* Board-specific fixup routines. */ |
diff --git a/arch/sh/kernel/io.c b/arch/sh/kernel/io.c index 29cf4588fc05..59fb020718a3 100644 --- a/arch/sh/kernel/io.c +++ b/arch/sh/kernel/io.c | |||
@@ -12,6 +12,7 @@ | |||
12 | * for more details. | 12 | * for more details. |
13 | */ | 13 | */ |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/pci.h> | ||
15 | #include <asm/machvec.h> | 16 | #include <asm/machvec.h> |
16 | #include <asm/io.h> | 17 | #include <asm/io.h> |
17 | 18 | ||
@@ -69,6 +70,10 @@ void __iomem *ioport_map(unsigned long port, unsigned int nr) | |||
69 | if (ret) | 70 | if (ret) |
70 | return ret; | 71 | return ret; |
71 | 72 | ||
73 | ret = __get_pci_io_base(port, nr); | ||
74 | if (ret) | ||
75 | return ret; | ||
76 | |||
72 | return __ioport_map(port, nr); | 77 | return __ioport_map(port, nr); |
73 | } | 78 | } |
74 | EXPORT_SYMBOL(ioport_map); | 79 | EXPORT_SYMBOL(ioport_map); |