26 #include <linux/kernel.h>
27 #include <linux/module.h>
29 #include <linux/slab.h>
30 #include <linux/types.h>
31 #include <linux/pci.h>
38 static int check_sta_before_sun;
40 #define DRIVER_VERSION "0.1"
42 #define DRIVER_DESC "ACPI PCI Slot Detection Driver"
49 #define _COMPONENT ACPI_PCI_COMPONENT
52 #define MY_NAME "pci_slot"
53 #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg)
54 #define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg)
55 #define dbg(format, arg...) \
58 printk(KERN_DEBUG "%s: " format, \
62 #define SLOT_NAME_SIZE 21
70 static int acpi_pci_slot_add(
struct acpi_pci_root *root);
71 static void acpi_pci_slot_remove(
struct acpi_pci_root *root);
75 static struct acpi_pci_driver acpi_pci_slot_driver = {
76 .add = acpi_pci_slot_add,
77 .remove = acpi_pci_slot_remove,
84 unsigned long long adr, sta;
89 dbg(
"Checking slot on path: %s\n", (
char *)buffer.
pointer);
91 if (check_sta_before_sun) {
100 dbg(
"_ADR returned %d on %s\n", status, (
char *)buffer.
pointer);
107 dbg(
"_SUN returned %d on %s\n", status, (
char *)buffer.
pointer);
111 device = (adr >> 16) & 0xffff;
137 unsigned long long sun;
144 device = check_slot(handle, &sun);
150 err(
"%s: cannot allocate memory\n", __func__);
154 snprintf(name,
sizeof(name),
"%llu", sun);
156 if (IS_ERR(pci_slot)) {
157 err(
"pci_create_slot returned %ld\n", PTR_ERR(pci_slot));
164 INIT_LIST_HEAD(&slot->
list);
166 list_add(&slot->
list, &slot_list);
171 dbg(
"pci_slot: %p, pci_bus: %x, device: %d, name: %s\n",
172 pci_slot, pci_bus->
number, device, name);
186 walk_p2p_bridge(
acpi_handle handle,
u32 lvl,
void *context,
void **rv)
188 int device,
function;
189 unsigned long long adr;
199 pci_bus = parent_context->
pci_bus;
210 device = (adr >> 16) & 0xffff;
211 function = adr & 0xffff;
219 child_context.root_handle = parent_context->
root_handle;
223 user_function,
NULL, &child_context,
NULL);
228 walk_p2p_bridge,
NULL, &child_context,
NULL);
247 struct pci_bus *pci_bus = root->bus;
252 context.root_handle =
handle;
254 dbg(
"root bridge walk, pci_bus = %x\n", pci_bus->
number);
256 user_function,
NULL, &context,
NULL);
261 walk_p2p_bridge,
NULL, &context,
NULL);
263 err(
"%s: walk_p2p_bridge failure - %d\n", __func__, status);
273 acpi_pci_slot_add(
struct acpi_pci_root *root)
277 status = walk_root_bridge(root, register_slot);
279 err(
"%s: register_slot failure - %d\n", __func__, status);
289 acpi_pci_slot_remove(
struct acpi_pci_root *root)
292 struct pci_bus *pbus;
310 info(
"%s detected: will evaluate _STA before calling _SUN\n", d->
ident);
311 check_sta_before_sun = 1;
323 .callback = do_sta_before_sun,
324 .ident =
"Fujitsu PRIMEQUEST",
334 acpi_pci_slot_init(
void)
342 acpi_pci_slot_exit(
void)