From af229f1ccb54b9c10954673771d9fd80e4538c82 Mon Sep 17 00:00:00 2001 From: johnwc_yeh Date: Thu, 6 May 2021 16:09:16 +0800 Subject: cret: Disable Tablet mode detection for Clamshell sku It should disable tablet mode detection for Clamshell sku, plan to use fw_config to disable tablet mode. BUG=b:184504093 BRANCH=dedede TEST=make BOARD=cret Signed-off-by: johnwc_yeh Change-Id: I1bfd6e12da3df4dd435c5518c65fd3f85cb221d2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2875910 Reviewed-by: Elthan Huang Reviewed-by: Aseda Aboagye Commit-Queue: Aseda Aboagye --- board/cret/board.c | 21 ++++++++++++++++++--- board/cret/board.h | 2 ++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/board/cret/board.c b/board/cret/board.c index bb7fc16f93..82a5b7ee6e 100644 --- a/board/cret/board.c +++ b/board/cret/board.c @@ -47,6 +47,7 @@ #define INT_RECHECK_US 5000 +static void fw_config_tablet_mode(void); /* C0 interrupt line shared by BC 1.2 and charger */ static void check_c0_line(void); DECLARE_DEFERRED(check_c0_line); @@ -138,8 +139,7 @@ void board_init(void) /* Enable interrupt for passing through HPD */ gpio_enable_interrupt(GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL); - /* Enable gpio interrupt for base accelgyro sensor */ - gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); + fw_config_tablet_mode(); /* Turn on 5V if the system is on, otherwise turn it off. */ on = chipset_in_state(CHIPSET_STATE_ON | CHIPSET_STATE_ANY_SUSPEND | @@ -413,7 +413,7 @@ struct motion_sensor_t motion_sensors[] = { }, }; -const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); +unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); __override void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki, int *ki_div, @@ -567,3 +567,18 @@ __override const struct ec_response_keybd_config { return &cret_keybd; } + +static void fw_config_tablet_mode(void) +{ + if (get_cbi_fw_config_tablet_mode() == TABLET_MODE_PRESENT) { + motion_sensor_count = ARRAY_SIZE(motion_sensors); + /* Enable Base Accel interrupt */ + gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); + } else { + motion_sensor_count = 0; + gmr_tablet_switch_disable(); + /* Base accel is not stuffed, don't allow line to float */ + gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L, + GPIO_INPUT | GPIO_PULL_DOWN); + } +} diff --git a/board/cret/board.h b/board/cret/board.h index b5892582ab..eb7cd3faf1 100644 --- a/board/cret/board.h +++ b/board/cret/board.h @@ -119,6 +119,8 @@ #define CONFIG_ACCELGYRO_BMI160_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) +#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT + #define CONFIG_LID_ANGLE #define CONFIG_LID_ANGLE_UPDATE #define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL -- cgit v1.2.1