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 <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/884306
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Mary Ruthven
2018-01-23 13:26:04 -08:00
committed by chrome-bot
parent 8160d1ae86
commit 4d0eb3be49
2 changed files with 13 additions and 4 deletions

View File

@@ -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);

View File

@@ -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