Lines Matching +full:hart +full:- +full:compatible

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2014 - 2023, Intel Corporation
9 * Darren Hart <dvhart@linux.intel.com>
38 * https://github.com/UEFI/DSD-Guide/blob/main/src/dsd-guide.adoc
41 /* ACPI _DSD device properties GUID [1]: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 */
44 /* Hotplug in D3 GUID: 6211e2c0-58a3-4af3-90e1-927a4e0c55a4 */
47 /* External facing port GUID: efcc06cc-73ac-4bc3-bff0-76143807c389 */
50 /* Thunderbolt GUID for IMR_VALID: c44d002f-69f9-4e7d-a904-a7baabdf43f7 */
53 /* Thunderbolt GUID for WAKE_SUPPORTED: 6c501103-c189-4296-ba72-9bf5a26ebe5d */
56 /* Storage device needs D3 GUID: 5025030f-842f-4ab4-a561-99a5189762d0 */
61 /* ACPI _DSD data subnodes GUID [1]: dbb8e3e6-5886-4ba6-8795-1319f52a966b */
66 /* ACPI _DSD data buffer GUID [1]: edb12dd0-363d-4085-a3d2-49522ca160c4 */
95 dn->name = link->package.elements[0].string.pointer; in acpi_nondev_subnode_extract()
96 fwnode_init(&dn->fwnode, &acpi_data_fwnode_ops); in acpi_nondev_subnode_extract()
97 dn->parent = parent; in acpi_nondev_subnode_extract()
98 INIT_LIST_HEAD(&dn->data.properties); in acpi_nondev_subnode_extract()
99 INIT_LIST_HEAD(&dn->data.subnodes); in acpi_nondev_subnode_extract()
101 result = acpi_extract_properties(handle, desc, &dn->data); in acpi_nondev_subnode_extract()
115 && acpi_enumerate_nondev_subnodes(scope, desc, &dn->data, in acpi_nondev_subnode_extract()
116 &dn->fwnode)) in acpi_nondev_subnode_extract()
118 } else if (acpi_enumerate_nondev_subnodes(NULL, desc, &dn->data, in acpi_nondev_subnode_extract()
119 &dn->fwnode)) { in acpi_nondev_subnode_extract()
124 dn->handle = handle; in acpi_nondev_subnode_extract()
125 dn->data.pointer = desc; in acpi_nondev_subnode_extract()
126 list_add_tail(&dn->sibling, list); in acpi_nondev_subnode_extract()
167 status = acpi_get_handle(scope, link->package.elements[1].string.pointer, in acpi_nondev_subnode_ok()
183 for (i = 0; i < links->package.count; i++) { in acpi_add_nondev_subnodes()
188 link = &links->package.elements[i]; in acpi_add_nondev_subnodes()
190 if (link->package.count != 2) in acpi_add_nondev_subnodes()
194 if (link->package.elements[0].type != ACPI_TYPE_STRING) in acpi_add_nondev_subnodes()
198 switch (link->package.elements[1].type) { in acpi_add_nondev_subnodes()
204 handle = link->package.elements[1].reference.handle; in acpi_add_nondev_subnodes()
209 desc = &link->package.elements[1]; in acpi_add_nondev_subnodes()
231 for (i = 0; i < desc->package.count; i += 2) { in acpi_enumerate_nondev_subnodes()
235 guid = &desc->package.elements[i]; in acpi_enumerate_nondev_subnodes()
236 links = &desc->package.elements[i + 1]; in acpi_enumerate_nondev_subnodes()
242 if (guid->type != ACPI_TYPE_BUFFER || in acpi_enumerate_nondev_subnodes()
243 guid->buffer.length != 16 || in acpi_enumerate_nondev_subnodes()
244 links->type != ACPI_TYPE_PACKAGE) in acpi_enumerate_nondev_subnodes()
247 if (!guid_equal((guid_t *)guid->buffer.pointer, &ads_guid)) in acpi_enumerate_nondev_subnodes()
250 return acpi_add_nondev_subnodes(scope, links, &data->subnodes, in acpi_enumerate_nondev_subnodes()
265 switch (value->type) { in acpi_property_value_ok()
272 for (j = 0; j < value->package.count; j++) in acpi_property_value_ok()
273 switch (value->package.elements[j].type) { in acpi_property_value_ok()
292 for (i = 0; i < properties->package.count; i++) { in acpi_properties_format_valid()
295 property = &properties->package.elements[i]; in acpi_properties_format_valid()
300 if (property->package.count != 2 in acpi_properties_format_valid()
301 || property->package.elements[0].type != ACPI_TYPE_STRING in acpi_properties_format_valid()
302 || !acpi_property_value_ok(&property->package.elements[1])) in acpi_properties_format_valid()
313 ret = acpi_data_get_property_array(&adev->data, "compatible", in acpi_init_of_compatible()
316 ret = acpi_dev_get_property(adev, "compatible", in acpi_init_of_compatible()
322 if (parent && parent->flags.of_compatible_ok) in acpi_init_of_compatible()
328 adev->data.of_compatible = of_compatible; in acpi_init_of_compatible()
331 adev->flags.of_compatible_ok = 1; in acpi_init_of_compatible()
354 INIT_LIST_HEAD(&props->list); in acpi_data_add_props()
355 props->guid = guid; in acpi_data_add_props()
356 props->properties = properties; in acpi_data_add_props()
357 list_add_tail(&props->list, &data->properties); in acpi_data_add_props()
371 list_for_each_entry(dn, &data->subnodes, sibling) { in acpi_untie_nondev_subnodes()
372 acpi_detach_data(dn->handle, acpi_nondev_subnode_tag); in acpi_untie_nondev_subnodes()
374 acpi_untie_nondev_subnodes(&dn->data); in acpi_untie_nondev_subnodes()
382 list_for_each_entry(dn, &data->subnodes, sibling) { in acpi_tie_nondev_subnodes()
386 status = acpi_attach_data(dn->handle, acpi_nondev_subnode_tag, dn); in acpi_tie_nondev_subnodes()
388 acpi_handle_err(dn->handle, "Can't tag data node\n"); in acpi_tie_nondev_subnodes()
392 ret = acpi_tie_nondev_subnodes(&dn->data); in acpi_tie_nondev_subnodes()
410 if (check_mul_overflow((size_t)properties->package.count, in acpi_data_add_buffer_props()
417 properties->package.count); in acpi_data_add_buffer_props()
425 props->guid = &buffer_prop_guid; in acpi_data_add_buffer_props()
426 props->bufs = (void *)(props + 1); in acpi_data_add_buffer_props()
427 props->properties = (void *)(props->bufs + properties->package.count); in acpi_data_add_buffer_props()
430 package = props->properties; in acpi_data_add_buffer_props()
431 package->type = ACPI_TYPE_PACKAGE; in acpi_data_add_buffer_props()
432 package->package.elements = package + 1; in acpi_data_add_buffer_props()
433 count = &package->package.count; in acpi_data_add_buffer_props()
439 for (i = 0; i < properties->package.count; i++) { in acpi_data_add_buffer_props()
441 union acpi_object *property = &properties->package.elements[i]; in acpi_data_add_buffer_props()
445 if (property->type != ACPI_TYPE_PACKAGE || in acpi_data_add_buffer_props()
446 property->package.count != 2) { in acpi_data_add_buffer_props()
449 i, property->package.count); in acpi_data_add_buffer_props()
453 prop = &property->package.elements[0]; in acpi_data_add_buffer_props()
454 obj = &property->package.elements[1]; in acpi_data_add_buffer_props()
456 if (prop->type != ACPI_TYPE_STRING || in acpi_data_add_buffer_props()
457 obj->type != ACPI_TYPE_STRING) { in acpi_data_add_buffer_props()
460 prop->type, obj->type); in acpi_data_add_buffer_props()
464 status = acpi_evaluate_object_typed(handle, obj->string.pointer, in acpi_data_add_buffer_props()
470 obj->string.length, in acpi_data_add_buffer_props()
471 obj->string.pointer); in acpi_data_add_buffer_props()
475 package->type = ACPI_TYPE_PACKAGE; in acpi_data_add_buffer_props()
476 package->package.elements = prop; in acpi_data_add_buffer_props()
477 package->package.count = 2; in acpi_data_add_buffer_props()
482 obj->type = ACPI_TYPE_BUFFER; in acpi_data_add_buffer_props()
483 obj->buffer.length = buf_obj->buffer.length; in acpi_data_add_buffer_props()
484 obj->buffer.pointer = buf_obj->buffer.pointer; in acpi_data_add_buffer_props()
486 props->bufs[i] = buf.pointer; in acpi_data_add_buffer_props()
492 list_add(&props->list, &data->properties); in acpi_data_add_buffer_props()
502 if (desc->package.count % 2) in acpi_extract_properties()
506 for (i = 0; i < desc->package.count; i += 2) { in acpi_extract_properties()
510 guid = &desc->package.elements[i]; in acpi_extract_properties()
511 properties = &desc->package.elements[i + 1]; in acpi_extract_properties()
517 if (guid->type != ACPI_TYPE_BUFFER || in acpi_extract_properties()
518 guid->buffer.length != 16 || in acpi_extract_properties()
519 properties->type != ACPI_TYPE_PACKAGE) in acpi_extract_properties()
522 if (guid_equal((guid_t *)guid->buffer.pointer, in acpi_extract_properties()
528 if (!acpi_is_property_guid((guid_t *)guid->buffer.pointer)) in acpi_extract_properties()
538 acpi_data_add_props(data, (const guid_t *)guid->buffer.pointer, in acpi_extract_properties()
542 return !list_empty(&data->properties); in acpi_extract_properties()
552 INIT_LIST_HEAD(&adev->data.properties); in acpi_init_properties()
553 INIT_LIST_HEAD(&adev->data.subnodes); in acpi_init_properties()
555 if (!adev->handle) in acpi_init_properties()
560 * Device Tree compatible properties for this device. in acpi_init_properties()
562 list_for_each_entry(hwid, &adev->pnp.ids, list) { in acpi_init_properties()
563 if (!strcmp(hwid->id, ACPI_DT_NAMESPACE_HID)) { in acpi_init_properties()
569 status = acpi_evaluate_object_typed(adev->handle, "_DSD", NULL, &buf, in acpi_init_properties()
574 if (acpi_extract_properties(adev->handle, buf.pointer, &adev->data)) { in acpi_init_properties()
575 adev->data.pointer = buf.pointer; in acpi_init_properties()
579 if (acpi_enumerate_nondev_subnodes(adev->handle, buf.pointer, in acpi_init_properties()
580 &adev->data, acpi_fwnode_handle(adev))) in acpi_init_properties()
581 adev->data.pointer = buf.pointer; in acpi_init_properties()
583 if (!adev->data.pointer) { in acpi_init_properties()
584 acpi_handle_debug(adev->handle, "Invalid _DSD data, skipping\n"); in acpi_init_properties()
587 if (!acpi_tie_nondev_subnodes(&adev->data)) in acpi_init_properties()
588 acpi_untie_nondev_subnodes(&adev->data); in acpi_init_properties()
592 if (acpi_of && !adev->flags.of_compatible_ok) in acpi_init_properties()
593 acpi_handle_info(adev->handle, in acpi_init_properties()
594 ACPI_DT_NAMESPACE_HID " requires 'compatible' property\n"); in acpi_init_properties()
596 if (!adev->data.pointer) in acpi_init_properties()
607 list_del(&props->list); in acpi_free_device_properties()
609 if (props->bufs) in acpi_free_device_properties()
610 for (i = 0; i < props->properties->package.count; i++) in acpi_free_device_properties()
611 ACPI_FREE(props->bufs[i]); in acpi_free_device_properties()
624 acpi_destroy_nondev_subnodes(&dn->data.subnodes); in acpi_destroy_nondev_subnodes()
625 wait_for_completion(&dn->kobj_done); in acpi_destroy_nondev_subnodes()
626 list_del(&dn->sibling); in acpi_destroy_nondev_subnodes()
627 ACPI_FREE((void *)dn->data.pointer); in acpi_destroy_nondev_subnodes()
628 acpi_free_device_properties(&dn->data.properties); in acpi_destroy_nondev_subnodes()
635 acpi_untie_nondev_subnodes(&adev->data); in acpi_free_properties()
636 acpi_destroy_nondev_subnodes(&adev->data.subnodes); in acpi_free_properties()
637 ACPI_FREE((void *)adev->data.pointer); in acpi_free_properties()
638 adev->data.of_compatible = NULL; in acpi_free_properties()
639 adev->data.pointer = NULL; in acpi_free_properties()
640 acpi_free_device_properties(&adev->data.properties); in acpi_free_properties()
644 * acpi_data_get_property - return an ACPI property with given name
657 * %-EINVAL if the arguments are invalid,
658 * %-EINVAL if the property doesn't exist,
659 * %-EPROTO if the property value type doesn't match @type.
668 return -EINVAL; in acpi_data_get_property()
670 if (!data->pointer || list_empty(&data->properties)) in acpi_data_get_property()
671 return -EINVAL; in acpi_data_get_property()
673 list_for_each_entry(props, &data->properties, list) { in acpi_data_get_property()
677 properties = props->properties; in acpi_data_get_property()
678 for (i = 0; i < properties->package.count; i++) { in acpi_data_get_property()
682 property = &properties->package.elements[i]; in acpi_data_get_property()
684 propname = &property->package.elements[0]; in acpi_data_get_property()
685 propvalue = &property->package.elements[1]; in acpi_data_get_property()
687 if (!strcmp(name, propname->string.pointer)) { in acpi_data_get_property()
689 propvalue->type != type) in acpi_data_get_property()
690 return -EPROTO; in acpi_data_get_property()
698 return -EINVAL; in acpi_data_get_property()
702 * acpi_dev_get_property - return an ACPI property with given name.
711 return adev ? acpi_data_get_property(&adev->data, name, type, obj) : -EINVAL; in acpi_dev_get_property()
720 return &adev->data; in acpi_device_data_of_node()
724 return &dn->data; in acpi_device_data_of_node()
730 * acpi_node_prop_get - return an ACPI property with given name.
744 * acpi_data_get_property_array - return an ACPI array property with given name
757 * %-EINVAL if the arguments are invalid,
758 * %-EINVAL if the property doesn't exist,
759 * %-EPROTO if the property is not a package or the type of its elements
776 for (i = 0; i < prop->package.count; i++) in acpi_data_get_property_array()
777 if (prop->package.elements[i].type != type) in acpi_data_get_property_array()
778 return -EPROTO; in acpi_data_get_property_array()
829 return -EINVAL; in acpi_get_ref_args()
833 return -EINVAL; in acpi_get_ref_args()
836 args->fwnode = ref_fwnode; in acpi_get_ref_args()
837 args->nargs = nargs; in acpi_get_ref_args()
839 args->args[i] = (*element)[i].integer.value; in acpi_get_ref_args()
856 scope = to_acpi_device_node(fwnode)->handle; in acpi_parse_string_ref()
858 scope = to_acpi_data_node(fwnode)->handle; in acpi_parse_string_ref()
882 return &dn->fwnode; in acpi_parse_string_ref()
886 * __acpi_node_get_property_reference - returns handle to the referenced object
896 * target object in @args->adev. If the reference includes arguments, store
897 * them in the @args->args[] array.
906 * "cs-gpios",
915 * Calling this function with index %2 or index %3 return %-ENOENT. If the
916 * property does not contain any more values %-ENOENT is returned. The NULL
934 return -ENOENT; in __acpi_node_get_property_reference()
938 return ret == -EINVAL ? -ENOENT : -EINVAL; in __acpi_node_get_property_reference()
940 switch (obj->type) { in __acpi_node_get_property_reference()
944 return -ENOENT; in __acpi_node_get_property_reference()
946 device = acpi_fetch_acpi_dev(obj->reference.handle); in __acpi_node_get_property_reference()
948 return -EINVAL; in __acpi_node_get_property_reference()
953 args->fwnode = acpi_fwnode_handle(device); in __acpi_node_get_property_reference()
954 args->nargs = 0; in __acpi_node_get_property_reference()
959 return -ENOENT; in __acpi_node_get_property_reference()
961 ref_fwnode = acpi_parse_string_ref(fwnode, obj->string.pointer); in __acpi_node_get_property_reference()
963 return -EINVAL; in __acpi_node_get_property_reference()
965 args->fwnode = ref_fwnode; in __acpi_node_get_property_reference()
966 args->nargs = 0; in __acpi_node_get_property_reference()
982 return -EINVAL; in __acpi_node_get_property_reference()
985 if (index >= obj->package.count) in __acpi_node_get_property_reference()
986 return -ENOENT; in __acpi_node_get_property_reference()
988 element = obj->package.elements; in __acpi_node_get_property_reference()
989 end = element + obj->package.count; in __acpi_node_get_property_reference()
992 switch (element->type) { in __acpi_node_get_property_reference()
994 device = acpi_fetch_acpi_dev(element->reference.handle); in __acpi_node_get_property_reference()
996 return -EINVAL; in __acpi_node_get_property_reference()
1012 element->string.pointer); in __acpi_node_get_property_reference()
1014 return -EINVAL; in __acpi_node_get_property_reference()
1030 return -ENOENT; in __acpi_node_get_property_reference()
1034 return -EINVAL; in __acpi_node_get_property_reference()
1040 return -ENOENT; in __acpi_node_get_property_reference()
1060 if (obj->integer.value > U8_MAX) in acpi_data_prop_read_single()
1061 return -EOVERFLOW; in acpi_data_prop_read_single()
1063 *(u8 *)val = obj->integer.value; in acpi_data_prop_read_single()
1066 if (obj->integer.value > U16_MAX) in acpi_data_prop_read_single()
1067 return -EOVERFLOW; in acpi_data_prop_read_single()
1069 *(u16 *)val = obj->integer.value; in acpi_data_prop_read_single()
1072 if (obj->integer.value > U32_MAX) in acpi_data_prop_read_single()
1073 return -EOVERFLOW; in acpi_data_prop_read_single()
1075 *(u32 *)val = obj->integer.value; in acpi_data_prop_read_single()
1079 *(u64 *)val = obj->integer.value; in acpi_data_prop_read_single()
1083 *(char **)val = obj->string.pointer; in acpi_data_prop_read_single()
1086 return -EINVAL; in acpi_data_prop_read_single()
1102 if (__items->type == ACPI_TYPE_BUFFER) { \
1103 __val[i] = __items->buffer.pointer[i]; \
1107 ret = -EPROTO; \
1115 ret = -EOVERFLOW; \
1131 return -EPROTO; in acpi_copy_property_array_string()
1151 * single-value, but its type does not match, so return. in acpi_data_prop_read()
1153 if (ret >= 0 || ret == -EOVERFLOW) in acpi_data_prop_read()
1157 * Reading this property as a single-value one failed, but its in acpi_data_prop_read()
1158 * value may still be represented as one-element array, so in acpi_data_prop_read()
1171 if (obj->type == ACPI_TYPE_BUFFER) in acpi_data_prop_read()
1172 return obj->buffer.length; in acpi_data_prop_read()
1174 return obj->package.count; in acpi_data_prop_read()
1181 if (obj->type == ACPI_TYPE_BUFFER) { in acpi_data_prop_read()
1182 if (nval > obj->buffer.length) in acpi_data_prop_read()
1183 return -EOVERFLOW; in acpi_data_prop_read()
1185 if (nval > obj->package.count) in acpi_data_prop_read()
1186 return -EOVERFLOW; in acpi_data_prop_read()
1191 return -EINVAL; in acpi_data_prop_read()
1193 if (obj->type == ACPI_TYPE_BUFFER) { in acpi_data_prop_read()
1195 return -EPROTO; in acpi_data_prop_read()
1198 items = obj->package.elements; in acpi_data_prop_read()
1217 min_t(u32, nval, obj->package.count)); in acpi_data_prop_read()
1220 ret = -EINVAL; in acpi_data_prop_read()
1227 * acpi_node_prop_read - retrieve the value of an ACPI property with given name.
1263 * acpi_get_next_subnode - Return the next child node handle for a fwnode
1297 head = &adev->data.subnodes; in acpi_get_next_subnode()
1299 head = &data->data.subnodes; in acpi_get_next_subnode()
1308 next = dn->sibling.next; in acpi_get_next_subnode()
1316 return &dn->fwnode; in acpi_get_next_subnode()
1322 * acpi_node_get_parent - Return parent fwnode of this fwnode
1333 return to_acpi_data_node(fwnode)->parent; in acpi_node_get_parent()
1359 name = to_acpi_data_node(fwnode)->name; in is_acpi_graph_node()
1367 * acpi_graph_get_next_endpoint - Get next endpoint ACPI firmware node
1424 * acpi_graph_get_child_prop_value - Return a child with a given property value
1453 * acpi_graph_get_remote_endpoint - Parses and returns remote end of an endpoint
1467 ret = acpi_node_get_property_reference(__fwnode, "remote-endpoint", 0, in acpi_graph_get_remote_endpoint()
1546 return -ENXIO; in acpi_fwnode_property_read_int_array()
1586 return dn->name; in acpi_fwnode_get_name()
1628 endpoint->local_fwnode = fwnode; in acpi_fwnode_graph_parse_endpoint()
1630 if (fwnode_property_read_u32(port_fwnode, "reg", &endpoint->port)) in acpi_fwnode_graph_parse_endpoint()
1631 fwnode_property_read_u32(port_fwnode, "port", &endpoint->port); in acpi_fwnode_graph_parse_endpoint()
1632 if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id)) in acpi_fwnode_graph_parse_endpoint()
1633 fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id); in acpi_fwnode_graph_parse_endpoint()
1686 fwnode->ops == &acpi_device_fwnode_ops; in is_acpi_device_node()
1692 return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops; in is_acpi_data_node()