summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Hsu <Henry.Hsu@quantatw.com>2014-10-01 12:32:12 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-03 02:56:49 +0000
commit2b887a2219aabc707669df00655e04f2d3295eb5 (patch)
tree71531883a0f7d5f43eef7be806c0e9b80fbde906
parent085cd334b62959c9d62f3ee46903ae02c20a10bb (diff)
downloadchrome-ec-release-R40-6457.B.tar.gz
CHERRY-PICK: Paine, Yuna: Support force lid openrelease-R40-6457.B
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: I46c4415af5864e27173d21f8f804a27f0f1c4065 Original-Change-Id: I94527b7ef7f9efe779c6b86f3eab651f99af6000 Signed-off-by: Henry Hsu <Henry.Hsu@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/220740 Reviewed-by: Mohammed Habibulla <moch@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/227363 Reviewed-on: https://chromium-review.googlesource.com/232596 Reviewed-by: Allen Hung <allen.hung@intel.com> Commit-Queue: Allen Hung <allen.hung@intel.com> Tested-by: Allen Hung <allen.hung@intel.com>
-rw-r--r--common/lid_switch.c21
-rw-r--r--include/ec_commands.h10
-rw-r--r--util/ectool.c26
3 files changed, 56 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));
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 2266f07971..4fcf3b9fb2 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -1466,6 +1466,16 @@ struct ec_response_motion_sense {
} __packed;
/*****************************************************************************/
+/* Force lid open command */
+
+/* Make lid event always open */
+#define EC_CMD_FORCE_LID_OPEN 0x2c
+
+struct ec_params_force_lid_open {
+ uint8_t enabled;
+} __packed;
+
+/*****************************************************************************/
/* USB charging control commands */
/* Set USB port charging mode */
diff --git a/util/ectool.c b/util/ectool.c
index 062ffafedb..a135aa3768 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -104,6 +104,8 @@ const char help_str[] =
" Reads from EC flash to a file\n"
" flashwrite <offset> <infile>\n"
" Writes to EC flash from a file\n"
+ " forcelidopen <enable>\n"
+ " Forces the lid switch to open position\n"
" gpioget <GPIO name>\n"
" Get the value of GPIO signal\n"
" gpioset <GPIO name>\n"
@@ -5104,6 +5106,29 @@ struct command {
int (*handler)(int argc, char *argv[]);
};
+int cmd_force_lid_open(int argc, char *argv[])
+{
+ struct ec_params_force_lid_open p;
+ char *e;
+ int rv;
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s <0|1>\n", argv[0]);
+ return -1;
+ }
+ p.enabled = strtol(argv[1], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad value.\n");
+ return -1;
+ }
+
+ rv = ec_command(EC_CMD_FORCE_LID_OPEN, 0, &p, sizeof(p), NULL, 0);
+ if (rv < 0)
+ return rv;
+ printf("Success.\n");
+ return 0;
+}
+
/* NULL-terminated list of commands */
const struct command commands[] = {
{"extpwrcurrentlimit", cmd_ext_power_current_limit},
@@ -5137,6 +5162,7 @@ const struct command commands[] = {
{"flashwrite", cmd_flash_write},
{"flashinfo", cmd_flash_info},
{"flashpd", cmd_flash_pd},
+ {"forcelidopen", cmd_force_lid_open},
{"gpioget", cmd_gpio_get},
{"gpioset", cmd_gpio_set},
{"hangdetect", cmd_hang_detect},