summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorPaul Ma <magf@bitland.corp-partner.google.com>2019-08-06 17:44:48 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-21 11:57:58 +0000
commit986085f59b453894c59848842ca5faf15e97dd2d (patch)
tree23e1fb17bff3c46d5b67719f28f9499ce58f2450 /board
parent5b494f3544a8bd726269350ba560b9c505e16e84 (diff)
downloadchrome-ec-986085f59b453894c59848842ca5faf15e97dd2d.tar.gz
akemi: enable motion sensor drivers
Akemi use lis2dwl as lid sensor and lsm6ds3tr-c as base sensor. This patch enable both of them. lis2dwl works in forced mode. BUG=b:138978278 BRANCH=none TEST=boot Akemi board, use command 'accelinfo on' to see sensor output, make sure the data are correct. Cq-Depend: chromium:1741598 Change-Id: I6ff19e388c74d95b8287b9899a81d2a3f866939e Signed-off-by: Paul Ma <magf@bitland.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1741106 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Justin TerAvest <teravest@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/akemi/board.c70
-rw-r--r--board/akemi/board.h13
-rw-r--r--board/akemi/gpio.inc2
3 files changed, 46 insertions, 39 deletions
diff --git a/board/akemi/board.c b/board/akemi/board.c
index 99ac93fcb2..20070d3e73 100644
--- a/board/akemi/board.c
+++ b/board/akemi/board.c
@@ -10,8 +10,8 @@
#include "button.h"
#include "common.h"
#include "cros_board_info.h"
-#include "driver/accel_bma2x2.h"
-#include "driver/accelgyro_bmi160.h"
+#include "driver/accel_lis2dw12.h"
+#include "driver/accelgyro_lsm6dsm.h"
#include "driver/als_tcs3400.h"
#include "driver/bc12/pi3usb9201.h"
#include "driver/ppc/sn5s330.h"
@@ -174,11 +174,10 @@ const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = {
static struct mutex g_base_mutex;
static struct mutex g_lid_mutex;
+/* Lid accel private data */
+static struct stprivate_data g_lis2dwl_data;
/* Base accel private data */
-static struct bmi160_drv_data_t g_bmi160_data;
-
-/* BMA255 private data */
-static struct accelgyro_saved_data_t g_bma255_data;
+static struct lsm6dsm_data lsm6dsm_data;
/* ALS private data */
static struct als_drv_data_t g_tcs3400_data = {
@@ -239,24 +238,24 @@ struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
.name = "Lid Accel",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_BMA255,
+ .chip = MOTIONSENSE_CHIP_LIS2DWL,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_LID,
- .drv = &bma2x2_accel_drv,
+ .drv = &lis2dw12_drv,
.mutex = &g_lid_mutex,
- .drv_data = &g_bma255_data,
+ .drv_data = &g_lis2dwl_data,
.port = I2C_PORT_ACCEL,
- .i2c_spi_addr_flags = BMA2x2_I2C_ADDR1_FLAGS,
+ .i2c_spi_addr_flags = LIS2DWL_ADDR1_FLAGS,
.rot_standard_ref = &lid_standard_ref,
- .min_frequency = BMA255_ACCEL_MIN_FREQ,
- .max_frequency = BMA255_ACCEL_MAX_FREQ,
- .default_range = 2, /* g, to support tablet mode */
+ .default_range = 4, /* g */
+ .min_frequency = LIS2DW12_ODR_MIN_VAL,
+ .max_frequency = LIS2DW12_ODR_MAX_VAL,
.config = {
/* EC use accel for angle detection */
[SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
+ .odr = 12500 | ROUND_UP_FLAG,
},
- /* Sensor on in S3 */
+ /* Sensor on for lid angle detection */
[SENSOR_CONFIG_EC_S3] = {
.odr = 10000 | ROUND_UP_FLAG,
},
@@ -266,25 +265,31 @@ struct motion_sensor_t motion_sensors[] = {
[BASE_ACCEL] = {
.name = "Base Accel",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_BMI160,
+ .chip = MOTIONSENSE_CHIP_LSM6DSM,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
+ .drv = &lsm6dsm_drv,
.mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
+ .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data,
+ MOTIONSENSE_TYPE_ACCEL),
+ .int_signal = GPIO_BASE_SIXAXIS_INT_L,
+ .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 = &base_standard_ref,
- .min_frequency = BMI160_ACCEL_MIN_FREQ,
- .max_frequency = BMI160_ACCEL_MAX_FREQ,
- .default_range = 2, /* g, to support tablet mode */
+ .default_range = 4, /* g */
+ .min_frequency = LSM6DSM_ODR_MIN_VAL,
+ .max_frequency = LSM6DSM_ODR_MAX_VAL,
.config = {
+ /* EC use accel for angle detection */
[SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
+ .odr = 13000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
},
- /* Sensor on in S3 */
+ /* Sensor on for angle detection */
[SENSOR_CONFIG_EC_S3] = {
.odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
},
},
},
@@ -292,18 +297,21 @@ struct motion_sensor_t motion_sensors[] = {
[BASE_GYRO] = {
.name = "Base Gyro",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_BMI160,
+ .chip = MOTIONSENSE_CHIP_LSM6DSM,
.type = MOTIONSENSE_TYPE_GYRO,
.location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
+ .drv = &lsm6dsm_drv,
.mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
+ .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data,
+ MOTIONSENSE_TYPE_GYRO),
+ .int_signal = GPIO_BASE_SIXAXIS_INT_L,
+ .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.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 = &base_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,
},
[CLEAR_ALS] = {
diff --git a/board/akemi/board.h b/board/akemi/board.h
index b72fb11176..5a55320d60 100644
--- a/board/akemi/board.h
+++ b/board/akemi/board.h
@@ -29,15 +29,14 @@
#define CONFIG_PWM_KBLIGHT
/* Sensors */
-/* BMI160 Base accel/gyro */
+/* LSM6DS3TR-C Base accel/gyro */
#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+#define CONFIG_ACCELGYRO_LSM6DSM
+#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
-#define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT
-/* BMA253 Lid accel */
-#define CONFIG_ACCEL_BMA255
-#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(LID_ACCEL) | BIT(CLEAR_ALS))
+/* LIS2DWL Lid accel */
+#define CONFIG_ACCEL_LIS2DWL
+#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(LID_ACCEL)|BIT(CLEAR_ALS))
#define CONFIG_LID_ANGLE
#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
diff --git a/board/akemi/gpio.inc b/board/akemi/gpio.inc
index 93f80a9d75..5c570afc51 100644
--- a/board/akemi/gpio.inc
+++ b/board/akemi/gpio.inc
@@ -25,7 +25,7 @@ GPIO_INT(PG_EC_ALL_SYS_PWRGD, PIN(F, 4), GPIO_INT_BOTH, power_signal_interrupt)
GPIO_INT(PP5000_A_PG_OD, PIN(D, 7), GPIO_INT_BOTH, power_signal_interrupt)
/* Sensor Interrupts */
-GPIO_INT(BASE_SIXAXIS_INT_L, PIN(5, 6), GPIO_INT_FALLING, bmi160_interrupt)
+GPIO_INT(BASE_SIXAXIS_INT_L, PIN(5, 6), GPIO_INT_FALLING, lsm6dsm_interrupt)
GPIO_INT(TCS3400_INT_ODL, PIN(F, 1), GPIO_INT_FALLING, tcs3400_interrupt)
/* USB-C interrupts */