summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/cr50/board.c10
-rw-r--r--chip/g/i2cs.c3
-rw-r--r--common/i2cs_tpm.c9
3 files changed, 21 insertions, 1 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c
index 1bb6ce46ec..e370973778 100644
--- a/board/cr50/board.c
+++ b/board/cr50/board.c
@@ -765,6 +765,14 @@ void i2cs_set_pinmux(void)
*/
GWRITE_FIELD(PINMUX, DIOA1_CTL, PU, 1);
GWRITE_FIELD(PINMUX, DIOA9_CTL, PU, 1);
- /* TODO(scollyer): Do we need to add wake on SCL activity here? */
+ /* Allow I2CS_SCL to wake from sleep */
+ GWRITE_FIELD(PINMUX, EXITEDGE0, DIOA9, 1); /* edge sensitive */
+ GWRITE_FIELD(PINMUX, EXITINV0, DIOA9, 1); /* wake on low */
+ GWRITE_FIELD(PINMUX, EXITEN0, DIOA9, 1); /* enable powerdown exit */
+
+ /* Allow I2CS_SDA to wake from sleep */
+ GWRITE_FIELD(PINMUX, EXITEDGE0, DIOA1, 1); /* edge sensitive */
+ GWRITE_FIELD(PINMUX, EXITINV0, DIOA1, 1); /* wake on low */
+ GWRITE_FIELD(PINMUX, EXITEN0, DIOA1, 1); /* enable powerdown exit */
}
diff --git a/chip/g/i2cs.c b/chip/g/i2cs.c
index 77c451079f..5e45ec0ee8 100644
--- a/chip/g/i2cs.c
+++ b/chip/g/i2cs.c
@@ -122,6 +122,9 @@ static void _i2cs_write_complete_int(void)
/* Reset the IRQ condition. */
GWRITE_FIELD(I2CS, INT_STATE, INTR_WRITE_COMPLETE, 1);
+ /* We're receiving some bytes, so don't sleep */
+ disable_sleep(SLEEP_MASK_I2C_SLAVE);
+
if (write_complete_handler_) {
uint16_t bytes_written;
uint16_t bytes_processed;
diff --git a/common/i2cs_tpm.c b/common/i2cs_tpm.c
index b9ab003b16..7700fd8373 100644
--- a/common/i2cs_tpm.c
+++ b/common/i2cs_tpm.c
@@ -9,6 +9,7 @@
#include "hooks.h"
#include "i2cs.h"
#include "registers.h"
+#include "system.h"
#include "tpm_registers.h"
/*
@@ -129,6 +130,14 @@ static void process_read_access(uint16_t reg_size,
tpm_register_get(tpm_reg, data, reg_size);
/* Transfer TPM fifo data to the I2CS HW fifo */
i2cs_post_read_fill_fifo(data, reg_size);
+
+ /*
+ * Could be the end of a TPM trasaction. Set sleep to be reenabled in 1
+ * second. If this is not the end of a TPM response, then sleep will be
+ * disabled again in the next I2CS interrupt.
+ */
+ delay_sleep_by(1 * SECOND);
+ enable_sleep(SLEEP_MASK_I2C_SLAVE);
}
static void process_write_access(uint16_t reg_size, uint16_t tpm_reg,