summaryrefslogtreecommitdiffstats
path: root/sys/dev/i2c
diff options
context:
space:
mode:
authorjsg <jsg@openbsd.org>2016-04-02 00:56:39 +0000
committerjsg <jsg@openbsd.org>2016-04-02 00:56:39 +0000
commit90a2c5412ab0b8af7614deebb11c9ddc6463a2f8 (patch)
tree5903de013c3fca51daa5ebec4c85a2d5304c9288 /sys/dev/i2c
parentMake the gpio intr_establish callback return an int so the same function (diff)
downloadwireguard-openbsd-90a2c5412ab0b8af7614deebb11c9ddc6463a2f8.tar.xz
wireguard-openbsd-90a2c5412ab0b8af7614deebb11c9ddc6463a2f8.zip
Add support for I2C HID devices with GPIO signalled interrupts.
Required for the keyboard and touchpad on the ideapad 100s. ok kettenis@
Diffstat (limited to 'sys/dev/i2c')
-rw-r--r--sys/dev/i2c/i2cvar.h3
-rw-r--r--sys/dev/i2c/ihidev.c15
2 files changed, 14 insertions, 4 deletions
diff --git a/sys/dev/i2c/i2cvar.h b/sys/dev/i2c/i2cvar.h
index 5a8e71d67bd..40b487c379c 100644
--- a/sys/dev/i2c/i2cvar.h
+++ b/sys/dev/i2c/i2cvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: i2cvar.h,v 1.13 2016/01/12 17:30:23 deraadt Exp $ */
+/* $OpenBSD: i2cvar.h,v 1.14 2016/04/02 00:56:39 jsg Exp $ */
/* $NetBSD: i2cvar.h,v 1.1 2003/09/30 00:35:31 thorpej Exp $ */
/*
@@ -110,6 +110,7 @@ struct i2c_attach_args {
int ia_int_flags; /* IRQ flags */
char *ia_name; /* chip name */
void *ia_cookie; /* pass extra info from bus to dev */
+ void *acpi_gpio;
};
/*
diff --git a/sys/dev/i2c/ihidev.c b/sys/dev/i2c/ihidev.c
index 8d5c3e9118b..804771930a1 100644
--- a/sys/dev/i2c/ihidev.c
+++ b/sys/dev/i2c/ihidev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ihidev.c,v 1.9 2016/01/29 17:11:58 jcs Exp $ */
+/* $OpenBSD: ihidev.c,v 1.10 2016/04/02 00:56:39 jsg Exp $ */
/*
* HID-over-i2c driver
*
@@ -30,8 +30,11 @@
#include <dev/hid/hid.h>
-/* XXX */
+#if defined(__i386__) || defined(__amd64__)
+#include "acpi.h"
#include <dev/acpi/acpivar.h>
+#include <dev/acpi/amltypes.h>
+#endif
/* #define IHIDEV_DEBUG */
@@ -156,8 +159,14 @@ ihidev_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ibuf = malloc(sc->sc_isize, M_DEVBUF, M_NOWAIT | M_ZERO);
/* register interrupt with system */
+#if NACPI > 0
+ if (ia->ia_int > 0 && ia->acpi_gpio != NULL) {
+ struct acpi_gpio *gpio = ia->acpi_gpio;
+ gpio->intr_establish(gpio->cookie, ia->ia_int,
+ ia->ia_int_flags, ihidev_intr, sc);
+ } else
+#endif
if (ia->ia_int > 0) {
- /* XXX: don't assume this uses acpi_intr_establish */
sc->sc_ih = acpi_intr_establish(ia->ia_int, ia->ia_int_flags,
IPL_BIO, ihidev_intr, sc, sc->sc_dev.dv_xname);
if (sc->sc_ih == NULL) {