From 4d0eb3be49fac06cdb932a3ac9fb429d97f7a340 Mon Sep 17 00:00:00 2001 From: Mary Ruthven Date: Tue, 23 Jan 2018 13:26:04 -0800 Subject: [PATCH] cr50: fix ec and servo detection This change reenables the gpio interrupts if the signal is not high. BUG=none BRANCH=cr50 TEST=firmware_Cr50DeviceState Change-Id: Iae4e18594954789cd6841e01d1c943de3b389415 Signed-off-by: Mary Ruthven Reviewed-on: https://chromium-review.googlesource.com/884306 Reviewed-by: Randall Spangler --- board/cr50/ec_state.c | 6 +++++- board/cr50/servo_state.c | 11 ++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/board/cr50/ec_state.c b/board/cr50/ec_state.c index a208cbfd2c..ddea279909 100644 --- a/board/cr50/ec_state.c +++ b/board/cr50/ec_state.c @@ -112,6 +112,11 @@ static void ec_detect(void) set_ec_on(); return; } + /* + * Make sure the interrupt is enabled. We will need to detect the on + * transition if we enter the off or debouncing state + */ + gpio_enable_interrupt(GPIO_DETECT_EC); /* EC wasn't detected. If we're already off, done. */ if (state == DEVICE_STATE_OFF) @@ -134,6 +139,5 @@ static void ec_detect(void) set_state(DEVICE_STATE_INIT_DEBOUNCING); else set_state(DEVICE_STATE_DEBOUNCING); - gpio_enable_interrupt(GPIO_DETECT_EC); } DECLARE_HOOK(HOOK_SECOND, ec_detect, HOOK_PRIO_DEFAULT); diff --git a/board/cr50/servo_state.c b/board/cr50/servo_state.c index 8c574f5a4e..505e694142 100644 --- a/board/cr50/servo_state.c +++ b/board/cr50/servo_state.c @@ -139,7 +139,6 @@ static void servo_detect(void) servo_connect(); return; } - /* * If servo has become detectable but wasn't detected above, assume * it's disconnected. @@ -152,8 +151,15 @@ static void servo_detect(void) * debouncing state below, because we want to give priority to servo * being able to drive it again. */ - if (state == DEVICE_STATE_UNDETECTABLE) + if (state == DEVICE_STATE_UNDETECTABLE) { set_state(DEVICE_STATE_DISCONNECTED); + return; + } + /* + * Make sure the interrupt is enabled. We will need to detect the on + * transition if we enter the off or debouncing state + */ + gpio_enable_interrupt(GPIO_DETECT_SERVO); /* Servo wasn't detected. If we're already disconnected, done. */ if (state == DEVICE_STATE_DISCONNECTED) @@ -180,7 +186,6 @@ static void servo_detect(void) set_state(DEVICE_STATE_INIT_DEBOUNCING); else set_state(DEVICE_STATE_DEBOUNCING); - gpio_enable_interrupt(GPIO_DETECT_SERVO); } /* * Do this at slightly elevated priority so it runs before rdd_check_pin() and