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 pci_dev_for_each_resource(dev, r, i) { in pcibios_claim_one_bus()
295 if (r->parent || !r->start || !r->flags) in pcibios_claim_one_bus()
298 (r->flags & IORESOURCE_PCI_FIXED)) { in pcibios_claim_one_bus()
299 if (pci_claim_resource(dev, i) == 0) in pcibios_claim_one_bus()
302 pci_claim_bridge_resource(dev, i); in pcibios_claim_one_bus()
307 list_for_each_entry(child_bus, &b->children, node) in pcibios_claim_one_bus()
333 /* Scan all of the recorded PCI controllers. */ in common_init_pci()
334 for (next_busno = 0, hose = hose_head; hose; hose = hose->next) { in common_init_pci()
335 sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0; in common_init_pci()
337 /* Adjust hose mem_space limit to prevent PCI allocations in common_init_pci()
339 pci_mem_end = min((u32)__direct_map_base, sg_base) - 1; in common_init_pci()
340 end = hose->mem_space->start + pci_mem_end; in common_init_pci()
341 if (hose->mem_space->end > end) in common_init_pci()
342 hose->mem_space->end = end; in common_init_pci()
345 pci_add_resource_offset(&resources, hose->io_space, in common_init_pci()
346 hose->io_space->start); in common_init_pci()
347 pci_add_resource_offset(&resources, hose->mem_space, in common_init_pci()
348 hose->mem_space->start); in common_init_pci()
354 list_splice_init(&resources, &bridge->windows); in common_init_pci()
355 bridge->dev.parent = NULL; in common_init_pci()
356 bridge->sysdata = hose; in common_init_pci()
357 bridge->busnr = next_busno; in common_init_pci()
358 bridge->ops = alpha_mv.pci_ops; in common_init_pci()
359 bridge->swizzle_irq = alpha_mv.pci_swizzle; in common_init_pci()
360 bridge->map_irq = alpha_mv.pci_map_irq; in common_init_pci()
368 bus = hose->bus = bridge->bus; in common_init_pci()
369 hose->need_domain_info = need_domain_info; in common_init_pci()
370 next_busno = bus->busn_res.end + 1; in common_init_pci()
371 /* Don't allow 8-bit bus number overflow inside the hose - in common_init_pci()
382 for (hose = hose_head; hose; hose = hose->next) { in common_init_pci()
383 bus = hose->bus; in common_init_pci()
400 hose_tail = &hose->next; in alloc_pci_controller()
419 memory. Do this on a per-card basis so that we choose the right hose. */
425 struct pci_dev *dev; in SYSCALL_DEFINE3() local
429 for(hose = hose_head; hose; hose = hose->next) in SYSCALL_DEFINE3()
430 if (hose->index == bus) break; in SYSCALL_DEFINE3()
431 if (!hose) return -ENODEV; in SYSCALL_DEFINE3()
437 dev = pci_get_domain_bus_and_slot(0, bus, dfn); in SYSCALL_DEFINE3()
438 if (!dev) in SYSCALL_DEFINE3()
439 return -ENODEV; in SYSCALL_DEFINE3()
440 hose = dev->sysdata; in SYSCALL_DEFINE3()
441 pci_dev_put(dev); in SYSCALL_DEFINE3()
447 return hose->index; in SYSCALL_DEFINE3()
449 return hose->sparse_mem_base; in SYSCALL_DEFINE3()
451 return hose->dense_mem_base; in SYSCALL_DEFINE3()
453 return hose->sparse_io_base; in SYSCALL_DEFINE3()
455 return hose->dense_io_base; in SYSCALL_DEFINE3()
457 return hose->bus->number; in SYSCALL_DEFINE3()
460 return -EOPNOTSUPP; in SYSCALL_DEFINE3()
465 void pci_iounmap(struct pci_dev *dev, void __iomem * addr) in pci_iounmap() argument