summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2017-07-17 16:23:47 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-07-27 19:56:22 -0700
commit3be8c42996dc69a497025a9a3404cc58154cc234 (patch)
tree3cdedcac3bbf020ef8e6b02e55097cd6fb8a7bc9 /common
parente03e58c745716241df056750b765d1c7d5985b62 (diff)
downloadchrome-ec-3be8c42996dc69a497025a9a3404cc58154cc234.tar.gz
cr50: Preserve CCD state across deep sleep
Define two bits in a long-life register to hold the current CCD state across deep sleep. Update the bits on CCD config change, and restore them on init. This is necessary because Cr50 loses RAM contents on deep sleep. It would be really inconvenient to open CCD, get a cup of coffee, and come back to find CCD has locked again because Cr50 was idle too long. See go/cr50-ccd-wp for more information. BUG=b:62537474 BRANCH=cr50 TEST=manual with CR50_DEV=1 build ccdinfo --> state=opened idle d ccdunlock ccdinfo --> state=unlocked (wait for deep sleep) sysinfo --> reset flags = hibernate wake-pin ccdinfo --> state=unlocked reboot sysinfo --> reset flags = hard ccdinfo --> state=opened Change-Id: I7864f374af5c159bc9691b094958fb030f3cb8ad Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/575996 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/ccd_config.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/common/ccd_config.c b/common/ccd_config.c
index 2c465c6d68..021ae121f3 100644
--- a/common/ccd_config.c
+++ b/common/ccd_config.c
@@ -14,6 +14,7 @@
#include "nvmem_vars.h"
#include "physical_presence.h"
#include "system.h"
+#include "system_chip.h"
#include "task.h"
#include "timer.h"
#include "trng.h"
@@ -21,15 +22,6 @@
#define CPRINTS(format, args...) cprints(CC_CCD, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_CCD, format, ## args)
-enum ccd_state {
- CCD_STATE_LOCKED = 0,
- CCD_STATE_UNLOCKED,
- CCD_STATE_OPENED,
-
- /* Number of CCD states */
- CCD_STATE_COUNT
-};
-
/* Restriction state for ccdunlock when no password is set */
enum ccd_unlock_restrict {
/* Unrestricted */
@@ -151,12 +143,7 @@ static const char *ccd_state_names[CCD_STATE_COUNT] = {
static const char *ccd_cap_state_names[CCD_CAP_STATE_COUNT] = {
"Default", "Always", "UnlessLocked", "IfOpened"};
-#ifdef CONFIG_CASE_CLOSED_DEBUG_V1_UNSAFE
-static enum ccd_state ccd_state = CCD_STATE_OPENED;
-#else
static enum ccd_state ccd_state = CCD_STATE_LOCKED;
-#endif
-
static struct ccd_config config;
static uint8_t ccd_config_loaded;
static struct mutex ccd_config_mutex;
@@ -630,8 +617,13 @@ static void ccd_testlab_toggle(void)
/******************************************************************************/
/* External interface */
-void ccd_config_init(void)
+void ccd_config_init(enum ccd_state state)
{
+ /* Set initial state, after making sure it's a valid one */
+ if (state != CCD_STATE_UNLOCKED && state != CCD_STATE_OPENED)
+ state = CCD_STATE_LOCKED;
+ ccd_state = state;
+
ccd_load_config();
}
@@ -683,6 +675,11 @@ int ccd_is_cap_enabled(enum ccd_capability cap)
}
}
+enum ccd_state ccd_get_state(void)
+{
+ return ccd_state;
+}
+
/******************************************************************************/
/* Console commands */