diff options
author | Hank Xie <hank.xie@quanta.corp-partner.google.com> | 2022-03-22 04:53:32 -0400 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-03-29 01:51:37 +0000 |
commit | f08f86b89267b8a6c350484ee15fb8cb18816aa0 (patch) | |
tree | bda07c4330bf5b35e4433cc797a83c6f5d214310 /board/lantis/board.c | |
parent | 9196f57b1c33ccae691e53755093c97eaf30ae6d (diff) | |
download | chrome-ec-f08f86b89267b8a6c350484ee15fb8cb18816aa0.tar.gz |
landia: Add supporting of 2nd source LID accel sensor BMA422
Add SSFC field to support the 2nd source Lid accel sensor.
BUG=b:226041272
BRANCH=dedede
TEST=On landia. Set SSFC and make sure the LID sensor works normally.
Signed-off-by: Hank Xie <hank.xie@quanta.corp-partner.google.com>
Cq-Depend: chromium:3554182
Change-Id: Ibb24c7a797038660dff6c66d954c06b36c006d3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3535547
Reviewed-by: Devin Lu <Devin.Lu@quantatw.com>
Reviewed-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'board/lantis/board.c')
-rw-r--r-- | board/lantis/board.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/board/lantis/board.c b/board/lantis/board.c index 43ca935c87..5bc76e9ee2 100644 --- a/board/lantis/board.c +++ b/board/lantis/board.c @@ -8,11 +8,13 @@ #include "adc_chip.h" #include "button.h" #include "cbi_fw_config.h" +#include "cbi_ssfc.h" #include "charge_manager.h" #include "charge_state_v2.h" #include "charger.h" #include "cros_board_info.h" #include "driver/accel_bma2x2.h" +#include "driver/accel_bma422.h" #include "driver/accelgyro_lsm6dsm.h" #include "driver/bc12/pi3usb9201.h" #include "driver/charger/sm5803.h" @@ -292,6 +294,7 @@ static struct mutex g_base_mutex; /* Sensor Data */ static struct accelgyro_saved_data_t g_bma253_data; +static struct accelgyro_saved_data_t g_bma422_data; static struct lsm6dsm_data lsm6dsm_data = LSM6DSM_DATA; /* Matrix to rotate accelrator into standard reference frame */ @@ -381,6 +384,41 @@ struct motion_sensor_t motion_sensors[] = { unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); +struct motion_sensor_t bma422_lid_accel = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_BMA422, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &bma4_accel_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_bma422_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = BMA4_I2C_ADDR_PRIMARY, + .rot_standard_ref = &lid_standard_ref, + .default_range = 2, + .min_frequency = BMA4_ACCEL_MIN_FREQ, + .max_frequency = BMA4_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 12500 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* Sensor on in S3 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 12500 | ROUND_UP_FLAG, + .ec_rate = 0, + }, + }, +}; + +static void board_update_motion_sensor_config(void) +{ + if (get_cbi_ssfc_lid_sensor() == SSFC_SENSOR_BMA422) + motion_sensors[LID_ACCEL] = bma422_lid_accel; +} + static const struct ec_response_keybd_config lantis_keybd_backlight = { .num_top_row_keys = 10, .action_keys = { @@ -527,6 +565,8 @@ void board_init(void) motion_sensor_count = ARRAY_SIZE(motion_sensors); /* Enable Base Accel interrupt */ gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); + + board_update_motion_sensor_config(); } else { motion_sensor_count = 0; gmr_tablet_switch_disable(); |