From 45b4eda8771ad03777a03326207075dce57f13e3 Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Mon, 3 Nov 2014 10:09:47 -0800 Subject: 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 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 Commit-Queue: Vincent Palatin Tested-by: Vincent Palatin --- board/zinger/board.h | 1 + board/zinger/runtime.c | 5 ++++- chip/stm32/clock-stm32f0.c | 2 +- 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 */ -- cgit v1.2.1