Lines Matching +full:bus +full:- +full:range
1 // SPDX-License-Identifier: GPL-2.0-or-later
12 * Common pmac/prep/chrp pci routines. -- Cort
36 #include <asm/pci-bridge.h>
39 #include <asm/ppc-pci.h>
75 int ret, phb_id = -1; in get_phb_number()
81 * the respective device-tree properties. Firstly, try powernv by in get_phb_number()
82 * reading "ibm,opal-phbid", only present in OPAL environment. in get_phb_number()
84 ret = of_property_read_u64(dn, "ibm,opal-phbid", &prop); in get_phb_number()
91 phb_id = (int)(prop & (MAX_PHBS - 1)); in get_phb_number()
116 phb->global_number = get_phb_number(dev); in pcibios_alloc_controller()
117 list_add_tail(&phb->list_node, &hose_list); in pcibios_alloc_controller()
119 phb->dn = dev; in pcibios_alloc_controller()
120 phb->is_dynamic = slab_is_available(); in pcibios_alloc_controller()
140 if (phb->global_number < MAX_PHBS) in pcibios_free_controller()
141 clear_bit(phb->global_number, phb_bitmap); in pcibios_free_controller()
143 list_del(&phb->list_node); in pcibios_free_controller()
146 if (phb->is_dynamic) in pcibios_free_controller()
158 * The callback occurs when all references to the root bus
162 * which is associated with the 'struct pci_controller.bus'
163 * (root bus) - it expects .release_data to hold a pointer
179 bridge->release_data; in pcibios_free_controller_deferred()
181 pr_debug("domain %d, dynamic %d\n", phb->global_number, phb->is_dynamic); in pcibios_free_controller_deferred()
193 resource_size_t pcibios_window_alignment(struct pci_bus *bus, in pcibios_window_alignment() argument
196 struct pci_controller *phb = pci_bus_to_host(bus); in pcibios_window_alignment()
198 if (phb->controller_ops.window_alignment) in pcibios_window_alignment()
199 return phb->controller_ops.window_alignment(bus, type); in pcibios_window_alignment()
209 void pcibios_setup_bridge(struct pci_bus *bus, unsigned long type) in pcibios_setup_bridge() argument
211 struct pci_controller *hose = pci_bus_to_host(bus); in pcibios_setup_bridge()
213 if (hose->controller_ops.setup_bridge) in pcibios_setup_bridge()
214 hose->controller_ops.setup_bridge(bus, type); in pcibios_setup_bridge()
219 struct pci_controller *phb = pci_bus_to_host(dev->bus); in pcibios_reset_secondary_bus()
221 if (phb->controller_ops.reset_secondary_bus) { in pcibios_reset_secondary_bus()
222 phb->controller_ops.reset_secondary_bus(dev); in pcibios_reset_secondary_bus()
267 return hose->pci_io_size; in pcibios_io_size()
269 return resource_size(&hose->io_resource); in pcibios_io_size()
282 if (address >= hose->io_base_virt && in pcibios_vaddr_is_ioport()
283 address < (hose->io_base_virt + size)) { in pcibios_vaddr_is_ioport()
301 if (address >= hose->io_base_phys && in pci_address_to_pio()
302 address < (hose->io_base_phys + size)) { in pci_address_to_pio()
304 (unsigned long)hose->io_base_virt - _IO_BASE; in pci_address_to_pio()
305 ret = base + (address - hose->io_base_phys); in pci_address_to_pio()
316 * Return the domain number for this bus.
318 int pci_domain_nr(struct pci_bus *bus) in pci_domain_nr() argument
320 struct pci_controller *hose = pci_bus_to_host(bus); in pci_domain_nr()
322 return hose->global_number; in pci_domain_nr()
327 * PCI bus numbers have not yet been assigned, and you need to
338 if (hose->dn == node) in pci_find_hose_for_OF_device()
340 node = node->parent; in pci_find_hose_for_OF_device()
350 if (hose->global_number == domain_nr) in pci_find_controller_for_domain()
367 /* Try to get a mapping from the device-tree */ in pci_read_irq_line()
380 return -1; in pci_read_irq_line()
382 return -1; in pci_read_irq_line()
385 return -1; in pci_read_irq_line()
397 return -1; in pci_read_irq_line()
402 pci_dev->irq = virq; in pci_read_irq_line()
408 * Platform support for /proc/bus/pci/X/Y mmap()s.
409 * -- paulus.
413 struct pci_controller *hose = pci_bus_to_host(pdev->bus); in pci_iobar_pfn()
417 return -EINVAL; in pci_iobar_pfn()
420 ioaddr -= (unsigned long)hose->io_base_virt - _IO_BASE; in pci_iobar_pfn()
422 vma->vm_pgoff += (ioaddr + hose->io_base_phys) >> PAGE_SHIFT; in pci_iobar_pfn()
447 struct resource *rp = &pdev->resource[i]; in pci_phys_mem_access_prot()
448 int flags = rp->flags; in pci_phys_mem_access_prot()
453 /* In the range of this resource? */ in pci_phys_mem_access_prot()
454 if (offset < (rp->start & PAGE_MASK) || in pci_phys_mem_access_prot()
455 offset > rp->end) in pci_phys_mem_access_prot()
464 if (found->flags & IORESOURCE_PREFETCH) in pci_phys_mem_access_prot()
469 pr_debug("PCI: Non-PCI map for %llx, prot: %lx\n", in pci_phys_mem_access_prot()
475 /* This provides legacy IO read access on a bus */
476 int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val, size_t size) in pci_legacy_read() argument
479 struct pci_controller *hose = pci_bus_to_host(bus); in pci_legacy_read()
480 struct resource *rp = &hose->io_resource; in pci_legacy_read()
483 /* Check if port can be supported by that bus. We only check in pci_legacy_read()
484 * the ranges of the PHB though, not the bus itself as the rules in pci_legacy_read()
488 offset = (unsigned long)hose->io_base_virt - _IO_BASE; in pci_legacy_read()
491 if (!(rp->flags & IORESOURCE_IO)) in pci_legacy_read()
492 return -ENXIO; in pci_legacy_read()
493 if (offset < rp->start || (offset + size) > rp->end) in pci_legacy_read()
494 return -ENXIO; in pci_legacy_read()
495 addr = hose->io_base_virt + port; in pci_legacy_read()
503 return -EINVAL; in pci_legacy_read()
508 return -EINVAL; in pci_legacy_read()
512 return -EINVAL; in pci_legacy_read()
515 /* This provides legacy IO write access on a bus */
516 int pci_legacy_write(struct pci_bus *bus, loff_t port, u32 val, size_t size) in pci_legacy_write() argument
519 struct pci_controller *hose = pci_bus_to_host(bus); in pci_legacy_write()
520 struct resource *rp = &hose->io_resource; in pci_legacy_write()
523 /* Check if port can be supported by that bus. We only check in pci_legacy_write()
524 * the ranges of the PHB though, not the bus itself as the rules in pci_legacy_write()
528 offset = (unsigned long)hose->io_base_virt - _IO_BASE; in pci_legacy_write()
531 if (!(rp->flags & IORESOURCE_IO)) in pci_legacy_write()
532 return -ENXIO; in pci_legacy_write()
533 if (offset < rp->start || (offset + size) > rp->end) in pci_legacy_write()
534 return -ENXIO; in pci_legacy_write()
535 addr = hose->io_base_virt + port; in pci_legacy_write()
548 return -EINVAL; in pci_legacy_write()
553 return -EINVAL; in pci_legacy_write()
557 return -EINVAL; in pci_legacy_write()
560 /* This provides legacy IO or memory mmap access on a bus */
561 int pci_mmap_legacy_page_range(struct pci_bus *bus, in pci_mmap_legacy_page_range() argument
565 struct pci_controller *hose = pci_bus_to_host(bus); in pci_mmap_legacy_page_range()
567 ((resource_size_t)vma->vm_pgoff) << PAGE_SHIFT; in pci_mmap_legacy_page_range()
568 resource_size_t size = vma->vm_end - vma->vm_start; in pci_mmap_legacy_page_range()
572 pci_domain_nr(bus), bus->number, in pci_mmap_legacy_page_range()
575 (unsigned long long)(offset + size - 1)); in pci_mmap_legacy_page_range()
585 if ((offset + size) > hose->isa_mem_size) { in pci_mmap_legacy_page_range()
587 "Process %s (pid:%d) mapped non-existing PCI legacy memory for 0%04x:%02x\n", in pci_mmap_legacy_page_range()
588 current->comm, current->pid, pci_domain_nr(bus), bus->number); in pci_mmap_legacy_page_range()
589 if (vma->vm_flags & VM_SHARED) in pci_mmap_legacy_page_range()
593 offset += hose->isa_mem_phys; in pci_mmap_legacy_page_range()
595 unsigned long io_offset = (unsigned long)hose->io_base_virt - _IO_BASE; in pci_mmap_legacy_page_range()
597 rp = &hose->io_resource; in pci_mmap_legacy_page_range()
598 if (!(rp->flags & IORESOURCE_IO)) in pci_mmap_legacy_page_range()
599 return -ENXIO; in pci_mmap_legacy_page_range()
600 if (roffset < rp->start || (roffset + size) > rp->end) in pci_mmap_legacy_page_range()
601 return -ENXIO; in pci_mmap_legacy_page_range()
602 offset += hose->io_base_phys; in pci_mmap_legacy_page_range()
604 pr_debug(" -> mapping phys %llx\n", (unsigned long long)offset); in pci_mmap_legacy_page_range()
606 vma->vm_pgoff = offset >> PAGE_SHIFT; in pci_mmap_legacy_page_range()
607 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); in pci_mmap_legacy_page_range()
608 return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, in pci_mmap_legacy_page_range()
609 vma->vm_end - vma->vm_start, in pci_mmap_legacy_page_range()
610 vma->vm_page_prot); in pci_mmap_legacy_page_range()
619 if (rsrc->flags & IORESOURCE_IO) { in pci_resource_to_user()
620 pcibios_resource_to_bus(dev->bus, ®ion, in pci_resource_to_user()
631 * That means we may have 64-bit values where some apps only expect in pci_resource_to_user()
632 * 32 (like X itself since it thinks only Sparc has 64-bit MMIO). in pci_resource_to_user()
634 *start = rsrc->start; in pci_resource_to_user()
635 *end = rsrc->end; in pci_resource_to_user()
639 * pci_process_bridge_OF_ranges - Parse PCI bridge resources from device tree
642 * @primary: set if primary bus (32 bits only, soon to be deprecated)
651 * - We can only cope with one IO space range and up to 3 Memory space
655 * - Some busses have IO space not starting at 0, which causes trouble with
659 * - Some 32 bits platforms such as 4xx can have physical space larger than
667 struct of_pci_range range; in pci_process_bridge_OF_ranges() local
678 for_each_of_pci_range(&parser, &range) { in pci_process_bridge_OF_ranges()
679 /* If we failed translation or got a zero-sized region in pci_process_bridge_OF_ranges()
684 if (range.cpu_addr == OF_BAD_ADDR || range.size == 0) in pci_process_bridge_OF_ranges()
689 switch (range.flags & IORESOURCE_TYPE_BITS) { in pci_process_bridge_OF_ranges()
692 " IO 0x%016llx..0x%016llx -> 0x%016llx\n", in pci_process_bridge_OF_ranges()
693 range.cpu_addr, range.cpu_addr + range.size - 1, in pci_process_bridge_OF_ranges()
694 range.pci_addr); in pci_process_bridge_OF_ranges()
696 /* We support only one IO range */ in pci_process_bridge_OF_ranges()
697 if (hose->pci_io_size) { in pci_process_bridge_OF_ranges()
699 " \\--> Skipped (too many) !\n"); in pci_process_bridge_OF_ranges()
704 if (range.size > 0x01000000) in pci_process_bridge_OF_ranges()
705 range.size = 0x01000000; in pci_process_bridge_OF_ranges()
708 hose->io_base_virt = ioremap(range.cpu_addr, in pci_process_bridge_OF_ranges()
709 range.size); in pci_process_bridge_OF_ranges()
714 (unsigned long)hose->io_base_virt; in pci_process_bridge_OF_ranges()
719 hose->pci_io_size = range.pci_addr + range.size; in pci_process_bridge_OF_ranges()
720 hose->io_base_phys = range.cpu_addr - range.pci_addr; in pci_process_bridge_OF_ranges()
723 res = &hose->io_resource; in pci_process_bridge_OF_ranges()
724 range.cpu_addr = range.pci_addr; in pci_process_bridge_OF_ranges()
728 " MEM 0x%016llx..0x%016llx -> 0x%016llx %s\n", in pci_process_bridge_OF_ranges()
729 range.cpu_addr, range.cpu_addr + range.size - 1, in pci_process_bridge_OF_ranges()
730 range.pci_addr, in pci_process_bridge_OF_ranges()
731 (range.flags & IORESOURCE_PREFETCH) ? in pci_process_bridge_OF_ranges()
737 " \\--> Skipped (too many) !\n"); in pci_process_bridge_OF_ranges()
741 if (range.pci_addr == 0) { in pci_process_bridge_OF_ranges()
743 isa_mem_base = range.cpu_addr; in pci_process_bridge_OF_ranges()
744 hose->isa_mem_phys = range.cpu_addr; in pci_process_bridge_OF_ranges()
745 hose->isa_mem_size = range.size; in pci_process_bridge_OF_ranges()
749 hose->mem_offset[memno] = range.cpu_addr - in pci_process_bridge_OF_ranges()
750 range.pci_addr; in pci_process_bridge_OF_ranges()
751 res = &hose->mem_resources[memno++]; in pci_process_bridge_OF_ranges()
755 res->name = dev->full_name; in pci_process_bridge_OF_ranges()
756 res->flags = range.flags; in pci_process_bridge_OF_ranges()
757 res->start = range.cpu_addr; in pci_process_bridge_OF_ranges()
758 res->end = range.cpu_addr + range.size - 1; in pci_process_bridge_OF_ranges()
759 res->parent = res->child = res->sibling = NULL; in pci_process_bridge_OF_ranges()
765 int pci_proc_domain(struct pci_bus *bus) in pci_proc_domain() argument
767 struct pci_controller *hose = pci_bus_to_host(bus); in pci_proc_domain()
772 return hose->global_number != 0; in pci_proc_domain()
789 struct pci_controller *hose = pci_bus_to_host(dev->bus); in pcibios_fixup_resources()
798 if (dev->is_virtfn) in pcibios_fixup_resources()
802 struct resource *res = dev->resource + i; in pcibios_fixup_resources()
804 if (!res->flags) in pcibios_fixup_resources()
807 /* If we're going to re-assign everything, we mark all resources in pcibios_fixup_resources()
808 * as unset (and 0-base them). In addition, we mark BARs starting in pcibios_fixup_resources()
810 * since in that case, we don't want to re-assign anything in pcibios_fixup_resources()
812 pcibios_resource_to_bus(dev->bus, ®, res); in pcibios_fixup_resources()
815 /* Only print message if not re-assigning */ in pcibios_fixup_resources()
819 res->end -= res->start; in pcibios_fixup_resources()
820 res->start = 0; in pcibios_fixup_resources()
821 res->flags |= IORESOURCE_UNSET; in pcibios_fixup_resources()
837 * as Apple "closed" bridge resources and bare-metal pSeries unassigned bridges
839 static int pcibios_uninitialized_bridge_resource(struct pci_bus *bus, in pcibios_uninitialized_bridge_resource() argument
842 struct pci_controller *hose = pci_bus_to_host(bus); in pcibios_uninitialized_bridge_resource()
843 struct pci_dev *dev = bus->self; in pcibios_uninitialized_bridge_resource()
854 if (res->flags & IORESOURCE_MEM) { in pcibios_uninitialized_bridge_resource()
855 pcibios_resource_to_bus(dev->bus, ®ion, res); in pcibios_uninitialized_bridge_resource()
857 /* If the BAR is non-0 then it's probably been initialized */ in pcibios_uninitialized_bridge_resource()
873 if ((hose->mem_resources[i].flags & IORESOURCE_MEM) && in pcibios_uninitialized_bridge_resource()
874 hose->mem_resources[i].start == hose->mem_offset[i]) in pcibios_uninitialized_bridge_resource()
883 /* If the BAR is non-0, then we consider it assigned */ in pcibios_uninitialized_bridge_resource()
884 offset = (unsigned long)hose->io_base_virt - _IO_BASE; in pcibios_uninitialized_bridge_resource()
885 if (((res->start - offset) & 0xfffffffful) != 0) in pcibios_uninitialized_bridge_resource()
889 * starting at low addresses -is- valid. What we do instead if that in pcibios_uninitialized_bridge_resource()
904 /* Fixup resources of a PCI<->PCI bridge */
905 static void pcibios_fixup_bridge(struct pci_bus *bus) in pcibios_fixup_bridge() argument
910 struct pci_dev *dev = bus->self; in pcibios_fixup_bridge()
912 pci_bus_for_each_resource(bus, res, i) { in pcibios_fixup_bridge()
913 if (!res || !res->flags) in pcibios_fixup_bridge()
915 if (i >= 3 && bus->self->transparent) in pcibios_fixup_bridge()
923 res->flags |= IORESOURCE_UNSET; in pcibios_fixup_bridge()
924 res->start = 0; in pcibios_fixup_bridge()
925 res->end = -1; in pcibios_fixup_bridge()
929 pr_debug("PCI:%s Bus rsrc %d %pR\n", pci_name(dev), i, res); in pcibios_fixup_bridge()
932 * and clear them out so they get re-assigned later in pcibios_fixup_bridge()
934 if (pcibios_uninitialized_bridge_resource(bus, res)) { in pcibios_fixup_bridge()
935 res->flags = 0; in pcibios_fixup_bridge()
941 void pcibios_setup_bus_self(struct pci_bus *bus) in pcibios_setup_bus_self() argument
945 /* Fix up the bus resources for P2P bridges */ in pcibios_setup_bus_self()
946 if (bus->self != NULL) in pcibios_setup_bus_self()
947 pcibios_fixup_bridge(bus); in pcibios_setup_bus_self()
949 /* Platform specific bus fixups. This is currently only used in pcibios_setup_bus_self()
953 ppc_md.pcibios_fixup_bus(bus); in pcibios_setup_bus_self()
955 /* Setup bus DMA mappings */ in pcibios_setup_bus_self()
956 phb = pci_bus_to_host(bus); in pcibios_setup_bus_self()
957 if (phb->controller_ops.dma_bus_setup) in pcibios_setup_bus_self()
958 phb->controller_ops.dma_bus_setup(bus); in pcibios_setup_bus_self()
967 set_dev_node(&dev->dev, pcibus_to_node(dev->bus)); in pcibios_bus_add_device()
970 set_dma_ops(&dev->dev, pci_dma_ops); in pcibios_bus_add_device()
971 dev->dev.archdata.dma_offset = PCI_DRAM_OFFSET; in pcibios_bus_add_device()
974 phb = pci_bus_to_host(dev->bus); in pcibios_bus_add_device()
975 if (phb->controller_ops.dma_dev_setup) in pcibios_bus_add_device()
976 phb->controller_ops.dma_dev_setup(dev); in pcibios_bus_add_device()
999 /* No special bus mastering setup handling */ in pcibios_set_master()
1002 void pcibios_fixup_bus(struct pci_bus *bus) in pcibios_fixup_bus() argument
1004 /* When called from the generic PCI probe, read PCI<->PCI bridge in pcibios_fixup_bus()
1005 * bases. This is -not- called when generating the PCI tree from in pcibios_fixup_bus()
1006 * the OF device-tree. in pcibios_fixup_bus()
1008 pci_read_bridge_bases(bus); in pcibios_fixup_bus()
1010 /* Now fixup the bus bus */ in pcibios_fixup_bus()
1011 pcibios_setup_bus_self(bus); in pcibios_fixup_bus()
1018 !(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA)) in skip_isa_ioresource_align()
1026 * addresses to be allocated in the 0x000-0x0ff region
1030 * the low 10 bits of the IO address. The 0x00-0xff region
1032 * bits, so it's ok to allocate at, say, 0x2800-0x28ff,
1033 * but we want to try to avoid allocating at 0x2900-0x2bff
1034 * which might have be mirrored at 0x0100-0x03ff..
1040 resource_size_t start = res->start; in pcibios_align_resource()
1042 if (res->flags & IORESOURCE_IO) { in pcibios_align_resource()
1063 for (pp = &parent->child; (p = *pp) != NULL; pp = &p->sibling) { in reparent_resources()
1064 if (p->end < res->start) in reparent_resources()
1066 if (res->end < p->start) in reparent_resources()
1068 if (p->start < res->start || p->end > res->end) in reparent_resources()
1069 return -1; /* not completely contained */ in reparent_resources()
1074 return -1; /* didn't find any conflicting entries? */ in reparent_resources()
1075 res->parent = parent; in reparent_resources()
1076 res->child = *firstpp; in reparent_resources()
1077 res->sibling = *pp; in reparent_resources()
1080 for (p = res->child; p != NULL; p = p->sibling) { in reparent_resources()
1081 p->parent = res; in reparent_resources()
1083 p->name, p, res->name); in reparent_resources()
1091 * On the other hand, we cannot just re-allocate all devices, as it would
1097 * - I/O or memory regions not configured
1098 * - regions configured, but not enabled in the command register
1099 * - bogus I/O addresses above 64K used
1100 * - expansion ROMs left enabled (this may sound harmless, but given
1106 * (1) Allocate resources for all buses behind PCI-to-PCI bridges.
1121 static void pcibios_allocate_bus_resources(struct pci_bus *bus) in pcibios_allocate_bus_resources() argument
1127 pr_debug("PCI: Allocating bus resources for %04x:%02x...\n", in pcibios_allocate_bus_resources()
1128 pci_domain_nr(bus), bus->number); in pcibios_allocate_bus_resources()
1130 pci_bus_for_each_resource(bus, res, i) { in pcibios_allocate_bus_resources()
1131 if (!res || !res->flags || res->start > res->end || res->parent) in pcibios_allocate_bus_resources()
1135 if (res->flags & IORESOURCE_UNSET) in pcibios_allocate_bus_resources()
1138 if (bus->parent == NULL) in pcibios_allocate_bus_resources()
1139 pr = (res->flags & IORESOURCE_IO) ? in pcibios_allocate_bus_resources()
1142 pr = pci_find_parent_resource(bus->self, res); in pcibios_allocate_bus_resources()
1146 * bridge is transparent -- paulus in pcibios_allocate_bus_resources()
1152 pr_debug("PCI: %s (bus %d) bridge rsrc %d: %pR, parent %p (%s)\n", in pcibios_allocate_bus_resources()
1153 bus->self ? pci_name(bus->self) : "PHB", bus->number, in pcibios_allocate_bus_resources()
1154 i, res, pr, (pr && pr->name) ? pr->name : "nil"); in pcibios_allocate_bus_resources()
1156 if (pr && !(pr->flags & IORESOURCE_UNSET)) { in pcibios_allocate_bus_resources()
1157 struct pci_dev *dev = bus->self; in pcibios_allocate_bus_resources()
1175 i, bus->number); in pcibios_allocate_bus_resources()
1183 res->start = 0; in pcibios_allocate_bus_resources()
1184 res->end = -1; in pcibios_allocate_bus_resources()
1185 res->flags = 0; in pcibios_allocate_bus_resources()
1188 list_for_each_entry(b, &bus->children, node) in pcibios_allocate_bus_resources()
1194 struct resource *pr, *r = &dev->resource[idx]; in alloc_resource()
1200 if (!pr || (pr->flags & IORESOURCE_UNSET) || in alloc_resource()
1207 r->flags |= IORESOURCE_UNSET; in alloc_resource()
1208 r->end -= r->start; in alloc_resource()
1209 r->start = 0; in alloc_resource()
1223 r = &dev->resource[idx]; in pcibios_allocate_resources()
1224 if (r->parent) /* Already allocated */ in pcibios_allocate_resources()
1226 if (!r->flags || (r->flags & IORESOURCE_UNSET)) in pcibios_allocate_resources()
1233 if (r->flags & IORESOURCE_IO) in pcibios_allocate_resources()
1242 r = &dev->resource[PCI_ROM_RESOURCE]; in pcibios_allocate_resources()
1243 if (r->flags) { in pcibios_allocate_resources()
1248 pci_read_config_dword(dev, dev->rom_base_reg, ®); in pcibios_allocate_resources()
1252 r->flags &= ~IORESOURCE_ROM_ENABLE; in pcibios_allocate_resources()
1253 pci_write_config_dword(dev, dev->rom_base_reg, in pcibios_allocate_resources()
1260 static void __init pcibios_reserve_legacy_regions(struct pci_bus *bus) in pcibios_reserve_legacy_regions() argument
1262 struct pci_controller *hose = pci_bus_to_host(bus); in pcibios_reserve_legacy_regions()
1267 pr_debug("Reserving legacy ranges for domain %04x\n", pci_domain_nr(bus)); in pcibios_reserve_legacy_regions()
1270 if (!(hose->io_resource.flags & IORESOURCE_IO)) in pcibios_reserve_legacy_regions()
1272 offset = (unsigned long)hose->io_base_virt - _IO_BASE; in pcibios_reserve_legacy_regions()
1275 res->name = "Legacy IO"; in pcibios_reserve_legacy_regions()
1276 res->flags = IORESOURCE_IO; in pcibios_reserve_legacy_regions()
1277 res->start = offset; in pcibios_reserve_legacy_regions()
1278 res->end = (offset + 0xfff) & 0xfffffffful; in pcibios_reserve_legacy_regions()
1280 if (request_resource(&hose->io_resource, res)) { in pcibios_reserve_legacy_regions()
1283 pci_domain_nr(bus), bus->number, res); in pcibios_reserve_legacy_regions()
1290 pres = &hose->mem_resources[i]; in pcibios_reserve_legacy_regions()
1291 offset = hose->mem_offset[i]; in pcibios_reserve_legacy_regions()
1292 if (!(pres->flags & IORESOURCE_MEM)) in pcibios_reserve_legacy_regions()
1295 if ((pres->start - offset) <= 0xa0000 && in pcibios_reserve_legacy_regions()
1296 (pres->end - offset) >= 0xbffff) in pcibios_reserve_legacy_regions()
1303 res->name = "Legacy VGA memory"; in pcibios_reserve_legacy_regions()
1304 res->flags = IORESOURCE_MEM; in pcibios_reserve_legacy_regions()
1305 res->start = 0xa0000 + offset; in pcibios_reserve_legacy_regions()
1306 res->end = 0xbffff + offset; in pcibios_reserve_legacy_regions()
1311 pci_domain_nr(bus), bus->number, res); in pcibios_reserve_legacy_regions()
1330 * bus available resources to avoid allocating things on top of them in pcibios_resource_survey()
1348 * rest of the code later, for now, keep it as-is as our main
1349 * resource allocation function doesn't deal with sub-trees yet.
1351 void pcibios_claim_one_bus(struct pci_bus *bus) in pcibios_claim_one_bus() argument
1356 list_for_each_entry(dev, &bus->devices, bus_list) { in pcibios_claim_one_bus()
1360 struct resource *r = &dev->resource[i]; in pcibios_claim_one_bus()
1362 if (r->parent || !r->start || !r->flags) in pcibios_claim_one_bus()
1375 list_for_each_entry(child_bus, &bus->children, node) in pcibios_claim_one_bus()
1384 * added to a bus, this include calling it for a PHB that is just
1387 void pcibios_finish_adding_to_bus(struct pci_bus *bus) in pcibios_finish_adding_to_bus() argument
1389 pr_debug("PCI: Finishing adding to hotplug bus %04x:%02x\n", in pcibios_finish_adding_to_bus()
1390 pci_domain_nr(bus), bus->number); in pcibios_finish_adding_to_bus()
1392 /* Allocate bus and devices resources */ in pcibios_finish_adding_to_bus()
1393 pcibios_allocate_bus_resources(bus); in pcibios_finish_adding_to_bus()
1394 pcibios_claim_one_bus(bus); in pcibios_finish_adding_to_bus()
1396 if (bus->self) in pcibios_finish_adding_to_bus()
1397 pci_assign_unassigned_bridge_resources(bus->self); in pcibios_finish_adding_to_bus()
1399 pci_assign_unassigned_bus_resources(bus); in pcibios_finish_adding_to_bus()
1403 pci_bus_add_devices(bus); in pcibios_finish_adding_to_bus()
1409 struct pci_controller *phb = pci_bus_to_host(dev->bus); in pcibios_enable_device()
1411 if (phb->controller_ops.enable_device_hook) in pcibios_enable_device()
1412 if (!phb->controller_ops.enable_device_hook(dev)) in pcibios_enable_device()
1413 return -EINVAL; in pcibios_enable_device()
1420 struct pci_controller *phb = pci_bus_to_host(dev->bus); in pcibios_disable_device()
1422 if (phb->controller_ops.disable_device) in pcibios_disable_device()
1423 phb->controller_ops.disable_device(dev); in pcibios_disable_device()
1428 return (unsigned long) hose->io_base_virt - _IO_BASE; in pcibios_io_space_offset()
1439 res = &hose->io_resource; in pcibios_setup_phb_resources()
1441 if (!res->flags) { in pcibios_setup_phb_resources()
1444 hose->dn, hose->global_number); in pcibios_setup_phb_resources()
1455 res = &hose->mem_resources[i]; in pcibios_setup_phb_resources()
1456 if (!res->flags) in pcibios_setup_phb_resources()
1459 offset = hose->mem_offset[i]; in pcibios_setup_phb_resources()
1479 null_read_config(struct pci_bus *bus, unsigned int devfn, int offset, in null_read_config() argument
1486 null_write_config(struct pci_bus *bus, unsigned int devfn, int offset, in null_write_config() argument
1505 static struct pci_bus bus; in fake_pci_bus() local
1508 printk(KERN_ERR "Can't find hose for PCI bus %d!\n", busnr); in fake_pci_bus()
1510 bus.number = busnr; in fake_pci_bus()
1511 bus.sysdata = hose; in fake_pci_bus()
1512 bus.ops = hose? hose->ops: &null_pci_ops; in fake_pci_bus()
1513 return &bus; in fake_pci_bus()
1517 int early_##rw##_config_##size(struct pci_controller *hose, int bus, \
1520 return pci_bus_##rw##_config_##size(fake_pci_bus(hose, bus), \
1531 int early_find_capability(struct pci_controller *hose, int bus, int devfn, in EARLY_PCI_OP()
1534 return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap); in EARLY_PCI_OP()
1537 struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) in pcibios_get_phb_of_node() argument
1539 struct pci_controller *hose = bus->sysdata; in pcibios_get_phb_of_node()
1541 return of_node_get(hose->dn); in pcibios_get_phb_of_node()
1545 * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
1551 struct pci_bus *bus; in pcibios_scan_phb() local
1552 struct device_node *node = hose->dn; in pcibios_scan_phb()
1560 /* Wire up PHB bus resources */ in pcibios_scan_phb()
1563 hose->busn.start = hose->first_busno; in pcibios_scan_phb()
1564 hose->busn.end = hose->last_busno; in pcibios_scan_phb()
1565 hose->busn.flags = IORESOURCE_BUS; in pcibios_scan_phb()
1566 pci_add_resource(&resources, &hose->busn); in pcibios_scan_phb()
1568 /* Create an empty bus for the toplevel */ in pcibios_scan_phb()
1569 bus = pci_create_root_bus(hose->parent, hose->first_busno, in pcibios_scan_phb()
1570 hose->ops, hose, &resources); in pcibios_scan_phb()
1571 if (bus == NULL) { in pcibios_scan_phb()
1572 pr_err("Failed to create bus for PCI domain %04x\n", in pcibios_scan_phb()
1573 hose->global_number); in pcibios_scan_phb()
1577 hose->bus = bus; in pcibios_scan_phb()
1581 if (node && hose->controller_ops.probe_mode) in pcibios_scan_phb()
1582 mode = hose->controller_ops.probe_mode(bus); in pcibios_scan_phb()
1585 of_scan_bus(node, bus); in pcibios_scan_phb()
1588 pci_bus_update_busn_res_end(bus, 255); in pcibios_scan_phb()
1589 hose->last_busno = pci_scan_child_bus(bus); in pcibios_scan_phb()
1590 pci_bus_update_busn_res_end(bus, hose->last_busno); in pcibios_scan_phb()
1600 if (bus && !pci_has_flag(PCI_PROBE_ONLY)) { in pcibios_scan_phb()
1602 list_for_each_entry(child, &bus->children, node) in pcibios_scan_phb()
1610 int i, class = dev->class >> 8; in fixup_hide_host_resource_fsl()
1612 int prog_if = dev->class & 0xf; in fixup_hide_host_resource_fsl()
1616 (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) && in fixup_hide_host_resource_fsl()
1618 (dev->bus->parent == NULL)) { in fixup_hide_host_resource_fsl()
1620 dev->resource[i].start = 0; in fixup_hide_host_resource_fsl()
1621 dev->resource[i].end = 0; in fixup_hide_host_resource_fsl()
1622 dev->resource[i].flags = 0; in fixup_hide_host_resource_fsl()