2 * IOAPIC/IOxAPIC/IOSAPIC driver
4 * Copyright (C) 2009 Fujitsu Limited.
5 * (c) Copyright 2009 Hewlett-Packard Development Company, L.P.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
13 * This driver manages PCI I/O APICs added by hotplug after boot. We try to
14 * claim all I/O APIC PCI devices, but those present at boot were registered
15 * when we parsed the ACPI MADT, so we'll fail when we try to re-register
19 #include <linux/pci.h>
20 #include <linux/module.h>
21 #include <linux/acpi.h>
22 #include <linux/slab.h>
29 static int ioapic_probe(struct pci_dev
*dev
, const struct pci_device_id
*ent
)
33 unsigned long long gsb
;
34 struct ioapic
*ioapic
;
39 handle
= ACPI_HANDLE(&dev
->dev
);
43 status
= acpi_evaluate_integer(handle
, "_GSB", NULL
, &gsb
);
44 if (ACPI_FAILURE(status
))
48 * The previous code in acpiphp evaluated _MAT if _GSB failed, but
49 * ACPI spec 4.0 sec 6.2.2 requires _GSB for hot-pluggable I/O APICs.
52 ioapic
= kzalloc(sizeof(*ioapic
), GFP_KERNEL
);
56 ioapic
->handle
= handle
;
57 ioapic
->gsi_base
= (u32
) gsb
;
59 if (dev
->class == PCI_CLASS_SYSTEM_PIC_IOAPIC
)
64 ret
= pci_enable_device(dev
);
70 if (pci_request_region(dev
, 0, type
))
73 res
= &dev
->resource
[0];
74 if (acpi_register_ioapic(ioapic
->handle
, res
->start
, ioapic
->gsi_base
))
77 pci_set_drvdata(dev
, ioapic
);
78 dev_info(&dev
->dev
, "%s at %pR, GSI %u\n", type
, res
, ioapic
->gsi_base
);
82 pci_release_region(dev
, 0);
84 pci_disable_device(dev
);
90 static void ioapic_remove(struct pci_dev
*dev
)
92 struct ioapic
*ioapic
= pci_get_drvdata(dev
);
94 acpi_unregister_ioapic(ioapic
->handle
, ioapic
->gsi_base
);
95 pci_release_region(dev
, 0);
96 pci_disable_device(dev
);
101 static DEFINE_PCI_DEVICE_TABLE(ioapic_devices
) = {
102 { PCI_DEVICE_CLASS(PCI_CLASS_SYSTEM_PIC_IOAPIC
, ~0) },
103 { PCI_DEVICE_CLASS(PCI_CLASS_SYSTEM_PIC_IOXAPIC
, ~0) },
106 MODULE_DEVICE_TABLE(pci
, ioapic_devices
);
108 static struct pci_driver ioapic_driver
= {
110 .id_table
= ioapic_devices
,
111 .probe
= ioapic_probe
,
112 .remove
= ioapic_remove
,
115 static int __init
ioapic_init(void)
117 return pci_register_driver(&ioapic_driver
);
119 module_init(ioapic_init
);
121 MODULE_LICENSE("GPL");