Module Name: src Committed By: christos Date: Mon Jan 23 04:12:26 UTC 2012
Modified Files: src/sys/dev/ic: tpm.c tpmreg.h Log Message: reduce the polling interval to 2 seconds, and try harder to get interrupts working. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/tpm.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/tpmreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/ic/tpm.c diff -u src/sys/dev/ic/tpm.c:1.3 src/sys/dev/ic/tpm.c:1.4 --- src/sys/dev/ic/tpm.c:1.3 Sun Jan 22 15:41:25 2012 +++ src/sys/dev/ic/tpm.c Sun Jan 22 23:12:26 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: tpm.c,v 1.3 2012/01/22 20:41:25 christos Exp $ */ +/* $NetBSD: tpm.c,v 1.4 2012/01/23 04:12:26 christos Exp $ */ /* * Copyright (c) 2008, 2009 Michael Shalayeff * Copyright (c) 2009, 2010 Hans-Jörg Höxer @@ -18,7 +18,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.3 2012/01/22 20:41:25 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.4 2012/01/23 04:12:26 christos Exp $"); #if 0 #define TPM_DEBUG @@ -132,24 +132,40 @@ tpm_tis12_irqinit(struct tpm_softc *sc, } /* Ack and disable all interrupts. */ + r = bus_space_read_4(sc->sc_bt, sc->sc_bh, TPM_INTERRUPT_ENABLE); bus_space_write_4(sc->sc_bt, sc->sc_bh, TPM_INTERRUPT_ENABLE, - bus_space_read_4(sc->sc_bt, sc->sc_bh, TPM_INTERRUPT_ENABLE) & - ~TPM_GLOBAL_INT_ENABLE); + r & ~TPM_GLOBAL_INT_ENABLE); bus_space_write_4(sc->sc_bt, sc->sc_bh, TPM_INT_STATUS, bus_space_read_4(sc->sc_bt, sc->sc_bh, TPM_INT_STATUS)); +#ifdef TPM_DEBUG + char buf[128]; + snprintb(buf, sizeof(buf), TPM_INTERRUPT_ENABLE_BITS, r); + aprint_debug_dev(sc->sc_dev, "%s: before ien %s\n", __func__, buf); +#endif /* Program interrupt vector. */ bus_space_write_1(sc->sc_bt, sc->sc_bh, TPM_INT_VECTOR, irq); sc->sc_vector = irq; /* Program interrupt type. */ + r &= ~(TPM_INT_EDGE_RISING|TPM_INT_EDGE_FALLING|TPM_INT_LEVEL_HIGH| + TPM_INT_LEVEL_LOW); + r |= TPM_GLOBAL_INT_ENABLE|TPM_CMD_READY_INT|TPM_LOCALITY_CHANGE_INT| + TPM_STS_VALID_INT|TPM_DATA_AVAIL_INT; if (sc->sc_capabilities & TPM_INTF_INT_EDGE_RISING) - r = TPM_INT_EDGE_RISING; + r |= TPM_INT_EDGE_RISING; + else if (sc->sc_capabilities & TPM_INTF_INT_EDGE_FALLING) + r |= TPM_INT_EDGE_FALLING; else if (sc->sc_capabilities & TPM_INTF_INT_LEVEL_HIGH) - r = TPM_INT_LEVEL_HIGH; + r |= TPM_INT_LEVEL_HIGH; else - r = TPM_INT_LEVEL_LOW; + r |= TPM_INT_LEVEL_LOW; + bus_space_write_4(sc->sc_bt, sc->sc_bh, TPM_INTERRUPT_ENABLE, r); +#ifdef TPM_DEBUG + snprintb(buf, sizeof(buf), TPM_INTERRUPT_ENABLE_BITS, r); + aprint_debug_dev(sc->sc_dev, "%s: after ien %s\n", __func__, buf); +#endif return 0; } Index: src/sys/dev/ic/tpmreg.h diff -u src/sys/dev/ic/tpmreg.h:1.2 src/sys/dev/ic/tpmreg.h:1.3 --- src/sys/dev/ic/tpmreg.h:1.2 Sun Jan 22 15:41:25 2012 +++ src/sys/dev/ic/tpmreg.h Sun Jan 22 23:12:26 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: tpmreg.h,v 1.2 2012/01/22 20:41:25 christos Exp $ */ +/* $NetBSD: tpmreg.h,v 1.3 2012/01/23 04:12:26 christos Exp $ */ /* * Copyright (c) 2008, 2009 Michael Shalayeff @@ -46,7 +46,9 @@ #define TPM_STS_VALID_INT 0x00000002 /* int on TPM_STS_VALID is set */ #define TPM_DATA_AVAIL_INT 0x00000001 /* int on TPM_STS_DATA_AVAIL is set */ #define TPM_INTERRUPT_ENABLE_BITS \ - "\020\040ENA\010RDY\03LOCH\02STSV\01DRDY" + "\177\020b\0DRDY\0b\1STSVALID\0b\2LOCCHG\0" \ + "F\3\2:\0HIGH\0:\1LOW\0:\2RISE\0:\3FALL\0" \ + "b\7IRDY\0b\x1fGIENABLE\0" #define TPM_INT_VECTOR 0x000c /* 8 bit reg for 4 bit irq vector */ #define TPM_INT_STATUS 0x0010 /* bits are & 0x87 from TPM_INTERRUPT_ENABLE */ @@ -84,7 +86,7 @@ #define TPM_ACCESS_TMO 2000 /* 2sec */ #define TPM_READY_TMO 2000 /* 2sec */ -#define TPM_READ_TMO 120000 /* 2 minutes */ +#define TPM_READ_TMO 2000 /* 2sec */ #define TPM_BURST_TMO 2000 /* 2sec */ #define TPM_LEGACY_BUSY 0x01