summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2015-09-30 14:37:51 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-30 23:19:54 -0700
commit63d7b7b6f4e3c49c5c8d03c189adfe76f2fc6732 (patch)
tree6417c3a5afb7b4fe55fc339624e2f0b53ce8007f
parent29162aeeccdbe46ea2b17df105d61f379e6581f2 (diff)
downloadchrome-ec-63d7b7b6f4e3c49c5c8d03c189adfe76f2fc6732.tar.gz
stm32: i2c: Inhibit deep sleep when addressed in slave mode
According to the stm32 databook, we cannot enter deep sleep when an i2c slave interface is addressed until it sees a stop condition. BUG=chrome-os-partner:45010 TEST=Enable deep sleep on glados_pd, verify that the PD state machine doesn't toggle between disconnect and debounce (no console spam) BRANCH=None Change-Id: I2016c30bccec916d1c22df93303acf50331bd318 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/303404 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r--chip/stm32/i2c-stm32f0.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/chip/stm32/i2c-stm32f0.c b/chip/stm32/i2c-stm32f0.c
index 4d2da2a353..8685ef5911 100644
--- a/chip/stm32/i2c-stm32f0.c
+++ b/chip/stm32/i2c-stm32f0.c
@@ -12,6 +12,7 @@
#include "host_command.h"
#include "i2c.h"
#include "registers.h"
+#include "system.h"
#include "task.h"
#include "timer.h"
#include "usb_pd_tcpc.h"
@@ -267,6 +268,8 @@ static void i2c_event_handler(int port)
/* Clear ADDR bit by writing to ADDRCF bit */
STM32_I2C_ICR(port) |= STM32_I2C_ICR_ADDRCF;
+ /* Inhibit stop mode when addressed until STOPF flag is set */
+ disable_sleep(SLEEP_MASK_I2C_SLAVE);
}
/* Stop condition on bus */
@@ -289,6 +292,9 @@ static void i2c_event_handler(int port)
/* Clear STOPF bit by writing to STOPCF bit */
STM32_I2C_ICR(port) |= STM32_I2C_ICR_STOPCF;
+
+ /* No longer inhibit deep sleep after stop condition */
+ enable_sleep(SLEEP_MASK_I2C_SLAVE);
}
/* Receiver full event */