2 #include <linux/acpi.h>
3 #include <linux/init.h>
9 static int __devinit can_skip_ioresource_align(const struct dmi_system_id *d)
11 pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
12 printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident);
16 static struct dmi_system_id acpi_pciprobe_dmi_table[] __devinitdata = {
18 * Systems where PCI IO resource ISA alignment can be skipped
19 * when the ISA enable bit in the bridge control is not set
22 .callback = can_skip_ioresource_align,
23 .ident = "IBM System x3800",
25 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
26 DMI_MATCH(DMI_PRODUCT_NAME, "x3800"),
30 .callback = can_skip_ioresource_align,
31 .ident = "IBM System x3850",
33 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
34 DMI_MATCH(DMI_PRODUCT_NAME, "x3850"),
38 .callback = can_skip_ioresource_align,
39 .ident = "IBM System x3950",
41 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
42 DMI_MATCH(DMI_PRODUCT_NAME, "x3950"),
48 struct pci_root_info {
57 resource_to_addr(struct acpi_resource *resource,
58 struct acpi_resource_address64 *addr)
62 status = acpi_resource_to_address64(resource, addr);
63 if (ACPI_SUCCESS(status) &&
64 (addr->resource_type == ACPI_MEMORY_RANGE ||
65 addr->resource_type == ACPI_IO_RANGE) &&
66 addr->address_length > 0 &&
67 addr->producer_consumer == ACPI_PRODUCER) {
74 count_resource(struct acpi_resource *acpi_res, void *data)
76 struct pci_root_info *info = data;
77 struct acpi_resource_address64 addr;
80 status = resource_to_addr(acpi_res, &addr);
81 if (ACPI_SUCCESS(status))
87 setup_resource(struct acpi_resource *acpi_res, void *data)
89 struct pci_root_info *info = data;
91 struct acpi_resource_address64 addr;
94 struct resource *root;
96 status = resource_to_addr(acpi_res, &addr);
97 if (!ACPI_SUCCESS(status))
100 if (addr.resource_type == ACPI_MEMORY_RANGE) {
101 root = &iomem_resource;
102 flags = IORESOURCE_MEM;
103 if (addr.info.mem.caching == ACPI_PREFETCHABLE_MEMORY)
104 flags |= IORESOURCE_PREFETCH;
105 } else if (addr.resource_type == ACPI_IO_RANGE) {
106 root = &ioport_resource;
107 flags = IORESOURCE_IO;
111 res = &info->res[info->res_num];
112 res->name = info->name;
114 res->start = addr.minimum + addr.translation_offset;
115 res->end = res->start + addr.address_length - 1;
118 if (insert_resource(root, res)) {
119 printk(KERN_ERR "PCI: Failed to allocate 0x%lx-0x%lx "
120 "from %s for %s\n", (unsigned long) res->start,
121 (unsigned long) res->end, root->name, info->name);
123 info->bus->resource[info->res_num] = res;
130 adjust_transparent_bridge_resources(struct pci_bus *bus)
134 list_for_each_entry(dev, &bus->devices, bus_list) {
136 u16 class = dev->class >> 8;
138 if (class == PCI_CLASS_BRIDGE_PCI && dev->transparent) {
139 for(i = 3; i < PCI_BUS_NUM_RESOURCES; i++)
140 dev->subordinate->resource[i] =
141 dev->bus->resource[i - 3];
147 get_current_resources(struct acpi_device *device, int busnum,
150 struct pci_root_info info;
155 acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource,
160 size = sizeof(*info.res) * info.res_num;
161 info.res = kmalloc(size, GFP_KERNEL);
165 info.name = kmalloc(12, GFP_KERNEL);
167 goto name_alloc_fail;
168 sprintf(info.name, "PCI Bus #%02x", busnum);
171 acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource,
174 adjust_transparent_bridge_resources(bus);
184 struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int busnum)
187 struct pci_sysdata *sd;
190 dmi_check_system(acpi_pciprobe_dmi_table);
192 if (domain && !pci_domains_supported) {
193 printk(KERN_WARNING "PCI: Multiple domains not supported "
194 "(dom %d, bus %d)\n", domain, busnum);
198 /* Allocate per-root-bus (not per bus) arch-specific data.
199 * TODO: leak; this memory is never freed.
200 * It's arguable whether it's worth the trouble to care.
202 sd = kzalloc(sizeof(*sd), GFP_KERNEL);
204 printk(KERN_ERR "PCI: OOM, not probing PCI bus %02x\n", busnum);
211 pxm = acpi_get_pxm(device->handle);
212 #ifdef CONFIG_ACPI_NUMA
214 sd->node = pxm_to_node(pxm);
217 bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
221 #ifdef CONFIG_ACPI_NUMA
224 printk("bus %d -> pxm %d -> node %d\n",
225 busnum, pxm, sd->node);
230 if (bus && (pci_probe & PCI_USE__CRS))
231 get_current_resources(device, busnum, bus);
236 extern int pci_routeirq;
237 static int __init pci_acpi_init(void)
239 struct pci_dev *dev = NULL;
247 printk(KERN_INFO "PCI: Using ACPI for IRQ routing\n");
248 acpi_irq_penalty_init();
250 pcibios_enable_irq = acpi_pci_irq_enable;
251 pcibios_disable_irq = acpi_pci_irq_disable;
255 * PCI IRQ routing is set up by pci_enable_device(), but we
256 * also do it here in case there are still broken drivers that
257 * don't use pci_enable_device().
259 printk(KERN_INFO "PCI: Routing PCI interrupts for all devices because \"pci=routeirq\" specified\n");
260 for_each_pci_dev(dev)
261 acpi_pci_irq_enable(dev);
263 printk(KERN_INFO "PCI: If a device doesn't work, try \"pci=routeirq\". If it helps, post a report\n");
265 #ifdef CONFIG_X86_IO_APIC
272 subsys_initcall(pci_acpi_init);