summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYicheng Li <yichengli@chromium.org>2019-10-08 17:31:56 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-12 11:43:38 +0000
commita6c2477aca71c0dd3aed21d34009aecf056a6f4a (patch)
tree934ddffe61c86bb25393cefc2db09e7a5fb2d569
parent7912c0fdbec588732e52bea1bd315ff6d102a15f (diff)
downloadchrome-ec-a6c2477aca71c0dd3aed21d34009aecf056a6f4a.tar.gz
chip/stm32: Fix bug that LPTIM_PERIOD_US became unsigned long.
Due to a refactoring of bit shifts (BIT macro), LPTIM_PERIOD_US changed from int to unsigned int, which in turn changed behavior of set_lptim_event. This causes a watchdog reset during a long suspend. In particular, this caused the stm32h7 FPMCU to reboot during long suspend and fingerprint unlock to not work. BUG=b:140538084 BRANCH=none TEST=verified that FPMCU no longer reboots during deep sleep, fingerprint unlock works after deep sleeping for a whole night. Change-Id: If2ed9cb94aad4216012e28ffec530bc4ce858093 Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1854785 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
-rw-r--r--chip/stm32/clock-stm32h7.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/chip/stm32/clock-stm32h7.c b/chip/stm32/clock-stm32h7.c
index a3ebb9aa36..f41a76b87a 100644
--- a/chip/stm32/clock-stm32h7.c
+++ b/chip/stm32/clock-stm32h7.c
@@ -32,7 +32,13 @@
* with /4 prescaler (2^2): period 125 us, full range ~8s
*/
#define LPTIM_PRESCALER_LOG2 2
-#define LPTIM_PRESCALER BIT(LPTIM_PRESCALER_LOG2)
+/*
+ * LPTIM_PRESCALER and LPTIM_PERIOD_US have to be signed, because we compare
+ * them to an int to decide whether to go to deep sleep. Simply using BIT()
+ * makes them unsigned, which causes a bug in deep sleep behavior.
+ * TODO(b/140538084): Explain exactly what the bug is.
+ */
+#define LPTIM_PRESCALER ((int)BIT(LPTIM_PRESCALER_LOG2))
#define LPTIM_PERIOD_US (SECOND / (STM32_LSI_CLOCK / LPTIM_PRESCALER))
/*