summaryrefslogtreecommitdiff
path: root/sys/dev/i2c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-11-18 20:47:46 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-11-18 20:47:46 +0000
commit2f3142ad6f36ebf979fed21f4b696409a5e6eee9 (patch)
tree45a7c15f1c757f5ad7d4dc0f9158d46eb2674c9f /sys/dev/i2c
parentbdc38026cbdb0d72ad7fcfbad35bf42f8d7a67f7 (diff)
support pca9556 and pca9557 too
cope with the polarity input register correctly, as well
Diffstat (limited to 'sys/dev/i2c')
-rw-r--r--sys/dev/i2c/pca9554.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/dev/i2c/pca9554.c b/sys/dev/i2c/pca9554.c
index 8c439de413b..488a894be14 100644
--- a/sys/dev/i2c/pca9554.c
+++ b/sys/dev/i2c/pca9554.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pca9554.c,v 1.2 2005/11/17 08:42:56 grange Exp $ */
+/* $OpenBSD: pca9554.c,v 1.3 2005/11/18 20:47:45 deraadt Exp $ */
/*
* Copyright (c) 2005 Theo de Raadt
@@ -71,8 +71,10 @@ pcagpio_match(struct device *parent, void *match, void *aux)
struct i2c_attach_args *ia = aux;
if (ia->ia_compat) {
- if (strcmp(ia->ia_compat, "PCA9554") == 0 ||
- strcmp(ia->ia_compat, "PCA9554M") == 0)
+ if (strcasecmp(ia->ia_compat, "PCA9554") == 0 ||
+ strcasecmp(ia->ia_compat, "PCA9554M") == 0 ||
+ strcasecmp(ia->ia_compat, "pca9556") == 0 ||
+ strcasecmp(ia->ia_compat, "pca9557") == 0)
return (1);
return (0);
}
@@ -139,7 +141,12 @@ pcagpio_attach(struct device *parent, struct device *self, void *aux)
SENSOR_ADD(&sc->sc_sensor[i]);
#endif
- printf(": %d inputs %d outputs\n", 8 - outputs, outputs);
+ printf(":"):
+ if (8 - outputs)
+ printf(" %d inputs", 8 - outputs);
+ if (outputs)
+ printf(" %d outputs", outputs);
+ printf("\n");
for (i = 0; i < PCAGPIO_NPINS; i++) {
sc->sc_gpio_pins[i].pin_num = i;
@@ -209,7 +216,7 @@ pcagpio_gpio_pin_read(void *arg, int pin)
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
sc->sc_addr, &cmd, sizeof cmd, &in, sizeof in, 0))
return 0;
- return (in & (1 << pin)) ? 1 : 0;
+ return ((in ^ sc->sc_polarity) & (1 << pin)) ? 1 : 0;
}
void