diff options
author | ben.chen2@quanta.corp-partner.google.com <ben.chen2@quanta.corp-partner.google.com> | 2019-08-30 17:55:42 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-09-18 05:32:25 +0000 |
commit | 483bb8f07b77929e029ba0518fa56bba39bfe710 (patch) | |
tree | ad593ca27c5584b83b8db63c8b841502260e80be /board | |
parent | c6526675656717e1bbbc6fa61b4e3d033909adf1 (diff) | |
download | chrome-ec-483bb8f07b77929e029ba0518fa56bba39bfe710.tar.gz |
Kindred: Use SKU ID to initialize motion_sensor_count
This CL adds the config option CONFIG_DYNAMIC_MOTION_SENSOR_COUNT and
the variable motion_sensor_count based on
CLAMSHELL or CONVERTIBLE designation by the SKU ID.
BUG=b:140217139
BRANCH=Master
TEST=use ectool set cbi sku id, ensure the motion sensors enable or not.
Change-Id: Idadc455417f9b4ae58fadcb6ddbc7c1f3a7feb8b
Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1780966
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/kindred/board.c | 36 | ||||
-rw-r--r-- | board/kindred/board.h | 4 |
2 files changed, 37 insertions, 3 deletions
diff --git a/board/kindred/board.c b/board/kindred/board.c index 0febc4ef4c..f458e38f7e 100644 --- a/board/kindred/board.c +++ b/board/kindred/board.c @@ -394,16 +394,46 @@ static void board_gpio_set_pp5000(void) } +static bool board_is_convertible(void) +{ + uint8_t sku_id = get_board_sku(); + /* SKU ID of Kled : 1, 2, 3, 4 */ + return (sku_id >= 1) && (sku_id <= 4); +} + +static void board_update_sensor_config_from_sku(void) +{ + /* + * There are two possible sensor configurations. Clamshell device will + * not have any of the motion sensors populated, while convertible + * devices have the BMI160 Accel/Gryo lid acceleration sensor. + * If a new SKU id is used that is not in the threshold, then the + * number of motion sensors will remain as ARRAY_SIZE(motion_sensors). + */ + if (board_is_convertible()) { + motion_sensor_count = ARRAY_SIZE(motion_sensors); + /* Enable gpio interrupt for base accelgyro sensor */ + gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); + + CPRINTS("Motion Sensor Count = %d", motion_sensor_count); + } else { + motion_sensor_count = 0; + /* Base accel is not stuffed, don't allow line to float */ + gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L, + GPIO_INPUT | GPIO_PULL_DOWN); + } +} + static void board_init(void) { /* Initialize Fans */ setup_fans(); - /* Enable gpio interrupt for base accelgyro sensor */ - gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); /* Enable HDMI HPD interrupt. */ gpio_enable_interrupt(GPIO_HDMI_CONN_HPD); /* Select correct gpio signal for PP5000_A control */ board_gpio_set_pp5000(); + /* Use sku_id to set motion sensor count */ + board_update_sensor_config_from_sku(); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); @@ -420,7 +450,7 @@ void board_overcurrent_event(int port, int is_overcurrented) bool board_has_kb_backlight(void) { uint8_t sku_id = get_board_sku(); - /* SKU ID of Kled: 1,2,3,4 */ + /* SKU ID of Kled with KB backlight: 1, 2, 3, 4 */ return (sku_id >= 1) && (sku_id <= 4); } diff --git a/board/kindred/board.h b/board/kindred/board.h index 8dc292b1df..b88695b31f 100644 --- a/board/kindred/board.h +++ b/board/kindred/board.h @@ -41,6 +41,7 @@ #define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL #define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL #define CONFIG_LID_ANGLE_UPDATE +#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT /* USB Type C and USB PD defines */ #define CONFIG_USB_PD_COMM_LOCKED @@ -166,6 +167,9 @@ enum battery_type { BATTERY_TYPE_COUNT, }; +/* Sensors without hardware FIFO are in forced mode */ +#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ |