Download raw body.
acpiec(4): fall back to namespace EC device when ECDT namepath is bogus
acpiec(4): fall back to namespace EC device when ECDT namepath is bogus
To: tech@openbsd.org
Subject: Re: acpiec(4): fall back to namespace EC device when ECDT namepath is bogus
Hi,
the diff in my previous mail had its whitespace mangled by the web
mail editor (one space after each tab was eaten), so it only applies
with fuzz and the resulting code does not follow KNF. Correct diff
below, sorry for the noise.
Index: sys/dev/acpi/acpiec.c
--- sys/dev/acpi/acpiec.c
+++ sys/dev/acpi/acpiec.c
@@ -49,6 +49,7 @@
int acpiec_getcrs(struct acpiec_softc *,
struct acpi_attach_args *);
int acpiec_parse_resources(int, union acpi_resource *, void *);
+int acpiec_foundecdt(struct aml_node *, void *);
void acpiec_wait(struct acpiec_softc *, uint8_t, uint8_t);
void acpiec_sci_event(struct acpiec_softc *);
@@ -435,6 +436,38 @@
}
int
+acpiec_foundecdt(struct aml_node *node, void *arg)
+{
+ struct acpiec_softc *sc = arg;
+ struct aml_value res;
+ const char *dev;
+
+ if (aml_evalnode(sc->sc_acpi, node, 0, NULL, &res) != 0)
+ return (0);
+
+ switch (res.type) {
+ case AML_OBJTYPE_STRING:
+ dev = res.v_string;
+ break;
+ case AML_OBJTYPE_INTEGER:
+ dev = aml_eisaid(aml_val2int(&res));
+ break;
+ default:
+ aml_freevalue(&res);
+ return (0);
+ }
+
+ if (strcmp(dev, ACPI_DEV_ECD) == 0) {
+ sc->sc_devnode = node->parent;
+ aml_freevalue(&res);
+ return (1);
+ }
+
+ aml_freevalue(&res);
+ return (0);
+}
+
+int
acpiec_getcrs(struct acpiec_softc *sc, struct acpi_attach_args *aa)
{
struct aml_value res;
@@ -463,6 +496,19 @@
sc->sc_devnode = aml_searchname(sc->sc_acpi->sc_root,
ecdt->ec_id);
+ /*
+ * Some BIOSes contain an ECDT whose namepath refers to an
+ * object that does not exist in the namespace (seen on a
+ * Lenovo IdeaPad L3 15ITL6 whose ECDT refers to
+ * \_SB.PC00.LPCB.H_EC while the namespace EC device is
+ * called EC0). Fall back to the Embedded Controller device
+ * found in the namespace such that _REG is evaluated on the
+ * right node and EC operation regions become available.
+ */
+ if (sc->sc_devnode == NULL)
+ aml_find_node(sc->sc_acpi->sc_root, "_HID",
+ acpiec_foundecdt, sc);
+
goto ecdtdone;
}
Sergey
acpiec(4): fall back to namespace EC device when ECDT namepath is bogus
acpiec(4): fall back to namespace EC device when ECDT namepath is bogus