diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2018-01-31 10:15:46 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-03-07 08:17:49 +0000 |
commit | 3627c64ccc26a8793d79e96eb2243f6807a632ec (patch) | |
tree | df2a82de6b9052d9e6dbaaa0b925a7eb78758b65 | |
parent | 0b789b22be42c18248747fca404e972004857893 (diff) | |
download | chrome-ec-3627c64ccc26a8793d79e96eb2243f6807a632ec.tar.gz |
board: meowth: add ST LSM6DSL sensors
Add LSM6DSL accel + gyro support to meowth.
FIFO and gesture support will be added later.
BUG=b:69140267,b:73546254
BRANCH=master
TEST=use accelinfo to get sensor data.
Change-Id: I4362fe5dd568fb5d696c460432b5c0a6a80be83e
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/952499
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | board/zoombini/board.c | 157 | ||||
-rw-r--r-- | board/zoombini/board.h | 5 |
2 files changed, 127 insertions, 35 deletions
diff --git a/board/zoombini/board.c b/board/zoombini/board.c index 2d26344237..6ce0198e4a 100644 --- a/board/zoombini/board.c +++ b/board/zoombini/board.c @@ -14,6 +14,7 @@ #include "common.h" #include "console.h" #include "compile_time_macros.h" +#include "driver/accelgyro_lsm6dsm.h" #include "driver/als_opt3001.h" #include "driver/led/lm3630a.h" #include "driver/pmic_tps650x30.h" @@ -37,6 +38,7 @@ #include "registers.h" #include "system.h" #include "switch.h" +#include "task.h" #include "tcpci.h" #include "usb_mux.h" #include "usb_pd_tcpm.h" @@ -208,43 +210,128 @@ static struct opt3001_drv_data_t g_opt3001_data = { .offset = 0, }; +/* Base Sensor mutex */ +static struct mutex g_base_mutex; + +/* + * Motion Sense + */ + +struct stprivate_data lsm6dsm_a_data; +struct stprivate_data lsm6dsm_g_data; +struct stprivate_data lsm6dsm_m_data; + struct motion_sensor_t motion_sensors[] = { + [LID_ACCEL] = { + .name = "LSM6DSL ACC", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSM, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = &lsm6dsm_a_data, + .port = I2C_PORT_SENSOR, + .addr = LSM6DSM_ADDR0, + .rot_standard_ref = NULL, + .default_range = 2, /* g, enough for laptop. */ + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, + .config = { + /* AP: by default use EC settings */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 13000, + .ec_rate = 13 * MSEC, + }, + /* Sensor off in S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0 + }, + /* Sensor off in S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0 + }, + }, + }, + [LID_GYRO] = { + .name = "LSM6DSL GYRO", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSM, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_LID, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = &lsm6dsm_g_data, + .port = I2C_PORT_SENSOR, + .addr = LSM6DSM_ADDR0, + .default_range = 245, /* dps */ + .rot_standard_ref = NULL, + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC does not need in S0 */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 13000, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, + }, [LID_ALS] = { - .name = "Light", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_OPT3001, - .type = MOTIONSENSE_TYPE_LIGHT, - .location = MOTIONSENSE_LOC_LID, - .drv = &opt3001_drv, - .drv_data = &g_opt3001_data, - .port = I2C_PORT_SENSOR, - .addr = OPT3001_I2C_ADDR, - .rot_standard_ref = NULL, - .default_range = 0x10000, /* scale = 1; uscale = 0 */ - .min_frequency = OPT3001_LIGHT_MIN_FREQ, - .max_frequency = OPT3001_LIGHT_MAX_FREQ, - .config = { - /* AP: by default shutdown all sensors */ - [SENSOR_CONFIG_AP] = { - .odr = 0, - .ec_rate = 0, - }, - /* Run ALS sensor in S0 */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 1000, - .ec_rate = 0, - }, - /* Sensor off in S3/S5 */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 0, - .ec_rate = 0, - }, - /* Sensor off in S3/S5 */ - [SENSOR_CONFIG_EC_S5] = { - .odr = 0, - .ec_rate = 0, - }, - }, + .name = "Light", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_OPT3001, + .type = MOTIONSENSE_TYPE_LIGHT, + .location = MOTIONSENSE_LOC_LID, + .drv = &opt3001_drv, + .drv_data = &g_opt3001_data, + .port = I2C_PORT_SENSOR, + .addr = OPT3001_I2C_ADDR, + .rot_standard_ref = NULL, + .default_range = 0x10000, /* scale = 1; uscale = 0 */ + .min_frequency = OPT3001_LIGHT_MIN_FREQ, + .max_frequency = OPT3001_LIGHT_MAX_FREQ, + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* Run ALS sensor in S0 */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 1000, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, }, }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); diff --git a/board/zoombini/board.h b/board/zoombini/board.h index 311707f396..ff83f43eaf 100644 --- a/board/zoombini/board.h +++ b/board/zoombini/board.h @@ -11,6 +11,8 @@ /* Optional features */ #define CONFIG_HIBERNATE_PSL #define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands. */ +#define CONFIG_CMD_ACCELS +#define CONFIG_CMD_ACCEL_INFO #define CONFIG_CMD_BUTTON #define CONFIG_CMD_PPC_DUMP @@ -38,6 +40,7 @@ #define CONFIG_LED_DRIVER_LM3630A #endif /* defined(BOARD_ZOOMBINI) */ +#define CONFIG_ACCELGYRO_LSM6DSM #define CONFIG_ALS #define CONFIG_ALS_OPT3001 #define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1 @@ -253,6 +256,8 @@ enum power_signal { }; enum sensor_id { + LID_ACCEL, + LID_GYRO, LID_ALS, }; |