aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/pci_root.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/pci_root.c')
-rw-r--r--drivers/acpi/pci_root.c101
1 files changed, 25 insertions, 76 deletions
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 7928d4dc7056..b3cc69c5caf1 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -45,9 +45,9 @@
45ACPI_MODULE_NAME("pci_root"); 45ACPI_MODULE_NAME("pci_root");
46#define ACPI_PCI_ROOT_CLASS "pci_bridge" 46#define ACPI_PCI_ROOT_CLASS "pci_bridge"
47#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" 47#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge"
48static int acpi_pci_root_add(struct acpi_device *device); 48static int acpi_pci_root_add(struct acpi_device *device,
49static int acpi_pci_root_remove(struct acpi_device *device, int type); 49 const struct acpi_device_id *not_used);
50static int acpi_pci_root_start(struct acpi_device *device); 50static void acpi_pci_root_remove(struct acpi_device *device);
51 51
52#define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \ 52#define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \
53 | OSC_ACTIVE_STATE_PWR_SUPPORT \ 53 | OSC_ACTIVE_STATE_PWR_SUPPORT \
@@ -58,17 +58,11 @@ static const struct acpi_device_id root_device_ids[] = {
58 {"PNP0A03", 0}, 58 {"PNP0A03", 0},
59 {"", 0}, 59 {"", 0},
60}; 60};
61MODULE_DEVICE_TABLE(acpi, root_device_ids);
62 61
63static struct acpi_driver acpi_pci_root_driver = { 62static struct acpi_scan_handler pci_root_handler = {
64 .name = "pci_root",
65 .class = ACPI_PCI_ROOT_CLASS,
66 .ids = root_device_ids, 63 .ids = root_device_ids,
67 .ops = { 64 .attach = acpi_pci_root_add,
68 .add = acpi_pci_root_add, 65 .detach = acpi_pci_root_remove,
69 .remove = acpi_pci_root_remove,
70 .start = acpi_pci_root_start,
71 },
72}; 66};
73 67
74/* Lock to protect both acpi_pci_roots and acpi_pci_drivers lists */ 68/* Lock to protect both acpi_pci_roots and acpi_pci_drivers lists */
@@ -188,21 +182,6 @@ static acpi_status try_get_root_bridge_busnr(acpi_handle handle,
188 return AE_OK; 182 return AE_OK;
189} 183}
190 184
191static void acpi_pci_bridge_scan(struct acpi_device *device)
192{
193 int status;
194 struct acpi_device *child = NULL;
195
196 if (device->flags.bus_address)
197 if (device->parent && device->parent->ops.bind) {
198 status = device->parent->ops.bind(device);
199 if (!status) {
200 list_for_each_entry(child, &device->children, node)
201 acpi_pci_bridge_scan(child);
202 }
203 }
204}
205
206static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766"; 185static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766";
207 186
208static acpi_status acpi_pci_run_osc(acpi_handle handle, 187static acpi_status acpi_pci_run_osc(acpi_handle handle,
@@ -445,14 +424,15 @@ out:
445} 424}
446EXPORT_SYMBOL(acpi_pci_osc_control_set); 425EXPORT_SYMBOL(acpi_pci_osc_control_set);
447 426
448static int acpi_pci_root_add(struct acpi_device *device) 427static int acpi_pci_root_add(struct acpi_device *device,
428 const struct acpi_device_id *not_used)
449{ 429{
450 unsigned long long segment, bus; 430 unsigned long long segment, bus;
451 acpi_status status; 431 acpi_status status;
452 int result; 432 int result;
453 struct acpi_pci_root *root; 433 struct acpi_pci_root *root;
454 acpi_handle handle; 434 acpi_handle handle;
455 struct acpi_device *child; 435 struct acpi_pci_driver *driver;
456 u32 flags, base_flags; 436 u32 flags, base_flags;
457 bool is_osc_granted = false; 437 bool is_osc_granted = false;
458 438
@@ -603,21 +583,6 @@ static int acpi_pci_root_add(struct acpi_device *device)
603 goto out_del_root; 583 goto out_del_root;
604 } 584 }
605 585
606 /*
607 * Attach ACPI-PCI Context
608 * -----------------------
609 * Thus binding the ACPI and PCI devices.
610 */
611 result = acpi_pci_bind_root(device);
612 if (result)
613 goto out_del_root;
614
615 /*
616 * Scan and bind all _ADR-Based Devices
617 */
618 list_for_each_entry(child, &device->children, node)
619 acpi_pci_bridge_scan(child);
620
621 /* ASPM setting */ 586 /* ASPM setting */
622 if (is_osc_granted) { 587 if (is_osc_granted) {
623 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) 588 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
@@ -632,24 +597,6 @@ static int acpi_pci_root_add(struct acpi_device *device)
632 if (device->wakeup.flags.run_wake) 597 if (device->wakeup.flags.run_wake)
633 device_set_run_wake(root->bus->bridge, true); 598 device_set_run_wake(root->bus->bridge, true);
634 599
635 return 0;
636
637out_del_root:
638 mutex_lock(&acpi_pci_root_lock);
639 list_del(&root->node);
640 mutex_unlock(&acpi_pci_root_lock);
641
642 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
643end:
644 kfree(root);
645 return result;
646}
647
648static int acpi_pci_root_start(struct acpi_device *device)
649{
650 struct acpi_pci_root *root = acpi_driver_data(device);
651 struct acpi_pci_driver *driver;
652
653 if (system_state != SYSTEM_BOOTING) 600 if (system_state != SYSTEM_BOOTING)
654 pci_assign_unassigned_bus_resources(root->bus); 601 pci_assign_unassigned_bus_resources(root->bus);
655 602
@@ -664,11 +611,20 @@ static int acpi_pci_root_start(struct acpi_device *device)
664 pci_enable_bridges(root->bus); 611 pci_enable_bridges(root->bus);
665 612
666 pci_bus_add_devices(root->bus); 613 pci_bus_add_devices(root->bus);
614 return 1;
667 615
668 return 0; 616out_del_root:
617 mutex_lock(&acpi_pci_root_lock);
618 list_del(&root->node);
619 mutex_unlock(&acpi_pci_root_lock);
620
621 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
622end:
623 kfree(root);
624 return result;
669} 625}
670 626
671static int acpi_pci_root_remove(struct acpi_device *device, int type) 627static void acpi_pci_root_remove(struct acpi_device *device)
672{ 628{
673 acpi_status status; 629 acpi_status status;
674 acpi_handle handle; 630 acpi_handle handle;
@@ -696,21 +652,14 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
696 list_del(&root->node); 652 list_del(&root->node);
697 mutex_unlock(&acpi_pci_root_lock); 653 mutex_unlock(&acpi_pci_root_lock);
698 kfree(root); 654 kfree(root);
699 return 0;
700} 655}
701 656
702static int __init acpi_pci_root_init(void) 657void __init acpi_pci_root_init(void)
703{ 658{
704 acpi_hest_init(); 659 acpi_hest_init();
705 660
706 if (acpi_pci_disabled) 661 if (!acpi_pci_disabled) {
707 return 0; 662 pci_acpi_crs_quirks();
708 663 acpi_scan_add_handler(&pci_root_handler);
709 pci_acpi_crs_quirks(); 664 }
710 if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0)
711 return -ENODEV;
712
713 return 0;
714} 665}
715
716subsys_initcall(acpi_pci_root_init);