summaryrefslogtreecommitdiff
path: root/core/cortex-m0
diff options
context:
space:
mode:
authorBobby Casey <bobbycasey@google.com>2021-02-22 10:42:20 -0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-01 00:02:59 +0000
commitb325538a3dedb7b89680e0d9385899638afd529e (patch)
tree7f7fcb615611a7525adb9c2d59c737ebdc90e79b /core/cortex-m0
parent3bdfeba224ba2f64a77d13fd0079d2f185f9cc87 (diff)
downloadchrome-ec-b325538a3dedb7b89680e0d9385899638afd529e.tar.gz
cortex-m: Don't execute WFI instruction if debugging
Allowing the processor to sleep causes the debugger to stop working. BRANCH=none BUG=b:180144572 TEST=Monitor power per go/cros-fpmcu-source-code-docs#dragonclaw-v0_2 TEST=Icetower (pp3300_dx_mcu_mw) with no debugger connected Idle: ~44 mW Low Power Mode: ~5.5 mW TEST=Icetower (pp3300_dx_mcu_mw) with debugger connected Idle: ~75 mW Low Power Mode: ~70 mW TEST=Dragonclaw (pp3300_dx_mcu_mw) with no debugger connected Idle: ~22 mW Low Power Mode: ~1.5 mW TEST=Dragonclaw (pp3300_dx_mcu_mw) with debugger connected Idle: ~64 mW Low Power Mode: ~19 mW Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: I48d58395b168dc3bb0932348cd8f5ce088fc0ac9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2713754 Commit-Queue: Tom Hughes <tomhughes@chromium.org> Tested-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'core/cortex-m0')
-rw-r--r--core/cortex-m0/cpu.h9
-rw-r--r--core/cortex-m0/task.c2
2 files changed, 10 insertions, 1 deletions
diff --git a/core/cortex-m0/cpu.h b/core/cortex-m0/cpu.h
index 48abf916d6..0fc2e655d4 100644
--- a/core/cortex-m0/cpu.h
+++ b/core/cortex-m0/cpu.h
@@ -10,6 +10,7 @@
#include <stdint.h>
#include "compile_time_macros.h"
+#include "debug.h"
/* Macro to access 32-bit registers */
#define CPUREG(addr) (*(volatile uint32_t *)(addr))
@@ -61,4 +62,12 @@ static inline void cpu_set_interrupt_priority(uint8_t irq, uint8_t priority)
(priority << prio_shift);
}
+static inline void cpu_enter_suspend_mode(void)
+{
+ /* Preserve debug sessions by not suspending when connected */
+ if (!debugger_is_connected()) {
+ asm("wfi");
+ }
+}
+
#endif /* __CROS_EC_CPU_H */
diff --git a/core/cortex-m0/task.c b/core/cortex-m0/task.c
index 5eb67c7346..4837c2dfbd 100644
--- a/core/cortex-m0/task.c
+++ b/core/cortex-m0/task.c
@@ -72,7 +72,7 @@ void __idle(void)
* Wait for the next irq event. This stops the CPU clock
* (sleep / deep sleep, depending on chip config).
*/
- asm("wfi");
+ cpu_enter_suspend_mode();
}
}
#endif /* !CONFIG_LOW_POWER_IDLE */