summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2019-03-25 15:11:17 -0700
committerVadim Bendebury <vbendeb@chromium.org>2019-09-21 19:11:19 -0700
commit8c2f909e700f9fa9f3cbe779b24b093cc7d2a8e8 (patch)
treecd81f5b55507dd9221e8714168528d16e1938ef2
parent0a091229e0765999d38c4eefd0bea051bfb050fc (diff)
downloadchrome-ec-8c2f909e700f9fa9f3cbe779b24b093cc7d2a8e8.tar.gz
cr50: add board_forcing_wp to get force wp state (take two)
A lot of places check if cr50 is forcing the wp state. Add a function for that. BUG=none BRANCH=cr50 TEST=none Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1539008 Reviewed-by: Namyoon Woo <namyoon@chromium.org> (cherry picked from commit 05e9ae7330cfa6144cbc29c30065a58f667fd48e) Change-Id: Idf7b6c979e7e0fb80b426535153b2ee2f7ebbdb2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1644041 Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> (cherry picked from commit 27abcae6269ae219f00b1fb5c459f37950aedc4c) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1705362 (cherry picked from commit 019bee7a25d4f0cf2d61d8265942313c9f0dfb04)
-rw-r--r--board/cr50/wp.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/board/cr50/wp.c b/board/cr50/wp.c
index b1be6a87b5..ba7e2f7de1 100644
--- a/board/cr50/wp.c
+++ b/board/cr50/wp.c
@@ -31,6 +31,14 @@ int board_battery_is_present(void)
}
/**
+ * Return non-zero if the wp state is being overridden.
+ */
+static int board_forcing_wp(void)
+{
+ return GREG32(PMU, LONG_LIFE_SCRATCH1) & BOARD_FORCING_WP;
+}
+
+/**
* Set the current write protect state in RBOX and long life scratch register.
*
* @param asserted: 0 to disable write protect, otherwise enable write protect.
@@ -68,7 +76,7 @@ static void check_wp_battery_presence(void)
int bp = board_battery_is_present();
/* If we're forcing WP, ignore battery detect */
- if (GREG32(PMU, LONG_LIFE_SCRATCH1) & BOARD_FORCING_WP)
+ if (board_forcing_wp())
return;
/* Otherwise, mirror battery */
@@ -121,7 +129,7 @@ static enum vendor_cmd_rc vc_set_wp(enum vendor_cmd_cc code,
return VENDOR_RC_BOGUS_ARGS;
/* Get current wp settings */
- if (GREG32(PMU, LONG_LIFE_SCRATCH1) & BOARD_FORCING_WP)
+ if (board_forcing_wp())
response |= WPV_FORCE;
if (wp_is_asserted())
response |= WPV_ENABLE;
@@ -164,8 +172,7 @@ static int command_wp(int argc, char **argv)
}
}
- forced = GREG32(PMU, LONG_LIFE_SCRATCH1) & BOARD_FORCING_WP;
- ccprintf("Flash WP: %s%s\n", forced ? "forced " : "",
+ ccprintf("Flash WP: %s%s\n", board_forcing_wp() ? "forced " : "",
wp_is_asserted() ? "enabled" : "disabled");
ccprintf(" at boot: ");
@@ -204,7 +211,7 @@ void init_wp_state(void)
* that was saved to the long-life registers before the deep
* sleep instead of going back to the at-boot default.
*/
- if (GREG32(PMU, LONG_LIFE_SCRATCH1) & BOARD_FORCING_WP) {
+ if (board_forcing_wp()) {
/* Temporarily forcing WP */
set_wp_state(GREG32(PMU, LONG_LIFE_SCRATCH1) &
BOARD_WP_ASSERTED);