aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/acpiphp_glue.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/acpiphp_glue.c')
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c106
1 files changed, 9 insertions, 97 deletions
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 44191db1f050..b6691cc8230b 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -303,12 +303,6 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
303 if (acpi_has_method(handle, "_STA")) 303 if (acpi_has_method(handle, "_STA"))
304 newfunc->flags |= FUNC_HAS_STA; 304 newfunc->flags |= FUNC_HAS_STA;
305 305
306 if (acpi_has_method(handle, "_PS0"))
307 newfunc->flags |= FUNC_HAS_PS0;
308
309 if (acpi_has_method(handle, "_PS3"))
310 newfunc->flags |= FUNC_HAS_PS3;
311
312 if (acpi_has_method(handle, "_DCK")) 306 if (acpi_has_method(handle, "_DCK"))
313 newfunc->flags |= FUNC_HAS_DCK; 307 newfunc->flags |= FUNC_HAS_DCK;
314 308
@@ -366,7 +360,7 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
366 360
367 if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function), 361 if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
368 &val, 60*1000)) 362 &val, 60*1000))
369 slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); 363 slot->flags |= SLOT_ENABLED;
370 364
371 if (is_dock_device(handle)) { 365 if (is_dock_device(handle)) {
372 /* we don't want to call this device's _EJ0 366 /* we don't want to call this device's _EJ0
@@ -446,73 +440,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
446 mutex_unlock(&bridge_mutex); 440 mutex_unlock(&bridge_mutex);
447} 441}
448 442
449static int power_on_slot(struct acpiphp_slot *slot)
450{
451 acpi_status status;
452 struct acpiphp_func *func;
453 int retval = 0;
454
455 /* if already enabled, just skip */
456 if (slot->flags & SLOT_POWEREDON)
457 goto err_exit;
458
459 list_for_each_entry(func, &slot->funcs, sibling) {
460 if (func->flags & FUNC_HAS_PS0) {
461 dbg("%s: executing _PS0\n", __func__);
462 status = acpi_evaluate_object(func_to_handle(func),
463 "_PS0", NULL, NULL);
464 if (ACPI_FAILURE(status)) {
465 warn("%s: _PS0 failed\n", __func__);
466 retval = -1;
467 goto err_exit;
468 } else
469 break;
470 }
471 }
472
473 /* TBD: evaluate _STA to check if the slot is enabled */
474
475 slot->flags |= SLOT_POWEREDON;
476
477 err_exit:
478 return retval;
479}
480
481
482static int power_off_slot(struct acpiphp_slot *slot)
483{
484 acpi_status status;
485 struct acpiphp_func *func;
486
487 int retval = 0;
488
489 /* if already disabled, just skip */
490 if ((slot->flags & SLOT_POWEREDON) == 0)
491 goto err_exit;
492
493 list_for_each_entry(func, &slot->funcs, sibling) {
494 if (func->flags & FUNC_HAS_PS3) {
495 status = acpi_evaluate_object(func_to_handle(func),
496 "_PS3", NULL, NULL);
497 if (ACPI_FAILURE(status)) {
498 warn("%s: _PS3 failed\n", __func__);
499 retval = -1;
500 goto err_exit;
501 } else
502 break;
503 }
504 }
505
506 /* TBD: evaluate _STA to check if the slot is disabled */
507
508 slot->flags &= (~SLOT_POWEREDON);
509
510 err_exit:
511 return retval;
512}
513
514
515
516/** 443/**
517 * acpiphp_max_busnr - return the highest reserved bus number under the given bus. 444 * acpiphp_max_busnr - return the highest reserved bus number under the given bus.
518 * @bus: bus to start search with 445 * @bus: bus to start search with
@@ -559,8 +486,13 @@ static void acpiphp_bus_trim(acpi_handle handle)
559 */ 486 */
560static void acpiphp_bus_add(acpi_handle handle) 487static void acpiphp_bus_add(acpi_handle handle)
561{ 488{
489 struct acpi_device *adev = NULL;
490
562 acpiphp_bus_trim(handle); 491 acpiphp_bus_trim(handle);
563 acpi_bus_scan(handle); 492 acpi_bus_scan(handle);
493 acpi_bus_get_device(handle, &adev);
494 if (adev)
495 acpi_device_set_power(adev, ACPI_STATE_D0);
564} 496}
565 497
566static void acpiphp_set_acpi_region(struct acpiphp_slot *slot) 498static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
@@ -1095,23 +1027,8 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
1095 int retval; 1027 int retval;
1096 1028
1097 mutex_lock(&slot->crit_sect); 1029 mutex_lock(&slot->crit_sect);
1098 1030 /* configure all functions */
1099 /* wake up all functions */ 1031 retval = enable_device(slot);
1100 retval = power_on_slot(slot);
1101 if (retval)
1102 goto err_exit;
1103
1104 if (get_slot_status(slot) == ACPI_STA_ALL) {
1105 /* configure all functions */
1106 retval = enable_device(slot);
1107 if (retval)
1108 power_off_slot(slot);
1109 } else {
1110 dbg("%s: Slot status is not ACPI_STA_ALL\n", __func__);
1111 power_off_slot(slot);
1112 }
1113
1114 err_exit:
1115 mutex_unlock(&slot->crit_sect); 1032 mutex_unlock(&slot->crit_sect);
1116 return retval; 1033 return retval;
1117} 1034}
@@ -1132,11 +1049,6 @@ int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot)
1132 if (retval) 1049 if (retval)
1133 goto err_exit; 1050 goto err_exit;
1134 1051
1135 /* power off all functions */
1136 retval = power_off_slot(slot);
1137 if (retval)
1138 goto err_exit;
1139
1140 list_for_each_entry(func, &slot->funcs, sibling) 1052 list_for_each_entry(func, &slot->funcs, sibling)
1141 if (func->flags & FUNC_HAS_EJ0) { 1053 if (func->flags & FUNC_HAS_EJ0) {
1142 acpi_handle handle = func_to_handle(func); 1054 acpi_handle handle = func_to_handle(func);
@@ -1159,7 +1071,7 @@ int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot)
1159 */ 1071 */
1160u8 acpiphp_get_power_status(struct acpiphp_slot *slot) 1072u8 acpiphp_get_power_status(struct acpiphp_slot *slot)
1161{ 1073{
1162 return (slot->flags & SLOT_POWEREDON); 1074 return (slot->flags & SLOT_ENABLED);
1163} 1075}
1164 1076
1165 1077