summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaviChandra Sadineni <ravisadineni@google.com>2018-09-27 08:09:32 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-09-27 16:02:14 +0000
commite4eea88b3c24058a380a3acbfaf33fc0a1a96ee9 (patch)
tree83fc56c379fbb091a9801980e199461f8c818763
parent54e976e84087c92999804d4da2bffab71a4d6b5c (diff)
downloadchrome-ec-e4eea88b3c24058a380a3acbfaf33fc0a1a96ee9.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. orig-Change-Id: Iab698e103a50b8d22bf216a6f816998cb158e38a orig-Reviewed-on: https://chromium-review.googlesource.com/1184172 Change-Id: I13a12c302fb6c50b11a70f15c218eb72079f2c17 Reviewed-on: https://chromium-review.googlesource.com/1240456 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Ravi Chandra Sadineni <ravisadineni@chromium.org> Tested-by: Ravi Chandra Sadineni <ravisadineni@chromium.org> Trybot-Ready: Ravi Chandra Sadineni <ravisadineni@chromium.org>
-rw-r--r--board/poppy/base_detect_lux.c18
-rw-r--r--board/poppy/base_detect_poppy.c16
-rw-r--r--board/poppy/board.c16
-rw-r--r--board/poppy/board.h1
-rw-r--r--common/base_state.c27
-rw-r--r--common/build.mk1
-rw-r--r--include/base_state.h11
-rw-r--r--include/config.h7
8 files changed, 81 insertions, 16 deletions
diff --git a/board/poppy/base_detect_lux.c b/board/poppy/base_detect_lux.c
index 48c4aa8929..3da86d5e27 100644
--- a/board/poppy/base_detect_lux.c
+++ b/board/poppy/base_detect_lux.c
@@ -210,3 +210,21 @@ static void base_init(void)
gpio_enable_interrupt(GPIO_BASE_DET_A);
}
DECLARE_HOOK(HOOK_INIT, base_init, HOOK_PRIO_DEFAULT+1);
+
+void base_force_state(int state)
+{
+ if (state == 1) {
+ gpio_disable_interrupt(GPIO_BASE_DET_A);
+ base_detect_change(BASE_CONNECTED);
+ CPRINTS("BD forced connected");
+ } else if (state == 0) {
+ gpio_disable_interrupt(GPIO_BASE_DET_A);
+ base_detect_change(BASE_DISCONNECTED);
+ CPRINTS("BD forced disconnected");
+ } else {
+ hook_call_deferred(&base_detect_deferred_data,
+ BASE_DETECT_DEBOUNCE_US);
+ gpio_enable_interrupt(GPIO_BASE_DET_A);
+ CPRINTS("BD forced reset");
+ }
+}
diff --git a/board/poppy/base_detect_poppy.c b/board/poppy/base_detect_poppy.c
index 83f395f43c..a049b41acd 100644
--- a/board/poppy/base_detect_poppy.c
+++ b/board/poppy/base_detect_poppy.c
@@ -238,3 +238,19 @@ static void base_init(void)
base_enable();
}
DECLARE_HOOK(HOOK_INIT, base_init, HOOK_PRIO_DEFAULT+1);
+
+void base_force_state(int state)
+{
+ if (state == 1) {
+ gpio_disable_interrupt(GPIO_BASE_DET_A);
+ base_detect_change(BASE_CONNECTED);
+ CPRINTS("BD forced connected");
+ } else if (state == 0) {
+ gpio_disable_interrupt(GPIO_BASE_DET_A);
+ base_detect_change(BASE_DISCONNECTED);
+ CPRINTS("BD forced disconnected");
+ } else {
+ base_enable();
+ CPRINTS("BD forced reset");
+ }
+}
diff --git a/board/poppy/board.c b/board/poppy/board.c
index c693e2374c..57224f3615 100644
--- a/board/poppy/board.c
+++ b/board/poppy/board.c
@@ -142,22 +142,6 @@ void anx74xx_cable_det_interrupt(enum gpio_signal signal)
}
#endif
-static int command_attach_base(int argc, char **argv)
-{
- tablet_set_mode(0);
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(attachbase, command_attach_base,
- NULL, "Simulate attach base");
-
-static int command_detach_base(int argc, char **argv)
-{
- tablet_set_mode(1);
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(detachbase, command_detach_base,
- NULL, "Simulate detach base");
-
#include "gpio_list.h"
/* power signal list. Must match order of enum power_signal. */
diff --git a/board/poppy/board.h b/board/poppy/board.h
index 6a5e12201d..562cf77223 100644
--- a/board/poppy/board.h
+++ b/board/poppy/board.h
@@ -15,6 +15,7 @@
#define CONFIG_BOARD_SPECIFIC_VERSION
#define CONFIG_BOARD_FORCE_RESET_PIN
#define CONFIG_BUTTON_TRIGGERED_RECOVERY
+#define CONFIG_DETACHABLE_BASE
#define CONFIG_DPTF
#define CONFIG_DPTF_DEVICE_ORIENTATION
#define CONFIG_EMULATED_SYSRQ
diff --git a/common/base_state.c b/common/base_state.c
new file mode 100644
index 0000000000..b35f6a6f4e
--- /dev/null
+++ b/common/base_state.c
@@ -0,0 +1,27 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "base_state.h"
+#include "console.h"
+
+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.");
diff --git a/common/build.mk b/common/build.mk
index e6b6a2da6c..c143082d2e 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -21,6 +21,7 @@ common-$(HAS_TASK_ALS)+=als.o
common-$(CONFIG_AP_HANG_DETECT)+=ap_hang_detect.o
common-$(CONFIG_BACKLIGHT_LID)+=backlight_lid.o
common-$(CONFIG_BASE32)+=base32.o
+common-$(CONFIG_DETACHABLE_BASE)+=base_state.o
common-$(CONFIG_BATTERY)+=battery.o
common-$(CONFIG_BLUETOOTH_LE)+=bluetooth_le.o
common-$(CONFIG_BLUETOOTH_LE_STACK)+=btle_hci_controller.o btle_ll.o
diff --git a/include/base_state.h b/include/base_state.h
new file mode 100644
index 0000000000..fd19721bae
--- /dev/null
+++ b/include/base_state.h
@@ -0,0 +1,11 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * Call board specific base_force_state function.
+ * Force the current state of the base, with 0 meaning detached,
+ * 1 meaning attached and 2 meaning reset to the original state.
+ */
+void base_force_state(int state);
diff --git a/include/config.h b/include/config.h
index f8bbae47ae..22780cf170 100644
--- a/include/config.h
+++ b/include/config.h
@@ -450,6 +450,13 @@
#undef CONFIG_BUTTON_TRIGGERED_RECOVERY
/*
+ * Compile detachable base support
+ *
+ * Enabled on all boards that have a detachable base.
+ */
+#undef CONFIG_DETACHABLE_BASE
+
+/*
* Indicates there is a dedicated recovery button. Note, that if there are
* volume buttons, a dedicated recovery button is not needed. This is intended
* because if a board has volume buttons, they can do everything a dedicated