summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2017-08-31 13:00:01 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-09-07 22:34:38 +0000
commit7e212201c520b91be7ab18411a7a38d0ce40e49e (patch)
treeaf76c815f51ca4bcb79c7180d2473746d66e9d5d /chip
parent3d003f8116b104d25098971bf306fc8fc1f83a82 (diff)
downloadchrome-ec-7e212201c520b91be7ab18411a7a38d0ce40e49e.tar.gz
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> (cherry picked from commit 536c1e34494afd508552ad29b07d08eeaa3e4b5f) Reviewed-on: https://chromium-review.googlesource.com/656419 Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/g/rdd.c37
-rw-r--r--chip/g/rdd.h10
2 files changed, 24 insertions, 23 deletions
diff --git a/chip/g/rdd.c b/chip/g/rdd.c
index 5e5ed42f6d..57c4bd96b9 100644
--- a/chip/g/rdd.c
+++ b/chip/g/rdd.c
@@ -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");
diff --git a/chip/g/rdd.h b/chip/g/rdd.h
index 4e25fe4293..1fd4f89152 100644
--- a/chip/g/rdd.h
+++ b/chip/g/rdd.h
@@ -12,16 +12,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
*/
void print_rdd_state(void);