summaryrefslogtreecommitdiff
path: root/board/malefor
diff options
context:
space:
mode:
authorxiong.huang <xiong.huang@bitland.corp-partner.google.com>2020-04-20 20:46:18 +0800
committerCommit Bot <commit-bot@chromium.org>2020-05-06 08:31:42 +0000
commit78f281827f03f83ec70a3b7b335d8b71f94b6525 (patch)
tree64514568ac68617955003bb180f715c7819ffd10 /board/malefor
parent32b54e8ad9d09f994c301d6d6ec822692bb1919a (diff)
downloadchrome-ec-78f281827f03f83ec70a3b7b335d8b71f94b6525.tar.gz
malefor: enable lid angle
Enable lid angle function to make peripherals get correct state on convertible SKUs. BUG=b:152434719 BRANCH=none TEST=boot malefor, test keyboard function when hinge is at 135, 180, 270, 360 degree when set bit #4 of CBI fw_config. No sensor data when clear bit #4 of CBI fw_config. Signed-off-by: xiong.huang <xiong.huang@bitland.corp-partner.google.com> Change-Id: I83797a4d4a16b2c2903ac7c6d9cc5597a9855ac0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2156685 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'board/malefor')
-rw-r--r--board/malefor/board.c34
-rw-r--r--board/malefor/board.h7
2 files changed, 33 insertions, 8 deletions
diff --git a/board/malefor/board.c b/board/malefor/board.c
index 4953182917..4211bdfabc 100644
--- a/board/malefor/board.c
+++ b/board/malefor/board.c
@@ -15,6 +15,7 @@
#include "fan_chip.h"
#include "gpio.h"
#include "hooks.h"
+#include "keyboard_scan.h"
#include "lid_switch.h"
#include "power.h"
#include "power_button.h"
@@ -29,10 +30,21 @@
#include "gpio_list.h" /* Must come after other header files. */
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
+
static void board_init(void)
{
- /* Enable gpio interrupt for base accelgyro sensor */
- gpio_enable_interrupt(GPIO_EC_IMU_INT_L);
+ if (ec_config_has_tablet_mode()) {
+ /* Enable gpio interrupt for base accelgyro sensor */
+ gpio_enable_interrupt(GPIO_EC_IMU_INT_L);
+ } else {
+ motion_sensor_count = 0;
+ /* Device is clamshell only */
+ tablet_set_mode(0);
+ /* Gyro is not present, don't allow line to float */
+ gpio_set_flags(GPIO_EC_IMU_INT_L, GPIO_INPUT | GPIO_PULL_DOWN);
+ }
/* Enable gpio interrupt for camera vsync */
gpio_enable_interrupt(GPIO_EC_CAM_VSYN_SLP_S0IX);
@@ -47,6 +59,24 @@ static void board_init(void)
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+int board_is_lid_angle_tablet_mode(void)
+{
+ return ec_config_has_tablet_mode();
+}
+
+/* Enable or disable input devices, based on tablet mode or chipset state */
+#ifndef TEST_BUILD
+void lid_angle_peripheral_enable(int enable)
+{
+ if (ec_config_has_tablet_mode()) {
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF) ||
+ tablet_get_mode())
+ enable = 0;
+ keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE);
+ }
+}
+#endif
+
/******************************************************************************/
/* Sensors */
/* Lid and base Sensor mutex */
diff --git a/board/malefor/board.h b/board/malefor/board.h
index 4b30fdc1d5..1ec6632a3d 100644
--- a/board/malefor/board.h
+++ b/board/malefor/board.h
@@ -26,6 +26,7 @@
/* Keyboard features */
/* Sensors */
+#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT
#define CONFIG_ACCEL_LIS2DE /* Lid accel */
#define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */
@@ -33,16 +34,10 @@
#define CONFIG_ACCEL_FORCE_MODE_MASK \
BIT(LID_ACCEL)
-/*
- * TODO: b/152434719 - Malefor will support 360-degree rotation of the
- * lid on some SKUs, these macros will be enabled once covers are ready.
- */
-#if 0
#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
-#endif
#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)