diff options
author | RaviChandra Sadineni <ravisadineni@google.com> | 2018-08-22 17:28:17 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-09-13 18:58:41 -0700 |
commit | 10b223dd62ca5178290a201a353e21bcd040b24d (patch) | |
tree | 39395acfc36316226aefddba15a5322f8008a736 /common/base_state.c | |
parent | 26767c965ee02fe47d86a96a28117a4a61bf90b2 (diff) | |
download | chrome-ec-10b223dd62ca5178290a201a353e21bcd040b24d.tar.gz |
base_detect: Expose console command to force state.
In an effort to test wake sources on any given platform, this
CL exposes console command to set the base state. This console
command can then be invoked by autottests from the uart interface.
We have two implementations for managing base status. One is interrupt
driven while the other is a polling via a task.
Boards current implementations then are:
interrupts: lux, soraka, cheza
polling task: nocturne, zoombini
For forcing base connect and disconnect,
interrupts: Disable interrupts and set forced base state.
polling task: Stop periodic task and set forced base state.
On reset,
interrupts: Schedule deferred task immediately and enable interrupts.
polling task: Clear forced base state and begin rescheduling periodic
task.
Signed-off-by: RaviChandra Sadineni <ravisadineni@google.com>
BRANCH=poppy,nocturne
BUG=chromium:820668, b:37223093
TEST=Tested on lux, soraka and nocturne
basestate a : attaches the lid, reflected in ui.
basestate d : detaches the lid, reflected in ui.
basestate r : resets to the correct state.
Wakes the device up on lux and nocturne and soraka.
Change-Id: Iab698e103a50b8d22bf216a6f816998cb158e38a
Reviewed-on: https://chromium-review.googlesource.com/1184172
Commit-Ready: Ravi Chandra Sadineni <ravisadineni@chromium.org>
Tested-by: Ravi Chandra Sadineni <ravisadineni@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Diffstat (limited to 'common/base_state.c')
-rw-r--r-- | common/base_state.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/common/base_state.c b/common/base_state.c index b0f352231d..053b6d4b23 100644 --- a/common/base_state.c +++ b/common/base_state.c @@ -10,6 +10,7 @@ #define CPRINTS(format, args...) cprints(CC_MOTION_LID, format, ## args) +#ifdef CONFIG_BASE_ATTACHED_SWITCH /* 1: base attached, 0: otherwise */ static int base_state; @@ -30,3 +31,24 @@ void base_set_state(int state) /* Notify host of mode change. This likely will wake it up. */ host_set_single_event(EC_HOST_EVENT_MODE_CHANGE); } +#endif + +static int command_setbasestate(int argc, char **argv) +{ + if (argc != 2) + return EC_ERROR_PARAM_COUNT; + if (argv[1][0] == 'a') + base_force_state(1); + else if (argv[1][0] == 'd') + base_force_state(0); + else if (argv[1][0] == 'r') + base_force_state(2); + else + return EC_ERROR_PARAM1; + + return EC_SUCCESS; + +} +DECLARE_CONSOLE_COMMAND(basestate, command_setbasestate, + "[attach | detach | reset]", + "Manually force base state to attached, detached or reset."); |