summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2019-01-22 16:59:13 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-01-30 13:06:41 -0800
commit54c06033f3813013296c9945d6ed13cd258a1db8 (patch)
tree36ab20ac4690c825e2d024c5b96047fd3ab92099
parentcc98aa2569f249071d75b435ac400a4c060c43fb (diff)
downloadchrome-ec-54c06033f3813013296c9945d6ed13cd258a1db8.tar.gz
cr50: Add VENDOR_CC_GET_PWR_BTN to query power button
Add the new TPM command VENDOR_CC_GET_PWR_BTN used to query whether there has been a recent (within 10 seconds) power button press by the user. This is used by coreboot on Sarien/Arcada to confirm user presence prior to enabling developer mode and prior to launching closed source diagnostics. BUG=b:119346609 BRANCH=cr50 TEST=make buildall. Tested power button query from coreboot recovery screen screen on Arcada and Sarien platforms. Change-Id: I20f91204fe30dda27b0d14b755bcd357938029f5 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1432313 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
-rw-r--r--board/cr50/power_button.c21
-rw-r--r--include/tpm_vendor_cmds.h7
2 files changed, 28 insertions, 0 deletions
diff --git a/board/cr50/power_button.c b/board/cr50/power_button.c
index c939d7b980..aff6bc305c 100644
--- a/board/cr50/power_button.c
+++ b/board/cr50/power_button.c
@@ -4,6 +4,7 @@
*/
#include "console.h"
+#include "extension.h"
#include "gpio.h"
#include "hooks.h"
#include "physical_presence.h"
@@ -13,6 +14,7 @@
#include "system_chip.h"
#include "task.h"
#include "timer.h"
+#include "u2f_impl.h"
#define CPRINTS(format, args...) cprints(CC_RBOX, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_RBOX, format, ## args)
@@ -125,3 +127,22 @@ static int command_powerbtn(int argc, char **argv)
}
DECLARE_CONSOLE_COMMAND(powerbtn, command_powerbtn, "",
"get the state of the power button");
+
+/*
+ * Perform a user presence check using the power button.
+ */
+static enum vendor_cmd_rc vc_get_pwr_btn(enum vendor_cmd_cc code,
+ void *buf,
+ size_t input_size,
+ size_t *response_size)
+{
+ if (pop_check_presence(1) == POP_TOUCH_YES)
+ *(uint8_t *)buf = 1;
+ else
+ *(uint8_t *)buf = 0;
+ *response_size = 1;
+
+ return VENDOR_RC_SUCCESS;
+}
+DECLARE_VENDOR_COMMAND(VENDOR_CC_GET_PWR_BTN, vc_get_pwr_btn);
+
diff --git a/include/tpm_vendor_cmds.h b/include/tpm_vendor_cmds.h
index 499e2c3fa2..a2e2b6920e 100644
--- a/include/tpm_vendor_cmds.h
+++ b/include/tpm_vendor_cmds.h
@@ -116,6 +116,13 @@ enum vendor_cmd_cc {
*/
VENDOR_CC_SN_INC_RMA = 42,
+ /*
+ * Gets the latched state of a power button press to indicate user
+ * recent user presence. The power button state is automatically cleared
+ * after PRESENCE_TIMEOUT.
+ */
+ VENDOR_CC_GET_PWR_BTN = 43,
+
LAST_VENDOR_COMMAND = 65535,
};