summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxiong.huang <xiong.huang@bitland.corp-partner.google.com>2019-08-05 15:28:57 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-16 11:57:30 +0000
commit19db4647c0a1258a061d0b92da3bb25022ee0fc8 (patch)
treeb5474a22c85116551cede551786d4e63d2d6ef5f
parent090c47f8f16588f5e216804f890e1f94009b6ddc (diff)
downloadchrome-ec-19db4647c0a1258a061d0b92da3bb25022ee0fc8.tar.gz
kodama: Add ACCEL and GYRO sensor LSM6DS3TR-C driver
Kodama project uses chip LSM6DS3TR-C instead of BMI160, and modify its driver information to support LSM6DS3TR-C well. BUG=b:136977971 BRANCH=master TEST=1) At EC RW stage, accel and gyro init successfully. 2) It can get accel sensor XYZ datas with command 'ectool motionsense' in VT2. Cq-Depend:chromium:1730377 Change-Id: I32d5fb7ea1b305e42e1e5bbe9e1f22c9e6220abd Signed-off-by: Xiong Huang <xiong.huang@bitland.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1736408 Reviewed-by: Paul Ma <magf@bitland.corp-partner.google.com> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r--board/kodama/board.c43
-rw-r--r--board/kodama/board.h4
-rw-r--r--board/kodama/gpio.inc2
3 files changed, 23 insertions, 26 deletions
diff --git a/board/kodama/board.c b/board/kodama/board.c
index 4580970249..54a2ffd9a9 100644
--- a/board/kodama/board.c
+++ b/board/kodama/board.c
@@ -13,7 +13,7 @@
#include "chipset.h"
#include "common.h"
#include "console.h"
-#include "driver/accelgyro_bmi160.h"
+#include "driver/accelgyro_lsm6dsm.h"
#include "driver/charger/rt946x.h"
#include "driver/sync.h"
#include "driver/tcpm/mt6370.h"
@@ -242,40 +242,37 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
#ifdef SECTION_IS_RW
static struct mutex g_lid_mutex;
-static struct bmi160_drv_data_t g_bmi160_data;
+static struct lsm6dsm_data lsm6dsm_data;
/* Matrix to rotate accelerometer into standard reference frame */
static const mat33_fp_t lid_standard_ref = {
- {FLOAT_TO_FP(1), 0, 0},
- {0, FLOAT_TO_FP(1), 0},
+ {FLOAT_TO_FP(-1), 0, 0},
+ {0, FLOAT_TO_FP(-1), 0},
{0, 0, FLOAT_TO_FP(1)}
};
struct motion_sensor_t motion_sensors[] = {
- /*
- * Note: bmi160: supports accelerometer and gyro sensor
- * Requirement: accelerometer sensor must init before gyro sensor
- * DO NOT change the order of the following table.
- */
[LID_ACCEL] = {
.name = "Accel",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_BMI160,
+ .chip = MOTIONSENSE_CHIP_LSM6DSM,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_LID,
- .drv = &bmi160_drv,
+ .drv = &lsm6dsm_drv,
.mutex = &g_lid_mutex,
- .drv_data = &g_bmi160_data,
+ .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, MOTIONSENSE_TYPE_ACCEL),
+ .int_signal = GPIO_ACCEL_INT_ODL,
+ .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_ACCEL,
- .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
+ .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS,
.rot_standard_ref = &lid_standard_ref,
.default_range = 4, /* g */
- .min_frequency = BMI160_ACCEL_MIN_FREQ,
- .max_frequency = BMI160_ACCEL_MAX_FREQ,
+ .min_frequency = LSM6DSM_ODR_MIN_VAL,
+ .max_frequency = LSM6DSM_ODR_MAX_VAL,
.config = {
/* Enable accel in S0 */
[SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
+ .odr = 13000 | ROUND_UP_FLAG,
.ec_rate = 100 * MSEC,
},
},
@@ -283,18 +280,18 @@ struct motion_sensor_t motion_sensors[] = {
[LID_GYRO] = {
.name = "Gyro",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_BMI160,
+ .chip = MOTIONSENSE_CHIP_LSM6DSM,
.type = MOTIONSENSE_TYPE_GYRO,
.location = MOTIONSENSE_LOC_LID,
- .drv = &bmi160_drv,
+ .drv = &lsm6dsm_drv,
.mutex = &g_lid_mutex,
- .drv_data = &g_bmi160_data,
+ .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, MOTIONSENSE_TYPE_GYRO),
.port = I2C_PORT_ACCEL,
- .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
- .default_range = 1000, /* dps */
+ .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS,
+ .default_range = 1000 | ROUND_UP_FLAG, /* dps */
.rot_standard_ref = &lid_standard_ref,
- .min_frequency = BMI160_GYRO_MIN_FREQ,
- .max_frequency = BMI160_GYRO_MAX_FREQ,
+ .min_frequency = LSM6DSM_ODR_MIN_VAL,
+ .max_frequency = LSM6DSM_ODR_MAX_VAL,
},
[VSYNC] = {
.name = "Camera vsync",
diff --git a/board/kodama/board.h b/board/kodama/board.h
index 4e12a2b3f7..d865edefcd 100644
--- a/board/kodama/board.h
+++ b/board/kodama/board.h
@@ -34,9 +34,9 @@
/* Motion Sensors */
#ifdef SECTION_IS_RW
-#define CONFIG_ACCELGYRO_BMI160
+#define CONFIG_ACCELGYRO_LSM6DSM
#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
/* Camera VSYNC */
diff --git a/board/kodama/gpio.inc b/board/kodama/gpio.inc
index 9345c3d27a..02f5a8fdc2 100644
--- a/board/kodama/gpio.inc
+++ b/board/kodama/gpio.inc
@@ -30,7 +30,7 @@ GPIO_INT(AP_EC_WATCHDOG_L, PIN(C, 2), GPIO_INT_FALLING,
chipset_watchdog_interrupt)
GPIO_INT_RW(ACCEL_INT_ODL, PIN(A, 4), GPIO_INT_FALLING | GPIO_SEL_1P8V | GPIO_PULL_UP,
- bmi160_interrupt)
+ lsm6dsm_interrupt)
GPIO_INT(CHARGER_INT_ODL, PIN(C, 13), GPIO_INT_FALLING | GPIO_PULL_UP,
rt946x_interrupt)
GPIO_INT_RO(EMMC_CMD, PIN(B, 15), GPIO_INT_FALLING,