Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/i2c Now that the ACPI layer no longer does this for ...



details:   https://anonhg.NetBSD.org/src/rev/458c5babcdf4
branches:  trunk
changeset: 950362:458c5babcdf4
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Jan 26 02:33:54 2021 +0000

description:
Now that the ACPI layer no longer does this for us, evaluate the _DSM
that returns the HID descriptor address at attach time.

diffstat:

 sys/dev/i2c/ihidev.c |  48 +++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 39 insertions(+), 9 deletions(-)

diffs (89 lines):

diff -r 96e777fdfa14 -r 458c5babcdf4 sys/dev/i2c/ihidev.c
--- a/sys/dev/i2c/ihidev.c      Tue Jan 26 01:23:08 2021 +0000
+++ b/sys/dev/i2c/ihidev.c      Tue Jan 26 02:33:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ihidev.c,v 1.16 2021/01/26 01:23:08 thorpej Exp $ */
+/* $NetBSD: ihidev.c,v 1.17 2021/01/26 02:33:54 thorpej Exp $ */
 /* $OpenBSD ihidev.c,v 1.13 2017/04/08 02:57:23 deraadt Exp $ */
 
 /*-
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.16 2021/01/26 01:23:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.17 2021/01/26 02:33:54 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -125,6 +125,8 @@
 static int     ihidev_print(void *, const char *);
 static int     ihidev_submatch(device_t, cfdata_t, const int *, void *);
 
+static bool    ihidev_acpi_get_info(struct ihidev_softc *);
+
 static const struct device_compatible_entry compat_data[] = {
        { .compat = "PNP0C50" },
        { .compat = "ACPI0C50" },
@@ -153,22 +155,21 @@
        device_t dev;
        int repid, repsz;
        int isize;
-       uint32_t v;
        int locs[IHIDBUSCF_NLOCS];
 
-
        sc->sc_dev = self;
        sc->sc_tag = ia->ia_tag;
        sc->sc_addr = ia->ia_addr;
-       sc->sc_phandle = ia->ia_cookie;
        mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_VM);
 
-       if (!prop_dictionary_get_uint32(ia->ia_prop, "hid-descr-addr", &v)) {
-               aprint_error(": no hid-descr-addr value\n");
+       sc->sc_phandle = ia->ia_cookie;
+       if (ia->ia_cookietype != I2C_COOKIE_ACPI) {
+               aprint_error(": unsupported device tree type\n");
                return;
        }
-
-       sc->sc_hid_desc_addr = v;
+       if (! ihidev_acpi_get_info(sc)) {
+               return;
+       }
 
        if (ihidev_hid_command(sc, I2C_HID_CMD_DESCR, NULL, false) ||
            ihidev_hid_desc_parse(sc)) {
@@ -968,3 +969,32 @@
 
        return 0;
 }
+
+static bool
+ihidev_acpi_get_info(struct ihidev_softc *sc)
+{               
+       ACPI_HANDLE hdl = (void *)(uintptr_t)sc->sc_phandle;
+       ACPI_STATUS status;
+       ACPI_INTEGER val;
+
+       /* 3cdff6f7-4267-4555-ad05-b30a3d8938de */
+       uint8_t i2c_hid_guid[] = {
+               0xF7, 0xF6, 0xDF, 0x3C,
+               0x67, 0x42,
+               0x55, 0x45,
+               0xAD, 0x05,
+               0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE,
+       };
+
+       status = acpi_dsm_integer(hdl, i2c_hid_guid, 1, 1, NULL, &val);
+       if (ACPI_FAILURE(status)) {
+               aprint_error_dev(sc->sc_dev,
+                   "failed to get HidDescriptorAddress: %s\n",
+                   AcpiFormatException(status)); 
+               return false;
+       }
+
+       sc->sc_hid_desc_addr = (u_int)val;
+
+       return true;
+}



Home | Main Index | Thread Index | Old Index