summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommy Chung <tommy.chung@quanta.corp-partner.google.com>2022-07-04 20:38:19 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-06 07:07:58 +0000
commit99c15b2115bd9e214bf60cd667fa9b2bcf42f1eb (patch)
treed9e7570920a4b8dd4e02aa38433cce854a7d650a
parente80b2d6c4ea18990c5dab11ece2dd77b37b31b12 (diff)
downloadchrome-ec-99c15b2115bd9e214bf60cd667fa9b2bcf42f1eb.tar.gz
dojo: Update base sensor by board version and SSFC value
BUG=b:237963220 BRANCH=cherry TEST=make sure that all base sensors work correctly with corresponding board version and ssfc value. Signed-off-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com> Change-Id: I2ba9d3bf3bc4b93ebefae466b8f1027d4bfb6aa7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3739114 Reviewed-by: Devin Lu <devin.lu@quantatw.com> Reviewed-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Chen-Tsung Hsieh <chentsung@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3746507 Commit-Queue: Chen-Tsung Hsieh <chentsung@chromium.org>
-rw-r--r--board/dojo/board.c153
-rw-r--r--board/dojo/board.h5
2 files changed, 112 insertions, 46 deletions
diff --git a/board/dojo/board.c b/board/dojo/board.c
index 690f9aa547..0b124d80ab 100644
--- a/board/dojo/board.c
+++ b/board/dojo/board.c
@@ -5,6 +5,7 @@
/* Dojo board configuration */
#include "cbi_fw_config.h"
+#include "cbi_ssfc.h"
#include "charge_manager.h"
#include "charge_state_v2.h"
#include "common.h"
@@ -13,6 +14,7 @@
#include "driver/accel_kionix.h"
#include "driver/accel_kx022.h"
#include "driver/accelgyro_icm426xx.h"
+#include "driver/accelgyro_icm42607.h"
#include "driver/accelgyro_icm_common.h"
#include "driver/accelgyro_bmi_common_public.h"
#include "driver/accelgyro_bmi260_public.h"
@@ -31,6 +33,7 @@
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
uint32_t board_version;
+enum ec_ssfc_base_sensor base_sensor;
/* Keyboard scan setting */
__override struct keyboard_scan_config keyscan_config = {
@@ -110,21 +113,26 @@ static struct mutex g_base_mutex;
static struct mutex g_lid_mutex;
static struct icm_drv_data_t g_icm426xx_data;
+static struct icm_drv_data_t g_icm42607_data;
static struct bmi_drv_data_t g_bmi260_data;
static struct kionix_accel_data g_kx022_data;
/* Matrix to rotate accelrator into standard reference frame */
-static const mat33_fp_t base_standard_ref = { { FLOAT_TO_FP(-1), 0, 0 },
- { 0, FLOAT_TO_FP(-1), 0 },
- { 0, 0, FLOAT_TO_FP(1) } };
+static 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) } };
static const mat33_fp_t lid_standard_ref = { { FLOAT_TO_FP(1), 0, 0 },
{ 0, FLOAT_TO_FP(-1), 0 },
{ 0, 0, FLOAT_TO_FP(-1) } };
-static const mat33_fp_t bmi260_standard_ref = { { 0, FLOAT_TO_FP(-1), 0 },
- { FLOAT_TO_FP(1), 0, 0 },
- { 0, 0, FLOAT_TO_FP(1) } };
+static const mat33_fp_t icm42607_standard_ref = { { FLOAT_TO_FP(-1), 0, 0 },
+ { 0, FLOAT_TO_FP(-1), 0 },
+ { 0, 0, FLOAT_TO_FP(1) } };
+
+static const mat33_fp_t icm426xx_standard_ref = { { FLOAT_TO_FP(-1), 0, 0 },
+ { 0, FLOAT_TO_FP(-1), 0 },
+ { 0, 0, FLOAT_TO_FP(1) } };
struct motion_sensor_t motion_sensors[] = {
/*
@@ -135,44 +143,46 @@ struct motion_sensor_t motion_sensors[] = {
[BASE_ACCEL] = {
.name = "Base Accel",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_ICM426XX,
+ .chip = MOTIONSENSE_CHIP_BMI260,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_BASE,
- .drv = &icm426xx_drv,
+ .drv = &bmi260_drv,
.mutex = &g_base_mutex,
- .drv_data = &g_icm426xx_data,
+ .drv_data = &g_bmi260_data,
.port = I2C_PORT_ACCEL,
- .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS,
- .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs. */
+ .i2c_spi_addr_flags = BMI260_ADDR0_FLAGS,
.rot_standard_ref = &base_standard_ref,
- .min_frequency = ICM426XX_ACCEL_MIN_FREQ,
- .max_frequency = ICM426XX_ACCEL_MAX_FREQ,
+ .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_ICM426XX,
+ .chip = MOTIONSENSE_CHIP_BMI260,
.type = MOTIONSENSE_TYPE_GYRO,
.location = MOTIONSENSE_LOC_BASE,
- .drv = &icm426xx_drv,
+ .drv = &bmi260_drv,
.mutex = &g_base_mutex,
- .drv_data = &g_icm426xx_data,
+ .drv_data = &g_bmi260_data,
.port = I2C_PORT_ACCEL,
- .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS,
+ .i2c_spi_addr_flags = BMI260_ADDR0_FLAGS,
.default_range = 1000, /* dps */
.rot_standard_ref = &base_standard_ref,
- .min_frequency = ICM426XX_GYRO_MIN_FREQ,
- .max_frequency = ICM426XX_GYRO_MAX_FREQ,
+ .min_frequency = BMI_GYRO_MIN_FREQ,
+ .max_frequency = BMI_GYRO_MAX_FREQ,
},
[LID_ACCEL] = {
.name = "Lid Accel",
@@ -204,69 +214,117 @@ struct motion_sensor_t motion_sensors[] = {
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
-struct motion_sensor_t bmi260_base_accel = {
+struct motion_sensor_t icm42607_base_accel = {
.name = "Base Accel",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_BMI260,
+ .chip = MOTIONSENSE_CHIP_ICM42607,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi260_drv,
+ .drv = &icm42607_drv,
.mutex = &g_base_mutex,
- .drv_data = &g_bmi260_data,
+ .drv_data = &g_icm42607_data,
.port = I2C_PORT_ACCEL,
- .i2c_spi_addr_flags = BMI260_ADDR0_FLAGS,
- .rot_standard_ref = &bmi260_standard_ref,
- .min_frequency = BMI_ACCEL_MIN_FREQ,
- .max_frequency = BMI_ACCEL_MAX_FREQ,
- .default_range = 4, /* g */
+ .i2c_spi_addr_flags = ICM42607_ADDR0_FLAGS,
+ .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs.*/
+ .rot_standard_ref = &icm42607_standard_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,
},
- /* Sensor on in S3 */
+ /* EC use accel for angle detection */
[SENSOR_CONFIG_EC_S3] = {
.odr = 10000 | ROUND_UP_FLAG,
+ },
+ },
+};
+
+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_icm42607_data,
+ .port = I2C_PORT_ACCEL,
+ .i2c_spi_addr_flags = ICM42607_ADDR0_FLAGS,
+ .default_range = 1000, /* dps */
+ .rot_standard_ref = &icm42607_standard_ref,
+ .min_frequency = ICM42607_GYRO_MIN_FREQ,
+ .max_frequency = ICM42607_GYRO_MAX_FREQ,
+};
+
+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, to meet CDD 7.3.1/C-1-4 reqs. */
+ .rot_standard_ref = &icm426xx_standard_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 = 10000 | ROUND_UP_FLAG,
.ec_rate = 100 * MSEC,
},
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
},
};
-struct motion_sensor_t bmi260_base_gyro = {
+struct motion_sensor_t icm426xx_base_gyro = {
.name = "Base Gyro",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_BMI260,
+ .chip = MOTIONSENSE_CHIP_ICM426XX,
.type = MOTIONSENSE_TYPE_GYRO,
.location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi260_drv,
+ .drv = &icm426xx_drv,
.mutex = &g_base_mutex,
- .drv_data = &g_bmi260_data,
+ .drv_data = &g_icm426xx_data,
.port = I2C_PORT_ACCEL,
- .i2c_spi_addr_flags = BMI260_ADDR0_FLAGS,
+ .i2c_spi_addr_flags = ICM426XX_ADDR0_FLAGS,
.default_range = 1000, /* dps */
- .rot_standard_ref = &bmi260_standard_ref,
- .min_frequency = BMI_GYRO_MIN_FREQ,
- .max_frequency = BMI_GYRO_MAX_FREQ,
+ .rot_standard_ref = &icm426xx_standard_ref,
+ .min_frequency = ICM426XX_GYRO_MIN_FREQ,
+ .max_frequency = ICM426XX_GYRO_MAX_FREQ,
};
static void board_update_motion_sensor_config(void)
{
- if (board_version >= 2) {
- motion_sensors[BASE_ACCEL] = bmi260_base_accel;
- motion_sensors[BASE_GYRO] = bmi260_base_gyro;
- ccprints("BASE Accelgyro is BMI260");
- } else {
+ if (board_version <= 1 || base_sensor == SSFC_SENSOR_ICM426XX) {
+ motion_sensors[BASE_ACCEL] = icm426xx_base_accel;
+ motion_sensors[BASE_GYRO] = icm426xx_base_gyro;
ccprints("BASE Accelgyro is ICM426XX");
+ } else if (base_sensor == SSFC_SENSOR_ICM42607) {
+ motion_sensors[BASE_ACCEL] = icm42607_base_accel;
+ motion_sensors[BASE_GYRO] = icm42607_base_gyro;
+ ccprints("BASE Accelgyro is ICM42607");
+ } else {
+ ccprints("BASE Accelgyro is BMI260");
}
}
void motion_interrupt(enum gpio_signal signal)
{
- if (board_version >= 2)
- bmi260_interrupt(signal);
- else
+ if (board_version <= 1 || base_sensor == SSFC_SENSOR_ICM426XX)
icm426xx_interrupt(signal);
+ else if (base_sensor == SSFC_SENSOR_ICM42607)
+ icm42607_interrupt(signal);
+ else
+ bmi260_interrupt(signal);
}
/* PWM */
@@ -397,6 +455,9 @@ static void board_init(void)
/* Store board version for use of something */
cbi_get_board_version(&board_version);
+ /* Store base sensor to recognize which base sensor we are using */
+ base_sensor = get_cbi_ssfc_base_sensor();
+
board_update_motion_sensor_config();
board_update_vol_up_key();
}
diff --git a/board/dojo/board.h b/board/dojo/board.h
index dbf5854f65..1bdc016b23 100644
--- a/board/dojo/board.h
+++ b/board/dojo/board.h
@@ -63,6 +63,11 @@
#define CONFIG_ACCELGYRO_ICM426XX_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
+/* ICM42607 Base accel/gyro*/
+#define CONFIG_ACCELGYRO_ICM42607
+#define CONFIG_ACCELGYRO_ICM42607_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
+
/* BMI260 accel/gyro in base */
#define CONFIG_ACCELGYRO_BMI260
#define CONFIG_ACCELGYRO_BMI260_INT_EVENT \