• Home
  • Raw
  • Download

Lines Matching +full:wakeup +full:- +full:parent

1 // SPDX-License-Identifier: GPL-2.0-only
3 * scan.c - support for transforming the ACPI namespace into individual objects
16 #include <linux/dma-map-ops.h>
19 #include <linux/dma-direct.h>
31 #define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent)
48 * special-casing. Everything else is covered by ACPI namespace paths in STAO
87 hp->notify = notify; in acpi_initialize_hp_context()
88 hp->uevent = uevent; in acpi_initialize_hp_context()
97 return -EINVAL; in acpi_scan_add_handler()
99 list_add_tail(&handler->list_node, &acpi_scan_handlers_list); in acpi_scan_add_handler()
112 acpi_sysfs_add_hotplug_profile(&handler->hotplug, hotplug_profile_name); in acpi_scan_add_handler_with_hotplug()
126 mutex_lock_nested(&adev->physical_node_lock, SINGLE_DEPTH_NESTING); in acpi_scan_is_offline()
128 list_for_each_entry(pn, &adev->physical_node_list, node) in acpi_scan_is_offline()
129 if (device_supports_offline(pn->dev) && !pn->dev->offline) { in acpi_scan_is_offline()
131 kobject_uevent_env(&pn->dev->kobj, KOBJ_CHANGE, envp); in acpi_scan_is_offline()
137 mutex_unlock(&adev->physical_node_lock); in acpi_scan_is_offline()
152 if (device->handler && !device->handler->hotplug.enabled) { in acpi_bus_offline()
153 *ret_p = &device->dev; in acpi_bus_offline()
157 mutex_lock(&device->physical_node_lock); in acpi_bus_offline()
159 list_for_each_entry(pn, &device->physical_node_list, node) { in acpi_bus_offline()
164 if (pn->put_online) in acpi_bus_offline()
167 pn->put_online = false; in acpi_bus_offline()
169 ret = device_offline(pn->dev); in acpi_bus_offline()
171 pn->put_online = !ret; in acpi_bus_offline()
173 *ret_p = pn->dev; in acpi_bus_offline()
181 mutex_unlock(&device->physical_node_lock); in acpi_bus_offline()
195 mutex_lock(&device->physical_node_lock); in acpi_bus_online()
197 list_for_each_entry(pn, &device->physical_node_list, node) in acpi_bus_online()
198 if (pn->put_online) { in acpi_bus_online()
199 device_online(pn->dev); in acpi_bus_online()
200 pn->put_online = false; in acpi_bus_online()
203 mutex_unlock(&device->physical_node_lock); in acpi_bus_online()
210 acpi_handle handle = device->handle; in acpi_scan_try_to_offline()
230 return -EPERM; in acpi_scan_try_to_offline()
248 return -EBUSY; in acpi_scan_try_to_offline()
256 acpi_handle handle = device->handle; in acpi_scan_hot_remove()
260 if (device->handler && device->handler->hotplug.demand_offline) { in acpi_scan_hot_remove()
262 return -EBUSY; in acpi_scan_hot_remove()
270 "Hot-removing device %s...\n", dev_name(&device->dev))); in acpi_scan_hot_remove()
280 return -ENODEV; in acpi_scan_hot_remove()
282 return -EIO; in acpi_scan_hot_remove()
294 "Eject incomplete - status 0x%llx\n", sta); in acpi_scan_hot_remove()
303 dev_warn(&adev->dev, "Still not present\n"); in acpi_scan_device_not_present()
304 return -EALREADY; in acpi_scan_device_not_present()
315 if (adev->status.present || adev->status.functional) { in acpi_scan_device_check()
324 if (adev->handler) { in acpi_scan_device_check()
325 dev_warn(&adev->dev, "Already enumerated\n"); in acpi_scan_device_check()
326 return -EALREADY; in acpi_scan_device_check()
328 error = acpi_bus_scan(adev->handle); in acpi_scan_device_check()
330 dev_warn(&adev->dev, "Namespace scan failure\n"); in acpi_scan_device_check()
333 if (!adev->handler) { in acpi_scan_device_check()
334 dev_warn(&adev->dev, "Enumeration failure\n"); in acpi_scan_device_check()
335 error = -ENODEV; in acpi_scan_device_check()
345 struct acpi_scan_handler *handler = adev->handler; in acpi_scan_bus_check()
350 if (!(adev->status.present || adev->status.functional)) { in acpi_scan_bus_check()
354 if (handler && handler->hotplug.scan_dependent) in acpi_scan_bus_check()
355 return handler->hotplug.scan_dependent(adev); in acpi_scan_bus_check()
357 error = acpi_bus_scan(adev->handle); in acpi_scan_bus_check()
359 dev_warn(&adev->dev, "Namespace scan failure\n"); in acpi_scan_bus_check()
362 list_for_each_entry(child, &adev->children, node) { in acpi_scan_bus_check()
379 if (adev->handler && !adev->handler->hotplug.enabled) { in acpi_generic_hotplug_event()
380 dev_info(&adev->dev, "Eject disabled\n"); in acpi_generic_hotplug_event()
381 return -EPERM; in acpi_generic_hotplug_event()
383 acpi_evaluate_ost(adev->handle, ACPI_NOTIFY_EJECT_REQUEST, in acpi_generic_hotplug_event()
387 return -EINVAL; in acpi_generic_hotplug_event()
393 int error = -ENODEV; in acpi_device_hotplug()
403 if (adev->handle == INVALID_ACPI_HANDLE) in acpi_device_hotplug()
406 if (adev->flags.is_dock_station) { in acpi_device_hotplug()
408 } else if (adev->flags.hotplug_notify) { in acpi_device_hotplug()
414 notify = adev->hp ? adev->hp->notify : NULL; in acpi_device_hotplug()
429 case -EPERM: in acpi_device_hotplug()
432 case -EBUSY: in acpi_device_hotplug()
441 acpi_evaluate_ost(adev->handle, src, ost_code, NULL); in acpi_device_hotplug()
453 if (device->wakeup.flags.valid) in acpi_free_power_resources_lists()
454 acpi_power_resources_list_free(&device->wakeup.resources); in acpi_free_power_resources_lists()
456 if (!device->power.flags.power_resources) in acpi_free_power_resources_lists()
460 struct acpi_device_power_state *ps = &device->power.states[i]; in acpi_free_power_resources_lists()
461 acpi_power_resources_list_free(&ps->resources); in acpi_free_power_resources_lists()
470 acpi_free_pnp_ids(&acpi_dev->pnp); in acpi_device_release()
480 if (device->parent) in acpi_device_del()
481 list_del(&device->node); in acpi_device_del()
484 if (!strcmp(acpi_device_bus_id->bus_id, in acpi_device_del()
486 ida_simple_remove(&acpi_device_bus_id->instance_ida, device->pnp.instance_no); in acpi_device_del()
487 if (ida_is_empty(&acpi_device_bus_id->instance_ida)) { in acpi_device_del()
488 list_del(&acpi_device_bus_id->node); in acpi_device_del()
489 kfree_const(acpi_device_bus_id->bus_id); in acpi_device_del()
495 list_del(&device->wakeup_list); in acpi_device_del()
500 if (device->remove) in acpi_device_del()
501 device->remove(device); in acpi_device_del()
503 device_del(&device->dev); in acpi_device_del()
524 list_del(&adev->del_list); in acpi_device_del_work_fn()
537 put_device(&adev->dev); in acpi_device_del_work_fn()
542 * acpi_scan_drop_device - Drop an ACPI device object.
574 list_add_tail(&adev->del_list, &acpi_device_del_list); in acpi_scan_drop_device()
576 adev->handle = INVALID_ACPI_HANDLE; in acpi_scan_drop_device()
587 return -EINVAL; in acpi_get_device_data()
596 return -ENODEV; in acpi_get_device_data()
610 get_device(&((struct acpi_device *)dev)->dev); in get_acpi_device()
623 put_device(&adev->dev); in acpi_bus_put_acpi_device()
632 if (!strcmp(acpi_device_bus_id->bus_id, dev_id)) in acpi_device_bus_id_match()
641 struct ida *instance_ida = &acpi_device_bus_id->instance_ida; in acpi_device_set_name()
648 device->pnp.instance_no = result; in acpi_device_set_name()
649 dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, result); in acpi_device_set_name()
659 if (device->handle) { in acpi_device_add()
662 status = acpi_attach_data(device->handle, acpi_scan_drop_device, in acpi_device_add()
665 acpi_handle_err(device->handle, in acpi_device_add()
667 return -ENODEV; in acpi_device_add()
673 * ------- in acpi_device_add()
674 * Link this device to its parent and siblings. in acpi_device_add()
676 INIT_LIST_HEAD(&device->children); in acpi_device_add()
677 INIT_LIST_HEAD(&device->node); in acpi_device_add()
678 INIT_LIST_HEAD(&device->wakeup_list); in acpi_device_add()
679 INIT_LIST_HEAD(&device->physical_node_list); in acpi_device_add()
680 INIT_LIST_HEAD(&device->del_list); in acpi_device_add()
681 mutex_init(&device->physical_node_lock); in acpi_device_add()
694 result = -ENOMEM; in acpi_device_add()
697 acpi_device_bus_id->bus_id = in acpi_device_add()
699 if (!acpi_device_bus_id->bus_id) { in acpi_device_add()
701 result = -ENOMEM; in acpi_device_add()
705 ida_init(&acpi_device_bus_id->instance_ida); in acpi_device_add()
709 kfree_const(acpi_device_bus_id->bus_id); in acpi_device_add()
714 list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); in acpi_device_add()
717 if (device->parent) in acpi_device_add()
718 list_add_tail(&device->node, &device->parent->children); in acpi_device_add()
720 if (device->wakeup.flags.valid) in acpi_device_add()
721 list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list); in acpi_device_add()
724 if (device->parent) in acpi_device_add()
725 device->dev.parent = &device->parent->dev; in acpi_device_add()
726 device->dev.bus = &acpi_bus_type; in acpi_device_add()
727 device->dev.release = release; in acpi_device_add()
728 result = device_add(&device->dev); in acpi_device_add()
730 dev_err(&device->dev, "Error registering device\n"); in acpi_device_add()
737 dev_name(&device->dev)); in acpi_device_add()
743 if (device->parent) in acpi_device_add()
744 list_del(&device->node); in acpi_device_add()
745 list_del(&device->wakeup_list); in acpi_device_add()
750 acpi_detach_data(device->handle, acpi_scan_drop_device); in acpi_device_add()
754 /* --------------------------------------------------------------------------
756 -------------------------------------------------------------------------- */
793 status = acpi_get_handle(ACPI_ROOT_OBJECT, obj->string.pointer, in acpi_bus_get_ejd()
803 acpi_handle handle = dev->handle; in acpi_bus_extract_wakeup_device_power_package()
804 struct acpi_device_wakeup *wakeup = &dev->wakeup; in acpi_bus_extract_wakeup_device_power_package() local
809 int err = -ENODATA; in acpi_bus_extract_wakeup_device_power_package()
811 INIT_LIST_HEAD(&wakeup->resources); in acpi_bus_extract_wakeup_device_power_package()
822 if (!package || package->package.count < 2) in acpi_bus_extract_wakeup_device_power_package()
825 element = &(package->package.elements[0]); in acpi_bus_extract_wakeup_device_power_package()
829 if (element->type == ACPI_TYPE_PACKAGE) { in acpi_bus_extract_wakeup_device_power_package()
830 if ((element->package.count < 2) || in acpi_bus_extract_wakeup_device_power_package()
831 (element->package.elements[0].type != in acpi_bus_extract_wakeup_device_power_package()
833 || (element->package.elements[1].type != ACPI_TYPE_INTEGER)) in acpi_bus_extract_wakeup_device_power_package()
836 wakeup->gpe_device = in acpi_bus_extract_wakeup_device_power_package()
837 element->package.elements[0].reference.handle; in acpi_bus_extract_wakeup_device_power_package()
838 wakeup->gpe_number = in acpi_bus_extract_wakeup_device_power_package()
839 (u32) element->package.elements[1].integer.value; in acpi_bus_extract_wakeup_device_power_package()
840 } else if (element->type == ACPI_TYPE_INTEGER) { in acpi_bus_extract_wakeup_device_power_package()
841 wakeup->gpe_device = NULL; in acpi_bus_extract_wakeup_device_power_package()
842 wakeup->gpe_number = element->integer.value; in acpi_bus_extract_wakeup_device_power_package()
847 element = &(package->package.elements[1]); in acpi_bus_extract_wakeup_device_power_package()
848 if (element->type != ACPI_TYPE_INTEGER) in acpi_bus_extract_wakeup_device_power_package()
851 wakeup->sleep_state = element->integer.value; in acpi_bus_extract_wakeup_device_power_package()
853 err = acpi_extract_power_resources(package, 2, &wakeup->resources); in acpi_bus_extract_wakeup_device_power_package()
857 if (!list_empty(&wakeup->resources)) { in acpi_bus_extract_wakeup_device_power_package()
860 err = acpi_power_wakeup_list_init(&wakeup->resources, in acpi_bus_extract_wakeup_device_power_package()
864 "of wakeup power resources failed\n"); in acpi_bus_extract_wakeup_device_power_package()
865 acpi_power_resources_list_free(&wakeup->resources); in acpi_bus_extract_wakeup_device_power_package()
868 if (sleep_state < wakeup->sleep_state) { in acpi_bus_extract_wakeup_device_power_package()
871 (int)wakeup->sleep_state, sleep_state); in acpi_bus_extract_wakeup_device_power_package()
872 wakeup->sleep_state = sleep_state; in acpi_bus_extract_wakeup_device_power_package()
889 struct acpi_device_wakeup *wakeup = &device->wakeup; in acpi_wakeup_gpe_init() local
892 wakeup->flags.notifier_present = 0; in acpi_wakeup_gpe_init()
894 /* Power button, Lid switch always enable wakeup */ in acpi_wakeup_gpe_init()
897 /* Do not use Lid/sleep button for S5 wakeup */ in acpi_wakeup_gpe_init()
898 if (wakeup->sleep_state == ACPI_STATE_S5) in acpi_wakeup_gpe_init()
899 wakeup->sleep_state = ACPI_STATE_S4; in acpi_wakeup_gpe_init()
901 acpi_mark_gpe_for_wake(wakeup->gpe_device, wakeup->gpe_number); in acpi_wakeup_gpe_init()
902 device_set_wakeup_capable(&device->dev, true); in acpi_wakeup_gpe_init()
906 status = acpi_setup_gpe_for_wake(device->handle, wakeup->gpe_device, in acpi_wakeup_gpe_init()
907 wakeup->gpe_number); in acpi_wakeup_gpe_init()
916 if (!acpi_has_method(device->handle, "_PRW")) in acpi_bus_get_wakeup_device_flags()
921 dev_err(&device->dev, "_PRW evaluation error: %d\n", err); in acpi_bus_get_wakeup_device_flags()
925 device->wakeup.flags.valid = acpi_wakeup_gpe_init(device); in acpi_bus_get_wakeup_device_flags()
926 device->wakeup.prepare_count = 0; in acpi_bus_get_wakeup_device_flags()
941 struct acpi_device_power_state *ps = &device->power.states[state]; in acpi_bus_init_power_state()
946 INIT_LIST_HEAD(&ps->resources); in acpi_bus_init_power_state()
949 status = acpi_evaluate_object(device->handle, pathname, NULL, &buffer); in acpi_bus_init_power_state()
954 && package->type == ACPI_TYPE_PACKAGE in acpi_bus_init_power_state()
955 && package->package.count) in acpi_bus_init_power_state()
956 acpi_extract_power_resources(package, 0, &ps->resources); in acpi_bus_init_power_state()
963 if (acpi_has_method(device->handle, pathname)) in acpi_bus_init_power_state()
964 ps->flags.explicit_set = 1; in acpi_bus_init_power_state()
967 if (!list_empty(&ps->resources) || ps->flags.explicit_set) in acpi_bus_init_power_state()
968 ps->flags.valid = 1; in acpi_bus_init_power_state()
970 ps->power = -1; /* Unknown - driver assigned */ in acpi_bus_init_power_state()
971 ps->latency = -1; /* Unknown - driver assigned */ in acpi_bus_init_power_state()
979 if (!acpi_has_method(device->handle, "_PS0") && in acpi_bus_get_power_flags()
980 !acpi_has_method(device->handle, "_PR0")) in acpi_bus_get_power_flags()
983 device->flags.power_manageable = 1; in acpi_bus_get_power_flags()
988 if (acpi_has_method(device->handle, "_PSC")) in acpi_bus_get_power_flags()
989 device->power.flags.explicit_get = 1; in acpi_bus_get_power_flags()
991 if (acpi_has_method(device->handle, "_IRC")) in acpi_bus_get_power_flags()
992 device->power.flags.inrush_current = 1; in acpi_bus_get_power_flags()
994 if (acpi_has_method(device->handle, "_DSW")) in acpi_bus_get_power_flags()
995 device->power.flags.dsw_present = 1; in acpi_bus_get_power_flags()
1003 INIT_LIST_HEAD(&device->power.states[ACPI_STATE_D3_COLD].resources); in acpi_bus_get_power_flags()
1006 device->power.states[ACPI_STATE_D0].flags.valid = 1; in acpi_bus_get_power_flags()
1007 device->power.states[ACPI_STATE_D0].power = 100; in acpi_bus_get_power_flags()
1008 device->power.states[ACPI_STATE_D3_HOT].flags.valid = 1; in acpi_bus_get_power_flags()
1015 if (!list_empty(&device->power.states[ACPI_STATE_D0].resources)) { in acpi_bus_get_power_flags()
1016 device->power.flags.power_resources = 1; in acpi_bus_get_power_flags()
1021 if (!list_empty(&device->power.states[ACPI_STATE_D3_HOT].resources)) in acpi_bus_get_power_flags()
1022 device->power.states[ACPI_STATE_D3_COLD].flags.valid = 1; in acpi_bus_get_power_flags()
1026 device->flags.power_manageable = 0; in acpi_bus_get_power_flags()
1032 if (acpi_has_method(device->handle, "_STA")) in acpi_bus_get_flags()
1033 device->flags.dynamic_status = 1; in acpi_bus_get_flags()
1036 if (acpi_has_method(device->handle, "_RMV")) in acpi_bus_get_flags()
1037 device->flags.removable = 1; in acpi_bus_get_flags()
1040 if (acpi_has_method(device->handle, "_EJD") || in acpi_bus_get_flags()
1041 acpi_has_method(device->handle, "_EJ0")) in acpi_bus_get_flags()
1042 device->flags.ejectable = 1; in acpi_bus_get_flags()
1053 * ------ in acpi_device_get_busid()
1058 strcpy(device->pnp.bus_id, "ACPI"); in acpi_device_get_busid()
1062 switch (device->device_type) { in acpi_device_get_busid()
1064 strcpy(device->pnp.bus_id, "PWRF"); in acpi_device_get_busid()
1067 strcpy(device->pnp.bus_id, "SLPF"); in acpi_device_get_busid()
1070 strcpy(device->pnp.bus_id, "ECDT"); in acpi_device_get_busid()
1073 acpi_get_name(device->handle, ACPI_SINGLE_NAME, &buffer); in acpi_device_get_busid()
1075 for (i = 3; i > 1; i--) { in acpi_device_get_busid()
1081 strcpy(device->pnp.bus_id, bus_id); in acpi_device_get_busid()
1087 * acpi_ata_match - see if an acpi object is an ATA device
1101 * acpi_bay_match - see if an acpi object is an ejectable driver bay
1124 list_for_each_entry(hwid, &adev->pnp.ids, list) in acpi_device_is_battery()
1125 if (!strcmp("PNP0C0A", hwid->id)) in acpi_device_is_battery()
1133 acpi_handle handle = adev->handle; in is_ejectable_bay()
1142 * acpi_dock_match - see if an acpi object has a _DCK method
1206 if (list_empty(&device->pnp.ids)) in acpi_device_hid()
1209 hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list); in acpi_device_hid()
1210 return hid->id; in acpi_device_hid()
1222 id->id = kstrdup_const(dev_id, GFP_KERNEL); in acpi_add_id()
1223 if (!id->id) { in acpi_add_id()
1228 list_add_tail(&id->list, &pnp->ids); in acpi_add_id()
1229 pnp->type.hardware_id = 1; in acpi_add_id()
1295 if (info->valid & ACPI_VALID_HID) { in acpi_set_pnp_ids()
1296 acpi_add_id(pnp, info->hardware_id.string); in acpi_set_pnp_ids()
1297 pnp->type.platform_id = 1; in acpi_set_pnp_ids()
1299 if (info->valid & ACPI_VALID_CID) { in acpi_set_pnp_ids()
1300 cid_list = &info->compatible_id_list; in acpi_set_pnp_ids()
1301 for (i = 0; i < cid_list->count; i++) in acpi_set_pnp_ids()
1302 acpi_add_id(pnp, cid_list->ids[i].string); in acpi_set_pnp_ids()
1304 if (info->valid & ACPI_VALID_ADR) { in acpi_set_pnp_ids()
1305 pnp->bus_address = info->address; in acpi_set_pnp_ids()
1306 pnp->type.bus_address = 1; in acpi_set_pnp_ids()
1308 if (info->valid & ACPI_VALID_UID) in acpi_set_pnp_ids()
1309 pnp->unique_id = kstrdup(info->unique_id.string, in acpi_set_pnp_ids()
1311 if (info->valid & ACPI_VALID_CLS) in acpi_set_pnp_ids()
1312 acpi_add_id(pnp, info->class_code.string); in acpi_set_pnp_ids()
1328 else if (list_empty(&pnp->ids) && in acpi_set_pnp_ids()
1332 strcpy(pnp->device_name, ACPI_BUS_DEVICE_NAME); in acpi_set_pnp_ids()
1333 strcpy(pnp->device_class, ACPI_BUS_CLASS); in acpi_set_pnp_ids()
1362 list_for_each_entry_safe(id, tmp, &pnp->ids, list) { in acpi_free_pnp_ids()
1363 kfree_const(id->id); in acpi_free_pnp_ids()
1366 kfree(pnp->unique_id); in acpi_free_pnp_ids()
1370 * acpi_dma_supported - Check DMA support for the specified device.
1380 if (adev->flags.cca_seen) in acpi_dma_supported()
1384 * Per ACPI 6.0 sec 6.2.17, assume devices can do cache-coherent in acpi_dma_supported()
1395 * acpi_get_dma_attr - Check the supported DMA attr for the specified device.
1405 if (adev->flags.coherent_dma) in acpi_get_dma_attr()
1412 * acpi_dma_get_range() - Get device DMA parameters.
1438 if (adev && acpi_has_method(adev->handle, METHOD_NAME__DMA)) in acpi_dma_get_range()
1441 dma_dev = dma_dev->parent; in acpi_dma_get_range()
1445 return -ENODEV; in acpi_dma_get_range()
1447 if (!acpi_has_method(adev->handle, METHOD_NAME__CRS)) { in acpi_dma_get_range()
1448 acpi_handle_warn(adev->handle, "_DMA is valid only if _CRS is present\n"); in acpi_dma_get_range()
1449 return -EINVAL; in acpi_dma_get_range()
1456 ret = -ENOMEM; in acpi_dma_get_range()
1461 if (rentry->res->start >= rentry->res->end) { in acpi_dma_get_range()
1463 ret = -EINVAL; in acpi_dma_get_range()
1468 r->cpu_start = rentry->res->start; in acpi_dma_get_range()
1469 r->dma_start = rentry->res->start - rentry->offset; in acpi_dma_get_range()
1470 r->size = resource_size(rentry->res); in acpi_dma_get_range()
1471 r->offset = rentry->offset; in acpi_dma_get_range()
1484 * acpi_dma_configure_id - Set-up DMA configuration for the device.
1502 if (PTR_ERR(iommu) == -EPROBE_DEFER) in acpi_dma_configure_id()
1503 return -EPROBE_DEFER; in acpi_dma_configure_id()
1516 struct acpi_device *parent = adev->parent; in acpi_init_coherency() local
1518 if (parent && parent->flags.cca_seen) { in acpi_init_coherency()
1523 adev->flags.cca_seen = 1; in acpi_init_coherency()
1524 cca = parent->flags.coherent_dma; in acpi_init_coherency()
1526 status = acpi_evaluate_integer(adev->handle, "_CCA", in acpi_init_coherency()
1529 adev->flags.cca_seen = 1; in acpi_init_coherency()
1533 * required for DMA-able devices (e.g. x86), in acpi_init_coherency()
1538 acpi_handle_debug(adev->handle, in acpi_init_coherency()
1542 adev->flags.coherent_dma = cca; in acpi_init_coherency()
1549 if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) in acpi_check_serial_bus_slave()
1555 return -1; in acpi_check_serial_bus_slave()
1560 struct acpi_device *parent = device->parent; in acpi_is_indirect_io_slave() local
1566 return parent && !acpi_match_device_ids(parent, indirect_io_hosts); in acpi_is_indirect_io_slave()
1575 * These devices have multiple I2cSerialBus resources and an i2c-client in acpi_device_enumeration_by_parent()
1577 * Normally we only instantiate an i2c-client for the first resource, in acpi_device_enumeration_by_parent()
1579 * drivers/platform/x86/i2c-multi-instantiate.c driver, which knows in acpi_device_enumeration_by_parent()
1590 * such as the rfkill-gpio driver. in acpi_device_enumeration_by_parent()
1602 (fwnode_property_present(&device->fwnode, "spiSclkPeriod") || in acpi_device_enumeration_by_parent()
1603 fwnode_property_present(&device->fwnode, "i2cAddress") || in acpi_device_enumeration_by_parent()
1604 fwnode_property_present(&device->fwnode, "baud"))) in acpi_device_enumeration_by_parent()
1622 INIT_LIST_HEAD(&device->pnp.ids); in acpi_init_device_object()
1623 device->device_type = type; in acpi_init_device_object()
1624 device->handle = handle; in acpi_init_device_object()
1625 device->parent = acpi_bus_get_parent(handle); in acpi_init_device_object()
1626 device->fwnode.ops = &acpi_device_fwnode_ops; in acpi_init_device_object()
1629 acpi_set_pnp_ids(handle, &device->pnp, type); in acpi_init_device_object()
1632 device->flags.match_driver = false; in acpi_init_device_object()
1633 device->flags.initialized = true; in acpi_init_device_object()
1634 device->flags.enumeration_by_parent = in acpi_init_device_object()
1637 device_initialize(&device->dev); in acpi_init_device_object()
1638 dev_set_uevent_suppress(&device->dev, true); in acpi_init_device_object()
1641 device->dep_unmet = 1; in acpi_init_device_object()
1646 dev_set_uevent_suppress(&device->dev, false); in acpi_device_add_finalize()
1647 kobject_uevent(&device->dev.kobj, KOBJ_ADD); in acpi_device_add_finalize()
1661 return -ENOMEM; in acpi_add_single_object()
1668 * Note this must be done before the get power-/wakeup_dev-flags calls. in acpi_add_single_object()
1679 acpi_device_release(&device->dev); in acpi_add_single_object()
1686 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Added %s [%s] parent %s\n", in acpi_add_single_object()
1687 dev_name(&device->dev), (char *) buffer.pointer, in acpi_add_single_object()
1688 device->parent ? dev_name(&device->parent->dev) : "(null)")); in acpi_add_single_object()
1737 return -ENODEV; in acpi_bus_type_and_status()
1743 return -ENODEV; in acpi_bus_type_and_status()
1756 return -ENODEV; in acpi_bus_type_and_status()
1767 return -ENODEV; in acpi_bus_type_and_status()
1775 return adev->status.present || adev->status.functional; in acpi_device_is_present()
1784 if (handler->match) in acpi_scan_handler_matching()
1785 return handler->match(idstr, matchid); in acpi_scan_handler_matching()
1787 for (devid = handler->ids; devid->id[0]; devid++) in acpi_scan_handler_matching()
1788 if (!strcmp((char *)devid->id, idstr)) { in acpi_scan_handler_matching()
1812 if (!!hotplug->enabled == !!val) in acpi_scan_hotplug_enabled()
1817 hotplug->enabled = val; in acpi_scan_hotplug_enabled()
1826 if (acpi_dock_match(adev->handle) || is_ejectable_bay(adev)) { in acpi_scan_init_hotplug()
1830 list_for_each_entry(hwid, &adev->pnp.ids, list) { in acpi_scan_init_hotplug()
1833 handler = acpi_scan_match_handler(hwid->id, NULL); in acpi_scan_init_hotplug()
1835 adev->flags.hotplug_notify = true; in acpi_scan_init_hotplug()
1848 adev->dep_unmet = 0; in acpi_device_dep_initialize()
1850 if (!acpi_has_method(adev->handle, "_DEP")) in acpi_device_dep_initialize()
1853 status = acpi_evaluate_reference(adev->handle, "_DEP", NULL, in acpi_device_dep_initialize()
1856 dev_dbg(&adev->dev, "Failed to evaluate _DEP.\n"); in acpi_device_dep_initialize()
1866 dev_dbg(&adev->dev, "Error reading _DEP device info\n"); in acpi_device_dep_initialize()
1874 skip = info->valid & ACPI_VALID_HID && in acpi_device_dep_initialize()
1875 !strcmp(info->hardware_id.string, "INT3396"); in acpi_device_dep_initialize()
1886 dep->master = dep_devices.handles[i]; in acpi_device_dep_initialize()
1887 dep->slave = adev->handle; in acpi_device_dep_initialize()
1888 adev->dep_unmet++; in acpi_device_dep_initialize()
1891 list_add_tail(&dep->node , &acpi_dep_list); in acpi_device_dep_initialize()
1937 if (!device->flags.enumeration_by_parent) { in acpi_default_enumeration()
1958 if (adev->data.of_compatible) in acpi_generic_device_attach()
1974 list_for_each_entry(hwid, &device->pnp.ids, list) { in acpi_scan_attach_handler()
1978 handler = acpi_scan_match_handler(hwid->id, &devid); in acpi_scan_attach_handler()
1980 if (!handler->attach) { in acpi_scan_attach_handler()
1981 device->pnp.type.platform_id = 0; in acpi_scan_attach_handler()
1984 device->handler = handler; in acpi_scan_attach_handler()
1985 ret = handler->attach(device, devid); in acpi_scan_attach_handler()
1989 device->handler = NULL; in acpi_scan_attach_handler()
2004 if (ACPI_SUCCESS(acpi_bus_get_ejd(device->handle, &ejd))) in acpi_bus_attach()
2010 device->flags.initialized = false; in acpi_bus_attach()
2012 device->flags.power_manageable = 0; in acpi_bus_attach()
2015 if (device->handler) in acpi_bus_attach()
2018 if (!device->flags.initialized) { in acpi_bus_attach()
2019 device->flags.power_manageable = in acpi_bus_attach()
2020 device->power.states[ACPI_STATE_D0].flags.valid; in acpi_bus_attach()
2022 device->flags.power_manageable = 0; in acpi_bus_attach()
2024 device->flags.initialized = true; in acpi_bus_attach()
2025 } else if (device->flags.visited) { in acpi_bus_attach()
2033 device->flags.match_driver = true; in acpi_bus_attach()
2034 if (ret > 0 && !device->flags.enumeration_by_parent) { in acpi_bus_attach()
2039 ret = device_attach(&device->dev); in acpi_bus_attach()
2043 if (device->pnp.type.platform_id || device->flags.enumeration_by_parent) in acpi_bus_attach()
2049 list_for_each_entry(child, &device->children, node) in acpi_bus_attach()
2052 if (device->handler && device->handler->hotplug.notify_online) in acpi_bus_attach()
2053 device->handler->hotplug.notify_online(device); in acpi_bus_attach()
2063 if (dep->master == handle) { in acpi_walk_dep_device_list()
2064 acpi_bus_get_device(dep->slave, &adev); in acpi_walk_dep_device_list()
2068 adev->dep_unmet--; in acpi_walk_dep_device_list()
2069 if (!adev->dep_unmet) in acpi_walk_dep_device_list()
2071 list_del(&dep->node); in acpi_walk_dep_device_list()
2080 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
2083 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
2086 * If no devices were found, -ENODEV is returned, but it does not mean that
2105 return -ENODEV; in acpi_bus_scan()
2110 * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects.
2117 struct acpi_scan_handler *handler = adev->handler; in acpi_bus_trim()
2120 list_for_each_entry_reverse(child, &adev->children, node) in acpi_bus_trim()
2123 adev->flags.match_driver = false; in acpi_bus_trim()
2125 if (handler->detach) in acpi_bus_trim()
2126 handler->detach(adev); in acpi_bus_trim()
2128 adev->handler = NULL; in acpi_bus_trim()
2130 device_release_driver(&adev->dev); in acpi_bus_trim()
2137 adev->flags.initialized = false; in acpi_bus_trim()
2152 device->flags.match_driver = true; in acpi_bus_register_early_device()
2153 return device_attach(&device->dev); in acpi_bus_register_early_device()
2162 * Enumerate all fixed-feature devices. in acpi_bus_scan_fixed()
2173 device->flags.match_driver = true; in acpi_bus_scan_fixed()
2174 result = device_attach(&device->dev); in acpi_bus_scan_fixed()
2178 device_init_wakeup(&device->dev, true); in acpi_bus_scan_fixed()
2190 device->flags.match_driver = true; in acpi_bus_scan_fixed()
2191 result = device_attach(&device->dev); in acpi_bus_scan_fixed()
2209 spcr_uart_addr = spcr_ptr->serial_port.address; in acpi_get_spcr_uart_addr()
2245 if (stao_ptr->header.length > sizeof(struct acpi_table_stao)) in acpi_scan_init()
2248 if (stao_ptr->ignore_uart) in acpi_scan_init()
2275 /* Fixed feature devices do not exist on HW-reduced platform */ in acpi_scan_init()
2279 acpi_detach_data(acpi_root->handle, in acpi_scan_init()
2282 put_device(&acpi_root->dev); in acpi_scan_init()
2301 if (!ape->subtable_valid || ape->subtable_valid(&header->common, ape)) in acpi_match_madt()
2302 if (!ape->probe_subtbl(header, end)) in acpi_match_madt()
2316 for (ape = ap_head; nr; ape++, nr--) { in __acpi_probe_device_table()
2317 if (ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id)) { in __acpi_probe_device_table()
2319 acpi_table_parse_madt(ape->type, acpi_match_madt, 0); in __acpi_probe_device_table()
2323 res = acpi_table_parse(ape->id, ape->probe_table); in __acpi_probe_device_table()
2345 if (tew->event == ACPI_TABLE_EVENT_LOAD) { in acpi_table_events_fn()
2368 INIT_WORK(&tew->work, acpi_table_events_fn); in acpi_scan_table_handler()
2369 tew->table = table; in acpi_scan_table_handler()
2370 tew->event = event; in acpi_scan_table_handler()
2372 schedule_work(&tew->work); in acpi_scan_table_handler()