diff options
author | Yu-An Chen <yu-an.chen@quanta.corp-partner.google.com> | 2021-04-15 16:55:16 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-15 19:18:32 +0000 |
commit | 422b445e69ba0e4be24306c1095b17f704beb5f8 (patch) | |
tree | ed10c15a86cc6bf9d8a8921dcfc3468566cf83dc /board | |
parent | b6e94066b0543c06669bb54b54b3568e9359511b (diff) | |
download | chrome-ec-422b445e69ba0e4be24306c1095b17f704beb5f8.tar.gz |
Metaknight: Support motion sensor 2nd source
Support motion sensor 2nd source:
-Base : ICM-426xx
BUG=b:177868819
BRANCH=dedede
TEST=rework ICM-426xx to DUT, check ectool motionsense
lid_angle is correct.
Signed-off-by: yu-an.chen@quanta.corp-partner.google.com
Change-Id: I8aa344662654d2f02d8cdd5101fcfe568931085f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2825720
Tested-by: Yu-An Chen <yu-an.chen@quanta.corp-partner.google.com>
Auto-Submit: Yu-An Chen <yu-an.chen@quanta.corp-partner.google.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/metaknight/board.c | 65 | ||||
-rw-r--r-- | board/metaknight/board.h | 3 |
2 files changed, 67 insertions, 1 deletions
diff --git a/board/metaknight/board.c b/board/metaknight/board.c index e4fee336f0..03fff8d9c7 100644 --- a/board/metaknight/board.c +++ b/board/metaknight/board.c @@ -18,6 +18,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_icm426xx.h" #include "driver/accelgyro_lsm6dsm.h" #include "driver/temp_sensor/thermistor.h" #include "temp_sensor.h" @@ -434,10 +436,17 @@ static const mat33_fp_t base_lsm6dsm_ref = { { 0, 0, FLOAT_TO_FP(-1)} }; +static const mat33_fp_t base_icm_ref = { + { FLOAT_TO_FP(-1), 0, 0}, + { 0, FLOAT_TO_FP(1), 0}, + { 0, 0, FLOAT_TO_FP(-1)} +}; + static struct accelgyro_saved_data_t g_bma253_data; static struct bmi_drv_data_t g_bmi160_data; static struct kionix_accel_data g_kx022_data; static struct lsm6dsm_data lsm6dsm_data = LSM6DSM_DATA; +static struct icm_drv_data_t g_icm426xx_data; struct motion_sensor_t motion_sensors[] = { [LID_ACCEL] = { @@ -587,6 +596,53 @@ struct motion_sensor_t lsm6dsm_base_gyro = { .max_frequency = LSM6DSM_ODR_MAX_VAL, }; + +struct motion_sensor_t icm426xx_base_accel = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_ICM426XX, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &icm426xx_drv, + .mutex = &g_base_mutex, + .drv_data = &g_icm426xx_data, + .port = I2C_PORT_ACCEL, + .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS, + .default_range = 4, /* g, enough for laptop */ + .rot_standard_ref = &base_icm_ref, + .min_frequency = ICM426XX_ACCEL_MIN_FREQ, + .max_frequency = ICM426XX_ACCEL_MAX_FREQ, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 13000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, +}; + +struct motion_sensor_t icm426xx_base_gyro = { + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_ICM426XX, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &icm426xx_drv, + .mutex = &g_base_mutex, + .drv_data = &g_icm426xx_data, + .port = I2C_PORT_ACCEL, + .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS, + .default_range = 1000, /* dps */ + .rot_standard_ref = &base_standard_ref, + .min_frequency = ICM426XX_GYRO_MIN_FREQ, + .max_frequency = ICM426XX_GYRO_MAX_FREQ, +}; + static int base_gyro_config; void board_init(void) @@ -630,8 +686,12 @@ void board_init(void) if (base_gyro_config == SSFC_SENSOR_LSM6DSM) { motion_sensors[BASE_ACCEL] = lsm6dsm_base_accel; - motion_sensors[BASE_GYRO] = lsm6dsm_base_gyro; + motion_sensors[BASE_GYRO] = lsm6dsm_base_gyro; cprints(CC_SYSTEM, "SSFC: BASE GYRO is LSM6DSM"); + } else if (get_cbi_ssfc_base_sensor() == SSFC_SENSOR_ICM426XX) { + motion_sensors[BASE_ACCEL] = icm426xx_base_accel; + motion_sensors[BASE_GYRO] = icm426xx_base_gyro; + cprints(CC_SYSTEM, "SSFC: BASE GYRO is ICM426XX"); } else cprints(CC_SYSTEM, "SSFC: BASE GYRO is BMI160"); @@ -805,6 +865,9 @@ void motion_interrupt(enum gpio_signal signal) case SSFC_SENSOR_LSM6DSM: lsm6dsm_interrupt(signal); break; + case SSFC_SENSOR_ICM426XX: + icm426xx_interrupt(signal); + break; case SSFC_SENSOR_BMI160: default: bmi160_interrupt(signal); diff --git a/board/metaknight/board.h b/board/metaknight/board.h index 80f38a8ac0..dbe005b800 100644 --- a/board/metaknight/board.h +++ b/board/metaknight/board.h @@ -104,6 +104,7 @@ #define CONFIG_ACCEL_KX022 /* Lid accel second source */ #define CONFIG_ACCELGYRO_BMI160 /* Base accel */ #define CONFIG_ACCELGYRO_LSM6DSM /* Base accel second source */ +#define CONFIG_ACCELGYRO_ICM426XX /* Base accel second source */ /* Lid operates in forced mode, base in FIFO */ #define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) @@ -116,6 +117,8 @@ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) #define CONFIG_ACCEL_LSM6DSM_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) +#define CONFIG_ACCELGYRO_ICM426XX_INT_EVENT \ + TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) #define CONFIG_LID_ANGLE #define CONFIG_LID_ANGLE_UPDATE |