Lines Matching +full:iommu +full:- +full:map +full:- +full:mask
1 // SPDX-License-Identifier: GPL-2.0
41 volatile int pci_poke_cpu = -1;
62 pci_poke_cpu = -1; in pci_config_read8()
84 pci_poke_cpu = -1; in pci_config_read16()
106 pci_poke_cpu = -1; in pci_config_read32()
127 pci_poke_cpu = -1; in pci_config_write8()
146 pci_poke_cpu = -1; in pci_config_write16()
165 pci_poke_cpu = -1; in pci_config_write32()
201 /* The of_device layer has translated all of the assigned-address properties
213 addrs = of_get_property(node, "assigned-addresses", &proplen); in pci_parse_of_addrs()
219 op_res = &op->resource[0]; in pci_parse_of_addrs()
220 for (; proplen >= 20; proplen -= 20, addrs += 5, op_res++) { in pci_parse_of_addrs()
231 op_res->start, op_res->end, i); in pci_parse_of_addrs()
234 res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2]; in pci_parse_of_addrs()
235 } else if (i == dev->rom_base_reg) { in pci_parse_of_addrs()
236 res = &dev->resource[PCI_ROM_RESOURCE]; in pci_parse_of_addrs()
242 res->start = op_res->start; in pci_parse_of_addrs()
243 res->end = op_res->end; in pci_parse_of_addrs()
244 res->flags = flags; in pci_parse_of_addrs()
245 res->name = pci_name(dev); in pci_parse_of_addrs()
251 static void pci_init_dev_archdata(struct dev_archdata *sd, void *iommu, in pci_init_dev_archdata() argument
256 sd->iommu = iommu; in pci_init_dev_archdata()
257 sd->stc = stc; in pci_init_dev_archdata()
258 sd->host_controller = host_controller; in pci_init_dev_archdata()
259 sd->op = op; in pci_init_dev_archdata()
260 sd->numa_node = numa_node; in pci_init_dev_archdata()
277 sd = &dev->dev.archdata; in of_create_pci_dev()
278 pci_init_dev_archdata(sd, pbm->iommu, &pbm->stc, pbm, op, in of_create_pci_dev()
279 pbm->numa_node); in of_create_pci_dev()
280 sd = &op->dev.archdata; in of_create_pci_dev()
281 sd->iommu = pbm->iommu; in of_create_pci_dev()
282 sd->stc = &pbm->stc; in of_create_pci_dev()
283 sd->numa_node = pbm->numa_node; in of_create_pci_dev()
292 dev->sysdata = node; in of_create_pci_dev()
293 dev->dev.parent = bus->bridge; in of_create_pci_dev()
294 dev->dev.bus = &pci_bus_type; in of_create_pci_dev()
295 dev->dev.of_node = of_node_get(node); in of_create_pci_dev()
296 dev->devfn = devfn; in of_create_pci_dev()
297 dev->multifunction = 0; /* maybe a lie? */ in of_create_pci_dev()
301 dev->vendor = of_getintprop_default(node, "vendor-id", 0xffff); in of_create_pci_dev()
302 dev->device = of_getintprop_default(node, "device-id", 0xffff); in of_create_pci_dev()
303 dev->subsystem_vendor = in of_create_pci_dev()
304 of_getintprop_default(node, "subsystem-vendor-id", 0); in of_create_pci_dev()
305 dev->subsystem_device = in of_create_pci_dev()
306 of_getintprop_default(node, "subsystem-id", 0); in of_create_pci_dev()
308 dev->cfg_size = pci_cfg_space_size(dev); in of_create_pci_dev()
317 dev->class = class >> 8; in of_create_pci_dev()
318 dev->revision = class & 0xff; in of_create_pci_dev()
320 dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(bus), in of_create_pci_dev()
321 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn)); in of_create_pci_dev()
327 if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE) in of_create_pci_dev()
330 dev->current_state = PCI_UNKNOWN; /* unknown power state */ in of_create_pci_dev()
331 dev->error_state = pci_channel_io_normal; in of_create_pci_dev()
332 dev->dma_mask = 0xffffffff; in of_create_pci_dev()
335 /* a PCI-PCI bridge */ in of_create_pci_dev()
336 dev->hdr_type = PCI_HEADER_TYPE_BRIDGE; in of_create_pci_dev()
337 dev->rom_base_reg = PCI_ROM_ADDRESS1; in of_create_pci_dev()
339 dev->hdr_type = PCI_HEADER_TYPE_CARDBUS; in of_create_pci_dev()
341 dev->hdr_type = PCI_HEADER_TYPE_NORMAL; in of_create_pci_dev()
342 dev->rom_base_reg = PCI_ROM_ADDRESS; in of_create_pci_dev()
344 dev->irq = sd->op->archdata.irqs[0]; in of_create_pci_dev()
345 if (dev->irq == 0xffffffff) in of_create_pci_dev()
346 dev->irq = PCI_IRQ_NONE; in of_create_pci_dev()
350 dev->vendor, dev->device, dev->hdr_type, dev->class); in of_create_pci_dev()
352 pci_parse_of_addrs(sd->op, node, dev); in of_create_pci_dev()
362 static void apb_calc_first_last(u8 map, u32 *first_p, u32 *last_p) in apb_calc_first_last() argument
369 if ((map & (1 << idx)) != 0) { in apb_calc_first_last()
391 u8 map; in apb_fake_ranges() local
393 pci_read_config_byte(dev, APB_IO_ADDRESS_MAP, &map); in apb_fake_ranges()
394 apb_calc_first_last(map, &first, &last); in apb_fake_ranges()
395 res = bus->resource[0]; in apb_fake_ranges()
396 res->flags = IORESOURCE_IO; in apb_fake_ranges()
398 region.end = (last << 21) + ((1 << 21) - 1); in apb_fake_ranges()
399 pcibios_bus_to_resource(dev->bus, res, ®ion); in apb_fake_ranges()
401 pci_read_config_byte(dev, APB_MEM_ADDRESS_MAP, &map); in apb_fake_ranges()
402 apb_calc_first_last(map, &first, &last); in apb_fake_ranges()
403 res = bus->resource[1]; in apb_fake_ranges()
404 res->flags = IORESOURCE_MEM; in apb_fake_ranges()
406 region.end = (last << 29) + ((1 << 29) - 1); in apb_fake_ranges()
407 pcibios_bus_to_resource(dev->bus, res, ®ion); in apb_fake_ranges()
431 /* parse bus-range property */ in of_scan_pci_bridge()
432 busrange = of_get_property(node, "bus-range", &len); in of_scan_pci_bridge()
434 pci_info(dev, "Can't get bus-range for PCI-PCI bridge %pOF\n", in of_scan_pci_bridge()
440 pci_info(dev, " Bridge bus range [%u --> %u]\n", in of_scan_pci_bridge()
451 bus = pci_add_new_bus(dev->bus, dev, busrange[0]); in of_scan_pci_bridge()
458 bus->primary = dev->bus->number; in of_scan_pci_bridge()
460 bus->bridge_ctl = 0; in of_scan_pci_bridge()
467 /* PCI #address-cells == 3 and #size-cells == 2 always */ in of_scan_pci_bridge()
468 res = &dev->resource[PCI_BRIDGE_RESOURCES]; in of_scan_pci_bridge()
469 for (i = 0; i < PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES; ++i) { in of_scan_pci_bridge()
470 res->flags = 0; in of_scan_pci_bridge()
471 bus->resource[i] = res; in of_scan_pci_bridge()
482 for (; len >= 32; len -= 32, ranges += 8) { in of_scan_pci_bridge()
496 /* On PCI-Express systems, PCI bridges that have no devices downstream in of_scan_pci_bridge()
497 * have a bogus size value where the first 32-bit cell is 0xffffffff. in of_scan_pci_bridge()
507 res = bus->resource[0]; in of_scan_pci_bridge()
508 if (res->flags) { in of_scan_pci_bridge()
514 if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) { in of_scan_pci_bridge()
519 res = bus->resource[i]; in of_scan_pci_bridge()
523 res->flags = flags; in of_scan_pci_bridge()
525 region.end = region.start + size - 1; in of_scan_pci_bridge()
531 pcibios_bus_to_resource(dev->bus, res, ®ion); in of_scan_pci_bridge()
534 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus), in of_scan_pci_bridge()
535 bus->number); in of_scan_pci_bridge()
537 pci_info(dev, " bus name: %s\n", bus->name); in of_scan_pci_bridge()
553 node, bus->number); in pci_of_scan_bus()
555 prev_devfn = -1; in pci_of_scan_bus()
579 pci_info(dev, "dev header type: %x\n", dev->hdr_type); in pci_of_scan_bus()
593 dp = pdev->dev.of_node; in show_pciobppath_attr()
606 list_for_each_entry(dev, &bus->devices, bus_list) { in pci_bus_register_of_sysfs()
614 err = sysfs_create_file(&dev->dev.kobj, &dev_attr_obppath.attr); in pci_bus_register_of_sysfs()
617 list_for_each_entry(child_bus, &bus->children, node) in pci_bus_register_of_sysfs()
626 if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) in pci_claim_legacy_resources()
633 p->name = "Video RAM area"; in pci_claim_legacy_resources()
634 p->flags = IORESOURCE_MEM | IORESOURCE_BUSY; in pci_claim_legacy_resources()
638 pcibios_bus_to_resource(dev->bus, p, ®ion); in pci_claim_legacy_resources()
649 p, conflict->name, conflict); in pci_claim_legacy_resources()
665 list_for_each_entry(dev, &bus->devices, bus_list) { in pci_claim_bus_resources()
669 struct resource *r = &dev->resource[i]; in pci_claim_bus_resources()
671 if (r->parent || !r->start || !r->flags) in pci_claim_bus_resources()
684 list_for_each_entry(child_bus, &bus->children, node) in pci_claim_bus_resources()
692 struct device_node *node = pbm->op->dev.of_node; in pci_scan_one_pbm()
697 pci_add_resource_offset(&resources, &pbm->io_space, in pci_scan_one_pbm()
698 pbm->io_offset); in pci_scan_one_pbm()
699 pci_add_resource_offset(&resources, &pbm->mem_space, in pci_scan_one_pbm()
700 pbm->mem_offset); in pci_scan_one_pbm()
701 if (pbm->mem64_space.flags) in pci_scan_one_pbm()
702 pci_add_resource_offset(&resources, &pbm->mem64_space, in pci_scan_one_pbm()
703 pbm->mem64_offset); in pci_scan_one_pbm()
704 pbm->busn.start = pbm->pci_first_busno; in pci_scan_one_pbm()
705 pbm->busn.end = pbm->pci_last_busno; in pci_scan_one_pbm()
706 pbm->busn.flags = IORESOURCE_BUS; in pci_scan_one_pbm()
707 pci_add_resource(&resources, &pbm->busn); in pci_scan_one_pbm()
708 bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops, in pci_scan_one_pbm()
725 int pcibios_enable_device(struct pci_dev *dev, int mask) in pcibios_enable_device() argument
734 struct resource *res = &dev->resource[i]; in pcibios_enable_device()
737 if (!(mask & (1<<i))) in pcibios_enable_device()
740 if (res->flags & IORESOURCE_IO) in pcibios_enable_device()
742 if (res->flags & IORESOURCE_MEM) in pcibios_enable_device()
747 pci_info(dev, "enabling device (%04x -> %04x)\n", oldcmd, cmd); in pcibios_enable_device()
756 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller; in pci_iobar_pfn()
760 return -EINVAL; in pci_iobar_pfn()
762 vma->vm_pgoff += (ioaddr + pbm->io_space.start) >> PAGE_SHIFT; in pci_iobar_pfn()
770 struct pci_pbm_info *pbm = pbus->sysdata; in pcibus_to_node()
772 return pbm->numa_node; in pcibus_to_node()
781 struct pci_pbm_info *pbm = pbus->sysdata; in pci_domain_nr()
785 ret = -ENXIO; in pci_domain_nr()
787 ret = pbm->index; in pci_domain_nr()
797 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller; in arch_setup_msi_irq()
800 if (!pbm->setup_msi_irq) in arch_setup_msi_irq()
801 return -EINVAL; in arch_setup_msi_irq()
803 return pbm->setup_msi_irq(&irq, pdev, desc); in arch_setup_msi_irq()
810 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller; in arch_teardown_msi_irq()
812 if (pbm->teardown_msi_irq) in arch_teardown_msi_irq()
813 pbm->teardown_msi_irq(irq, pdev); in arch_teardown_msi_irq()
817 /* ALI sound chips generate 31-bits of DMA, a special register
822 struct iommu *iommu = dev->archdata.iommu; in ali_sound_dma_hack() local
829 if (to_pci_dev(dev)->vendor != PCI_VENDOR_ID_AL || in ali_sound_dma_hack()
830 to_pci_dev(dev)->device != PCI_DEVICE_ID_AL_M5451 || in ali_sound_dma_hack()
839 if (iommu->dma_addr_mask & 0x80000000) in ali_sound_dma_hack()
861 pcibios_resource_to_bus(pdev->bus, ®ion, (struct resource *) rp); in pci_resource_to_user()
879 if (dev->is_virtfn) { in pcibios_device_add()
882 pdev = dev->physfn; in pcibios_device_add()
883 psd = &pdev->dev.archdata; in pcibios_device_add()
884 pci_init_dev_archdata(&dev->dev.archdata, psd->iommu, in pcibios_device_add()
885 psd->stc, psd->host_controller, NULL, in pcibios_device_add()
886 psd->numa_node); in pcibios_device_add()
908 list_for_each_entry(pdev, &pbus->devices, bus_list) { in pcie_bus_slot_names()
914 slot_num = of_get_property(pdev->dev.of_node, in pcie_bus_slot_names()
915 "physical-slot#", &len); in pcie_bus_slot_names()
928 list_for_each_entry(bus, &pbus->children, node) in pcie_bus_slot_names()
940 u32 mask; in pci_bus_slot_names() local
942 prop = of_get_property(node, "slot-names", &len); in pci_bus_slot_names()
946 mask = prop->slot_mask; in pci_bus_slot_names()
947 sp = prop->names; in pci_bus_slot_names()
950 pci_info(bus, "Making slots for [%pOF] mask[0x%02x]\n", in pci_bus_slot_names()
951 node, mask); in pci_bus_slot_names()
954 while (mask) { in pci_bus_slot_names()
958 if (!(mask & this_bit)) { in pci_bus_slot_names()
972 mask &= ~this_bit; in pci_bus_slot_names()
985 pdev = list_first_entry(&pbus->devices, struct pci_dev, in of_pci_slot_init()
992 if (pbus->self) { in of_pci_slot_init()
994 /* PCI->PCI bridge */ in of_pci_slot_init()
995 node = pbus->self->dev.of_node; in of_pci_slot_init()
998 struct pci_pbm_info *pbm = pbus->sysdata; in of_pci_slot_init()
1001 node = pbm->op->dev.of_node; in of_pci_slot_init()