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>
This commit is contained in:
Randall Spangler
2017-08-04 18:29:01 -07:00
committed by chrome-bot
parent 6c55126080
commit bb66df5399
4 changed files with 8 additions and 46 deletions

View File

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

View File

@@ -175,7 +175,6 @@ enum device_type {
DEVICE_EC,
DEVICE_SERVO,
DEVICE_BATTERY_PRESENT,
DEVICE_CCD_MODE,
DEVICE_COUNT
};

View File

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

View File

@@ -12,14 +12,6 @@ void rdd_detached(void);
/* Attach to debug cable */
void rdd_attached(void);
/*
* Called by the device state module when the state of the CCD mode pin changes
* and will either enable or disable case closed debugging.
*
* @param pin_level: The level of the CCD_MODE_L pin.
*/
void ccd_mode_pin_changed(int pin_level);
/*
* USB is only used for CCD, so only enable UTMI wakeups when RDD detects that
* a debug accessory is attached and disable it as a wakeup source when the