Lines Matching +full:pci +full:- +full:dev

1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/alpha/kernel/pci.c
10 /* 2.3.x PCI/resources, 1999 Andrea Arcangeli <andrea@suse.de> */
14 * PCI-PCI bridges cleanup
17 #include <linux/pci.h>
37 "PCI IO bus 0", "PCI IO bus 1", "PCI IO bus 2", "PCI IO bus 3",
38 "PCI IO bus 4", "PCI IO bus 5", "PCI IO bus 6", "PCI IO bus 7"
42 "PCI mem bus 0", "PCI mem bus 1", "PCI mem bus 2", "PCI mem bus 3",
43 "PCI mem bus 4", "PCI mem bus 5", "PCI mem bus 6", "PCI mem bus 7"
49 * If PCI_PROBE_ONLY in pci_flags is set, we don't change any PCI resource
54 * The PCI controller list.
64 static void quirk_isa_bridge(struct pci_dev *dev) in quirk_isa_bridge() argument
66 dev->class = PCI_CLASS_BRIDGE_ISA << 8; in quirk_isa_bridge()
70 static void quirk_cypress(struct pci_dev *dev) in quirk_cypress() argument
74 /* The generic legacy mode IDE fixup in drivers/pci/probe.c in quirk_cypress()
76 it has non-standard register layout. Fix that. */ in quirk_cypress()
77 if (dev->class >> 8 == PCI_CLASS_STORAGE_IDE) { in quirk_cypress()
78 dev->resource[2].start = dev->resource[3].start = 0; in quirk_cypress()
79 dev->resource[2].end = dev->resource[3].end = 0; in quirk_cypress()
80 dev->resource[2].flags = dev->resource[3].flags = 0; in quirk_cypress()
81 if (PCI_FUNC(dev->devfn) == 2) { in quirk_cypress()
82 dev->resource[0].start = 0x170; in quirk_cypress()
83 dev->resource[0].end = 0x177; in quirk_cypress()
84 dev->resource[1].start = 0x376; in quirk_cypress()
85 dev->resource[1].end = 0x376; in quirk_cypress()
89 /* The Cypress bridge responds on the PCI bus in the address range in quirk_cypress()
90 0xffff0000-0xffffffff (conventional x86 BIOS ROM). There is no in quirk_cypress()
92 BIOS ranges (disabled after power-up), and some consoles do turn in quirk_cypress()
93 them on. So if we use a large direct-map window, or a large SG in quirk_cypress()
94 window, we must avoid the entire 0xfff00000-0xffffffff region. */ in quirk_cypress()
95 if (dev->class >> 8 == PCI_CLASS_BRIDGE_ISA) { in quirk_cypress()
97 __direct_map_size = 0xfff00000UL - __direct_map_base; in quirk_cypress()
99 struct pci_controller *hose = dev->sysdata; in quirk_cypress()
100 struct pci_iommu_arena *pci = hose->sg_pci; in quirk_cypress() local
101 if (pci && pci->dma_base + pci->size >= 0xfff00000UL) in quirk_cypress()
102 pci->size = 0xfff00000UL - pci->dma_base; in quirk_cypress()
108 /* Called for each device after PCI setup is done. */
109 static void pcibios_fixup_final(struct pci_dev *dev) in pcibios_fixup_final() argument
111 unsigned int class = dev->class >> 8; in pcibios_fixup_final()
114 dev->dma_mask = MAX_ISA_DMA_ADDRESS - 1; in pcibios_fixup_final()
115 isa_bridge = dev; in pcibios_fixup_final()
120 /* Just declaring that the power-of-ten prefixes are actually the
121 power-of-two ones doesn't make it true :) */
130 struct pci_dev *dev = data; in pcibios_align_resource() local
131 struct pci_controller *hose = dev->sysdata; in pcibios_align_resource()
133 resource_size_t start = res->start; in pcibios_align_resource()
135 if (res->flags & IORESOURCE_IO) { in pcibios_align_resource()
137 if (start - hose->io_space->start < PCIBIOS_MIN_IO) in pcibios_align_resource()
138 start = PCIBIOS_MIN_IO + hose->io_space->start; in pcibios_align_resource()
141 * Put everything into 0x00-0xff region modulo 0x400 in pcibios_align_resource()
146 else if (res->flags & IORESOURCE_MEM) { in pcibios_align_resource()
148 if (start - hose->mem_space->start < PCIBIOS_MIN_MEM) in pcibios_align_resource()
149 start = PCIBIOS_MIN_MEM + hose->mem_space->start; in pcibios_align_resource()
153 * Alpha implementation of the PCI interface: in pcibios_align_resource()
160 * avoid allocating PCI devices in that range. in pcibios_align_resource()
161 * Can be allocated in 2nd-7th octant only. in pcibios_align_resource()
170 if (hose->sparse_mem_base && size <= 7 * 16*MB) { in pcibios_align_resource()
172 start &= ~(128*MB - 1); in pcibios_align_resource()
176 if (start/(128*MB) != (start + size - 1)/(128*MB)) { in pcibios_align_resource()
177 start &= ~(128*MB - 1); in pcibios_align_resource()
201 /* Store PCI device configuration left by SRM here. */
205 struct pci_dev *dev; member
210 static void pdev_save_srm_config(struct pci_dev *dev) in pdev_save_srm_config() argument
219 printk(KERN_INFO "pci: enabling save/restore of SRM state\n"); in pdev_save_srm_config()
228 tmp->next = srm_saved_configs; in pdev_save_srm_config()
229 tmp->dev = dev; in pdev_save_srm_config()
231 pci_save_state(dev); in pdev_save_srm_config()
246 for (tmp = srm_saved_configs; tmp; tmp = tmp->next) { in pci_restore_srm_config()
247 pci_restore_state(tmp->dev); in pci_restore_srm_config()
251 #define pdev_save_srm_config(dev) do {} while (0) argument
256 struct pci_dev *dev = bus->self; in pcibios_fixup_bus() local
258 if (pci_has_flag(PCI_PROBE_ONLY) && dev && in pcibios_fixup_bus()
259 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { in pcibios_fixup_bus()
263 list_for_each_entry(dev, &bus->devices, bus_list) { in pcibios_fixup_bus()
264 pdev_save_srm_config(dev); in pcibios_fixup_bus()
274 pcibios_set_master(struct pci_dev *dev) in pcibios_set_master() argument
277 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat); in pcibios_set_master()
279 printk("PCI: Setting latency timer of device %s to 64\n", in pcibios_set_master()
280 pci_name(dev)); in pcibios_set_master()
281 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64); in pcibios_set_master()
287 struct pci_dev *dev; in pcibios_claim_one_bus() local
290 list_for_each_entry(dev, &b->devices, bus_list) { in pcibios_claim_one_bus()
294 struct resource *r = &dev->resource[i]; in pcibios_claim_one_bus()
296 if (r->parent || !r->start || !r->flags) in pcibios_claim_one_bus()
299 (r->flags & IORESOURCE_PCI_FIXED)) { in pcibios_claim_one_bus()
300 if (pci_claim_resource(dev, i) == 0) in pcibios_claim_one_bus()
303 pci_claim_bridge_resource(dev, i); in pcibios_claim_one_bus()
308 list_for_each_entry(child_bus, &b->children, node) in pcibios_claim_one_bus()
334 /* Scan all of the recorded PCI controllers. */ in common_init_pci()
335 for (next_busno = 0, hose = hose_head; hose; hose = hose->next) { in common_init_pci()
336 sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0; in common_init_pci()
338 /* Adjust hose mem_space limit to prevent PCI allocations in common_init_pci()
340 pci_mem_end = min((u32)__direct_map_base, sg_base) - 1; in common_init_pci()
341 end = hose->mem_space->start + pci_mem_end; in common_init_pci()
342 if (hose->mem_space->end > end) in common_init_pci()
343 hose->mem_space->end = end; in common_init_pci()
346 pci_add_resource_offset(&resources, hose->io_space, in common_init_pci()
347 hose->io_space->start); in common_init_pci()
348 pci_add_resource_offset(&resources, hose->mem_space, in common_init_pci()
349 hose->mem_space->start); in common_init_pci()
355 list_splice_init(&resources, &bridge->windows); in common_init_pci()
356 bridge->dev.parent = NULL; in common_init_pci()
357 bridge->sysdata = hose; in common_init_pci()
358 bridge->busnr = next_busno; in common_init_pci()
359 bridge->ops = alpha_mv.pci_ops; in common_init_pci()
360 bridge->swizzle_irq = alpha_mv.pci_swizzle; in common_init_pci()
361 bridge->map_irq = alpha_mv.pci_map_irq; in common_init_pci()
369 bus = hose->bus = bridge->bus; in common_init_pci()
370 hose->need_domain_info = need_domain_info; in common_init_pci()
371 next_busno = bus->busn_res.end + 1; in common_init_pci()
372 /* Don't allow 8-bit bus number overflow inside the hose - in common_init_pci()
383 for (hose = hose_head; hose; hose = hose->next) { in common_init_pci()
384 bus = hose->bus; in common_init_pci()
401 hose_tail = &hose->next; in alloc_pci_controller()
420 memory. Do this on a per-card basis so that we choose the right hose. */
426 struct pci_dev *dev; in SYSCALL_DEFINE3() local
430 for(hose = hose_head; hose; hose = hose->next) in SYSCALL_DEFINE3()
431 if (hose->index == bus) break; in SYSCALL_DEFINE3()
432 if (!hose) return -ENODEV; in SYSCALL_DEFINE3()
438 dev = pci_get_domain_bus_and_slot(0, bus, dfn); in SYSCALL_DEFINE3()
439 if (!dev) in SYSCALL_DEFINE3()
440 return -ENODEV; in SYSCALL_DEFINE3()
441 hose = dev->sysdata; in SYSCALL_DEFINE3()
442 pci_dev_put(dev); in SYSCALL_DEFINE3()
448 return hose->index; in SYSCALL_DEFINE3()
450 return hose->sparse_mem_base; in SYSCALL_DEFINE3()
452 return hose->dense_mem_base; in SYSCALL_DEFINE3()
454 return hose->sparse_io_base; in SYSCALL_DEFINE3()
456 return hose->dense_io_base; in SYSCALL_DEFINE3()
458 return hose->bus->number; in SYSCALL_DEFINE3()
461 return -EOPNOTSUPP; in SYSCALL_DEFINE3()
466 void pci_iounmap(struct pci_dev *dev, void __iomem * addr) in pci_iounmap() argument