summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2016-03-21 18:07:14 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-03-25 18:51:41 -0700
commitb45e7c85d0321ef349c1eb47e8fecf902c2c4203 (patch)
tree3c22ddf46824fa9e92de4c170a6395b342852717
parent6f24b75a15d5a00b2a5b06b0b4c1deb912d6dd98 (diff)
downloadchrome-ec-b45e7c85d0321ef349c1eb47e8fecf902c2c4203.tar.gz
Cr50: Cleanup check_reset_cause() code
There were some unnecessary shifts and conditionals. This just makes the code a little more readable. BUG=none BRANCH=none TEST=make buildall; test on Cr50 hw Change-Id: I084f191675d1b51101e9dc55c2e5a12b0b345d33 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/334870 Reviewed-by: Scott Collyer <scollyer@chromium.org>
-rw-r--r--chip/g/system.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/chip/g/system.c b/chip/g/system.c
index 4d935bcf37..8054a11bc0 100644
--- a/chip/g/system.c
+++ b/chip/g/system.c
@@ -10,29 +10,36 @@
static void check_reset_cause(void)
{
- uint32_t reset_source = GR_PMU_RSTSRC;
+ uint32_t g_rstsrc = GR_PMU_RSTSRC;
uint32_t flags = 0;
/* Clear the reset source now we have recorded it */
GR_PMU_CLRRST = 1;
- if (reset_source & (1 << GC_PMU_RSTSRC_POR_LSB))
- flags |= RESET_FLAG_POWER_ON;
- else if (reset_source & (1 << GC_PMU_RSTSRC_EXIT_LSB))
+ if (g_rstsrc & GC_PMU_RSTSRC_POR_MASK) {
+ /* If power-on reset is true, that's the only thing */
+ system_set_reset_flags(RESET_FLAG_POWER_ON);
+ return;
+ }
+
+ /* Low-power exit (ie, wake from deep sleep) */
+ if (g_rstsrc & GC_PMU_RSTSRC_EXIT_MASK)
flags |= RESET_FLAG_WAKE_PIN;
- if (reset_source & (1 << GC_PMU_RSTSRC_WDOG_LSB))
+ /* TODO(crosbug.com/p/47289): This bit doesn't work */
+ if (g_rstsrc & GC_PMU_RSTSRC_WDOG_MASK)
flags |= RESET_FLAG_WATCHDOG;
- if (reset_source & (1 << GC_PMU_RSTSRC_SOFTWARE_LSB))
+ if (g_rstsrc & GC_PMU_RSTSRC_SOFTWARE_MASK)
flags |= RESET_FLAG_HARD;
- if (reset_source & (1 << GC_PMU_RSTSRC_SYSRESET_LSB))
+
+ if (g_rstsrc & GC_PMU_RSTSRC_SYSRESET_MASK)
flags |= RESET_FLAG_SOFT;
- if (reset_source & (1 << GC_PMU_RSTSRC_FST_BRNOUT_LSB))
+ if (g_rstsrc & GC_PMU_RSTSRC_FST_BRNOUT_MASK)
flags |= RESET_FLAG_BROWNOUT;
- if (reset_source && !flags)
+ if (g_rstsrc && !flags)
flags |= RESET_FLAG_OTHER;
system_set_reset_flags(flags);
@@ -45,7 +52,8 @@ void system_pre_init(void)
void system_reset(int flags)
{
- /* TODO: if (flags & SYSTEM_RESET_PRESERVE_FLAGS), do so. */
+ /* TODO: Do we need to handle SYSTEM_RESET_PRESERVE_FLAGS? Doubtful. */
+ /* TODO(crosbug.com/p/47289): handle RESET_FLAG_WATCHDOG */
/* Disable interrupts to avoid task swaps during reboot */
interrupt_disable();