summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2016-01-13 10:25:31 +0000
committerkettenis <kettenis@openbsd.org>2016-01-13 10:25:31 +0000
commite08b9924103eabf1c0a3087a43a2983006f0031f (patch)
tree923e96fa6ad25795c3842b0a82b26749c5cf1420
parentAdd data structures and defines for Generic and I2C Serial Bus Connection (diff)
downloadwireguard-openbsd-e08b9924103eabf1c0a3087a43a2983006f0031f.tar.xz
wireguard-openbsd-e08b9924103eabf1c0a3087a43a2983006f0031f.zip
Don't confuse the HID descriptor address (which really is an office into the
register space of the i2c device) with the i2c address. For i2c busses enumerated by ACPI we get the address from the I2C Serial Bus Connection Resource Descriptor returned by the _CRS methide of the i2c device. Pass the HID descriptor address in the ia_size member. ok jcs@
-rw-r--r--sys/dev/acpi/dwiic.c11
-rw-r--r--sys/dev/i2c/ihidev.c7
-rw-r--r--sys/dev/i2c/ihidev.h3
3 files changed, 15 insertions, 6 deletions
diff --git a/sys/dev/acpi/dwiic.c b/sys/dev/acpi/dwiic.c
index d8dce614459..98040db08f6 100644
--- a/sys/dev/acpi/dwiic.c
+++ b/sys/dev/acpi/dwiic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dwiic.c,v 1.2 2016/01/12 17:30:24 deraadt Exp $ */
+/* $OpenBSD: dwiic.c,v 1.3 2016/01/13 10:25:31 kettenis Exp $ */
/*
* Synopsys DesignWare I2C controller
*
@@ -118,6 +118,7 @@ struct dwiic_crs {
uint32_t addr_min;
uint32_t addr_bas;
uint32_t addr_len;
+ uint16_t i2c_addr;
};
struct dwiic_softc {
@@ -385,6 +386,11 @@ dwiic_acpi_parse_crs(union acpi_resource *crs, void *arg)
sc_crs->addr_len = letoh32(crs->lr_m32fixed._len);
break;
+ case LR_SERBUS:
+ if (crs->lr_serbus.type == LR_SERBUS_I2C)
+ sc_crs->i2c_addr = letoh16(crs->lr_i2cbus._adr);
+ break;
+
default:
DPRINTF(("%s: unknown resource type %d\n", __func__,
AML_CRSTYPE(crs)));
@@ -523,7 +529,7 @@ dwiic_acpi_foundhid(struct aml_node *node, void *arg)
ia.ia_tag = sc->sc_iba.iba_tag;
ia.ia_size = 1;
ia.ia_name = "ihidev";
- ia.ia_addr = aml_val2int(&res); /* hid descriptor address */
+ ia.ia_size = aml_val2int(&res); /* hid descriptor address */
ia.ia_cookie = dev;
aml_freevalue(&res);
@@ -550,6 +556,7 @@ dwiic_acpi_foundhid(struct aml_node *node, void *arg)
ia.ia_int = crs.irq_int;
ia.ia_int_flags = crs.irq_flags;
+ ia.ia_addr = crs.i2c_addr;
if (config_found(sc->sc_iic, &ia, dwiic_i2c_print))
return 0;
diff --git a/sys/dev/i2c/ihidev.c b/sys/dev/i2c/ihidev.c
index b594836d86a..a65e372762c 100644
--- a/sys/dev/i2c/ihidev.c
+++ b/sys/dev/i2c/ihidev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ihidev.c,v 1.2 2016/01/12 17:30:23 deraadt Exp $ */
+/* $OpenBSD: ihidev.c,v 1.3 2016/01/13 10:25:31 kettenis Exp $ */
/*
* HID-over-i2c driver
*
@@ -117,6 +117,7 @@ ihidev_attach(struct device *parent, struct device *self, void *aux)
sc->sc_tag = ia->ia_tag;
sc->sc_addr = ia->ia_addr;
+ sc->sc_hid_desc_addr = ia->ia_size;
printf(": int %d", ia->ia_int);
@@ -239,10 +240,10 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg)
* register is passed from the controller, and is probably just
* the address of the device
*/
- uint8_t cmdbuf[] = { htole16(sc->sc_addr), 0x0 };
+ uint8_t cmdbuf[] = { htole16(sc->sc_hid_desc_addr), 0x0 };
DPRINTF(("%s: HID command I2C_HID_CMD_DESCR at 0x%x\n",
- sc->sc_dev.dv_xname, htole16(sc->sc_addr)));
+ sc->sc_dev.dv_xname, htole16(sc->sc_hid_desc_addr)));
/* 20 00 */
res = iic_exec(sc->sc_tag, I2C_OP_WRITE, sc->sc_addr, &cmdbuf,
diff --git a/sys/dev/i2c/ihidev.h b/sys/dev/i2c/ihidev.h
index d65498735cd..47c0e153c11 100644
--- a/sys/dev/i2c/ihidev.h
+++ b/sys/dev/i2c/ihidev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ihidev.h,v 1.1 2016/01/12 01:11:15 jcs Exp $ */
+/* $OpenBSD: ihidev.h,v 1.2 2016/01/13 10:25:31 kettenis Exp $ */
/*
* HID-over-i2c driver
*
@@ -71,6 +71,7 @@ struct ihidev_softc {
i2c_addr_t sc_addr;
void *sc_ih;
+ u_int sc_hid_desc_addr;
union {
uint8_t hid_desc_buf[sizeof(struct i2c_hid_desc)];
struct i2c_hid_desc hid_desc;