Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146657
b: refs/heads/master
c: 0bb34a6
h: refs/heads/master
i:
  146655: d502694
v: v3
  • Loading branch information
Paul Mundt committed Apr 20, 2009
1 parent f68f456 commit f8d721b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 95 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 394b6d2fe624246e258a218dac68d44fe9a8411f
refs/heads/master: 0bb34a6bf1f71d5ad2abfda582a2c2794957bc7b
51 changes: 51 additions & 0 deletions trunk/arch/sh/drivers/pci/pci-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,57 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
vma->vm_page_prot);
}

static void __iomem *ioport_map_pci(struct pci_dev *dev,
unsigned long port, unsigned int nr)
{
struct pci_channel *chan = dev->sysdata;

if (!chan->io_map_base)
chan->io_map_base = generic_io_base;

return (void __iomem *)(chan->io_map_base + port);
}

void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
{
resource_size_t start = pci_resource_start(dev, bar);
resource_size_t len = pci_resource_len(dev, bar);
unsigned long flags = pci_resource_flags(dev, bar);

if (unlikely(!len || !start))
return NULL;
if (maxlen && len > maxlen)
len = maxlen;

if (flags & IORESOURCE_IO)
return ioport_map_pci(dev, start, len);

/*
* Presently the IORESOURCE_MEM case is a bit special, most
* SH7751 style PCI controllers have PCI memory at a fixed
* location in the address space where no remapping is desired.
* With the IORESOURCE_MEM case more care has to be taken
* to inhibit page table mapping for legacy cores, but this is
* punted off to __ioremap().
* -- PFM.
*/
if (flags & IORESOURCE_MEM) {
if (flags & IORESOURCE_CACHEABLE)
return ioremap(start, len);

return ioremap_nocache(start, len);
}

return NULL;
}
EXPORT_SYMBOL(pci_iomap);

void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
{
iounmap(addr);
}
EXPORT_SYMBOL(pci_iounmap);

#ifdef CONFIG_HOTPLUG
EXPORT_SYMBOL(pcibios_resource_to_bus);
EXPORT_SYMBOL(pcibios_bus_to_resource);
Expand Down
35 changes: 0 additions & 35 deletions trunk/arch/sh/drivers/pci/pci-new.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,39 +187,4 @@ void __init pcibios_update_irq(struct pci_dev *dev, int irq)
pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
}

void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
{
resource_size_t start = pci_resource_start(dev, bar);
resource_size_t len = pci_resource_len(dev, bar);
unsigned long flags = pci_resource_flags(dev, bar);

if (unlikely(!len || !start))
return NULL;
if (maxlen && len > maxlen)
len = maxlen;

/*
* Presently the IORESOURCE_MEM case is a bit special, most
* SH7751 style PCI controllers have PCI memory at a fixed
* location in the address space where no remapping is desired.
* With the IORESOURCE_MEM case more care has to be taken
* to inhibit page table mapping for legacy cores, but this is
* punted off to __ioremap().
* -- PFM.
*/
if (flags & IORESOURCE_IO)
return ioport_map(start, len);
if (flags & IORESOURCE_MEM)
return ioremap(start, len);

return NULL;
}
EXPORT_SYMBOL(pci_iomap);

void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
{
iounmap(addr);
}
EXPORT_SYMBOL(pci_iounmap);

EXPORT_SYMBOL(board_pci_channels);
35 changes: 0 additions & 35 deletions trunk/arch/sh/drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,39 +144,4 @@ void __init pcibios_update_irq(struct pci_dev *dev, int irq)
pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
}

void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
{
resource_size_t start = pci_resource_start(dev, bar);
resource_size_t len = pci_resource_len(dev, bar);
unsigned long flags = pci_resource_flags(dev, bar);

if (unlikely(!len || !start))
return NULL;
if (maxlen && len > maxlen)
len = maxlen;

/*
* Presently the IORESOURCE_MEM case is a bit special, most
* SH7751 style PCI controllers have PCI memory at a fixed
* location in the address space where no remapping is desired.
* With the IORESOURCE_MEM case more care has to be taken
* to inhibit page table mapping for legacy cores, but this is
* punted off to __ioremap().
* -- PFM.
*/
if (flags & IORESOURCE_IO)
return ioport_map(start, len);
if (flags & IORESOURCE_MEM)
return ioremap(start, len);

return NULL;
}
EXPORT_SYMBOL(pci_iomap);

void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
{
iounmap(addr);
}
EXPORT_SYMBOL(pci_iounmap);

EXPORT_SYMBOL(board_pci_channels);
22 changes: 2 additions & 20 deletions trunk/arch/sh/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ struct pci_channel {
int enabled;
unsigned long reg_base;
unsigned long io_base;

unsigned long io_map_base;
};

/*
Expand Down Expand Up @@ -110,31 +112,11 @@ static inline int __is_pci_memory(unsigned long phys_addr, unsigned long size)
}
return 0;
}

static inline void __iomem *__get_pci_io_base(unsigned long port,
unsigned long size)
{
struct pci_channel *p;
struct resource *res;

for (p = board_pci_channels; p->init; p++) {
res = p->io_resource;
if (p->enabled && (port >= res->start) &&
(port + size) <= (res->end + 1))
return (void __iomem *)(p->io_base + port);
}
return NULL;
}
#else
static inline int __is_pci_memory(unsigned long phys_addr, unsigned long size)
{
return 0;
}
static inline void __iomem *__get_pci_io_base(unsigned long port,
unsigned long size)
{
return NULL;
}
#endif

/* Board-specific fixup routines. */
Expand Down
4 changes: 0 additions & 4 deletions trunk/arch/sh/kernel/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ void __iomem *ioport_map(unsigned long port, unsigned int nr)
if (ret)
return ret;

ret = __get_pci_io_base(port, nr);
if (ret)
return ret;

return __ioport_map(port, nr);
}
EXPORT_SYMBOL(ioport_map);
Expand Down

0 comments on commit f8d721b

Please sign in to comment.