summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2022-07-23 03:08:17 +0000
committerthorpej <thorpej@NetBSD.org>2022-07-23 03:08:17 +0000
commitb61b358a7ff3fd9689c139b116d4741de783fea4 (patch)
tree286ed71446d4adbc3fc5dae8c6b164eeefbe426c /sys/dev
parent4fde6390d921cd5c237c5a4d82ae1119a68b7e4b (diff)
- Handle dtlink in acpi_pack_compat_list().
- Don't pass the _HID value as the device name; always use the ACPI node name.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpi/acpi_i2c.c13
-rw-r--r--sys/dev/acpi/acpi_util.c72
-rw-r--r--sys/dev/acpi/acpi_util.h4
3 files changed, 70 insertions, 19 deletions
diff --git a/sys/dev/acpi/acpi_i2c.c b/sys/dev/acpi/acpi_i2c.c
index 7b17909ee54..89d0c66e965 100644
--- a/sys/dev/acpi/acpi_i2c.c
+++ b/sys/dev/acpi/acpi_i2c.c
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_i2c.c,v 1.11 2021/01/26 01:23:08 thorpej Exp $ */
+/* $NetBSD: acpi_i2c.c,v 1.12 2022/07/23 03:08:17 thorpej Exp $ */
/*-
* Copyright (c) 2017, 2021 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.11 2021/01/26 01:23:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.12 2022/07/23 03:08:17 thorpej Exp $");
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
@@ -75,7 +75,6 @@ acpi_enter_i2c_device(struct acpi_devnode *ad, prop_array_t array)
prop_dictionary_t dev;
struct acpi_i2c_context i2cc;
ACPI_STATUS rv;
- const char *name;
char *clist;
size_t clist_size;
@@ -96,18 +95,14 @@ acpi_enter_i2c_device(struct acpi_devnode *ad, prop_array_t array)
ad->ad_name);
return;
}
- clist = acpi_pack_compat_list(ad->ad_devinfo, &clist_size);
+ clist = acpi_pack_compat_list(ad, &clist_size);
if (clist == NULL) {
prop_object_release(dev);
aprint_error("ignoring device %s (no _HID or _CID)\n",
ad->ad_name);
return;
}
- if ((ad->ad_devinfo->Valid & ACPI_VALID_HID) == 0)
- name = ad->ad_name;
- else
- name = ad->ad_devinfo->HardwareId.String;
- prop_dictionary_set_string(dev, "name", name);
+ prop_dictionary_set_string(dev, "name", ad->ad_name);
prop_dictionary_set_uint32(dev, "addr", i2cc.i2c_addr);
prop_dictionary_set_uint64(dev, "cookie", (uintptr_t)ad->ad_handle);
prop_dictionary_set_uint32(dev, "cookietype", I2C_COOKIE_ACPI);
diff --git a/sys/dev/acpi/acpi_util.c b/sys/dev/acpi/acpi_util.c
index 674d9f9132c..414521e0c41 100644
--- a/sys/dev/acpi/acpi_util.c
+++ b/sys/dev/acpi/acpi_util.c
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_util.c,v 1.32 2022/01/22 11:49:17 thorpej Exp $ */
+/* $NetBSD: acpi_util.c,v 1.33 2022/07/23 03:08:17 thorpej Exp $ */
/*-
* Copyright (c) 2003, 2007, 2021 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.32 2022/01/22 11:49:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.33 2022/07/23 03:08:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -395,25 +395,81 @@ acpi_name(ACPI_HANDLE handle)
* string list.
*/
char *
-acpi_pack_compat_list(ACPI_DEVICE_INFO *ad, size_t *sizep)
+acpi_pack_compat_list(struct acpi_devnode *ad, size_t *sizep)
{
+ ACPI_DEVICE_INFO *devinfo = ad->ad_devinfo;
+
KASSERT(sizep != NULL);
char *sl = NULL;
size_t slsize = 0;
uint32_t i;
+ bool dtlink = false;
- if ((ad->Valid & ACPI_VALID_HID) != 0) {
- strlist_append(&sl, &slsize, ad->HardwareId.String);
+ ACPI_BUFFER buf;
+ ACPI_STATUS ret;
+ ACPI_OBJECT *obj;
+ char *compatible;
+ int n;
+
+ buf.Pointer = NULL;
+ buf.Length = ACPI_ALLOCATE_BUFFER;
+
+ if ((devinfo->Valid & ACPI_VALID_HID) != 0) {
+ const char *cp = devinfo->HardwareId.String;
+
+ if (device_compatible_pmatch_strlist(cp, strlen(cp) + 1,
+ dtlink_compat_data)) {
+ dtlink = true;
+ } else {
+ strlist_append(&sl, &slsize, cp);
+ }
}
- if ((ad->Valid & ACPI_VALID_CID) != 0) {
- for (i = 0; i < ad->CompatibleIdList.Count; i++) {
+ if ((devinfo->Valid & ACPI_VALID_CID) != 0) {
+ for (i = 0; i < devinfo->CompatibleIdList.Count; i++) {
+ const char *cp =
+ devinfo->CompatibleIdList.Ids[i].String;
+
+ if (device_compatible_pmatch_strlist(cp, strlen(cp) + 1,
+ dtlink_compat_data)) {
+ dtlink = true;
+ } else {
+ strlist_append(&sl, &slsize, cp);
+ }
+ }
+ }
+
+ if (dtlink) {
+ ret = acpi_dsd_string(ad->ad_handle, "compatible",
+ &compatible);
+ if (ACPI_SUCCESS(ret)) {
+ strlist_append(&sl, &slsize, compatible);
+ kmem_strfree(compatible);
+ goto done;
+ }
+
+ ret = acpi_dsd_property(ad->ad_handle, "compatible", &buf,
+ ACPI_TYPE_PACKAGE, &obj);
+ if (ACPI_FAILURE(ret)) {
+ goto done;
+ }
+ if (obj->Package.Count == 0) {
+ goto done;
+ }
+ for (n = 0; n < obj->Package.Count; n++) {
+ if (obj->Package.Elements[n].Type != ACPI_TYPE_STRING) {
+ continue;
+ }
strlist_append(&sl, &slsize,
- ad->CompatibleIdList.Ids[i].String);
+ obj->Package.Elements[n].String.Pointer);
}
}
+ done:
+ if (buf.Pointer != NULL) {
+ ACPI_FREE(buf.Pointer);
+ }
*sizep = slsize;
return sl;
}
diff --git a/sys/dev/acpi/acpi_util.h b/sys/dev/acpi/acpi_util.h
index 0659d21299c..47649cba4b6 100644
--- a/sys/dev/acpi/acpi_util.h
+++ b/sys/dev/acpi/acpi_util.h
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_util.h,v 1.14 2022/01/22 11:49:17 thorpej Exp $ */
+/* $NetBSD: acpi_util.h,v 1.15 2022/07/23 03:08:17 thorpej Exp $ */
/*-
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -94,7 +94,7 @@ int acpi_match_class(ACPI_HANDLE, uint8_t, uint8_t, uint8_t);
ACPI_HANDLE acpi_match_cpu_info(struct cpu_info *);
struct cpu_info *acpi_match_cpu_handle(ACPI_HANDLE);
-char *acpi_pack_compat_list(ACPI_DEVICE_INFO *, size_t *);
+char *acpi_pack_compat_list(struct acpi_devnode *ad, size_t *);
ACPI_STATUS acpi_dsd_integer(ACPI_HANDLE, const char *, ACPI_INTEGER *);
ACPI_STATUS acpi_dsd_string(ACPI_HANDLE, const char *, char **);