From: kettenis Date: Wed, 2 Oct 2024 21:21:32 +0000 (+0000) Subject: Improve the heuristic for detecting i2c devices. On the x1e some of the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a38da08acb453d4466a55dfed71de15ff1a1ff72;p=openbsd Improve the heuristic for detecting i2c devices. On the x1e some of the USB controllers have an I2cSerialBusV2() (possibly defining a connection to some sort of eUSB2 to USB2 redriver chip) but are not i2c devices themselves. So check if a device has MMIO resources and assume it isn't a proper i2c device if it has those. Makes the Type-A ports on my vivobook work in acpi mode. ok patrick@, mlarkin@ --- diff --git a/sys/dev/acpi/qciic.c b/sys/dev/acpi/qciic.c index 5a467016022..13096d079b1 100644 --- a/sys/dev/acpi/qciic.c +++ b/sys/dev/acpi/qciic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qciic.c,v 1.6 2024/06/19 21:27:22 patrick Exp $ */ +/* $OpenBSD: qciic.c,v 1.7 2024/10/02 21:21:32 kettenis Exp $ */ /* * Copyright (c) 2022 Mark Kettenis * @@ -74,6 +74,7 @@ struct qciic_crs { uint16_t gpio_int_pin; uint16_t gpio_int_flags; struct aml_node *node; + int skip; }; int qciic_acpi_match(struct device *, void *, void *); @@ -373,6 +374,11 @@ qciic_acpi_parse_crs(int crsidx, union acpi_resource *crs, void *arg) uint16_t pin; switch (AML_CRSTYPE(crs)) { + case LR_MEM32FIXED: + /* An MMIO address means this is not an I2C device. */ + sc_crs->skip = 1; + break; + case LR_SERBUS: if (crs->lr_serbus.type == LR_SERBUS_I2C) { sc_crs->i2c_addr = crs->lr_i2cbus._adr; @@ -440,7 +446,7 @@ qciic_acpi_found_hid(struct aml_node *node, void *arg) aml_freevalue(&res); /* Skip if not using this bus. */ - if (crs.i2c_bus != sc->sc_node) + if (crs.skip || crs.i2c_bus != sc->sc_node) return 0; acpi_attach_deps(acpi_softc, node->parent);