diff options
author | Ching-Kang Yen <chingkang@chromium.org> | 2020-03-11 17:34:37 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-04-24 07:25:49 +0000 |
commit | b3dec5ad4762dbea3fc96d3a1dfa6b418dc7f65a (patch) | |
tree | 4f8bd6d4d8c9d9aff8c9a4d581a8f13de3d2bc83 /board/volteer/sensors.c | |
parent | e0da937f6e9f5bf507b80e18d041be8bd7dc8d7a (diff) | |
download | chrome-ec-b3dec5ad4762dbea3fc96d3a1dfa6b418dc7f65a.tar.gz |
volteer: Add board config for BMI260
Add board config of volteer for supportting BMI260.
BRANCH=None
BUG=b:146144827
TEST=make -j4 BOARD=volteer \
&& flash_ec --image build/volteer/ec.bin --board volteer
Then, check sensor data is available on DUT by ectool motionsense.
TEST=make buildall -j
TEST=tast run ${IP} hardware.SensorRing
Change-Id: Iff5ea63d9c22ec63adc27f293e2f338a5aca5480
Signed-off-by: Ching-Kang Yen <chingkang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2097805
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
Tested-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'board/volteer/sensors.c')
-rw-r--r-- | board/volteer/sensors.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/board/volteer/sensors.c b/board/volteer/sensors.c index e13d7fd57e..f59c199e07 100644 --- a/board/volteer/sensors.c +++ b/board/volteer/sensors.c @@ -7,20 +7,27 @@ #include "common.h" #include "accelgyro.h" #include "driver/accel_bma2x2.h" +#include "driver/accelgyro_bmi_common.h" +#include "driver/accelgyro_bmi260.h" #include "driver/als_tcs3400.h" #include "driver/sync.h" #include "keyboard_scan.h" #include "hooks.h" +#include "i2c.h" #include "task.h" #include "util.h" /******************************************************************************/ /* Sensors */ static struct mutex g_lid_accel_mutex; +static struct mutex g_base_mutex; /* BMA253 private data */ static struct accelgyro_saved_data_t g_bma253_data; +/* BMI260 private data */ +static struct bmi_drv_data_t g_bmi260_data; + /* TCS3400 private data */ static struct als_drv_data_t g_tcs3400_data = { .als_cal.scale = 1, @@ -86,6 +93,12 @@ static const mat33_fp_t lid_standard_ref = { { 0, 0, FLOAT_TO_FP(-1)} }; +const mat33_fp_t base_standard_ref = { + { 0, FLOAT_TO_FP(1), 0}, + { FLOAT_TO_FP(-1), 0, 0}, + { 0, 0, FLOAT_TO_FP(1)} +}; + struct motion_sensor_t motion_sensors[] = { [LID_ACCEL] = { .name = "Lid Accel", @@ -113,7 +126,51 @@ struct motion_sensor_t motion_sensors[] = { }, }, }, + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_BMI260, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi260_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi260_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = BMI260_ADDR0_FLAGS, + .rot_standard_ref = &base_standard_ref, + .min_frequency = BMI_ACCEL_MIN_FREQ, + .max_frequency = BMI_ACCEL_MAX_FREQ, + .default_range = 4, /* g */ + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* Sensor on in S3 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, + }, + [BASE_GYRO] = { + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_BMI260, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &bmi260_drv, + .mutex = &g_base_mutex, + .drv_data = &g_bmi260_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = BMI260_ADDR0_FLAGS, + .default_range = 1000, /* dps */ + .rot_standard_ref = &base_standard_ref, + .min_frequency = BMI_GYRO_MIN_FREQ, + .max_frequency = BMI_GYRO_MAX_FREQ, + }, [CLEAR_ALS] = { .name = "Clear Light", .active_mask = SENSOR_ACTIVE_S0_S3, @@ -180,5 +237,7 @@ static void baseboard_sensors_init(void) gpio_enable_interrupt(GPIO_EC_CAM_VSYN_SLP_S0IX); /* Enable interrupt for the TCS3400 color light sensor */ gpio_enable_interrupt(GPIO_EC_ALS_RGB_INT_L); + /* Enable interrupt for the BMI260 accel/gyro sensor */ + gpio_enable_interrupt(GPIO_EC_IMU_INT_L); } DECLARE_HOOK(HOOK_INIT, baseboard_sensors_init, HOOK_PRIO_DEFAULT); |