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>
30 #define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent)
47 * special-casing. Everything else is covered by ACPI namespace paths in STAO
86 hp->notify = notify; in acpi_initialize_hp_context()
87 hp->uevent = uevent; in acpi_initialize_hp_context()
96 return -EINVAL; in acpi_scan_add_handler()
98 list_add_tail(&handler->list_node, &acpi_scan_handlers_list); in acpi_scan_add_handler()
111 acpi_sysfs_add_hotplug_profile(&handler->hotplug, hotplug_profile_name); in acpi_scan_add_handler_with_hotplug()
125 mutex_lock_nested(&adev->physical_node_lock, SINGLE_DEPTH_NESTING); in acpi_scan_is_offline()
127 list_for_each_entry(pn, &adev->physical_node_list, node) in acpi_scan_is_offline()
128 if (device_supports_offline(pn->dev) && !pn->dev->offline) { in acpi_scan_is_offline()
130 kobject_uevent_env(&pn->dev->kobj, KOBJ_CHANGE, envp); in acpi_scan_is_offline()
136 mutex_unlock(&adev->physical_node_lock); in acpi_scan_is_offline()
151 if (device->handler && !device->handler->hotplug.enabled) { in acpi_bus_offline()
152 *ret_p = &device->dev; in acpi_bus_offline()
156 mutex_lock(&device->physical_node_lock); in acpi_bus_offline()
158 list_for_each_entry(pn, &device->physical_node_list, node) { in acpi_bus_offline()
163 if (pn->put_online) in acpi_bus_offline()
166 pn->put_online = false; in acpi_bus_offline()
168 ret = device_offline(pn->dev); in acpi_bus_offline()
170 pn->put_online = !ret; in acpi_bus_offline()
172 *ret_p = pn->dev; in acpi_bus_offline()
180 mutex_unlock(&device->physical_node_lock); in acpi_bus_offline()
194 mutex_lock(&device->physical_node_lock); in acpi_bus_online()
196 list_for_each_entry(pn, &device->physical_node_list, node) in acpi_bus_online()
197 if (pn->put_online) { in acpi_bus_online()
198 device_online(pn->dev); in acpi_bus_online()
199 pn->put_online = false; in acpi_bus_online()
202 mutex_unlock(&device->physical_node_lock); in acpi_bus_online()
209 acpi_handle handle = device->handle; in acpi_scan_try_to_offline()
229 return -EPERM; in acpi_scan_try_to_offline()
247 return -EBUSY; in acpi_scan_try_to_offline()
255 acpi_handle handle = device->handle; in acpi_scan_hot_remove()
259 if (device->handler && device->handler->hotplug.demand_offline) { in acpi_scan_hot_remove()
261 return -EBUSY; in acpi_scan_hot_remove()
269 "Hot-removing device %s...\n", dev_name(&device->dev))); in acpi_scan_hot_remove()
279 return -ENODEV; in acpi_scan_hot_remove()
281 return -EIO; in acpi_scan_hot_remove()
293 "Eject incomplete - status 0x%llx\n", sta); in acpi_scan_hot_remove()
302 dev_warn(&adev->dev, "Still not present\n"); in acpi_scan_device_not_present()
303 return -EALREADY; in acpi_scan_device_not_present()
314 if (adev->status.present || adev->status.functional) { in acpi_scan_device_check()
323 if (adev->handler) { in acpi_scan_device_check()
324 dev_warn(&adev->dev, "Already enumerated\n"); in acpi_scan_device_check()
325 return -EALREADY; in acpi_scan_device_check()
327 error = acpi_bus_scan(adev->handle); in acpi_scan_device_check()
329 dev_warn(&adev->dev, "Namespace scan failure\n"); in acpi_scan_device_check()
332 if (!adev->handler) { in acpi_scan_device_check()
333 dev_warn(&adev->dev, "Enumeration failure\n"); in acpi_scan_device_check()
334 error = -ENODEV; in acpi_scan_device_check()
344 struct acpi_scan_handler *handler = adev->handler; in acpi_scan_bus_check()
349 if (!(adev->status.present || adev->status.functional)) { in acpi_scan_bus_check()
353 if (handler && handler->hotplug.scan_dependent) in acpi_scan_bus_check()
354 return handler->hotplug.scan_dependent(adev); in acpi_scan_bus_check()
356 error = acpi_bus_scan(adev->handle); in acpi_scan_bus_check()
358 dev_warn(&adev->dev, "Namespace scan failure\n"); in acpi_scan_bus_check()
361 list_for_each_entry(child, &adev->children, node) { in acpi_scan_bus_check()
378 if (adev->handler && !adev->handler->hotplug.enabled) { in acpi_generic_hotplug_event()
379 dev_info(&adev->dev, "Eject disabled\n"); in acpi_generic_hotplug_event()
380 return -EPERM; in acpi_generic_hotplug_event()
382 acpi_evaluate_ost(adev->handle, ACPI_NOTIFY_EJECT_REQUEST, in acpi_generic_hotplug_event()
386 return -EINVAL; in acpi_generic_hotplug_event()
392 int error = -ENODEV; in acpi_device_hotplug()
402 if (adev->handle == INVALID_ACPI_HANDLE) in acpi_device_hotplug()
405 if (adev->flags.is_dock_station) { in acpi_device_hotplug()
407 } else if (adev->flags.hotplug_notify) { in acpi_device_hotplug()
413 notify = adev->hp ? adev->hp->notify : NULL; in acpi_device_hotplug()
428 case -EPERM: in acpi_device_hotplug()
431 case -EBUSY: in acpi_device_hotplug()
440 acpi_evaluate_ost(adev->handle, src, ost_code, NULL); in acpi_device_hotplug()
452 if (device->wakeup.flags.valid) in acpi_free_power_resources_lists()
453 acpi_power_resources_list_free(&device->wakeup.resources); in acpi_free_power_resources_lists()
455 if (!device->power.flags.power_resources) in acpi_free_power_resources_lists()
459 struct acpi_device_power_state *ps = &device->power.states[i]; in acpi_free_power_resources_lists()
460 acpi_power_resources_list_free(&ps->resources); in acpi_free_power_resources_lists()
469 acpi_free_pnp_ids(&acpi_dev->pnp); in acpi_device_release()
479 if (device->parent) in acpi_device_del()
480 list_del(&device->node); in acpi_device_del()
483 if (!strcmp(acpi_device_bus_id->bus_id, in acpi_device_del()
485 ida_simple_remove(&acpi_device_bus_id->instance_ida, device->pnp.instance_no); in acpi_device_del()
486 if (ida_is_empty(&acpi_device_bus_id->instance_ida)) { in acpi_device_del()
487 list_del(&acpi_device_bus_id->node); in acpi_device_del()
488 kfree_const(acpi_device_bus_id->bus_id); in acpi_device_del()
494 list_del(&device->wakeup_list); in acpi_device_del()
499 if (device->remove) in acpi_device_del()
500 device->remove(device); in acpi_device_del()
502 device_del(&device->dev); in acpi_device_del()
523 list_del(&adev->del_list); in acpi_device_del_work_fn()
536 put_device(&adev->dev); in acpi_device_del_work_fn()
541 * acpi_scan_drop_device - Drop an ACPI device object.
573 list_add_tail(&adev->del_list, &acpi_device_del_list); in acpi_scan_drop_device()
575 adev->handle = INVALID_ACPI_HANDLE; in acpi_scan_drop_device()
586 return -EINVAL; in acpi_get_device_data()
595 return -ENODEV; in acpi_get_device_data()
609 get_device(&((struct acpi_device *)dev)->dev); in get_acpi_device()
622 put_device(&adev->dev); in acpi_bus_put_acpi_device()
631 if (!strcmp(acpi_device_bus_id->bus_id, dev_id)) in acpi_device_bus_id_match()
640 struct ida *instance_ida = &acpi_device_bus_id->instance_ida; in acpi_device_set_name()
647 device->pnp.instance_no = result; in acpi_device_set_name()
648 dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, result); in acpi_device_set_name()
658 if (device->handle) { in acpi_device_add()
661 status = acpi_attach_data(device->handle, acpi_scan_drop_device, in acpi_device_add()
664 acpi_handle_err(device->handle, in acpi_device_add()
666 return -ENODEV; in acpi_device_add()
672 * ------- in acpi_device_add()
673 * Link this device to its parent and siblings. in acpi_device_add()
675 INIT_LIST_HEAD(&device->children); in acpi_device_add()
676 INIT_LIST_HEAD(&device->node); in acpi_device_add()
677 INIT_LIST_HEAD(&device->wakeup_list); in acpi_device_add()
678 INIT_LIST_HEAD(&device->physical_node_list); in acpi_device_add()
679 INIT_LIST_HEAD(&device->del_list); in acpi_device_add()
680 mutex_init(&device->physical_node_lock); in acpi_device_add()
693 result = -ENOMEM; in acpi_device_add()
696 acpi_device_bus_id->bus_id = in acpi_device_add()
698 if (!acpi_device_bus_id->bus_id) { in acpi_device_add()
700 result = -ENOMEM; in acpi_device_add()
704 ida_init(&acpi_device_bus_id->instance_ida); in acpi_device_add()
708 kfree_const(acpi_device_bus_id->bus_id); in acpi_device_add()
713 list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); in acpi_device_add()
716 if (device->parent) in acpi_device_add()
717 list_add_tail(&device->node, &device->parent->children); in acpi_device_add()
719 if (device->wakeup.flags.valid) in acpi_device_add()
720 list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list); in acpi_device_add()
723 if (device->parent) in acpi_device_add()
724 device->dev.parent = &device->parent->dev; in acpi_device_add()
725 device->dev.bus = &acpi_bus_type; in acpi_device_add()
726 device->dev.release = release; in acpi_device_add()
727 result = device_add(&device->dev); in acpi_device_add()
729 dev_err(&device->dev, "Error registering device\n"); in acpi_device_add()
736 dev_name(&device->dev)); in acpi_device_add()
742 if (device->parent) in acpi_device_add()
743 list_del(&device->node); in acpi_device_add()
744 list_del(&device->wakeup_list); in acpi_device_add()
749 acpi_detach_data(device->handle, acpi_scan_drop_device); in acpi_device_add()
753 /* --------------------------------------------------------------------------
755 -------------------------------------------------------------------------- */
792 status = acpi_get_handle(ACPI_ROOT_OBJECT, obj->string.pointer, in acpi_bus_get_ejd()
802 acpi_handle handle = dev->handle; in acpi_bus_extract_wakeup_device_power_package()
803 struct acpi_device_wakeup *wakeup = &dev->wakeup; in acpi_bus_extract_wakeup_device_power_package() local
808 int err = -ENODATA; in acpi_bus_extract_wakeup_device_power_package()
810 INIT_LIST_HEAD(&wakeup->resources); in acpi_bus_extract_wakeup_device_power_package()
821 if (!package || package->package.count < 2) in acpi_bus_extract_wakeup_device_power_package()
824 element = &(package->package.elements[0]); in acpi_bus_extract_wakeup_device_power_package()
828 if (element->type == ACPI_TYPE_PACKAGE) { in acpi_bus_extract_wakeup_device_power_package()
829 if ((element->package.count < 2) || in acpi_bus_extract_wakeup_device_power_package()
830 (element->package.elements[0].type != in acpi_bus_extract_wakeup_device_power_package()
832 || (element->package.elements[1].type != ACPI_TYPE_INTEGER)) in acpi_bus_extract_wakeup_device_power_package()
835 wakeup->gpe_device = in acpi_bus_extract_wakeup_device_power_package()
836 element->package.elements[0].reference.handle; in acpi_bus_extract_wakeup_device_power_package()
837 wakeup->gpe_number = in acpi_bus_extract_wakeup_device_power_package()
838 (u32) element->package.elements[1].integer.value; in acpi_bus_extract_wakeup_device_power_package()
839 } else if (element->type == ACPI_TYPE_INTEGER) { in acpi_bus_extract_wakeup_device_power_package()
840 wakeup->gpe_device = NULL; in acpi_bus_extract_wakeup_device_power_package()
841 wakeup->gpe_number = element->integer.value; in acpi_bus_extract_wakeup_device_power_package()
846 element = &(package->package.elements[1]); in acpi_bus_extract_wakeup_device_power_package()
847 if (element->type != ACPI_TYPE_INTEGER) in acpi_bus_extract_wakeup_device_power_package()
850 wakeup->sleep_state = element->integer.value; in acpi_bus_extract_wakeup_device_power_package()
852 err = acpi_extract_power_resources(package, 2, &wakeup->resources); in acpi_bus_extract_wakeup_device_power_package()
856 if (!list_empty(&wakeup->resources)) { in acpi_bus_extract_wakeup_device_power_package()
859 err = acpi_power_wakeup_list_init(&wakeup->resources, in acpi_bus_extract_wakeup_device_power_package()
863 "of wakeup power resources failed\n"); in acpi_bus_extract_wakeup_device_power_package()
864 acpi_power_resources_list_free(&wakeup->resources); in acpi_bus_extract_wakeup_device_power_package()
867 if (sleep_state < wakeup->sleep_state) { in acpi_bus_extract_wakeup_device_power_package()
870 (int)wakeup->sleep_state, sleep_state); in acpi_bus_extract_wakeup_device_power_package()
871 wakeup->sleep_state = sleep_state; in acpi_bus_extract_wakeup_device_power_package()
888 struct acpi_device_wakeup *wakeup = &device->wakeup; in acpi_wakeup_gpe_init() local
891 wakeup->flags.notifier_present = 0; in acpi_wakeup_gpe_init()
893 /* Power button, Lid switch always enable wakeup */ in acpi_wakeup_gpe_init()
896 /* Do not use Lid/sleep button for S5 wakeup */ in acpi_wakeup_gpe_init()
897 if (wakeup->sleep_state == ACPI_STATE_S5) in acpi_wakeup_gpe_init()
898 wakeup->sleep_state = ACPI_STATE_S4; in acpi_wakeup_gpe_init()
900 acpi_mark_gpe_for_wake(wakeup->gpe_device, wakeup->gpe_number); in acpi_wakeup_gpe_init()
901 device_set_wakeup_capable(&device->dev, true); in acpi_wakeup_gpe_init()
905 status = acpi_setup_gpe_for_wake(device->handle, wakeup->gpe_device, in acpi_wakeup_gpe_init()
906 wakeup->gpe_number); in acpi_wakeup_gpe_init()
915 if (!acpi_has_method(device->handle, "_PRW")) in acpi_bus_get_wakeup_device_flags()
920 dev_err(&device->dev, "_PRW evaluation error: %d\n", err); in acpi_bus_get_wakeup_device_flags()
924 device->wakeup.flags.valid = acpi_wakeup_gpe_init(device); in acpi_bus_get_wakeup_device_flags()
925 device->wakeup.prepare_count = 0; in acpi_bus_get_wakeup_device_flags()
940 struct acpi_device_power_state *ps = &device->power.states[state]; in acpi_bus_init_power_state()
945 INIT_LIST_HEAD(&ps->resources); in acpi_bus_init_power_state()
948 status = acpi_evaluate_object(device->handle, pathname, NULL, &buffer); in acpi_bus_init_power_state()
953 && package->type == ACPI_TYPE_PACKAGE in acpi_bus_init_power_state()
954 && package->package.count) in acpi_bus_init_power_state()
955 acpi_extract_power_resources(package, 0, &ps->resources); in acpi_bus_init_power_state()
962 if (acpi_has_method(device->handle, pathname)) in acpi_bus_init_power_state()
963 ps->flags.explicit_set = 1; in acpi_bus_init_power_state()
966 if (!list_empty(&ps->resources) || ps->flags.explicit_set) in acpi_bus_init_power_state()
967 ps->flags.valid = 1; in acpi_bus_init_power_state()
969 ps->power = -1; /* Unknown - driver assigned */ in acpi_bus_init_power_state()
970 ps->latency = -1; /* Unknown - driver assigned */ in acpi_bus_init_power_state()
978 if (!acpi_has_method(device->handle, "_PS0") && in acpi_bus_get_power_flags()
979 !acpi_has_method(device->handle, "_PR0")) in acpi_bus_get_power_flags()
982 device->flags.power_manageable = 1; in acpi_bus_get_power_flags()
987 if (acpi_has_method(device->handle, "_PSC")) in acpi_bus_get_power_flags()
988 device->power.flags.explicit_get = 1; in acpi_bus_get_power_flags()
990 if (acpi_has_method(device->handle, "_IRC")) in acpi_bus_get_power_flags()
991 device->power.flags.inrush_current = 1; in acpi_bus_get_power_flags()
993 if (acpi_has_method(device->handle, "_DSW")) in acpi_bus_get_power_flags()
994 device->power.flags.dsw_present = 1; in acpi_bus_get_power_flags()
1002 INIT_LIST_HEAD(&device->power.states[ACPI_STATE_D3_COLD].resources); in acpi_bus_get_power_flags()
1005 device->power.states[ACPI_STATE_D0].flags.valid = 1; in acpi_bus_get_power_flags()
1006 device->power.states[ACPI_STATE_D0].power = 100; in acpi_bus_get_power_flags()
1007 device->power.states[ACPI_STATE_D3_HOT].flags.valid = 1; in acpi_bus_get_power_flags()
1014 if (!list_empty(&device->power.states[ACPI_STATE_D0].resources)) { in acpi_bus_get_power_flags()
1015 device->power.flags.power_resources = 1; in acpi_bus_get_power_flags()
1020 if (!list_empty(&device->power.states[ACPI_STATE_D3_HOT].resources)) in acpi_bus_get_power_flags()
1021 device->power.states[ACPI_STATE_D3_COLD].flags.valid = 1; in acpi_bus_get_power_flags()
1025 device->flags.power_manageable = 0; in acpi_bus_get_power_flags()
1031 if (acpi_has_method(device->handle, "_STA")) in acpi_bus_get_flags()
1032 device->flags.dynamic_status = 1; in acpi_bus_get_flags()
1035 if (acpi_has_method(device->handle, "_RMV")) in acpi_bus_get_flags()
1036 device->flags.removable = 1; in acpi_bus_get_flags()
1039 if (acpi_has_method(device->handle, "_EJD") || in acpi_bus_get_flags()
1040 acpi_has_method(device->handle, "_EJ0")) in acpi_bus_get_flags()
1041 device->flags.ejectable = 1; in acpi_bus_get_flags()
1052 * ------ in acpi_device_get_busid()
1057 strcpy(device->pnp.bus_id, "ACPI"); in acpi_device_get_busid()
1061 switch (device->device_type) { in acpi_device_get_busid()
1063 strcpy(device->pnp.bus_id, "PWRF"); in acpi_device_get_busid()
1066 strcpy(device->pnp.bus_id, "SLPF"); in acpi_device_get_busid()
1069 strcpy(device->pnp.bus_id, "ECDT"); in acpi_device_get_busid()
1072 acpi_get_name(device->handle, ACPI_SINGLE_NAME, &buffer); in acpi_device_get_busid()
1074 for (i = 3; i > 1; i--) { in acpi_device_get_busid()
1080 strcpy(device->pnp.bus_id, bus_id); in acpi_device_get_busid()
1086 * acpi_ata_match - see if an acpi object is an ATA device
1100 * acpi_bay_match - see if an acpi object is an ejectable driver bay
1123 list_for_each_entry(hwid, &adev->pnp.ids, list) in acpi_device_is_battery()
1124 if (!strcmp("PNP0C0A", hwid->id)) in acpi_device_is_battery()
1132 acpi_handle handle = adev->handle; in is_ejectable_bay()
1141 * acpi_dock_match - see if an acpi object has a _DCK method
1205 if (list_empty(&device->pnp.ids)) in acpi_device_hid()
1208 hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list); in acpi_device_hid()
1209 return hid->id; in acpi_device_hid()
1221 id->id = kstrdup_const(dev_id, GFP_KERNEL); in acpi_add_id()
1222 if (!id->id) { in acpi_add_id()
1227 list_add_tail(&id->list, &pnp->ids); in acpi_add_id()
1228 pnp->type.hardware_id = 1; in acpi_add_id()
1294 if (info->valid & ACPI_VALID_HID) { in acpi_set_pnp_ids()
1295 acpi_add_id(pnp, info->hardware_id.string); in acpi_set_pnp_ids()
1296 pnp->type.platform_id = 1; in acpi_set_pnp_ids()
1298 if (info->valid & ACPI_VALID_CID) { in acpi_set_pnp_ids()
1299 cid_list = &info->compatible_id_list; in acpi_set_pnp_ids()
1300 for (i = 0; i < cid_list->count; i++) in acpi_set_pnp_ids()
1301 acpi_add_id(pnp, cid_list->ids[i].string); in acpi_set_pnp_ids()
1303 if (info->valid & ACPI_VALID_ADR) { in acpi_set_pnp_ids()
1304 pnp->bus_address = info->address; in acpi_set_pnp_ids()
1305 pnp->type.bus_address = 1; in acpi_set_pnp_ids()
1307 if (info->valid & ACPI_VALID_UID) in acpi_set_pnp_ids()
1308 pnp->unique_id = kstrdup(info->unique_id.string, in acpi_set_pnp_ids()
1310 if (info->valid & ACPI_VALID_CLS) in acpi_set_pnp_ids()
1311 acpi_add_id(pnp, info->class_code.string); in acpi_set_pnp_ids()
1327 else if (list_empty(&pnp->ids) && in acpi_set_pnp_ids()
1331 strcpy(pnp->device_name, ACPI_BUS_DEVICE_NAME); in acpi_set_pnp_ids()
1332 strcpy(pnp->device_class, ACPI_BUS_CLASS); in acpi_set_pnp_ids()
1361 list_for_each_entry_safe(id, tmp, &pnp->ids, list) { in acpi_free_pnp_ids()
1362 kfree_const(id->id); in acpi_free_pnp_ids()
1365 kfree(pnp->unique_id); in acpi_free_pnp_ids()
1369 * acpi_dma_supported - Check DMA support for the specified device.
1379 if (adev->flags.cca_seen) in acpi_dma_supported()
1383 * Per ACPI 6.0 sec 6.2.17, assume devices can do cache-coherent in acpi_dma_supported()
1394 * acpi_get_dma_attr - Check the supported DMA attr for the specified device.
1404 if (adev->flags.coherent_dma) in acpi_get_dma_attr()
1411 * acpi_dma_get_range() - Get device DMA parameters.
1441 if (adev && acpi_has_method(adev->handle, METHOD_NAME__DMA)) in acpi_dma_get_range()
1444 dma_dev = dma_dev->parent; in acpi_dma_get_range()
1448 return -ENODEV; in acpi_dma_get_range()
1450 if (!acpi_has_method(adev->handle, METHOD_NAME__CRS)) { in acpi_dma_get_range()
1451 acpi_handle_warn(adev->handle, "_DMA is valid only if _CRS is present\n"); in acpi_dma_get_range()
1452 return -EINVAL; in acpi_dma_get_range()
1458 if (dma_offset && rentry->offset != dma_offset) { in acpi_dma_get_range()
1459 ret = -EINVAL; in acpi_dma_get_range()
1463 dma_offset = rentry->offset; in acpi_dma_get_range()
1466 if (rentry->res->start < dma_start) in acpi_dma_get_range()
1467 dma_start = rentry->res->start; in acpi_dma_get_range()
1468 if (rentry->res->end > dma_end) in acpi_dma_get_range()
1469 dma_end = rentry->res->end; in acpi_dma_get_range()
1473 ret = -EINVAL; in acpi_dma_get_range()
1478 *dma_addr = dma_start - dma_offset; in acpi_dma_get_range()
1479 len = dma_end - dma_start; in acpi_dma_get_range()
1490 * acpi_dma_configure_id - Set-up DMA configuration for the device.
1509 if (PTR_ERR(iommu) == -EPROBE_DEFER) in acpi_dma_configure_id()
1510 return -EPROBE_DEFER; in acpi_dma_configure_id()
1523 struct acpi_device *parent = adev->parent; in acpi_init_coherency() local
1525 if (parent && parent->flags.cca_seen) { in acpi_init_coherency()
1530 adev->flags.cca_seen = 1; in acpi_init_coherency()
1531 cca = parent->flags.coherent_dma; in acpi_init_coherency()
1533 status = acpi_evaluate_integer(adev->handle, "_CCA", in acpi_init_coherency()
1536 adev->flags.cca_seen = 1; in acpi_init_coherency()
1540 * required for DMA-able devices (e.g. x86), in acpi_init_coherency()
1545 acpi_handle_debug(adev->handle, in acpi_init_coherency()
1549 adev->flags.coherent_dma = cca; in acpi_init_coherency()
1556 if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) in acpi_check_serial_bus_slave()
1562 return -1; in acpi_check_serial_bus_slave()
1567 struct acpi_device *parent = device->parent; in acpi_is_indirect_io_slave() local
1573 return parent && !acpi_match_device_ids(parent, indirect_io_hosts); in acpi_is_indirect_io_slave()
1582 * These devices have multiple I2cSerialBus resources and an i2c-client in acpi_device_enumeration_by_parent()
1584 * Normally we only instantiate an i2c-client for the first resource, in acpi_device_enumeration_by_parent()
1586 * drivers/platform/x86/i2c-multi-instantiate.c driver, which knows in acpi_device_enumeration_by_parent()
1597 * such as the rfkill-gpio driver. in acpi_device_enumeration_by_parent()
1609 (fwnode_property_present(&device->fwnode, "spiSclkPeriod") || in acpi_device_enumeration_by_parent()
1610 fwnode_property_present(&device->fwnode, "i2cAddress") || in acpi_device_enumeration_by_parent()
1611 fwnode_property_present(&device->fwnode, "baud"))) in acpi_device_enumeration_by_parent()
1629 INIT_LIST_HEAD(&device->pnp.ids); in acpi_init_device_object()
1630 device->device_type = type; in acpi_init_device_object()
1631 device->handle = handle; in acpi_init_device_object()
1632 device->parent = acpi_bus_get_parent(handle); in acpi_init_device_object()
1633 device->fwnode.ops = &acpi_device_fwnode_ops; in acpi_init_device_object()
1636 acpi_set_pnp_ids(handle, &device->pnp, type); in acpi_init_device_object()
1639 device->flags.match_driver = false; in acpi_init_device_object()
1640 device->flags.initialized = true; in acpi_init_device_object()
1641 device->flags.enumeration_by_parent = in acpi_init_device_object()
1644 device_initialize(&device->dev); in acpi_init_device_object()
1645 dev_set_uevent_suppress(&device->dev, true); in acpi_init_device_object()
1648 device->dep_unmet = 1; in acpi_init_device_object()
1653 dev_set_uevent_suppress(&device->dev, false); in acpi_device_add_finalize()
1654 kobject_uevent(&device->dev.kobj, KOBJ_ADD); in acpi_device_add_finalize()
1668 return -ENOMEM; in acpi_add_single_object()
1675 * Note this must be done before the get power-/wakeup_dev-flags calls. in acpi_add_single_object()
1686 acpi_device_release(&device->dev); in acpi_add_single_object()
1693 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Added %s [%s] parent %s\n", in acpi_add_single_object()
1694 dev_name(&device->dev), (char *) buffer.pointer, in acpi_add_single_object()
1695 device->parent ? dev_name(&device->parent->dev) : "(null)")); in acpi_add_single_object()
1744 return -ENODEV; in acpi_bus_type_and_status()
1750 return -ENODEV; in acpi_bus_type_and_status()
1763 return -ENODEV; in acpi_bus_type_and_status()
1774 return -ENODEV; in acpi_bus_type_and_status()
1782 return adev->status.present || adev->status.functional; in acpi_device_is_present()
1791 if (handler->match) in acpi_scan_handler_matching()
1792 return handler->match(idstr, matchid); in acpi_scan_handler_matching()
1794 for (devid = handler->ids; devid->id[0]; devid++) in acpi_scan_handler_matching()
1795 if (!strcmp((char *)devid->id, idstr)) { in acpi_scan_handler_matching()
1819 if (!!hotplug->enabled == !!val) in acpi_scan_hotplug_enabled()
1824 hotplug->enabled = val; in acpi_scan_hotplug_enabled()
1833 if (acpi_dock_match(adev->handle) || is_ejectable_bay(adev)) { in acpi_scan_init_hotplug()
1837 list_for_each_entry(hwid, &adev->pnp.ids, list) { in acpi_scan_init_hotplug()
1840 handler = acpi_scan_match_handler(hwid->id, NULL); in acpi_scan_init_hotplug()
1842 adev->flags.hotplug_notify = true; in acpi_scan_init_hotplug()
1855 adev->dep_unmet = 0; in acpi_device_dep_initialize()
1857 if (!acpi_has_method(adev->handle, "_DEP")) in acpi_device_dep_initialize()
1860 status = acpi_evaluate_reference(adev->handle, "_DEP", NULL, in acpi_device_dep_initialize()
1863 dev_dbg(&adev->dev, "Failed to evaluate _DEP.\n"); in acpi_device_dep_initialize()
1873 dev_dbg(&adev->dev, "Error reading _DEP device info\n"); in acpi_device_dep_initialize()
1881 skip = info->valid & ACPI_VALID_HID && in acpi_device_dep_initialize()
1882 !strcmp(info->hardware_id.string, "INT3396"); in acpi_device_dep_initialize()
1893 dep->master = dep_devices.handles[i]; in acpi_device_dep_initialize()
1894 dep->slave = adev->handle; in acpi_device_dep_initialize()
1895 adev->dep_unmet++; in acpi_device_dep_initialize()
1898 list_add_tail(&dep->node , &acpi_dep_list); in acpi_device_dep_initialize()
1944 if (!device->flags.enumeration_by_parent) { in acpi_default_enumeration()
1965 if (adev->data.of_compatible) in acpi_generic_device_attach()
1981 list_for_each_entry(hwid, &device->pnp.ids, list) { in acpi_scan_attach_handler()
1985 handler = acpi_scan_match_handler(hwid->id, &devid); in acpi_scan_attach_handler()
1987 if (!handler->attach) { in acpi_scan_attach_handler()
1988 device->pnp.type.platform_id = 0; in acpi_scan_attach_handler()
1991 device->handler = handler; in acpi_scan_attach_handler()
1992 ret = handler->attach(device, devid); in acpi_scan_attach_handler()
1996 device->handler = NULL; in acpi_scan_attach_handler()
2011 if (ACPI_SUCCESS(acpi_bus_get_ejd(device->handle, &ejd))) in acpi_bus_attach()
2017 device->flags.initialized = false; in acpi_bus_attach()
2019 device->flags.power_manageable = 0; in acpi_bus_attach()
2022 if (device->handler) in acpi_bus_attach()
2025 if (!device->flags.initialized) { in acpi_bus_attach()
2026 device->flags.power_manageable = in acpi_bus_attach()
2027 device->power.states[ACPI_STATE_D0].flags.valid; in acpi_bus_attach()
2029 device->flags.power_manageable = 0; in acpi_bus_attach()
2031 device->flags.initialized = true; in acpi_bus_attach()
2032 } else if (device->flags.visited) { in acpi_bus_attach()
2040 device->flags.match_driver = true; in acpi_bus_attach()
2041 if (ret > 0 && !device->flags.enumeration_by_parent) { in acpi_bus_attach()
2046 ret = device_attach(&device->dev); in acpi_bus_attach()
2050 if (device->pnp.type.platform_id || device->flags.enumeration_by_parent) in acpi_bus_attach()
2056 list_for_each_entry(child, &device->children, node) in acpi_bus_attach()
2059 if (device->handler && device->handler->hotplug.notify_online) in acpi_bus_attach()
2060 device->handler->hotplug.notify_online(device); in acpi_bus_attach()
2070 if (dep->master == handle) { in acpi_walk_dep_device_list()
2071 acpi_bus_get_device(dep->slave, &adev); in acpi_walk_dep_device_list()
2075 adev->dep_unmet--; in acpi_walk_dep_device_list()
2076 if (!adev->dep_unmet) in acpi_walk_dep_device_list()
2078 list_del(&dep->node); in acpi_walk_dep_device_list()
2087 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
2090 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
2093 * If no devices were found, -ENODEV is returned, but it does not mean that
2112 return -ENODEV; in acpi_bus_scan()
2117 * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects.
2124 struct acpi_scan_handler *handler = adev->handler; in acpi_bus_trim()
2127 list_for_each_entry_reverse(child, &adev->children, node) in acpi_bus_trim()
2130 adev->flags.match_driver = false; in acpi_bus_trim()
2132 if (handler->detach) in acpi_bus_trim()
2133 handler->detach(adev); in acpi_bus_trim()
2135 adev->handler = NULL; in acpi_bus_trim()
2137 device_release_driver(&adev->dev); in acpi_bus_trim()
2144 adev->flags.initialized = false; in acpi_bus_trim()
2159 device->flags.match_driver = true; in acpi_bus_register_early_device()
2160 return device_attach(&device->dev); in acpi_bus_register_early_device()
2169 * Enumerate all fixed-feature devices. in acpi_bus_scan_fixed()
2180 device->flags.match_driver = true; in acpi_bus_scan_fixed()
2181 result = device_attach(&device->dev); in acpi_bus_scan_fixed()
2185 device_init_wakeup(&device->dev, true); in acpi_bus_scan_fixed()
2197 device->flags.match_driver = true; in acpi_bus_scan_fixed()
2198 result = device_attach(&device->dev); in acpi_bus_scan_fixed()
2216 spcr_uart_addr = spcr_ptr->serial_port.address; in acpi_get_spcr_uart_addr()
2252 if (stao_ptr->header.length > sizeof(struct acpi_table_stao)) in acpi_scan_init()
2255 if (stao_ptr->ignore_uart) in acpi_scan_init()
2282 /* Fixed feature devices do not exist on HW-reduced platform */ in acpi_scan_init()
2286 acpi_detach_data(acpi_root->handle, in acpi_scan_init()
2289 put_device(&acpi_root->dev); in acpi_scan_init()
2308 if (!ape->subtable_valid || ape->subtable_valid(&header->common, ape)) in acpi_match_madt()
2309 if (!ape->probe_subtbl(header, end)) in acpi_match_madt()
2323 for (ape = ap_head; nr; ape++, nr--) { in __acpi_probe_device_table()
2324 if (ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id)) { in __acpi_probe_device_table()
2326 acpi_table_parse_madt(ape->type, acpi_match_madt, 0); in __acpi_probe_device_table()
2330 res = acpi_table_parse(ape->id, ape->probe_table); in __acpi_probe_device_table()
2352 if (tew->event == ACPI_TABLE_EVENT_LOAD) { in acpi_table_events_fn()
2375 INIT_WORK(&tew->work, acpi_table_events_fn); in acpi_scan_table_handler()
2376 tew->table = table; in acpi_scan_table_handler()
2377 tew->event = event; in acpi_scan_table_handler()
2379 schedule_work(&tew->work); in acpi_scan_table_handler()