summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason.Guo <jason.guo@quanta.corp-partner.google.com>2020-12-17 17:30:25 +0800
committerCommit Bot <commit-bot@chromium.org>2020-12-21 17:00:31 +0000
commitb8aa849de779ea14ba7713d7cc1379a62b835115 (patch)
treee4e1485825a807f5398cfe94e104660948b0385f
parentbb25469f290398d7816df35345834b69777db925 (diff)
downloadchrome-ec-b8aa849de779ea14ba7713d7cc1379a62b835115.tar.gz
gumboz: change LID accel motion sensor
This CL change lid accel motion sensor to KX022 from lis2dw12. BUG=b:175284218 BRANCH=zork TEST=ectool motionsense to make sure sensors work. Signed-off-by: jason.guo@quanta.corp-partner.google.com Change-Id: I995cb7b9ee1076db4ff719785e2c33ed0eace391 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2597123 Reviewed-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
-rw-r--r--board/gumboz/board.c145
-rw-r--r--board/gumboz/board.h2
2 files changed, 76 insertions, 71 deletions
diff --git a/board/gumboz/board.c b/board/gumboz/board.c
index 2deeaf8584..5e87e8dc21 100644
--- a/board/gumboz/board.c
+++ b/board/gumboz/board.c
@@ -6,7 +6,7 @@
#include "battery_smart.h"
#include "button.h"
#include "cros_board_info.h"
-#include "driver/accel_lis2dw12.h"
+#include "driver/accel_kionix.h"
#include "driver/accelgyro_lsm6dsm.h"
#include "driver/bc12/pi3usb9201.h"
#include "driver/ppc/aoz1380.h"
@@ -48,10 +48,16 @@ static struct mutex g_lid_mutex;
static struct mutex g_base_mutex;
/* sensor private data */
-static struct stprivate_data g_lis2dwl_data;
+static struct kionix_accel_data g_kx022_data;
static struct lsm6dsm_data g_lsm6dsm_data = LSM6DSM_DATA;
/* Matrix to rotate accelrator into standard reference frame */
+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 base_standard_ref = {
{ FLOAT_TO_FP(-1), 0, 0},
{ 0, FLOAT_TO_FP(-1), 0},
@@ -61,82 +67,81 @@ static const mat33_fp_t base_standard_ref = {
/* TODO(gcc >= 5.0) Remove the casts to const pointer at rot_standard_ref */
struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
- .name = "Lid Accel",
- .active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LIS2DWL,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &lis2dw12_drv,
- .mutex = &g_lid_mutex,
- .drv_data = &g_lis2dwl_data,
- .port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = LIS2DWL_ADDR1_FLAGS,
- .rot_standard_ref = NULL,
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = LIS2DW12_ODR_MIN_VAL,
- .max_frequency = LIS2DW12_ODR_MAX_VAL,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 12500 | ROUND_UP_FLAG,
- },
- /* Sensor on for lid angle detection */
- [SENSOR_CONFIG_EC_S3] = {
- .odr = 10000 | ROUND_UP_FLAG,
+ .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_mutex,
+ .drv_data = &g_kx022_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = KX022_ADDR1_FLAGS,
+ .rot_standard_ref = &lid_standard_ref,
+ .default_range = 2, /* g */
+ /* We only use 2g because its resolution is only 8-bits */
+ .min_frequency = KX022_ACCEL_MIN_FREQ,
+ .max_frequency = KX022_ACCEL_MAX_FREQ,
+ .config = {
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ },
},
},
- },
[BASE_ACCEL] = {
- .name = "Base Accel",
- .active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LSM6DSM,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &lsm6dsm_drv,
- .mutex = &g_base_mutex,
- .drv_data = LSM6DSM_ST_DATA(g_lsm6dsm_data,
- MOTIONSENSE_TYPE_ACCEL),
- .int_signal = GPIO_6AXIS_INT_L,
- .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
- .port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS,
- .default_range = 4, /* g, enough for laptop */
- .rot_standard_ref = &base_standard_ref,
- .min_frequency = LSM6DSM_ODR_MIN_VAL,
- .max_frequency = LSM6DSM_ODR_MAX_VAL,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 13000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
- },
- /* Sensor on for angle detection */
- [SENSOR_CONFIG_EC_S3] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_LSM6DSM,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &lsm6dsm_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = LSM6DSM_ST_DATA(g_lsm6dsm_data,
+ MOTIONSENSE_TYPE_ACCEL),
+ .int_signal = GPIO_6AXIS_INT_L,
+ .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS,
+ .default_range = 4, /* g, enough for laptop */
+ .rot_standard_ref = &base_standard_ref,
+ .min_frequency = LSM6DSM_ODR_MIN_VAL,
+ .max_frequency = LSM6DSM_ODR_MAX_VAL,
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 13000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
+ /* Sensor on for angle detection */
+ [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_LSM6DSM,
- .type = MOTIONSENSE_TYPE_GYRO,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &lsm6dsm_drv,
- .mutex = &g_base_mutex,
- .drv_data = LSM6DSM_ST_DATA(g_lsm6dsm_data,
- MOTIONSENSE_TYPE_GYRO),
- .int_signal = GPIO_6AXIS_INT_L,
- .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
- .port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS,
- .default_range = 1000 | ROUND_UP_FLAG, /* dps */
- .rot_standard_ref = &base_standard_ref,
- .min_frequency = LSM6DSM_ODR_MIN_VAL,
- .max_frequency = LSM6DSM_ODR_MAX_VAL,
+ .name = "Base Gyro",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_LSM6DSM,
+ .type = MOTIONSENSE_TYPE_GYRO,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &lsm6dsm_drv,
+ .mutex = &g_base_mutex,
+ .drv_data = LSM6DSM_ST_DATA(g_lsm6dsm_data,
+ MOTIONSENSE_TYPE_GYRO),
+ .int_signal = GPIO_6AXIS_INT_L,
+ .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS,
+ .default_range = 1000 | ROUND_UP_FLAG, /* dps */
+ .rot_standard_ref = &base_standard_ref,
+ .min_frequency = LSM6DSM_ODR_MIN_VAL,
+ .max_frequency = LSM6DSM_ODR_MAX_VAL,
},
};
diff --git a/board/gumboz/board.h b/board/gumboz/board.h
index 178ee0a013..583b3e01af 100644
--- a/board/gumboz/board.h
+++ b/board/gumboz/board.h
@@ -37,7 +37,7 @@
#define CONFIG_ACCELGYRO_LSM6DSM
#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
-#define CONFIG_ACCEL_LIS2DWL
+#define CONFIG_ACCEL_KX022 /* Lid accel */
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_CMD_ACCELS
#define CONFIG_CMD_ACCEL_INFO