summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2019-03-13 12:22:36 -0600
committerchrome-bot <chrome-bot@chromium.org>2019-04-05 03:53:53 -0700
commit63bf8f8ba87b23378391b147f1b3e9fdcf3d8dc5 (patch)
tree8c6facc63a6fac54f9c6d7eabd583b8645f5dd4d
parentb97918b72f1d30120f4598a58f7066d72fbd3e9c (diff)
downloadchrome-ec-63bf8f8ba87b23378391b147f1b3e9fdcf3d8dc5.tar.gz
cr50: Update to VENDOR_CC_GET_PWR_BTN
Change the VENDOR_CC_GET_PWR_BTN behavior to report the live state of the power button. On Wilco devices, the AP needs to poll for both a power button press and release prior to booting an untrusted OS. The falling edge of the power button is still latched, so the first call to VENDOR_CC_GET_PWR_BTN command will return a button state of 1 if this call is made within 10 seconds. Once the latched state is clear, VENDOR_CC_GET_PWR_BTN returns the live state of the power button. BUG=b:128431787 BRANCH=cr50 TEST=Added test code into vboot recovery screen to poll VENDOR_CC_GET_PWR_BTN command for a power button press and a power button release. Change-Id: I8bc34e4e6309f6b3bd8020655370eb50032a00f1 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1534337 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Matt Delco <delco@google.com>
-rw-r--r--board/cr50/power_button.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/board/cr50/power_button.c b/board/cr50/power_button.c
index 83379ae167..5f46a4d0a6 100644
--- a/board/cr50/power_button.c
+++ b/board/cr50/power_button.c
@@ -140,7 +140,18 @@ static enum vendor_cmd_rc vc_get_pwr_btn(enum vendor_cmd_cc code,
size_t input_size,
size_t *response_size)
{
- if (pop_check_presence(1) == POP_TOUCH_YES)
+ /*
+ * The AP uses VENDOR_CC_GET_PWR_BTN to poll both for the press and
+ * release of the power button.
+ *
+ * pop_check_presence(1) returns true if a new power button press was
+ * recorded in the last 10 seconds.
+ *
+ * Indicate button release if no new presses have been recorded and the
+ * current button state is not pressed.
+ */
+ if (pop_check_presence(1) == POP_TOUCH_YES ||
+ rbox_powerbtn_is_pressed())
*(uint8_t *)buf = 1;
else
*(uint8_t *)buf = 0;