sh/PCI: get rid of device resource fixups
Tell the PCI core about host bridge address translation so it can take care of bus-to-resource conversion for us. CC: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
Родитель
6c5705fec6
Коммит
7fa6a50eb3
|
@ -37,11 +37,20 @@ static void __devinit pcibios_scanbus(struct pci_channel *hose)
|
|||
static int next_busno;
|
||||
static int need_domain_info;
|
||||
LIST_HEAD(resources);
|
||||
struct resource *res;
|
||||
resource_size_t offset;
|
||||
int i;
|
||||
struct pci_bus *bus;
|
||||
|
||||
for (i = 0; i < hose->nr_resources; i++)
|
||||
pci_add_resource(&resources, hose->resources + i);
|
||||
for (i = 0; i < hose->nr_resources; i++) {
|
||||
res = hose->resources + i;
|
||||
offset = 0;
|
||||
if (res->flags & IORESOURCE_IO)
|
||||
offset = hose->io_offset;
|
||||
else if (res->flags & IORESOURCE_MEM)
|
||||
offset = hose->mem_offset;
|
||||
pci_add_resource_offset(&resources, res, offset);
|
||||
}
|
||||
|
||||
bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
|
||||
&resources);
|
||||
|
@ -143,42 +152,12 @@ static int __init pcibios_init(void)
|
|||
}
|
||||
subsys_initcall(pcibios_init);
|
||||
|
||||
static void pcibios_fixup_device_resources(struct pci_dev *dev,
|
||||
struct pci_bus *bus)
|
||||
{
|
||||
/* Update device resources. */
|
||||
struct pci_channel *hose = bus->sysdata;
|
||||
unsigned long offset = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
|
||||
if (!dev->resource[i].start)
|
||||
continue;
|
||||
if (dev->resource[i].flags & IORESOURCE_IO)
|
||||
offset = hose->io_offset;
|
||||
else if (dev->resource[i].flags & IORESOURCE_MEM)
|
||||
offset = hose->mem_offset;
|
||||
|
||||
dev->resource[i].start += offset;
|
||||
dev->resource[i].end += offset;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called after each bus is probed, but before its children
|
||||
* are examined.
|
||||
*/
|
||||
void __devinit pcibios_fixup_bus(struct pci_bus *bus)
|
||||
{
|
||||
struct pci_dev *dev;
|
||||
struct list_head *ln;
|
||||
|
||||
for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
|
||||
dev = pci_dev_b(ln);
|
||||
|
||||
if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
|
||||
pcibios_fixup_device_resources(dev, bus);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -208,36 +187,6 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
|
|||
return start;
|
||||
}
|
||||
|
||||
void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
|
||||
struct resource *res)
|
||||
{
|
||||
struct pci_channel *hose = dev->sysdata;
|
||||
unsigned long offset = 0;
|
||||
|
||||
if (res->flags & IORESOURCE_IO)
|
||||
offset = hose->io_offset;
|
||||
else if (res->flags & IORESOURCE_MEM)
|
||||
offset = hose->mem_offset;
|
||||
|
||||
region->start = res->start - offset;
|
||||
region->end = res->end - offset;
|
||||
}
|
||||
|
||||
void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
|
||||
struct pci_bus_region *region)
|
||||
{
|
||||
struct pci_channel *hose = dev->sysdata;
|
||||
unsigned long offset = 0;
|
||||
|
||||
if (res->flags & IORESOURCE_IO)
|
||||
offset = hose->io_offset;
|
||||
else if (res->flags & IORESOURCE_MEM)
|
||||
offset = hose->mem_offset;
|
||||
|
||||
res->start = region->start + offset;
|
||||
res->end = region->end + offset;
|
||||
}
|
||||
|
||||
int pcibios_enable_device(struct pci_dev *dev, int mask)
|
||||
{
|
||||
return pci_enable_resources(dev, mask);
|
||||
|
@ -381,8 +330,6 @@ EXPORT_SYMBOL(pci_iounmap);
|
|||
#endif /* CONFIG_GENERIC_IOMAP */
|
||||
|
||||
#ifdef CONFIG_HOTPLUG
|
||||
EXPORT_SYMBOL(pcibios_resource_to_bus);
|
||||
EXPORT_SYMBOL(pcibios_bus_to_resource);
|
||||
EXPORT_SYMBOL(PCIBIOS_MIN_IO);
|
||||
EXPORT_SYMBOL(PCIBIOS_MIN_MEM);
|
||||
#endif
|
||||
|
|
|
@ -114,11 +114,7 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
|
|||
/* Board-specific fixup routines. */
|
||||
int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin);
|
||||
|
||||
extern void pcibios_resource_to_bus(struct pci_dev *dev,
|
||||
struct pci_bus_region *region, struct resource *res);
|
||||
|
||||
extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
|
||||
struct pci_bus_region *region);
|
||||
#define ARCH_HAS_GENERIC_PCI_OFFSETS
|
||||
|
||||
#define pci_domain_nr(bus) ((struct pci_channel *)(bus)->sysdata)->index
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче