summaryrefslogtreecommitdiff
path: root/board/cr50/rdd.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2017-08-04 18:29:01 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-08-08 17:34:09 -0700
commitbb66df5399918087d407cc341f57416408f0d025 (patch)
tree972edb0124dd866dbba4eca1552041b56a40a11b /board/cr50/rdd.c
parent6c55126080f7fa1f165d38924834c894c4a24c27 (diff)
downloadchrome-ec-bb66df5399918087d407cc341f57416408f0d025.tar.gz
cr50: Merge CCD device handling to rdd.c
The device_state module is used for debouncing GPIO inputs to determine device sstate. It was overkill for managing the CCD cable (RDD) attach/detach state, and split that handling between 3 files (board.c, rdd.c, device_state.c). Move all of that logic into rdd.c so it's easier to maintain. BUG=none BRANCH=cr50 TEST=manual plug in CCD cable (or ground DIOM1) ccd command reports cable connected and AP UART TX+RX unplug CCD cable (or un-ground DIOM1) ccd command reports cable disconnected and AP UART disabled Change-Id: Id8fcd3a51605ae7a4843668ea18dd0ef84aceb2c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/604499 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/cr50/rdd.c')
-rw-r--r--board/cr50/rdd.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/board/cr50/rdd.c b/board/cr50/rdd.c
index 74ea87eff0..be5bf3417d 100644
--- a/board/cr50/rdd.c
+++ b/board/cr50/rdd.c
@@ -144,8 +144,6 @@ void rdd_attached(void)
GWRITE(PINMUX, DIOM1_SEL, GC_PINMUX_GPIO0_GPIO5_SEL);
/* Indicate case-closed debug mode (active low) */
gpio_set_flags(GPIO_CCD_MODE_L, GPIO_OUT_LOW);
-
- /* The device state module will handle the actual enabling of CCD. */
}
void rdd_detached(void)
@@ -161,21 +159,23 @@ void rdd_detached(void)
*/
if (!keep_ccd_enabled)
gpio_set_flags(GPIO_CCD_MODE_L, GPIO_INPUT);
-
- /* The device state module will handle the disabling of CCD. */
}
-void ccd_mode_pin_changed(int pin_level)
+static void rdd_check_pin(void)
{
- /* Inverted because active low. */
- int enable = pin_level ? 0 : 1;
+ /* The CCD mode pin is active low. */
+ int enable = !gpio_get_level(GPIO_CCD_MODE_L);
/* Keep CCD enabled if it's being forced enabled. */
- if (!enable && keep_ccd_enabled)
+ if (keep_ccd_enabled)
+ enable = 1;
+
+ if (enable == ccd_is_enabled())
return;
configure_ccd(enable);
}
+DECLARE_HOOK(HOOK_SECOND, rdd_check_pin, HOOK_PRIO_DEFAULT);
static void rdd_ccd_change_hook(void)
{