From 63d7b7b6f4e3c49c5c8d03c189adfe76f2fc6732 Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Wed, 30 Sep 2015 14:37:51 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/303404 Commit-Ready: Shawn N Tested-by: Shawn N Reviewed-by: Alec Berg --- chip/stm32/i2c-stm32f0.c | 6 ++++++ 1 file changed, 6 insertions(+) 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 */ -- cgit v1.2.1