summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBhanu Prakash Maiya <bhanumaiya@google.com>2021-07-15 00:29:18 -0700
committerCommit Bot <commit-bot@chromium.org>2021-07-17 00:19:17 +0000
commit7baf77c0b7adaba1f93d38af569e2210483447de (patch)
tree5bfc8f167a7d6a1676880de8b17b89109d1166da
parentfa3752236056753cc1c0449bfff4267f85ec60e0 (diff)
downloadchrome-ec-7baf77c0b7adaba1f93d38af569e2210483447de.tar.gz
guybrush: Enable LID ANGLE config on board
This patch implements lid_angle_peripheral_enable function. BRANCH=none BUG=b:178400750 TEST=Accel implementation tested on Guybrush $ ectool motionsense lid_angle Signed-off-by: Bhanu Prakash Maiya <bhanumaiya@chromium.org> Signed-off-by: Latchiamaran Senram <latchiamaran.senram@bosch.corp-partner.google.com> Change-Id: I0ece0c23350fd870c5fa696ae77dc221ef60dc4e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3029667 Commit-Queue: Bhanu Prakash Maiya <bhanumaiya@google.com> Tested-by: Bhanu Prakash Maiya <bhanumaiya@google.com> Auto-Submit: Bhanu Prakash Maiya <bhanumaiya@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--baseboard/guybrush/baseboard.h8
-rw-r--r--board/guybrush/board.c20
2 files changed, 26 insertions, 2 deletions
diff --git a/baseboard/guybrush/baseboard.h b/baseboard/guybrush/baseboard.h
index e3c9d5b25a..58975499a2 100644
--- a/baseboard/guybrush/baseboard.h
+++ b/baseboard/guybrush/baseboard.h
@@ -109,22 +109,26 @@
#define GPIO_KBD_KSO2 GPIO_EC_KSO_02_INV
/* Sensors */
+#ifdef HAS_TASK_MOTIONSENSE
#define CONFIG_TABLET_MODE
#define CONFIG_GMR_TABLET_MODE
#define GMR_TABLET_MODE_GPIO_L GPIO_TABLET_MODE
#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT
+#define CONFIG_LID_ANGLE
+#define CONFIG_LID_ANGLE_UPDATE
+#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
+#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
-#ifdef HAS_TASK_MOTIONSENSE
/* Enable sensor fifo, must also define the _SIZE and _THRES */
#define CONFIG_ACCEL_FIFO
/* FIFO size is a power of 2. */
#define CONFIG_ACCEL_FIFO_SIZE 256
/* Depends on how fast the AP boots and typical ODRs. */
#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO_SIZE / 3)
-#endif
/* Sensors without hardware FIFO are in forced mode */
#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL)
+#endif
/* Battery Config */
#define CONFIG_BATTERY_PRESENT_GPIO GPIO_EC_BATT_PRES_ODL
diff --git a/board/guybrush/board.c b/board/guybrush/board.c
index b91512f3b5..f6a707047d 100644
--- a/board/guybrush/board.c
+++ b/board/guybrush/board.c
@@ -19,6 +19,7 @@
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
+#include "keyboard_scan.h"
#include "lid_switch.h"
#include "power.h"
#include "power_button.h"
@@ -354,3 +355,22 @@ int board_get_soc_temp(int idx, int *temp_k)
return tmp112_get_val(idx, temp_k);
}
+
+#ifndef TEST_BUILD
+void lid_angle_peripheral_enable(int enable)
+{
+ int chipset_in_s0 = chipset_in_state(CHIPSET_STATE_ON);
+
+ if (enable) {
+ keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_ANGLE);
+ } else {
+ /*
+ * Ensure that the chipset is off before disabling the keyboard.
+ * When the chipset is on, the EC keeps the keyboard enabled and
+ * the AP decides whether to ignore input devices or not.
+ */
+ if (!chipset_in_s0)
+ keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_ANGLE);
+ }
+}
+#endif