From 1dacc6d70813b22212736a7ed813315c82262dc9 Mon Sep 17 00:00:00 2001 From: Tino Liu Date: Mon, 13 Aug 2018 17:33:08 +0800 Subject: Bobba: Disable Base Accel/Gyro sensor for clamshells BUG=b:112442777 BRANCH=none TEST=Verify screen will not rotate when sku id is clamshell Change-Id: I2cca78c05d52b8914018b9ea5f56918be93427f8 Signed-off-by: Tino Liu Reviewed-on: https://chromium-review.googlesource.com/1172306 Commit-Ready: ChromeOS CL Exonerator Bot Reviewed-by: Furquan Shaikh Reviewed-by: Jett Rink --- board/bobba/board.c | 26 +++++++++++++++++++++++++- board/bobba/board.h | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/board/bobba/board.c b/board/bobba/board.c index b3db6cebc6..5754848cc8 100644 --- a/board/bobba/board.c +++ b/board/bobba/board.c @@ -193,7 +193,31 @@ 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); + +static void setup_motion_sensors(uint8_t sku_id) +{ + /* SKU ID of Bobba360 and Sparky360: 9, 25, 26 */ + if (sku_id != 9 && sku_id != 25 && sku_id != 26) { + /* Clamshell Bobba has no base accel and base gyro */ + motion_sensor_count = ARRAY_SIZE(motion_sensors) - 2; + } +} + +/* Read CBI from i2c eeprom and initialize variables for board variants */ +static void cbi_init(void) +{ + uint8_t sku_id; + uint32_t val; + + if (cbi_get_sku_id(&val) != EC_SUCCESS || val > UINT8_MAX) + return; + sku_id = val; + CPRINTSUSB("SKU: %d", sku_id); + + setup_motion_sensors(sku_id); +} +DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_INIT_I2C + 1); /* Initialize board. */ static void board_init(void) diff --git a/board/bobba/board.h b/board/bobba/board.h index 2d3dfb0f85..40cc2e48ee 100644 --- a/board/bobba/board.h +++ b/board/bobba/board.h @@ -25,6 +25,7 @@ /* Sensors */ #define CONFIG_ACCEL_KX022 /* Lid accel */ #define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */ +#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT /* Sensors without hardware FIFO are in forced mode */ #define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) -- cgit v1.2.1