summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorNamyoon Woo <namyoon@chromium.org>2019-06-04 19:05:25 -0700
committerCommit Bot <commit-bot@chromium.org>2019-06-07 01:12:55 +0000
commit41bf123847ca110e334f92dc827ffd2e94d87d5d (patch)
tree5607f31471d0f6483ce4b936cf3db456aac9433e /board
parent1cb4329139b988153f8c20e69c23ba8214257c79 (diff)
downloadchrome-ec-41bf123847ca110e334f92dc827ffd2e94d87d5d.tar.gz
cr50: optimize set_ec_on() by prioritizing the case EC is on
This patch prioritize the case that EC is in ON over other cases like INIT, INIT_DEBOUNCING or DEBOUNCING in set_ec_on(). set_ec_on() is called every second to monitor EC status when EC_UART signal is detected. set_ec_on() shall finish quickly in most of time when EC is ON. BUG=None BRANCH=None TEST=ran flash_ec and uart_stress_tester.sh on Bob. Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: I6a53ca86ccb4f65c7450bfbfda78cb5cf5b6409d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1644598 Tested-by: Namyoon Woo <namyoon@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Namyoon Woo <namyoon@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/cr50/ec_state.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/board/cr50/ec_state.c b/board/cr50/ec_state.c
index c9ed7eeb31..c42518f709 100644
--- a/board/cr50/ec_state.c
+++ b/board/cr50/ec_state.c
@@ -61,6 +61,16 @@ static void set_state(enum device_state new_state)
*/
static void set_ec_on(void)
{
+ /* If we're already on, done */
+ if (state == DEVICE_STATE_ON)
+ return;
+
+ /* If we were debouncing ON->OFF, cancel it because we're still on */
+ if (state == DEVICE_STATE_DEBOUNCING) {
+ set_state(DEVICE_STATE_ON);
+ return;
+ }
+
if (state == DEVICE_STATE_INIT ||
state == DEVICE_STATE_INIT_DEBOUNCING) {
/*
@@ -75,14 +85,6 @@ static void set_ec_on(void)
return;
}
- /* If we were debouncing ON->OFF, cancel it because we're still on */
- if (state == DEVICE_STATE_DEBOUNCING)
- set_state(DEVICE_STATE_ON);
-
- /* If we're already on, done */
- if (state == DEVICE_STATE_ON)
- return;
-
/* We were previously off */
CPRINTS("EC on");
set_state(DEVICE_STATE_ON);