diff options
author | Devin Lu <Devin.Lu@quantatw.com> | 2021-07-19 11:03:05 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-07-21 02:19:33 +0000 |
commit | edc228bf8103f9b5f557c1891131d87bf55e62a5 (patch) | |
tree | 769921ba04ec648ae3369487dd396ea0c6cef657 | |
parent | 5af62af356e2c9799899ffb9ddd7b9dfee18d662 (diff) | |
download | chrome-ec-edc228bf8103f9b5f557c1891131d87bf55e62a5.tar.gz |
redrix: Configure Motion Sensors
Regarding the lid accelerometer, change to Bosch BMA253 and remove
the interrupt pin.
And the base accelerometer changed to LSM6DSLU.
BUG=b:193744971
BRANCH=none
TEST=make buildall -j
Signed-off-by: Devin Lu <Devin.Lu@quantatw.com>
Change-Id: I2db5f981e86217ce1cf8e207c40040493071f5d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3037286
Reviewed-by: Boris Mittelberg <bmbm@google.com>
-rw-r--r-- | board/redrix/board.c | 3 | ||||
-rw-r--r-- | board/redrix/board.h | 17 | ||||
-rw-r--r-- | board/redrix/gpio.inc | 3 | ||||
-rw-r--r-- | board/redrix/sensors.c | 54 |
4 files changed, 33 insertions, 44 deletions
diff --git a/board/redrix/board.c b/board/redrix/board.c index 9dfa67af7f..56e831addc 100644 --- a/board/redrix/board.c +++ b/board/redrix/board.c @@ -13,8 +13,7 @@ #include "gpio.h" #include "gpio_signal.h" #include "hooks.h" -#include "driver/accel_lis2dw12.h" -#include "driver/accelgyro_lsm6dso.h" +#include "driver/accelgyro_lsm6dsm.h" #include "driver/als_tcs3400.h" #include "fw_config.h" #include "hooks.h" diff --git a/board/redrix/board.h b/board/redrix/board.h index 04bb90ff5f..73b0e29a85 100644 --- a/board/redrix/board.h +++ b/board/redrix/board.h @@ -25,9 +25,13 @@ #define CONFIG_HIBERNATE_PSL_VCC1_RST_WAKEUP /* Sensors */ -#define CONFIG_ACCELGYRO_LSM6DSO /* Base accel */ -#define CONFIG_ACCEL_LSM6DSO_INT_EVENT \ +#define CONFIG_ACCEL_BMA255 /* Lid accel */ +#define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */ +#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) +#define CONFIG_LID_ANGLE +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL /* TCS3400 ALS */ #define CONFIG_ALS @@ -47,15 +51,6 @@ #define CONFIG_ACCEL_FORCE_MODE_MASK \ (BIT(LID_ACCEL) | BIT(CLEAR_ALS)) -/* Lid accel */ -#define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL -#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL -#define CONFIG_ACCEL_LIS2DWL -#define CONFIG_ACCEL_LIS2DW_AS_BASE -#define CONFIG_ACCEL_LIS2DW12_INT_EVENT \ - TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL) - #define CONFIG_ACCEL_INTERRUPTS /* Sensor console commands */ diff --git a/board/redrix/gpio.inc b/board/redrix/gpio.inc index d01c7994cf..f4b2c9e95b 100644 --- a/board/redrix/gpio.inc +++ b/board/redrix/gpio.inc @@ -9,9 +9,8 @@ /* INTERRUPT GPIOs: */ GPIO_INT(ACOK_OD, PIN(0, 0), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, extpower_interrupt) -GPIO_INT(EC_ACCEL_INT_R_L, PIN(8, 1), GPIO_SEL_1P8V | GPIO_INT_FALLING, lis2dw12_interrupt) GPIO_INT(EC_ALS_RGB_INT_R_L, PIN(D, 4), GPIO_INT_FALLING, tcs3400_interrupt) -GPIO_INT(EC_IMU_INT_R_L, PIN(5, 6), GPIO_SEL_1P8V | GPIO_INT_FALLING, lsm6dso_interrupt) +GPIO_INT(EC_IMU_INT_R_L, PIN(5, 6), GPIO_SEL_1P8V | GPIO_INT_FALLING, lsm6dsm_interrupt) GPIO_INT(EC_PROCHOT_IN_L, PIN(F, 0), GPIO_INT_BOTH, throttle_ap_prochot_input_interrupt) GPIO_INT(EC_VOLDN_BTN_ODL, PIN(9, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) GPIO_INT(EC_VOLUP_BTN_ODL, PIN(9, 7), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) diff --git a/board/redrix/sensors.c b/board/redrix/sensors.c index e80d5f912a..01ed65f13f 100644 --- a/board/redrix/sensors.c +++ b/board/redrix/sensors.c @@ -6,8 +6,8 @@ #include "common.h" #include "accelgyro.h" #include "adc_chip.h" -#include "driver/accel_lis2dw12.h" -#include "driver/accelgyro_lsm6dso.h" +#include "driver/accel_bma2x2.h" +#include "driver/accelgyro_lsm6dsm.h" #include "driver/als_tcs3400_public.h" #include "hooks.h" #include "motion_sense.h" @@ -50,8 +50,8 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); K_MUTEX_DEFINE(g_lid_accel_mutex); K_MUTEX_DEFINE(g_base_accel_mutex); -static struct stprivate_data g_lis2dw12_data; -static struct lsm6dso_data lsm6dso_data; +static struct accelgyro_saved_data_t g_bma253_data; +static struct lsm6dsm_data lsm6dsm_data; /* TODO(b/184779333): calibrate the orientation matrix on later board stage */ static const mat33_fp_t lid_standard_ref = { @@ -125,24 +125,22 @@ struct motion_sensor_t motion_sensors[] = { [LID_ACCEL] = { .name = "Lid Accel", .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LIS2DW12, + .chip = MOTIONSENSE_CHIP_BMA255, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_LID, - .drv = &lis2dw12_drv, + .drv = &bma2x2_accel_drv, .mutex = &g_lid_accel_mutex, - .drv_data = &g_lis2dw12_data, - .int_signal = GPIO_EC_ACCEL_INT_R_L, + .drv_data = &g_bma253_data, .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = LIS2DW12_ADDR0, - .flags = MOTIONSENSE_FLAG_INT_SIGNAL, + .i2c_spi_addr_flags = BMA2x2_I2C_ADDR1_FLAGS, .rot_standard_ref = &lid_standard_ref, /* identity matrix */ .default_range = 2, /* g */ - .min_frequency = LIS2DW12_ODR_MIN_VAL, - .max_frequency = LIS2DW12_ODR_MAX_VAL, + .min_frequency = BMA255_ACCEL_MIN_FREQ, + .max_frequency = BMA255_ACCEL_MAX_FREQ, .config = { /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S0] = { - .odr = 12500 | ROUND_UP_FLAG, + .odr = 10000 | ROUND_UP_FLAG, }, /* Sensor on for lid angle detection */ [SENSOR_CONFIG_EC_S3] = { @@ -154,21 +152,21 @@ struct motion_sensor_t motion_sensors[] = { [BASE_ACCEL] = { .name = "Base Accel", .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSO, + .chip = MOTIONSENSE_CHIP_LSM6DSM, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dso_drv, + .drv = &lsm6dsm_drv, .mutex = &g_base_accel_mutex, - .drv_data = LSM6DSO_ST_DATA(lsm6dso_data, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, MOTIONSENSE_TYPE_ACCEL), .int_signal = GPIO_EC_IMU_INT_R_L, .flags = MOTIONSENSE_FLAG_INT_SIGNAL, .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS, + .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS, .rot_standard_ref = &base_standard_ref, .default_range = 4, /* g */ - .min_frequency = LSM6DSO_ODR_MIN_VAL, - .max_frequency = LSM6DSO_ODR_MAX_VAL, + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, .config = { [SENSOR_CONFIG_EC_S0] = { .odr = 13000 | ROUND_UP_FLAG, @@ -184,21 +182,21 @@ struct motion_sensor_t motion_sensors[] = { [BASE_GYRO] = { .name = "Base Gyro", .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSO, + .chip = MOTIONSENSE_CHIP_LSM6DSM, .type = MOTIONSENSE_TYPE_GYRO, .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dso_drv, + .drv = &lsm6dsm_drv, .mutex = &g_base_accel_mutex, - .drv_data = LSM6DSO_ST_DATA(lsm6dso_data, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, MOTIONSENSE_TYPE_GYRO), .int_signal = GPIO_EC_IMU_INT_R_L, .flags = MOTIONSENSE_FLAG_INT_SIGNAL, .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS, + .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS, .default_range = 1000 | ROUND_UP_FLAG, /* dps */ .rot_standard_ref = &base_standard_ref, - .min_frequency = LSM6DSO_ODR_MIN_VAL, - .max_frequency = LSM6DSO_ODR_MAX_VAL, + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, .config = { [SENSOR_CONFIG_EC_S0] = { .odr = 13000 | ROUND_UP_FLAG, @@ -257,16 +255,14 @@ const struct motion_sensor_t *motion_als_sensors[] = { }; BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT); -static void baseboard_sensors_init(void) +static void board_sensors_init(void) { - /* Enable gpio interrupt for lid accel sensor */ - gpio_enable_interrupt(GPIO_EC_ACCEL_INT_R_L); /* Enable interrupt for the TCS3400 color light sensor */ gpio_enable_interrupt(GPIO_EC_ALS_RGB_INT_R_L); /* Enable gpio interrupt for base accelgyro sensor */ gpio_enable_interrupt(GPIO_EC_IMU_INT_R_L); } -DECLARE_HOOK(HOOK_INIT, baseboard_sensors_init, HOOK_PRIO_INIT_I2C + 1); +DECLARE_HOOK(HOOK_INIT, board_sensors_init, HOOK_PRIO_INIT_I2C + 1); /* Temperature sensor configuration */ const struct temp_sensor_t temp_sensors[] = { |