diff options
-rw-r--r-- | board/voxel/board.h | 3 | ||||
-rw-r--r-- | board/voxel/sensors.c | 62 |
2 files changed, 63 insertions, 2 deletions
diff --git a/board/voxel/board.h b/board/voxel/board.h index 1ef0548210..a672cf8bc1 100644 --- a/board/voxel/board.h +++ b/board/voxel/board.h @@ -47,10 +47,13 @@ /* BMI160 Base accel/gyro */ #define CONFIG_ACCELGYRO_BMI160 #define CONFIG_ACCELGYRO_ICM426XX /* Base accel second source*/ +#define CONFIG_ACCELGYRO_ICM42607 /* Base accel second source*/ #define CONFIG_ACCELGYRO_BMI160_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) #define CONFIG_ACCELGYRO_ICM426XX_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) +#define CONFIG_ACCELGYRO_ICM42607_INT_EVENT \ + TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) /* Lid operates in forced mode, base in FIFO */ #define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) diff --git a/board/voxel/sensors.c b/board/voxel/sensors.c index 00092dfe4e..ac444ad840 100644 --- a/board/voxel/sensors.c +++ b/board/voxel/sensors.c @@ -14,6 +14,7 @@ #include "driver/accelgyro_bmi160.h" #include "driver/accelgyro_icm_common.h" #include "driver/accelgyro_icm426xx.h" +#include "driver/accelgyro_icm42607.h" #include "driver/als_tcs3400.h" #include "driver/sync.h" #include "keyboard_scan.h" @@ -130,6 +131,52 @@ struct motion_sensor_t icm426xx_base_gyro = { .max_frequency = ICM426XX_GYRO_MAX_FREQ, }; +struct motion_sensor_t icm42607_base_accel = { + .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_icm426xx_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_icm_ref, + .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, + .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 icm42607_base_gyro = { + .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_icm426xx_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = ICM42607_ADDR0_FLAGS, + .default_range = 1000, /* dps */ + .rot_standard_ref = &base_icm_ref, + .min_frequency = ICM42607_GYRO_MIN_FREQ, + .max_frequency = ICM42607_GYRO_MAX_FREQ, +}; + struct motion_sensor_t motion_sensors[] = { [LID_ACCEL] = { .name = "Lid Accel", @@ -205,13 +252,21 @@ struct motion_sensor_t motion_sensors[] = { }; unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); +static enum ec_ssfc_base_sensor base_gyro_config = SSFC_SENSOR_BASE_DEFAULT; + static void board_sensors_init(void) { + base_gyro_config = get_cbi_ssfc_base_sensor(); + if (ec_cfg_has_tabletmode()) { - if (get_cbi_ssfc_base_sensor() == SSFC_SENSOR_BASE_ICM426XX) { + if (base_gyro_config == SSFC_SENSOR_BASE_ICM426XX) { motion_sensors[BASE_ACCEL] = icm426xx_base_accel; motion_sensors[BASE_GYRO] = icm426xx_base_gyro; ccprints("BASE GYRO is ICM426XX"); + } else if (base_gyro_config == SSFC_SENSOR_BASE_ICM42607) { + motion_sensors[BASE_ACCEL] = icm42607_base_accel; + motion_sensors[BASE_GYRO] = icm42607_base_gyro; + ccprints("BASE GYRO is ICM42607"); } else ccprints("BASE GYRO is BMI160"); @@ -236,10 +291,13 @@ DECLARE_HOOK(HOOK_INIT, board_sensors_init, HOOK_PRIO_DEFAULT); void motion_interrupt(enum gpio_signal signal) { - switch (get_cbi_ssfc_base_sensor()) { + switch (base_gyro_config) { case SSFC_SENSOR_BASE_ICM426XX: icm426xx_interrupt(signal); break; + case SSFC_SENSOR_BASE_ICM42607: + icm42607_interrupt(signal); + break; case SSFC_SENSOR_BASE_BMI160: default: bmi160_interrupt(signal); |