diff options
author | Michael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com> | 2021-12-03 16:50:44 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-12-07 01:41:04 +0000 |
commit | 2d10ad31b6a667b3e38e901057e1ad186fe8a1cd (patch) | |
tree | 4bcaf5381341f25c9b0a93a7de3b49d76f202c85 /board/ampton/board.c | |
parent | a105f637e3593615fe2dfa35275d9caa911aed26 (diff) | |
download | chrome-ec-2d10ad31b6a667b3e38e901057e1ad186fe8a1cd.tar.gz |
AmptonE: Implement EC motion sensor
Implement gyro sensor ICM42607 and lid sensor KX022.
BUG=b:206526996
BRANCH=firmware-octopus-11297.B
TEST=manual
1. watch ectool motionsense
2. watch ectool lid_angle
Signed-off-by: Michael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com>
Change-Id: Ib33d59dc359e1c4b189a6515ab6e31c5bc84e690
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3314480
Reviewed-by: Henry Sun <henrysun@google.com>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'board/ampton/board.c')
-rw-r--r-- | board/ampton/board.c | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/board/ampton/board.c b/board/ampton/board.c index 1634f02991..9b62a8dd02 100644 --- a/board/ampton/board.c +++ b/board/ampton/board.c @@ -13,6 +13,8 @@ #include "driver/accel_bma2x2.h" #include "driver/accel_kionix.h" #include "driver/accelgyro_bmi_common.h" +#include "driver/accelgyro_icm_common.h" +#include "driver/accelgyro_icm42607.h" #include "driver/ppc/sn5s330.h" #include "driver/sync.h" #include "driver/tcpm/it83xx_pd.h" @@ -172,9 +174,21 @@ const mat33_fp_t gyro_standard_ref = { { 0, 0, FLOAT_TO_FP(1)} }; +const mat33_fp_t base_standard_ref_icm42607 = { + { 0, FLOAT_TO_FP(1), 0}, + { FLOAT_TO_FP(1), 0, 0}, + { 0, 0, FLOAT_TO_FP(-1)} +}; + +const mat33_fp_t lid_standard_ref_sku57 = { + { FLOAT_TO_FP(1), 0, 0}, + { 0, FLOAT_TO_FP(-1), 0}, + { 0, 0, FLOAT_TO_FP(-1)} +}; /* sensor private data */ static struct kionix_accel_data g_kx022_data; static struct bmi_drv_data_t g_bmi160_data; +static struct icm_drv_data_t g_icm42607_data; /* BMA253 private data */ static struct accelgyro_saved_data_t g_bma253_data; @@ -208,6 +222,49 @@ static const struct motion_sensor_t motion_sensor_bma253 = { }, }; +struct motion_sensor_t motion_sensor_accel_icm42607 = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_ICM42607, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &icm42607_drv, + .mutex = &g_base_mutex, + .drv_data = &g_icm42607_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = ICM42607_ADDR0_FLAGS, + .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs. */ + .rot_standard_ref = &base_standard_ref_icm42607, + .min_frequency = ICM42607_ACCEL_MIN_FREQ, + .max_frequency = ICM42607_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + }, +}; + +struct motion_sensor_t motion_sensor_gyro_icm42607 = { + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_ICM42607, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &icm42607_drv, + .mutex = &g_base_mutex, + .drv_data = &g_icm42607_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = ICM42607_ADDR0_FLAGS, + .default_range = 1000, /* dps */ + .rot_standard_ref = &base_standard_ref_icm42607, + .min_frequency = ICM42607_GYRO_MIN_FREQ, + .max_frequency = ICM42607_GYRO_MAX_FREQ, +}; + /* Drivers */ struct motion_sensor_t motion_sensors[] = { [LID_ACCEL] = { @@ -299,7 +356,7 @@ static int board_is_convertible(void) { /* SKU IDs of Ampton & unprovisioned: 1, 2, 3, 4, 255 */ return sku_id == 1 || sku_id == 2 || sku_id == 3 || sku_id == 4 - || sku_id == 255; + || sku_id == 57 || sku_id == 255; } static int board_with_sensor_bma253(void) @@ -308,6 +365,12 @@ static int board_with_sensor_bma253(void) return sku_id == 3 || sku_id == 4; } +static int board_with_sensor_icm42607(void) +{ + /* SKU ID 3 and 4 of Ampton with BMA253 */ + return sku_id == 57; +} + static void board_update_sensor_config_from_sku(void) { if (board_is_convertible()) { @@ -315,6 +378,16 @@ static void board_update_sensor_config_from_sku(void) if (board_with_sensor_bma253()) motion_sensors[LID_ACCEL] = motion_sensor_bma253; + if (board_with_sensor_icm42607()) { + motion_sensors[BASE_ACCEL] = + motion_sensor_accel_icm42607; + motion_sensors[BASE_GYRO] = + motion_sensor_gyro_icm42607; + ccprints("Gyro sensor: ICM-42607"); + } + if (sku_id == 57) + motion_sensors[LID_ACCEL].rot_standard_ref = + &lid_standard_ref_sku57; /* Enable Base Accel interrupt */ gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); |