diff options
author | Jacky Wang <jacky5_wang@pegatron.corp-partner.google.com> | 2021-07-12 16:59:31 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-07-12 10:35:06 +0000 |
commit | 2badec0ee0b763e674cb800d689a3f7d0e821ca6 (patch) | |
tree | de90df24b30e22fe1fa95e213808a8317df97a43 /board/collis | |
parent | e96012c2ebf781480489c80427059691b6dd83c8 (diff) | |
download | chrome-ec-2badec0ee0b763e674cb800d689a3f7d0e821ca6.tar.gz |
collis: gyro sensor add 2nd source KX022
Gyro sensor add 2nd source KX022.
BUG=b:193378998
BRANCH=firmware-volteer-13672.B
TEST=make BOARD=collis
1. Set CBI SSFC 0x10 and using command "ectool motionsense" for sensor
kxo22.
2. Using command "ectool motionsense" for sensor BMA253.
Signed-off-by: Jacky Wang <jacky5_wang@pegatron.corp-partner.google.com>
Change-Id: If7ad58f8291743dcde87cf084e990ae312f2fd8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3020643
Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
Diffstat (limited to 'board/collis')
-rw-r--r-- | board/collis/board.h | 1 | ||||
-rw-r--r-- | board/collis/sensors.c | 41 |
2 files changed, 39 insertions, 3 deletions
diff --git a/board/collis/board.h b/board/collis/board.h index 1f5ca0e154..99466d5e76 100644 --- a/board/collis/board.h +++ b/board/collis/board.h @@ -45,6 +45,7 @@ /* Sensors */ /* BMA253 accelerometer in base */ #define CONFIG_ACCEL_BMA255 +#define CONFIG_ACCEL_KX022 /* BMI160 accel/gyro in base */ #define CONFIG_ACCELGYRO_BMI160 diff --git a/board/collis/sensors.c b/board/collis/sensors.c index a1e28f29b6..bab31212cb 100644 --- a/board/collis/sensors.c +++ b/board/collis/sensors.c @@ -6,7 +6,10 @@ /* Volteer family-specific sensor configuration */ #include "common.h" #include "accelgyro.h" +#include "cbi_ec_fw_config.h" +#include "cbi_ssfc.h" #include "driver/accel_bma2x2.h" +#include "driver/accel_kionix.h" #include "driver/accelgyro_bmi_common.h" #include "driver/accelgyro_bmi160.h" #include "driver/sync.h" @@ -22,8 +25,9 @@ static struct mutex g_lid_accel_mutex; static struct mutex g_base_mutex; -/* BMA253 private data */ +/* sensor private data */ static struct accelgyro_saved_data_t g_bma253_data; +static struct kionix_accel_data g_kx022_data; /* BMI160 private data */ static struct bmi_drv_data_t g_bmi160_data; @@ -41,6 +45,33 @@ const mat33_fp_t base_standard_ref = { { 0, 0, FLOAT_TO_FP(-1)} }; +struct motion_sensor_t kx022_lid_accel = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_KX022, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &kionix_accel_drv, + .mutex = &g_lid_accel_mutex, + .drv_data = &g_kx022_data, + .port = I2C_PORT_ACCEL, + .i2c_spi_addr_flags = KX022_ADDR1_FLAGS, + .rot_standard_ref = &lid_standard_ref, + .min_frequency = KX022_ACCEL_MIN_FREQ, + .max_frequency = KX022_ACCEL_MAX_FREQ, + .default_range = 2, /* g, to support tablet mode */ + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + }, +}; + struct motion_sensor_t motion_sensors[] = { [LID_ACCEL] = { .name = "Lid Accel", @@ -118,9 +149,13 @@ unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); static void baseboard_sensors_init(void) { - /* Note - BMA253 interrupt unused by EC */ + if (get_cbi_ssfc_lid_sensor() == SSFC_SENSOR_LID_KX022) { + motion_sensors[LID_ACCEL] = kx022_lid_accel; + ccprints("LID_ACCEL is KX022"); + } else + ccprints("LID_ACCEL is BMA253"); - /* Enable interrupt for the BMI160 accel/gyro sensor */ + /* Enable interrupt for the accel/gyro sensor */ gpio_enable_interrupt(GPIO_EC_IMU_INT_L); } DECLARE_HOOK(HOOK_INIT, baseboard_sensors_init, HOOK_PRIO_DEFAULT); |