chip/g: Move Rdd keepalive to chip driver

Previously, chip/g/rdd provided a method for an external console
command to override the Rdd cable detect state.  But since we'll be
refactoring the 'ccd' command, it's tidier to move this to a console
command inside the rdd driver itself.

BUG=none
BRANCH=cr50
TEST=manual, with no debug cable present
	rdd enable -> Rdd connect
	rdd -> keepalive
	rdd disable
	rdd -> connected (hasn't had a chance to run state machine)
	(wait <1 sec)
	rdd -> debouncing
	(wait 1 sec) -> Rdd disconnect

Change-Id: I141eedf8070b4ad2c96cc5a364f4e37dc29bed70
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/647991
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
This commit is contained in:
Randall Spangler
2017-08-31 13:00:01 -07:00
committed by chrome-bot
parent 69e10e84aa
commit 536c1e3449
3 changed files with 25 additions and 31 deletions

View File

@@ -168,13 +168,6 @@ static int command_ccd(int argc, char **argv)
usb_i2c_board_enable();
else
usb_i2c_board_disable();
} else if (!strcasecmp("keepalive", argv[1])) {
force_rdd_detect(val);
if (val) {
ccprintf("Warning CCD will remain "
"enabled until it is "
"explicitly disabled.\n");
}
} else
return EC_ERROR_PARAM1;
}
@@ -197,7 +190,7 @@ static int command_ccd(int argc, char **argv)
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(ccd, command_ccd,
"[uart|i2c|keepalive] [<BOOLEAN>]",
"[uart|i2c] [<BOOLEAN>]",
"Get/set the case closed debug state");
static int command_sys_rst(int argc, char **argv)

View File

@@ -51,8 +51,8 @@ static int rdd_is_detected(void)
void print_rdd_state(void)
{
ccprintf("RDD: %s\n",
force_detected ? "forced enable" : device_state_name(state));
ccprintf("Rdd: %s\n",
force_detected ? "keepalive" : device_state_name(state));
}
/**
@@ -60,7 +60,7 @@ void print_rdd_state(void)
*/
static void rdd_disconnect(void)
{
CPRINTS("Debug accessory disconnect");
CPRINTS("Rdd disconnect");
state = DEVICE_STATE_DISCONNECTED;
/*
@@ -92,7 +92,7 @@ static void rdd_connect(void)
return;
/* We were previously disconnected, so connect */
CPRINTS("Debug accessory connect");
CPRINTS("Rdd connect");
state = DEVICE_STATE_CONNECTED;
/* Start pulling CCD_MODE_L low to enable the SBUx muxes */
@@ -227,16 +227,27 @@ void init_rdd_state(void)
GWRITE_FIELD(RDD, INT_ENABLE, INTR_DEBUG_STATE_DETECTED, 1);
}
void force_rdd_detect(int enable)
static int command_rdd_keepalive(int argc, char **argv)
{
force_detected = enable;
if (argc == 1) {
print_rdd_state();
return EC_SUCCESS;
}
/*
* If we're forcing detection, trigger then connect handler early.
*
* Otherwise, we'll revert to the normal logic of checking the RDD
* hardware CC state.
*/
if (force_detected)
if (!parse_bool(argv[1], &force_detected))
return EC_ERROR_PARAM1;
if (force_detected) {
/* Force Rdd detect */
ccprintf("Forcing Rdd detect keepalive\n");
hook_call_deferred(&rdd_connect_data, 0);
} else {
/* Go back to actual hardware state */
ccprintf("Using actual Rdd state\n");
}
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(rddkeepalive, command_rdd_keepalive,
"[BOOLEAN]",
"Get Rdd state or force keepalive");

View File

@@ -11,16 +11,6 @@
*/
void init_rdd_state(void);
/**
* Enable/disable forcing debug accessory detection.
*
* When enabled, the RDD module will assert CCD_MODE_L even if the CC value
* does not indicate a debug accessory is present.
*
* @param enable Enable (1) or disable (0) keepalive.
*/
void force_rdd_detect(int enable);
/**
* Print debug accessory detect state
*/