summaryrefslogtreecommitdiff
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
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>
-rw-r--r--baseboard/volteer/baseboard.c17
-rw-r--r--baseboard/volteer/baseboard.h17
-rw-r--r--board/malefor/board.c34
-rw-r--r--board/malefor/board.h7
4 files changed, 66 insertions, 9 deletions
diff --git a/baseboard/volteer/baseboard.c b/baseboard/volteer/baseboard.c
index ee8cf8fc72..0964f53122 100644
--- a/baseboard/volteer/baseboard.c
+++ b/baseboard/volteer/baseboard.c
@@ -581,12 +581,27 @@ static void config_db_usb3(void)
}
static uint8_t board_id;
+static uint32_t fw_config;
uint8_t get_board_id(void)
{
return board_id;
}
+uint32_t get_fw_config(void)
+{
+ return fw_config;
+}
+
+/*
+ * ec_config_has_tablet_mode() will return 1 is present or 0
+ */
+enum ec_cfg_tablet_mode_type ec_config_has_tablet_mode(void)
+{
+ return ((get_fw_config() & EC_CFG_TABLET_MODE_MASK)
+ >> EC_CFG_TABLET_MODE_L);
+}
+
__overridable void config_volteer_gpios(void)
{
}
@@ -614,11 +629,11 @@ static void cbi_init(void)
config_volteer_gpios();
/* FW config */
-
if (cbi_get_fw_config(&cbi_val) != EC_SUCCESS) {
CPRINTS("CBI: Read FW config failed, assuming USB4");
usb_db_val = USB_DB_USB4;
} else {
+ fw_config = cbi_val;
usb_db_val = CBI_FW_CONFIG_USB_DB_TYPE(cbi_val);
}
diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h
index 7ce7acd673..f68fc431f6 100644
--- a/baseboard/volteer/baseboard.h
+++ b/baseboard/volteer/baseboard.h
@@ -279,6 +279,21 @@ enum usb_db_id {
#define CBI_FW_CONFIG_USB_DB_TYPE(bits) \
(((bits) & CBI_FW_CONFIG_USB_DB_MASK) >> CBI_FW_CONFIG_USB_DB_SHIFT)
+/*
+ * Tablet Mode (1 bit)
+ *
+ * ec_config_has_tablet_mode() will return 1 is present or 0
+ */
+enum ec_cfg_tablet_mode_type {
+ TABLET_MODE_NO = 0,
+ TABLET_MODE_YES = 1,
+};
+#define EC_CFG_TABLET_MODE_L 11
+#define EC_CFG_TABLET_MODE_H 11
+#define EC_CFG_TABLET_MODE_MASK \
+ GENMASK(EC_CFG_TABLET_MODE_H,\
+ EC_CFG_TABLET_MODE_L)
+
extern enum gpio_signal ps8xxx_rst_odl;
void board_reset_pd_mcu(void);
@@ -297,6 +312,8 @@ unsigned char get_board_id(void);
*/
__override_proto void config_volteer_gpios(void);
+enum ec_cfg_tablet_mode_type ec_config_has_tablet_mode(void);
+
#endif /* !__ASSEMBLER__ */
#endif /* __CROS_EC_BASEBOARD_H */
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)