Lines Matching +full:per +full:- +full:hart
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ACPI-WMI mapping driver
5 * Copyright (C) 2007-2008 Carlos Corbacho <carlos@strangeworlds.co.uk>
9 * Copyright (c) 2001-2007 Anton Altaparmakov
12 * WMI bus infrastructure by Andrew Lutomirski and Darren Hart:
37 MODULE_DESCRIPTION("ACPI-WMI Mapping Driver");
93 "05901221-D566-11D1-B2F0-00A0C9062910", /* wmi-bmof */
94 "8A42EA14-4F2A-FD45-6422-0087F7A7E608", /* dell-wmi-ddv */
95 "44FADEB1-B204-40F2-8581-394BBDC1B651", /* intel-wmi-sbl-fw-update */
96 "86CCFD48-205E-4A77-9C48-2021CBEDE341", /* intel-wmi-thunderbolt */
97 "F1DDEE52-063C-4784-A11E-8A06684B9B01", /* dell-smm-hwmon */
123 id = wdriver->id_table; in find_guid_context()
127 while (*id->guid_string) { in find_guid_context()
128 if (guid_parse_and_compare(id->guid_string, &wblock->gblock.guid)) in find_guid_context()
129 return id->context; in find_guid_context()
143 return -ENOENT; in get_subobj_info()
146 return -EIO; in get_subobj_info()
150 return -EIO; in get_subobj_info()
162 block = &wblock->gblock; in wmi_method_enable()
163 handle = wblock->acpi_device->handle; in wmi_method_enable()
165 snprintf(method, 5, "WE%02X", block->notify_id); in wmi_method_enable()
179 static_assert(ARRAY_SIZE(wblock->gblock.object_id) == 2); in get_acpi_method_name()
184 buffer[2] = wblock->gblock.object_id[0]; in get_acpi_method_name()
185 buffer[3] = wblock->gblock.object_id[1]; in get_acpi_method_name()
191 if (wblock->gblock.flags & ACPI_WMI_STRING) in get_param_acpi_type()
202 .value = wblock->gblock.notify_id, in get_event_data()
210 return acpi_evaluate_object(wblock->acpi_device->handle, "_WED", &input, out); in get_event_data()
218 if (guid_equal(guid, &wblock->gblock.guid)) in wmidev_match_guid()
229 if (wblock->gblock.flags & ACPI_WMI_EVENT && wblock->gblock.notify_id == *notify_id) in wmidev_match_notify_id()
249 return ERR_PTR(-ENODEV); in wmi_find_device_by_guid()
260 return ERR_PTR(-ENODEV); in wmi_find_event_by_notify_id()
267 put_device(&wdev->dev); in wmi_device_put()
275 * wmi_instance_count - Get number of WMI object instances
276 * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
299 * wmidev_instance_count - Get number of WMI object instances
310 return wblock->gblock.instance_count; in wmidev_instance_count()
315 * wmi_evaluate_method - Evaluate a WMI method (deprecated)
316 * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
322 * Call an ACPI-WMI method, the caller must free @out.
345 * wmidev_evaluate_method - Evaluate a WMI method
352 * Call an ACPI-WMI method, the caller must free @out.
367 block = &wblock->gblock; in wmidev_evaluate_method()
368 handle = wblock->acpi_device->handle; in wmidev_evaluate_method()
370 if (!(block->flags & ACPI_WMI_METHOD)) in wmidev_evaluate_method()
373 if (block->instance_count <= instance) in wmidev_evaluate_method()
387 params[2].buffer.length = in->length; in wmidev_evaluate_method()
388 params[2].buffer.pointer = in->pointer; in wmidev_evaluate_method()
411 block = &wblock->gblock; in __query_block()
412 handle = wblock->acpi_device->handle; in __query_block()
414 if (block->instance_count <= instance) in __query_block()
418 if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD)) in __query_block()
426 if (instance == 0 && test_bit(WMI_READ_TAKES_NO_ARGS, &wblock->flags)) in __query_block()
433 if (block->flags & ACPI_WMI_EXPENSIVE) { in __query_block()
449 * the WQxx method failed - we should disable collection anyway. in __query_block()
451 if ((block->flags & ACPI_WMI_EXPENSIVE) && ACPI_SUCCESS(wc_status)) { in __query_block()
466 * wmi_query_block - Return contents of a WMI block (deprecated)
467 * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
471 * Query a ACPI-WMI block, the caller must free @out.
496 * wmidev_block_query - Return contents of a WMI block
500 * Query an ACPI-WMI block, the caller must free the result.
517 * wmi_set_block - Write to a WMI block (deprecated)
518 * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
522 * Write the contents of the input buffer to an ACPI-WMI data block.
543 * wmidev_block_set - Write to a WMI block
548 * Write contents of the input buffer to an ACPI-WMI data block.
555 acpi_handle handle = wblock->acpi_device->handle; in wmidev_block_set()
556 struct guid_block *block = &wblock->gblock; in wmidev_block_set()
564 if (block->instance_count <= instance) in wmidev_block_set()
568 if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD)) in wmidev_block_set()
576 params[1].buffer.length = in->length; in wmidev_block_set()
577 params[1].buffer.pointer = in->pointer; in wmidev_block_set()
586 * wmi_install_notify_handler - Register handler for WMI events (deprecated)
587 * @guid: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
591 * Register a handler for events sent to the ACPI-WMI mapper device.
609 down_write(&wblock->notify_lock); in wmi_install_notify_handler()
610 if (wblock->handler) { in wmi_install_notify_handler()
613 wblock->handler = handler; in wmi_install_notify_handler()
614 wblock->handler_data = data; in wmi_install_notify_handler()
617 dev_warn(&wblock->dev.dev, "Failed to enable device\n"); in wmi_install_notify_handler()
621 up_write(&wblock->notify_lock); in wmi_install_notify_handler()
630 * wmi_remove_notify_handler - Unregister handler for WMI events (deprecated)
631 * @guid: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
633 * Unregister handler for events sent to the ACPI-WMI mapper device.
649 down_write(&wblock->notify_lock); in wmi_remove_notify_handler()
650 if (!wblock->handler) { in wmi_remove_notify_handler()
654 dev_warn(&wblock->dev.dev, "Failed to disable device\n"); in wmi_remove_notify_handler()
656 wblock->handler = NULL; in wmi_remove_notify_handler()
657 wblock->handler_data = NULL; in wmi_remove_notify_handler()
661 up_write(&wblock->notify_lock); in wmi_remove_notify_handler()
670 * wmi_get_event_data - Get WMI data associated with an event (deprecated)
699 * wmi_has_guid - Check if a GUID is available
700 * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
721 * wmi_get_acpi_device_uid() - Get _UID name of ACPI device that defines GUID (deprecated)
722 * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
739 uid = acpi_device_uid(wblock->acpi_device); in wmi_get_acpi_device_uid()
760 return sysfs_emit(buf, "wmi:%pUL\n", &wblock->gblock.guid); in modalias_show()
769 return sysfs_emit(buf, "%pUL\n", &wblock->gblock.guid); in guid_show()
778 return sysfs_emit(buf, "%d\n", (int)wblock->gblock.instance_count); in instance_count_show()
788 (wblock->gblock.flags & ACPI_WMI_EXPENSIVE) != 0); in expensive_show()
806 return sysfs_emit(buf, "%02X\n", (unsigned int)wblock->gblock.notify_id); in notify_id_show()
821 return sysfs_emit(buf, "%c%c\n", wblock->gblock.object_id[0], in object_id_show()
822 wblock->gblock.object_id[1]); in object_id_show()
831 return sysfs_emit(buf, "%d\n", (int)wdev->setable); in setable_show()
852 if (add_uevent_var(env, "MODALIAS=wmi:%pUL", &wblock->gblock.guid)) in wmi_dev_uevent()
853 return -ENOMEM; in wmi_dev_uevent()
855 if (add_uevent_var(env, "WMI_GUID=%pUL", &wblock->gblock.guid)) in wmi_dev_uevent()
856 return -ENOMEM; in wmi_dev_uevent()
872 const struct wmi_device_id *id = wmi_driver->id_table; in wmi_dev_match()
877 while (*id->guid_string) { in wmi_dev_match()
878 if (guid_parse_and_compare(id->guid_string, &wblock->gblock.guid)) in wmi_dev_match()
890 struct wmi_driver *wdriver = drv_to_wdrv(dev->driver); in wmi_dev_probe()
894 dev_warn(dev, "failed to enable device -- probing anyway\n"); in wmi_dev_probe()
896 if (wdriver->probe) { in wmi_dev_probe()
897 ret = wdriver->probe(dev_to_wdev(dev), in wmi_dev_probe()
907 down_write(&wblock->notify_lock); in wmi_dev_probe()
908 wblock->driver_ready = true; in wmi_dev_probe()
909 up_write(&wblock->notify_lock); in wmi_dev_probe()
917 struct wmi_driver *wdriver = drv_to_wdrv(dev->driver); in wmi_dev_remove()
919 down_write(&wblock->notify_lock); in wmi_dev_remove()
920 wblock->driver_ready = false; in wmi_dev_remove()
921 up_write(&wblock->notify_lock); in wmi_dev_remove()
923 if (wdriver->remove) in wmi_dev_remove()
924 wdriver->remove(dev_to_wdev(dev)); in wmi_dev_remove()
971 if (guid_equal(&wblock->gblock.guid, guid)) in guid_count()
987 if (wblock->gblock.flags & ACPI_WMI_EVENT) { in wmi_create_device()
988 wblock->dev.dev.type = &wmi_type_event; in wmi_create_device()
992 if (wblock->gblock.flags & ACPI_WMI_METHOD) { in wmi_create_device()
993 wblock->dev.dev.type = &wmi_type_method; in wmi_create_device()
999 * required per the WMI documentation. If it is not present, in wmi_create_device()
1003 result = get_subobj_info(device->handle, method, &info); in wmi_create_device()
1012 wblock->dev.dev.type = &wmi_type_data; in wmi_create_device()
1024 if (info->type != ACPI_TYPE_METHOD || info->param_count == 0) in wmi_create_device()
1025 set_bit(WMI_READ_TAKES_NO_ARGS, &wblock->flags); in wmi_create_device()
1030 if (acpi_has_method(device->handle, method)) in wmi_create_device()
1031 wblock->dev.setable = true; in wmi_create_device()
1034 init_rwsem(&wblock->notify_lock); in wmi_create_device()
1035 wblock->driver_ready = false; in wmi_create_device()
1036 wblock->dev.dev.bus = &wmi_bus_type; in wmi_create_device()
1037 wblock->dev.dev.parent = wmi_bus_dev; in wmi_create_device()
1039 count = guid_count(&wblock->gblock.guid); in wmi_create_device()
1041 dev_set_name(&wblock->dev.dev, "%pUL-%d", &wblock->gblock.guid, count); in wmi_create_device()
1043 dev_set_name(&wblock->dev.dev, "%pUL", &wblock->gblock.guid); in wmi_create_device()
1045 device_initialize(&wblock->dev.dev); in wmi_create_device()
1055 * Many aggregate WMI drivers do not use -EPROBE_DEFER when they in wmi_add_device()
1063 link = device_link_add(&wdev->dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER); in wmi_add_device()
1065 return -EINVAL; in wmi_add_device()
1067 return device_add(&wdev->dev); in wmi_add_device()
1080 if (guid_equal(&wblock->gblock.guid, guid)) { in guid_already_parsed_for_legacy()
1087 dev_warn(&device->dev, "duplicate WMI GUID %pUL (first instance was on %s)\n", in guid_already_parsed_for_legacy()
1088 guid, dev_name(&wblock->acpi_device->dev)); in guid_already_parsed_for_legacy()
1101 struct acpi_device *device = ACPI_COMPANION(&pdev->dev); in parse_wdg()
1110 status = acpi_evaluate_object(device->handle, "_WDG", NULL, &out); in parse_wdg()
1112 return -ENXIO; in parse_wdg()
1116 return -ENXIO; in parse_wdg()
1118 if (obj->type != ACPI_TYPE_BUFFER) { in parse_wdg()
1120 return -ENXIO; in parse_wdg()
1123 gblock = (const struct guid_block *)obj->buffer.pointer; in parse_wdg()
1124 total = obj->buffer.length / sizeof(struct guid_block); in parse_wdg()
1141 wblock->acpi_device = device; in parse_wdg()
1142 wblock->gblock = gblock[i]; in parse_wdg()
1150 list_add_tail(&wblock->list, &wmi_block_list); in parse_wdg()
1152 retval = wmi_add_device(pdev, &wblock->dev); in parse_wdg()
1155 &wblock->gblock.guid); in parse_wdg()
1157 list_del(&wblock->list); in parse_wdg()
1158 put_device(&wblock->dev.dev); in parse_wdg()
1197 case -EINVAL: in acpi_wmi_ec_space_handler()
1199 case -ENODEV: in acpi_wmi_ec_space_handler()
1201 case -ETIME: in acpi_wmi_ec_space_handler()
1210 struct wmi_driver *driver = drv_to_wdrv(wblock->dev.dev.driver); in wmi_notify_driver()
1214 if (!driver->no_notify_data) { in wmi_notify_driver()
1217 dev_warn(&wblock->dev.dev, "Failed to get event data\n"); in wmi_notify_driver()
1222 if (driver->notify) in wmi_notify_driver()
1223 driver->notify(&wblock->dev, data.pointer); in wmi_notify_driver()
1233 if (!(wblock->gblock.flags & ACPI_WMI_EVENT && wblock->gblock.notify_id == *event)) in wmi_notify_device()
1236 down_read(&wblock->notify_lock); in wmi_notify_device()
1240 if (wblock->dev.dev.driver && wblock->driver_ready) { in wmi_notify_device()
1243 if (wblock->handler) in wmi_notify_device()
1244 wblock->handler(*event, wblock->handler_data); in wmi_notify_device()
1246 up_read(&wblock->notify_lock); in wmi_notify_device()
1248 acpi_bus_generate_netlink_event(wblock->acpi_device->pnp.device_class, in wmi_notify_device()
1249 dev_name(&wblock->dev.dev), *event, 0); in wmi_notify_device()
1251 return -EBUSY; in wmi_notify_device()
1265 list_del(&wblock->list); in wmi_remove_device()
1273 struct device *wmi_bus_device = dev_get_drvdata(&device->dev); in acpi_wmi_remove()
1282 acpi_remove_notify_handler(acpi_device->handle, ACPI_ALL_NOTIFY, acpi_wmi_notify_handler); in acpi_wmi_remove_notify_handler()
1289 acpi_remove_address_space_handler(acpi_device->handle, ACPI_ADR_SPACE_EC, in acpi_wmi_remove_address_space_handler()
1307 acpi_device = ACPI_COMPANION(&device->dev); in acpi_wmi_probe()
1309 dev_err(&device->dev, "ACPI companion is missing\n"); in acpi_wmi_probe()
1310 return -ENODEV; in acpi_wmi_probe()
1313 wmi_bus_dev = device_create(&wmi_bus_class, &device->dev, MKDEV(0, 0), NULL, "wmi_bus-%s", in acpi_wmi_probe()
1314 dev_name(&device->dev)); in acpi_wmi_probe()
1318 error = devm_add_action_or_reset(&device->dev, acpi_wmi_remove_bus_device, wmi_bus_dev); in acpi_wmi_probe()
1322 dev_set_drvdata(&device->dev, wmi_bus_dev); in acpi_wmi_probe()
1324 status = acpi_install_address_space_handler(acpi_device->handle, in acpi_wmi_probe()
1329 dev_err(&device->dev, "Error installing EC region handler\n"); in acpi_wmi_probe()
1330 return -ENODEV; in acpi_wmi_probe()
1332 error = devm_add_action_or_reset(&device->dev, acpi_wmi_remove_address_space_handler, in acpi_wmi_probe()
1337 status = acpi_install_notify_handler(acpi_device->handle, ACPI_ALL_NOTIFY, in acpi_wmi_probe()
1340 dev_err(&device->dev, "Error installing notify handler\n"); in acpi_wmi_probe()
1341 return -ENODEV; in acpi_wmi_probe()
1343 error = devm_add_action_or_reset(&device->dev, acpi_wmi_remove_notify_handler, in acpi_wmi_probe()
1360 driver->driver.owner = owner; in __wmi_driver_register()
1361 driver->driver.bus = &wmi_bus_type; in __wmi_driver_register()
1363 return driver_register(&driver->driver); in __wmi_driver_register()
1368 * wmi_driver_unregister() - Unregister a WMI driver
1375 driver_unregister(&driver->driver); in wmi_driver_unregister()
1381 .name = "acpi-wmi",
1393 return -ENODEV; in acpi_wmi_init()