summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2014-11-03 10:09:47 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-18 09:10:42 +0000
commit45b4eda8771ad03777a03326207075dce57f13e3 (patch)
treee9fed5dc35f59827885fa6a99ef4656bdf5725a5
parent2ff6a30c47142db02be4b52ab42f2dd4da5aeb59 (diff)
downloadchrome-ec-45b4eda8771ad03777a03326207075dce57f13e3.tar.gz
Zinger: honor disable_sleep()
Extend the Zinger runtime to take into account the disable_sleep() issued by the USB protocol stack and avoid going into deep-sleep while connected. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=none TEST=connect Zinger to a PD power sink (Twinkie) and monitor the stop mode entry/exit on a GPIO. Change-Id: I04e35fdd65f3be3da7a4304dc1a92e6268930888 Reviewed-on: https://chromium-review.googlesource.com/230340 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/zinger/board.h1
-rw-r--r--board/zinger/runtime.c5
-rw-r--r--chip/stm32/clock-stm32f0.c2
3 files changed, 6 insertions, 2 deletions
diff --git a/board/zinger/board.h b/board/zinger/board.h
index df642890a7..89a44f370f 100644
--- a/board/zinger/board.h
+++ b/board/zinger/board.h
@@ -32,6 +32,7 @@
#undef CONFIG_COMMON_PANIC_OUTPUT
#undef CONFIG_COMMON_RUNTIME
#undef CONFIG_COMMON_TIMER
+#define CONFIG_LOW_POWER_IDLE
#undef CONFIG_CONSOLE_CMDHELP
#undef CONFIG_DEBUG_ASSERT
#undef CONFIG_DEBUG_EXCEPTIONS
diff --git a/board/zinger/runtime.c b/board/zinger/runtime.c
index d07139dbaf..4dda979d46 100644
--- a/board/zinger/runtime.c
+++ b/board/zinger/runtime.c
@@ -9,11 +9,13 @@
#include "cpu.h"
#include "debug.h"
#include "registers.h"
+#include "system.h"
#include "task.h"
#include "timer.h"
#include "util.h"
volatile uint32_t last_event;
+uint32_t sleep_mask;
timestamp_t get_time(void)
{
@@ -139,7 +141,8 @@ uint32_t task_wait_event(int timeout_us)
if (timeout_us < 0) {
asm volatile ("wfi");
} else if (timeout_us <=
- (STOP_MODE_LATENCY + SET_RTC_MATCH_DELAY)) {
+ (STOP_MODE_LATENCY + SET_RTC_MATCH_DELAY) ||
+ !DEEP_SLEEP_ALLOWED) {
STM32_TIM32_CCR1(2) = STM32_TIM32_CNT(2) + timeout_us;
STM32_TIM_SR(2) = 0; /* clear match flag */
STM32_TIM_DIER(2) = 2; /* match interrupt */
diff --git a/chip/stm32/clock-stm32f0.c b/chip/stm32/clock-stm32f0.c
index 81cea8c884..30a0efdf2b 100644
--- a/chip/stm32/clock-stm32f0.c
+++ b/chip/stm32/clock-stm32f0.c
@@ -500,7 +500,7 @@ DECLARE_CONSOLE_COMMAND(rtc_alarm, command_rtc_alarm_test,
NULL);
#endif /* CONFIG_CMD_RTC_ALARM */
-#ifdef CONFIG_LOW_POWER_IDLE
+#if defined(CONFIG_LOW_POWER_IDLE) && defined(CONFIG_COMMON_RUNTIME)
/**
* Print low power idle statistics
*/