diff options
author | Henry Hsu <Henry.Hsu@quantatw.com> | 2014-10-01 12:32:12 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-11-18 01:05:49 +0000 |
commit | 89442037be2ebd83be57b68bfabeaf2ad0367171 (patch) | |
tree | 7152745e8056ba17341e3b980a119152e153ad45 /common/lid_switch.c | |
parent | e96afe490f238f02e6598fe48f66cae895a1732f (diff) | |
download | chrome-ec-89442037be2ebd83be57b68bfabeaf2ad0367171.tar.gz |
lid_switch: Support forced lid open
Factory test process need lid switch no function or keep lid opened
BUG=chrome-os-partner:33304
BRANCH=paine,yuna
TEST=Run command "ectool forcelidopen 1" and "reboot". Then lid close
quickly, the system boot as lid opened.
Deault value or run command "ectool forcelidopen 0" make the device normal.
Change-Id: I94527b7ef7f9efe779c6b86f3eab651f99af6000
Signed-off-by: Henry Hsu <Henry.Hsu@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/230180
Reviewed-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-by: Bowgo Tsai <bowgotsai@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org>
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
Diffstat (limited to 'common/lid_switch.c')
-rw-r--r-- | common/lid_switch.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/common/lid_switch.c b/common/lid_switch.c index a676524b81..8671368631 100644 --- a/common/lid_switch.c +++ b/common/lid_switch.c @@ -21,6 +21,7 @@ #define LID_DEBOUNCE_US (30 * MSEC) /* Debounce time for lid switch */ static int debounced_lid_open; /* Debounced lid state */ +static int forced_lid_open; /* Forced lid open */ /** * Get raw lid switch state. @@ -29,7 +30,7 @@ static int debounced_lid_open; /* Debounced lid state */ */ static int raw_lid_open(void) { - return gpio_get_level(GPIO_LID_OPEN) ? 1 : 0; + return (forced_lid_open || gpio_get_level(GPIO_LID_OPEN)) ? 1 : 0; } /** @@ -125,3 +126,21 @@ DECLARE_CONSOLE_COMMAND(lidclose, command_lidclose, NULL, "Simulate lid close", NULL); + +/** + * Host command to enable/disable lid opened. + */ +static int hc_force_lid_open(struct host_cmd_handler_args *args) +{ + const struct ec_params_force_lid_open *p = args->params; + + /* Override lid open if necessary */ + forced_lid_open = p->enabled ? 1 : 0; + + /* Make this take effect immediately; no debounce time */ + hook_call_deferred(lid_change_deferred, 0); + + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_FORCE_LID_OPEN, hc_force_lid_open, + EC_VER_MASK(0)); |