Skip to content

Commit 8ce0143

Browse files
papadammpmundt
authored andcommitted
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>
1 parent ef339f2 commit 8ce0143

3 files changed

Lines changed: 25 additions & 28 deletions

File tree

‎arch/sh/drivers/pci/ops-rts7751r2d.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ static struct sh4_pci_address_map sh7751_pci_map = {
6868

6969
int __init pcibios_init_platform(void)
7070
{
71-
__set_io_port_base(SH7751_PCI_IO_BASE);
7271
return sh7751_pcic_init(&board_pci_channels[0], &sh7751_pci_map);
7372
}
7473

‎arch/sh/include/asm/pci.h‎

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,6 @@ extern struct pci_channel board_pci_channels[];
3838
#define PCIBIOS_MIN_IO __PCI_CHAN(bus)->io_resource->start
3939
#define PCIBIOS_MIN_MEM __PCI_CHAN(bus)->mem_resource->start
4040

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-
6841
struct pci_dev;
6942

7043
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)
137110
}
138111
return 0;
139112
}
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+
}
140128
#else
141129
static inline int __is_pci_memory(unsigned long phys_addr, unsigned long size)
142130
{
143131
return 0;
144132
}
133+
static inline void __iomem *__get_pci_io_base(unsigned long port,
134+
unsigned long size)
135+
{
136+
return NULL;
137+
}
145138
#endif
146139

147140
/* Board-specific fixup routines. */

‎arch/sh/kernel/io.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* for more details.
1313
*/
1414
#include <linux/module.h>
15+
#include <linux/pci.h>
1516
#include <asm/machvec.h>
1617
#include <asm/io.h>
1718

@@ -69,6 +70,10 @@ void __iomem *ioport_map(unsigned long port, unsigned int nr)
6970
if (ret)
7071
return ret;
7172

73+
ret = __get_pci_io_base(port, nr);
74+
if (ret)
75+
return ret;
76+
7277
return __ioport_map(port, nr);
7378
}
7479
EXPORT_SYMBOL(ioport_map);

0 commit comments

Comments
 (0)