static void add_resources(struct pci_root_info *info, struct list_head *resources) { int i; struct resource *res, *root, *conflict; coalesce_windows(info, IORESOURCE_MEM); coalesce_windows(info, IORESOURCE_IO); for (i = 0; i < info->res_num; i++) { res = &info->res[i]; if (res->flags & IORESOURCE_MEM) root = &iomem_resource; else if (res->flags & IORESOURCE_IO) root = &ioport_resource; else continue; conflict = insert_resource_conflict(root, res); if (conflict) dev_info(&info->bridge->dev, "ignoring host bridge window %pR (conflicts with %s %pR)\n", res, conflict->name, conflict); else pci_add_resource_offset(resources, res, info->res_offset[i]); } }
static void __init pci_controller_apertures(struct pci_controller *pci_ctrl, struct list_head *resources) { struct resource *res; unsigned long io_offset; int i; io_offset = (unsigned long)pci_ctrl->io_space.base; res = &pci_ctrl->io_resource; if (!res->flags) { if (io_offset) printk (KERN_ERR "I/O resource not set for host" " bridge %d\n", pci_ctrl->index); res->start = 0; res->end = IO_SPACE_LIMIT; res->flags = IORESOURCE_IO; } res->start += io_offset; res->end += io_offset; pci_add_resource_offset(resources, res, io_offset); for (i = 0; i < 3; i++) { res = &pci_ctrl->mem_resources[i]; if (!res->flags) { if (i > 0) continue; printk(KERN_ERR "Memory resource not set for " "host bridge %d\n", pci_ctrl->index); res->start = 0; res->end = ~0U; res->flags = IORESOURCE_MEM; } pci_add_resource(resources, res); } }
/* * Initialization. Try all known PCI access methods. Note that we support * using both PCI BIOS and direct access: in such cases, we use I/O ports * to access config space, but we still keep BIOS order of cards to be * compatible with 2.0.X. This should go away some day. */ static int __init pcibios_init(void) { resource_size_t io_offset, mem_offset; LIST_HEAD(resources); struct pci_bus *bus; ioport_resource.start = 0xA0000000; ioport_resource.end = 0xDFFFFFFF; iomem_resource.start = 0xA0000000; iomem_resource.end = 0xDFFFFFFF; if (insert_resource(&iomem_resource, &pci_iomem_resource) < 0) panic("Unable to insert PCI IOMEM resource\n"); if (insert_resource(&ioport_resource, &pci_ioport_resource) < 0) panic("Unable to insert PCI IOPORT resource\n"); if (!pci_probe) return 0; if (pci_check_direct() < 0) { printk(KERN_WARNING "PCI: No PCI bus detected\n"); return 0; } printk(KERN_INFO "PCI: Probing PCI hardware [mempage %08x]\n", MEM_PAGING_REG); io_offset = pci_ioport_resource.start - (pci_ioport_resource.start & 0x00ffffff); mem_offset = pci_iomem_resource.start - ((pci_iomem_resource.start & 0x03ffffff) | MEM_PAGING_REG); pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset); pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset); bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources); if (!bus) return 0; pcibios_resource_survey(); pci_bus_add_devices(bus); return 0; }
static int __init pci_v3_setup_resources(struct pci_sys_data *sys) { if (request_resource(&iomem_resource, &non_mem)) { printk(KERN_ERR "PCI: unable to allocate non-prefetchable " "memory region\n"); return -EBUSY; } if (request_resource(&iomem_resource, &pre_mem)) { release_resource(&non_mem); printk(KERN_ERR "PCI: unable to allocate prefetchable " "memory region\n"); return -EBUSY; } /* * the mem resource for this bus * the prefetch mem resource for this bus */ pci_add_resource_offset(&sys->resources, &non_mem, sys->mem_offset); pci_add_resource_offset(&sys->resources, &pre_mem, sys->mem_offset); return 1; }
static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys) { struct pcie_port *pp; int index; if (nr >= num_pcie_ports) return 0; index = pcie_port_map[nr]; printk(KERN_INFO "PCI: bus%d uses PCIe port %d\n", sys->busnr, index); pp = kzalloc(sizeof(*pp), GFP_KERNEL); if (!pp) panic("PCIe: failed to allocate pcie_port data"); sys->private_data = pp; pp->root_bus_nr = sys->busnr; spin_lock_init(&pp->conf_lock); switch (index) { case 0: kirkwood_enable_pcie_clk("0"); pcie0_ioresources_init(pp); pci_ioremap_io(SZ_64K * sys->busnr, KIRKWOOD_PCIE_IO_PHYS_BASE); break; case 1: kirkwood_enable_pcie_clk("1"); pcie1_ioresources_init(pp); pci_ioremap_io(SZ_64K * sys->busnr, KIRKWOOD_PCIE1_IO_PHYS_BASE); break; default: panic("PCIe setup: invalid controller %d", index); } if (request_resource(&iomem_resource, &pp->res)) panic("Request PCIe%d Memory resource failed\n", index); pci_add_resource_offset(&sys->resources, &pp->res, sys->mem_offset); /* * Generic PCIe unit setup. */ orion_pcie_set_local_bus_nr(pp->base, sys->busnr); orion_pcie_setup(pp->base); return 1; }
static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys) { struct pcie_port *pp; if (nr >= num_pcie_ports) return 0; pp = &pcie_port[nr]; sys->private_data = pp; pp->root_bus_nr = sys->busnr; /* * Generic PCIe unit setup. */ orion_pcie_set_local_bus_nr(pp->base, sys->busnr); orion_pcie_setup(pp->base); if (pp->index == 0) pci_ioremap_io(sys->busnr * SZ_64K, DOVE_PCIE0_IO_PHYS_BASE); else pci_ioremap_io(sys->busnr * SZ_64K, DOVE_PCIE1_IO_PHYS_BASE); /* * IORESOURCE_MEM */ snprintf(pp->mem_space_name, sizeof(pp->mem_space_name), "PCIe %d MEM", pp->index); pp->mem_space_name[sizeof(pp->mem_space_name) - 1] = 0; pp->res.name = pp->mem_space_name; if (pp->index == 0) { pp->res.start = DOVE_PCIE0_MEM_PHYS_BASE; pp->res.end = pp->res.start + DOVE_PCIE0_MEM_SIZE - 1; } else { pp->res.start = DOVE_PCIE1_MEM_PHYS_BASE; pp->res.end = pp->res.start + DOVE_PCIE1_MEM_SIZE - 1; } pp->res.flags = IORESOURCE_MEM; if (request_resource(&iomem_resource, &pp->res)) panic("Request PCIe Memory resource failed\n"); pci_add_resource_offset(&sys->resources, &pp->res, sys->mem_offset); return 1; }
static int __init mv78xx0_pcie_setup(int nr, struct pci_sys_data *sys) { struct pcie_port *pp; if (nr >= num_pcie_ports) return 0; pp = &pcie_port[nr]; sys->private_data = pp; pp->root_bus_nr = sys->busnr; /* * Generic PCIe unit setup. */ orion_pcie_set_local_bus_nr(pp->base, sys->busnr); orion_pcie_setup(pp->base); pci_ioremap_io(nr * SZ_64K, MV78XX0_PCIE_IO_PHYS_BASE(nr)); pci_add_resource_offset(&sys->resources, &pp->res, sys->mem_offset); return 1; }
void pci_add_resource(struct list_head *resources, struct resource *res) { pci_add_resource_offset(resources, res, 0); }