summaryrefslogtreecommitdiff
path: root/include/case_closed_debug.h
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 /include/case_closed_debug.h
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 'include/case_closed_debug.h')
-rw-r--r--include/case_closed_debug.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/include/case_closed_debug.h b/include/case_closed_debug.h
index 0b2ec8b468..77ad0f496f 100644
--- a/include/case_closed_debug.h
+++ b/include/case_closed_debug.h
@@ -46,6 +46,16 @@ enum ccd_mode ccd_get_mode(void);
/******************************************************************************/
/* New CCD "V1" configuration. Eventually this will supersede the above code */
+/* Case-closed debugging state */
+enum ccd_state {
+ CCD_STATE_LOCKED = 0,
+ CCD_STATE_UNLOCKED,
+ CCD_STATE_OPENED,
+
+ /* Number of CCD states */
+ CCD_STATE_COUNT
+};
+
/* Flags */
enum ccd_flag {
/* Flags that can only be set internally; fill from bottom up */
@@ -128,8 +138,13 @@ enum ccd_capability {
* Initialize CCD configuration at boot.
*
* This must be called before any command which gets/sets the configuration.
+ *
+ * @param state Initial case-closed debugging state. This should be
+ * CCD_STATE_LOCKED unless this is a debug build, or if
+ * a previous value is being restored after a low-power
+ * resume.
*/
-void ccd_config_init(void);
+void ccd_config_init(enum ccd_state state);
/**
* Get a single CCD flag.
@@ -149,11 +164,23 @@ int ccd_get_flag(enum ccd_flag flag);
int ccd_set_flag(enum ccd_flag flag, int value);
/**
- * Check if a CCD capability is enabled in the current CCD mode
+ * Check if a CCD capability is enabled in the current CCD mode.
*
* @param cap Capability to check
* @return 1 if capability is enabled, 0 if disabled
*/
int ccd_is_cap_enabled(enum ccd_capability cap);
+/**
+ * Get the current CCD state.
+ *
+ * This is intended for use by the board if it needs to back up the CCD state
+ * across low-power states and then restore it when calling ccd_config_init().
+ * Do NOT use this to gate debug capabilities; use ccd_is_cap_enabled() or
+ * ccd_get_flag() instead.
+ *
+ * @return The current CCD state.
+ */
+enum ccd_state ccd_get_state(void);
+
#endif /* __CROS_EC_CASE_CLOSED_DEBUG_H */