summaryrefslogtreecommitdiff
path: root/board
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
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')
-rw-r--r--board/cr50/board.c29
-rw-r--r--board/cr50/board.h1
-rw-r--r--board/cr50/rdd.c16
3 files changed, 8 insertions, 38 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c
index eb78139438..00e612c16a 100644
--- a/board/cr50/board.c
+++ b/board/cr50/board.c
@@ -1086,11 +1086,6 @@ struct device_config device_states[] = {
.detect = GPIO_BATT_PRES_L,
.name = "BattPrsnt"
},
- [DEVICE_CCD_MODE] = {
- .deferred = NULL,
- .detect = GPIO_CCD_MODE_L,
- .name = "CCD Mode"
- },
};
BUILD_ASSERT(ARRAY_SIZE(device_states) == DEVICE_COUNT);
@@ -1220,30 +1215,6 @@ void board_update_device_state(enum device_type device)
return;
}
- if (device == DEVICE_CCD_MODE) {
- /*
- * CCD mode pin does not have an interrupt handler, so this is
- * the only way the CCD MODE device state changes.
- *
- * This could potentially be moved to a HOOK_SECOND handler
- * in rdd.c, since nothing else cares.
- */
-
- int pin_level = gpio_get_level(device_states[device].detect);
- /* The CCD mode pin is active low. */
- int changed = device_set_state(device,
- pin_level ?
- DEVICE_STATE_OFF :
- DEVICE_STATE_ON);
-
- if (changed) {
- CPRINTS("CCD MODE changed: %d", pin_level);
- ccd_mode_pin_changed(pin_level);
- }
-
- return;
- }
-
if (device == DEVICE_SERVO) {
/*
* If we're driving the transmit line to the EC UART, then we
diff --git a/board/cr50/board.h b/board/cr50/board.h
index 665361b125..6909180e3d 100644
--- a/board/cr50/board.h
+++ b/board/cr50/board.h
@@ -175,7 +175,6 @@ enum device_type {
DEVICE_EC,
DEVICE_SERVO,
DEVICE_BATTERY_PRESENT,
- DEVICE_CCD_MODE,
DEVICE_COUNT
};
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)
{