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

1 // SPDX-License-Identifier: GPL-2.0-only
9 * Darren Hart <dvhart@linux.intel.com>
33 /* ACPI _DSD device properties GUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 */
36 /* Hotplug in D3 GUID: 6211e2c0-58a3-4af3-90e1-927a4e0c55a4 */
39 /* External facing port GUID: efcc06cc-73ac-4bc3-bff0-76143807c389 */
42 /* Thunderbolt GUID for IMR_VALID: c44d002f-69f9-4e7d-a904-a7baabdf43f7 */
45 /* Thunderbolt GUID for WAKE_SUPPORTED: 6c501103-c189-4296-ba72-9bf5a26ebe5d */
48 /* Storage device needs D3 GUID: 5025030f-842f-4ab4-a561-99a5189762d0 */
53 /* ACPI _DSD data subnodes GUID: dbb8e3e6-5886-4ba6-8795-1319f52a966b */
83 dn->name = link->package.elements[0].string.pointer; in acpi_nondev_subnode_extract()
84 fwnode_init(&dn->fwnode, &acpi_data_fwnode_ops); in acpi_nondev_subnode_extract()
85 dn->parent = parent; in acpi_nondev_subnode_extract()
86 INIT_LIST_HEAD(&dn->data.properties); in acpi_nondev_subnode_extract()
87 INIT_LIST_HEAD(&dn->data.subnodes); in acpi_nondev_subnode_extract()
89 result = acpi_extract_properties(handle, desc, &dn->data); in acpi_nondev_subnode_extract()
103 && acpi_enumerate_nondev_subnodes(scope, desc, &dn->data, in acpi_nondev_subnode_extract()
104 &dn->fwnode)) in acpi_nondev_subnode_extract()
106 } else if (acpi_enumerate_nondev_subnodes(NULL, desc, &dn->data, in acpi_nondev_subnode_extract()
107 &dn->fwnode)) { in acpi_nondev_subnode_extract()
112 dn->handle = handle; in acpi_nondev_subnode_extract()
113 dn->data.pointer = desc; in acpi_nondev_subnode_extract()
114 list_add_tail(&dn->sibling, list); in acpi_nondev_subnode_extract()
155 status = acpi_get_handle(scope, link->package.elements[1].string.pointer, in acpi_nondev_subnode_ok()
171 for (i = 0; i < links->package.count; i++) { in acpi_add_nondev_subnodes()
176 link = &links->package.elements[i]; in acpi_add_nondev_subnodes()
178 if (link->package.count != 2) in acpi_add_nondev_subnodes()
182 if (link->package.elements[0].type != ACPI_TYPE_STRING) in acpi_add_nondev_subnodes()
186 switch (link->package.elements[1].type) { in acpi_add_nondev_subnodes()
192 handle = link->package.elements[1].reference.handle; in acpi_add_nondev_subnodes()
197 desc = &link->package.elements[1]; in acpi_add_nondev_subnodes()
219 for (i = 0; i < desc->package.count; i += 2) { in acpi_enumerate_nondev_subnodes()
223 guid = &desc->package.elements[i]; in acpi_enumerate_nondev_subnodes()
224 links = &desc->package.elements[i + 1]; in acpi_enumerate_nondev_subnodes()
230 if (guid->type != ACPI_TYPE_BUFFER || in acpi_enumerate_nondev_subnodes()
231 guid->buffer.length != 16 || in acpi_enumerate_nondev_subnodes()
232 links->type != ACPI_TYPE_PACKAGE) in acpi_enumerate_nondev_subnodes()
235 if (!guid_equal((guid_t *)guid->buffer.pointer, &ads_guid)) in acpi_enumerate_nondev_subnodes()
238 return acpi_add_nondev_subnodes(scope, links, &data->subnodes, in acpi_enumerate_nondev_subnodes()
253 switch (value->type) { in acpi_property_value_ok()
260 for (j = 0; j < value->package.count; j++) in acpi_property_value_ok()
261 switch (value->package.elements[j].type) { in acpi_property_value_ok()
280 for (i = 0; i < properties->package.count; i++) { in acpi_properties_format_valid()
283 property = &properties->package.elements[i]; in acpi_properties_format_valid()
288 if (property->package.count != 2 in acpi_properties_format_valid()
289 || property->package.elements[0].type != ACPI_TYPE_STRING in acpi_properties_format_valid()
290 || !acpi_property_value_ok(&property->package.elements[1])) in acpi_properties_format_valid()
301 ret = acpi_data_get_property_array(&adev->data, "compatible", in acpi_init_of_compatible()
304 ret = acpi_dev_get_property(adev, "compatible", in acpi_init_of_compatible()
310 if (parent && parent->flags.of_compatible_ok) in acpi_init_of_compatible()
316 adev->data.of_compatible = of_compatible; in acpi_init_of_compatible()
319 adev->flags.of_compatible_ok = 1; in acpi_init_of_compatible()
342 INIT_LIST_HEAD(&props->list); in acpi_data_add_props()
343 props->guid = guid; in acpi_data_add_props()
344 props->properties = properties; in acpi_data_add_props()
345 list_add_tail(&props->list, &data->properties); in acpi_data_add_props()
359 list_for_each_entry(dn, &data->subnodes, sibling) { in acpi_untie_nondev_subnodes()
360 acpi_detach_data(dn->handle, acpi_nondev_subnode_tag); in acpi_untie_nondev_subnodes()
362 acpi_untie_nondev_subnodes(&dn->data); in acpi_untie_nondev_subnodes()
370 list_for_each_entry(dn, &data->subnodes, sibling) { in acpi_tie_nondev_subnodes()
374 status = acpi_attach_data(dn->handle, acpi_nondev_subnode_tag, dn); in acpi_tie_nondev_subnodes()
376 acpi_handle_err(dn->handle, "Can't tag data node\n"); in acpi_tie_nondev_subnodes()
380 ret = acpi_tie_nondev_subnodes(&dn->data); in acpi_tie_nondev_subnodes()
398 if (check_mul_overflow((size_t)properties->package.count, in acpi_data_add_buffer_props()
405 properties->package.count); in acpi_data_add_buffer_props()
413 props->guid = &buffer_prop_guid; in acpi_data_add_buffer_props()
414 props->bufs = (void *)(props + 1); in acpi_data_add_buffer_props()
415 props->properties = (void *)(props->bufs + properties->package.count); in acpi_data_add_buffer_props()
418 package = props->properties; in acpi_data_add_buffer_props()
419 package->type = ACPI_TYPE_PACKAGE; in acpi_data_add_buffer_props()
420 package->package.elements = package + 1; in acpi_data_add_buffer_props()
421 count = &package->package.count; in acpi_data_add_buffer_props()
427 for (i = 0; i < properties->package.count; i++) { in acpi_data_add_buffer_props()
429 union acpi_object *property = &properties->package.elements[i]; in acpi_data_add_buffer_props()
433 if (property->type != ACPI_TYPE_PACKAGE || in acpi_data_add_buffer_props()
434 property->package.count != 2) { in acpi_data_add_buffer_props()
437 i, property->package.count); in acpi_data_add_buffer_props()
441 prop = &property->package.elements[0]; in acpi_data_add_buffer_props()
442 obj = &property->package.elements[1]; in acpi_data_add_buffer_props()
444 if (prop->type != ACPI_TYPE_STRING || in acpi_data_add_buffer_props()
445 obj->type != ACPI_TYPE_STRING) { in acpi_data_add_buffer_props()
448 prop->type, obj->type); in acpi_data_add_buffer_props()
452 status = acpi_evaluate_object_typed(handle, obj->string.pointer, in acpi_data_add_buffer_props()
458 obj->string.length, in acpi_data_add_buffer_props()
459 obj->string.pointer); in acpi_data_add_buffer_props()
463 package->type = ACPI_TYPE_PACKAGE; in acpi_data_add_buffer_props()
464 package->package.elements = prop; in acpi_data_add_buffer_props()
465 package->package.count = 2; in acpi_data_add_buffer_props()
470 obj->type = ACPI_TYPE_BUFFER; in acpi_data_add_buffer_props()
471 obj->buffer.length = buf_obj->buffer.length; in acpi_data_add_buffer_props()
472 obj->buffer.pointer = buf_obj->buffer.pointer; in acpi_data_add_buffer_props()
474 props->bufs[i] = buf.pointer; in acpi_data_add_buffer_props()
480 list_add(&props->list, &data->properties); in acpi_data_add_buffer_props()
490 if (desc->package.count % 2) in acpi_extract_properties()
494 for (i = 0; i < desc->package.count; i += 2) { in acpi_extract_properties()
498 guid = &desc->package.elements[i]; in acpi_extract_properties()
499 properties = &desc->package.elements[i + 1]; in acpi_extract_properties()
505 if (guid->type != ACPI_TYPE_BUFFER || in acpi_extract_properties()
506 guid->buffer.length != 16 || in acpi_extract_properties()
507 properties->type != ACPI_TYPE_PACKAGE) in acpi_extract_properties()
510 if (guid_equal((guid_t *)guid->buffer.pointer, in acpi_extract_properties()
516 if (!acpi_is_property_guid((guid_t *)guid->buffer.pointer)) in acpi_extract_properties()
526 acpi_data_add_props(data, (const guid_t *)guid->buffer.pointer, in acpi_extract_properties()
530 return !list_empty(&data->properties); in acpi_extract_properties()
540 INIT_LIST_HEAD(&adev->data.properties); in acpi_init_properties()
541 INIT_LIST_HEAD(&adev->data.subnodes); in acpi_init_properties()
543 if (!adev->handle) in acpi_init_properties()
548 * Device Tree compatible properties for this device. in acpi_init_properties()
550 list_for_each_entry(hwid, &adev->pnp.ids, list) { in acpi_init_properties()
551 if (!strcmp(hwid->id, ACPI_DT_NAMESPACE_HID)) { in acpi_init_properties()
557 status = acpi_evaluate_object_typed(adev->handle, "_DSD", NULL, &buf, in acpi_init_properties()
562 if (acpi_extract_properties(adev->handle, buf.pointer, &adev->data)) { in acpi_init_properties()
563 adev->data.pointer = buf.pointer; in acpi_init_properties()
567 if (acpi_enumerate_nondev_subnodes(adev->handle, buf.pointer, in acpi_init_properties()
568 &adev->data, acpi_fwnode_handle(adev))) in acpi_init_properties()
569 adev->data.pointer = buf.pointer; in acpi_init_properties()
571 if (!adev->data.pointer) { in acpi_init_properties()
572 acpi_handle_debug(adev->handle, "Invalid _DSD data, skipping\n"); in acpi_init_properties()
575 if (!acpi_tie_nondev_subnodes(&adev->data)) in acpi_init_properties()
576 acpi_untie_nondev_subnodes(&adev->data); in acpi_init_properties()
580 if (acpi_of && !adev->flags.of_compatible_ok) in acpi_init_properties()
581 acpi_handle_info(adev->handle, in acpi_init_properties()
582 ACPI_DT_NAMESPACE_HID " requires 'compatible' property\n"); in acpi_init_properties()
584 if (!adev->data.pointer) in acpi_init_properties()
595 list_del(&props->list); in acpi_free_device_properties()
597 if (props->bufs) in acpi_free_device_properties()
598 for (i = 0; i < props->properties->package.count; i++) in acpi_free_device_properties()
599 ACPI_FREE(props->bufs[i]); in acpi_free_device_properties()
612 acpi_destroy_nondev_subnodes(&dn->data.subnodes); in acpi_destroy_nondev_subnodes()
613 wait_for_completion(&dn->kobj_done); in acpi_destroy_nondev_subnodes()
614 list_del(&dn->sibling); in acpi_destroy_nondev_subnodes()
615 ACPI_FREE((void *)dn->data.pointer); in acpi_destroy_nondev_subnodes()
616 acpi_free_device_properties(&dn->data.properties); in acpi_destroy_nondev_subnodes()
623 acpi_untie_nondev_subnodes(&adev->data); in acpi_free_properties()
624 acpi_destroy_nondev_subnodes(&adev->data.subnodes); in acpi_free_properties()
625 ACPI_FREE((void *)adev->data.pointer); in acpi_free_properties()
626 adev->data.of_compatible = NULL; in acpi_free_properties()
627 adev->data.pointer = NULL; in acpi_free_properties()
628 acpi_free_device_properties(&adev->data.properties); in acpi_free_properties()
632 * acpi_data_get_property - return an ACPI property with given name
645 * %-EINVAL if the arguments are invalid,
646 * %-EINVAL if the property doesn't exist,
647 * %-EPROTO if the property value type doesn't match @type.
656 return -EINVAL; in acpi_data_get_property()
658 if (!data->pointer || list_empty(&data->properties)) in acpi_data_get_property()
659 return -EINVAL; in acpi_data_get_property()
661 list_for_each_entry(props, &data->properties, list) { in acpi_data_get_property()
665 properties = props->properties; in acpi_data_get_property()
666 for (i = 0; i < properties->package.count; i++) { in acpi_data_get_property()
670 property = &properties->package.elements[i]; in acpi_data_get_property()
672 propname = &property->package.elements[0]; in acpi_data_get_property()
673 propvalue = &property->package.elements[1]; in acpi_data_get_property()
675 if (!strcmp(name, propname->string.pointer)) { in acpi_data_get_property()
677 propvalue->type != type) in acpi_data_get_property()
678 return -EPROTO; in acpi_data_get_property()
686 return -EINVAL; in acpi_data_get_property()
690 * acpi_dev_get_property - return an ACPI property with given name.
699 return adev ? acpi_data_get_property(&adev->data, name, type, obj) : -EINVAL; in acpi_dev_get_property()
708 return &adev->data; in acpi_device_data_of_node()
712 return &dn->data; in acpi_device_data_of_node()
718 * acpi_node_prop_get - return an ACPI property with given name.
732 * acpi_data_get_property_array - return an ACPI array property with given name
745 * %-EINVAL if the arguments are invalid,
746 * %-EINVAL if the property doesn't exist,
747 * %-EPROTO if the property is not a package or the type of its elements
764 for (i = 0; i < prop->package.count; i++) in acpi_data_get_property_array()
765 if (prop->package.elements[i].type != type) in acpi_data_get_property_array()
766 return -EPROTO; in acpi_data_get_property_array()
806 for (; *element < end && (*element)->type == ACPI_TYPE_STRING; in acpi_get_ref_args()
808 const char *child_name = (*element)->string.pointer; in acpi_get_ref_args()
812 return -EINVAL; in acpi_get_ref_args()
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()
848 * __acpi_node_get_property_reference - returns handle to the referenced object
857 * target object in @args->adev. If the reference includes arguments, store
858 * them in the @args->args[] array.
867 * "cs-gpios",
876 * Calling this function with index %2 or index %3 return %-ENOENT. If the
877 * property does not contain any more values %-ENOENT is returned. The NULL
894 return -ENOENT; in __acpi_node_get_property_reference()
898 return ret == -EINVAL ? -ENOENT : -EINVAL; in __acpi_node_get_property_reference()
900 switch (obj->type) { in __acpi_node_get_property_reference()
904 return -ENOENT; in __acpi_node_get_property_reference()
906 device = acpi_fetch_acpi_dev(obj->reference.handle); in __acpi_node_get_property_reference()
908 return -EINVAL; in __acpi_node_get_property_reference()
910 args->fwnode = acpi_fwnode_handle(device); in __acpi_node_get_property_reference()
911 args->nargs = 0; in __acpi_node_get_property_reference()
925 return -EINVAL; in __acpi_node_get_property_reference()
928 if (index >= obj->package.count) in __acpi_node_get_property_reference()
929 return -ENOENT; in __acpi_node_get_property_reference()
931 element = obj->package.elements; in __acpi_node_get_property_reference()
932 end = element + obj->package.count; in __acpi_node_get_property_reference()
935 switch (element->type) { in __acpi_node_get_property_reference()
937 device = acpi_fetch_acpi_dev(element->reference.handle); in __acpi_node_get_property_reference()
939 return -EINVAL; in __acpi_node_get_property_reference()
955 return -ENOENT; in __acpi_node_get_property_reference()
959 return -EINVAL; in __acpi_node_get_property_reference()
965 return -ENOENT; in __acpi_node_get_property_reference()
983 if (obj->integer.value > U8_MAX) in acpi_data_prop_read_single()
984 return -EOVERFLOW; in acpi_data_prop_read_single()
987 *(u8 *)val = obj->integer.value; in acpi_data_prop_read_single()
991 if (obj->integer.value > U16_MAX) in acpi_data_prop_read_single()
992 return -EOVERFLOW; in acpi_data_prop_read_single()
995 *(u16 *)val = obj->integer.value; in acpi_data_prop_read_single()
999 if (obj->integer.value > U32_MAX) in acpi_data_prop_read_single()
1000 return -EOVERFLOW; in acpi_data_prop_read_single()
1003 *(u32 *)val = obj->integer.value; in acpi_data_prop_read_single()
1008 *(u64 *)val = obj->integer.value; in acpi_data_prop_read_single()
1021 *(char **)val = obj->string.pointer; in acpi_data_prop_read_single()
1025 ret = -EINVAL; in acpi_data_prop_read_single()
1039 if (__items->type == ACPI_TYPE_BUFFER) { \
1040 __val[i] = __items->buffer.pointer[i]; \
1044 ret = -EPROTO; \
1052 ret = -EOVERFLOW; \
1068 return -EPROTO; in acpi_copy_property_array_string()
1088 * single-value, but its type does not match, so return. in acpi_data_prop_read()
1090 if (ret >= 0 || ret == -EOVERFLOW) in acpi_data_prop_read()
1094 * Reading this property as a single-value one failed, but its in acpi_data_prop_read()
1095 * value may still be represented as one-element array, so in acpi_data_prop_read()
1108 if (obj->type == ACPI_TYPE_BUFFER) in acpi_data_prop_read()
1109 return obj->buffer.length; in acpi_data_prop_read()
1111 return obj->package.count; in acpi_data_prop_read()
1118 if (obj->type == ACPI_TYPE_BUFFER) { in acpi_data_prop_read()
1119 if (nval > obj->buffer.length) in acpi_data_prop_read()
1120 return -EOVERFLOW; in acpi_data_prop_read()
1125 if (nval > obj->package.count) in acpi_data_prop_read()
1126 return -EOVERFLOW; in acpi_data_prop_read()
1130 return -EINVAL; in acpi_data_prop_read()
1132 if (obj->type != ACPI_TYPE_BUFFER) in acpi_data_prop_read()
1133 items = obj->package.elements; in acpi_data_prop_read()
1153 min_t(u32, nval, obj->package.count)); in acpi_data_prop_read()
1156 ret = -EINVAL; in acpi_data_prop_read()
1163 * acpi_node_prop_read - retrieve the value of an ACPI property with given name.
1199 * acpi_get_next_subnode - Return the next child node handle for a fwnode
1233 head = &adev->data.subnodes; in acpi_get_next_subnode()
1235 head = &data->data.subnodes; in acpi_get_next_subnode()
1244 next = dn->sibling.next; in acpi_get_next_subnode()
1252 return &dn->fwnode; in acpi_get_next_subnode()
1258 * acpi_node_get_parent - Return parent fwnode of this fwnode
1269 return to_acpi_data_node(fwnode)->parent; in acpi_node_get_parent()
1295 name = to_acpi_data_node(fwnode)->name; in is_acpi_graph_node()
1303 * acpi_graph_get_next_endpoint - Get next endpoint ACPI firmware node
1360 * acpi_graph_get_child_prop_value - Return a child with a given property value
1389 * acpi_graph_get_remote_endpoint - Parses and returns remote end of an endpoint
1403 ret = acpi_node_get_property_reference(__fwnode, "remote-endpoint", 0, in acpi_graph_get_remote_endpoint()
1482 return -ENXIO; in acpi_fwnode_property_read_int_array()
1522 return dn->name; in acpi_fwnode_get_name()
1564 endpoint->local_fwnode = fwnode; in acpi_fwnode_graph_parse_endpoint()
1566 if (fwnode_property_read_u32(port_fwnode, "reg", &endpoint->port)) in acpi_fwnode_graph_parse_endpoint()
1567 fwnode_property_read_u32(port_fwnode, "port", &endpoint->port); in acpi_fwnode_graph_parse_endpoint()
1568 if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id)) in acpi_fwnode_graph_parse_endpoint()
1569 fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id); in acpi_fwnode_graph_parse_endpoint()
1622 fwnode->ops == &acpi_device_fwnode_ops; in is_acpi_device_node()
1628 return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops; in is_acpi_data_node()