summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Yurchenko <grange@cvs.openbsd.org>2006-01-03 22:39:04 +0000
committerAlexander Yurchenko <grange@cvs.openbsd.org>2006-01-03 22:39:04 +0000
commita9828406adf7896570c78cd00b9b93f7614451b7 (patch)
treee035bac6b2e15790a05b1216ad20a7659d9e5dc2
parent9fcc5e977ed11e698f1f8250a5422b458968bb6f (diff)
Correct interrupt type check. Pointed out by kettenis@, thanks.
-rw-r--r--sys/dev/pci/piixpm.c27
-rw-r--r--sys/dev/pci/piixreg.h5
2 files changed, 22 insertions, 10 deletions
diff --git a/sys/dev/pci/piixpm.c b/sys/dev/pci/piixpm.c
index 6bde78086b5..afb8835f4cf 100644
--- a/sys/dev/pci/piixpm.c
+++ b/sys/dev/pci/piixpm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: piixpm.c,v 1.9 2006/01/01 20:52:27 deraadt Exp $ */
+/* $OpenBSD: piixpm.c,v 1.10 2006/01/03 22:39:03 grange Exp $ */
/*
* Copyright (c) 2005 Alexander Yurchenko <grange@openbsd.org>
@@ -123,10 +123,10 @@ piixpm_attach(struct device *parent, struct device *self, void *aux)
conf = pci_conf_read(pa->pa_pc, pa->pa_tag, PIIX_SMB_HOSTC);
DPRINTF((": conf 0x%x", conf));
- if ((conf & PIIX_SMB_HOSTC_SMI) == PIIX_SMB_HOSTC_SMI) {
+ if ((conf & PIIX_SMB_HOSTC_INTMASK) == PIIX_SMB_HOSTC_SMI) {
printf(": SMI");
sc->sc_poll = 1;
- } else if ((conf & PIIX_SMB_HOSTC_IRQ) == PIIX_SMB_HOSTC_IRQ) {
+ } else if ((conf & PIIX_SMB_HOSTC_INTMASK) == PIIX_SMB_HOSTC_IRQ) {
/* Install interrupt handler */
if (pci_intr_map(pa, &ih)) {
printf(": can't map interrupt\n");
@@ -199,8 +199,8 @@ piixpm_i2c_exec(void *cookie, i2c_op_t op, i2c_addr_t addr,
{
struct piixpm_softc *sc = cookie;
u_int8_t *b;
- u_int8_t ctl, st;
- int retries;
+ u_int8_t ctl, st, sctl;
+ int retries, error = 0;
DPRINTF(("%s: exec op %d, addr 0x%x, cmdlen %d, len %d, "
"flags 0x%x, status 0x%b\n", sc->sc_dev.dv_xname, op, addr,
@@ -220,6 +220,11 @@ piixpm_i2c_exec(void *cookie, i2c_op_t op, i2c_addr_t addr,
sc->sc_i2c_xfer.flags = flags;
sc->sc_i2c_xfer.error = 0;
+ /* Make sure SMBALERT# assertion disabled */
+ sctl = bus_space_read_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_SC);
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_SC,
+ sctl & ~PIIX_SMB_SC_ALERTEN);
+
/* Set slave address and transfer direction */
bus_space_write_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_TXSLVA,
PIIX_SMB_TXSLVA_ADDR(addr) |
@@ -269,16 +274,20 @@ piixpm_i2c_exec(void *cookie, i2c_op_t op, i2c_addr_t addr,
if (st & PIIX_SMB_HS_BUSY) {
printf("%s: timeout, status 0x%b\n",
sc->sc_dev.dv_xname, st, PIIX_SMB_HS_BITS);
- return (1);
+ error = 1;
+ } else {
+ piixpm_intr(sc);
}
- piixpm_intr(sc);
} else {
/* Wait for interrupt */
if (tsleep(sc, PRIBIO, "iicexec", PIIXPM_TIMEOUT * hz))
- return (1);
+ error = 1;
}
- if (sc->sc_i2c_xfer.error)
+ /* Restore SMBALERT# assertion */
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_SC, sctl);
+
+ if (error || sc->sc_i2c_xfer.error)
return (1);
return (0);
diff --git a/sys/dev/pci/piixreg.h b/sys/dev/pci/piixreg.h
index 314fd9ab02b..4a880995de6 100644
--- a/sys/dev/pci/piixreg.h
+++ b/sys/dev/pci/piixreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: piixreg.h,v 1.2 2005/12/28 20:10:44 grange Exp $ */
+/* $OpenBSD: piixreg.h,v 1.3 2006/01/03 22:39:03 grange Exp $ */
/*
* Copyright (c) 2005 Alexander Yurchenko <grange@openbsd.org>
@@ -33,6 +33,7 @@
#define PIIX_SMB_HOSTC_HSTEN (1 << 16) /* enable host controller */
#define PIIX_SMB_HOSTC_SMI (0 << 17) /* SMI */
#define PIIX_SMB_HOSTC_IRQ (4 << 17) /* IRQ */
+#define PIIX_SMB_HOSTC_INTMASK (7 << 17)
/* SMBus I/O registers */
#define PIIX_SMB_HS 0x00 /* host status */
@@ -58,6 +59,8 @@
#define PIIX_SMB_HD0 0x05 /* host data 0 */
#define PIIX_SMB_HD1 0x06 /* host data 1 */
#define PIIX_SMB_HBDB 0x07 /* host block data byte */
+#define PIIX_SMB_SC 0x08 /* slave control */
+#define PIIX_SMB_SC_ALERTEN (1 << 3) /* enable SMBALERT# */
#define PIIX_SMB_SIZE 0x10 /* SMBus I/O space size */