diff options
author | Jett Rink <jettrink@chromium.org> | 2019-01-30 10:19:16 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-02 17:47:24 +0000 |
commit | f61aac7cd0a62aa57ed8c33bb49c45b6d9ae43c0 (patch) | |
tree | d81a4a6b5c19750bae2fb0e34eee92c8d29908b3 | |
parent | 53397669f18b6a4729c238aa9a2b479c36966e12 (diff) | |
download | chrome-ec-f61aac7cd0a62aa57ed8c33bb49c45b6d9ae43c0.tar.gz |
lsm6ds3: Add LDM6DS3 variant to existing LSM6DSM
The lsm6dsX where X is M/L/3 are very similar. The only differences
appear to be the who am I register value and fifo size.
BRANCH=none
BUG=b:122281217
TEST=Arcada with CL stack, can read sensor data via EC console using
`accelread 0` command
Change-Id: Iaa12d49616c66e574e069b43aba2618722f0dda0
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1446533
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Gwendal Grignou <gwendal@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1719528
Reviewed-by: Edward Hill <ecgh@chromium.org>
Tested-by: Edward Hill <ecgh@chromium.org>
Commit-Queue: Edward Hill <ecgh@chromium.org>
-rw-r--r-- | driver/accelgyro_lsm6dsm.c | 7 | ||||
-rw-r--r-- | driver/accelgyro_lsm6dsm.h | 1 | ||||
-rw-r--r-- | include/config.h | 1 | ||||
-rw-r--r-- | include/ec_commands.h | 2 | ||||
-rw-r--r-- | util/ectool.c | 6 |
5 files changed, 15 insertions, 2 deletions
diff --git a/driver/accelgyro_lsm6dsm.c b/driver/accelgyro_lsm6dsm.c index 9e333c95f2..dc9a0ff5aa 100644 --- a/driver/accelgyro_lsm6dsm.c +++ b/driver/accelgyro_lsm6dsm.c @@ -4,7 +4,7 @@ */ /** - * LSM6DSx (x is L or M) accelerometer and gyro module for Chrome EC + * LSM6DSx (x is L/M/3) accelerometer and gyro module for Chrome EC * 3D digital accelerometer & 3D digital gyroscope * This driver supports both devices LSM6DSM and LSM6DSL */ @@ -600,8 +600,11 @@ static int init(const struct motion_sensor_t *s) if (ret != EC_SUCCESS) return EC_ERROR_UNKNOWN; - if (tmp != LSM6DSM_WHO_AM_I) + if (tmp != LSM6DS3_WHO_AM_I && tmp != LSM6DSM_WHO_AM_I) { + /* Unrecognized sensor */ + CPRINTS("Unknown WHO_AM_I value: 0x%x", tmp); return EC_ERROR_ACCESS_DENIED; + } /* * This sensor can be powered through an EC reboot, so the state of the diff --git a/driver/accelgyro_lsm6dsm.h b/driver/accelgyro_lsm6dsm.h index a9191bdfb4..bfbf1fc26c 100644 --- a/driver/accelgyro_lsm6dsm.h +++ b/driver/accelgyro_lsm6dsm.h @@ -69,6 +69,7 @@ /* Who Am I */ #define LSM6DSM_WHO_AM_I_REG 0x0f #define LSM6DSM_WHO_AM_I 0x6a +#define LSM6DS3_WHO_AM_I 0x69 #define LSM6DSM_CTRL1_ADDR 0x10 #define LSM6DSM_XL_ODR_MASK 0xf0 diff --git a/include/config.h b/include/config.h index 207f840fea..772135a211 100644 --- a/include/config.h +++ b/include/config.h @@ -77,6 +77,7 @@ #undef CONFIG_ACCEL_LIS2D_COMMON #undef CONFIG_ACCELGYRO_BMI160 #undef CONFIG_ACCELGYRO_LSM6DS0 +/* Use CONFIG_ACCELGYRO_LSM6DSM for LSM6DSL, LSM6DSM, and/or LSM6DS3 */ #undef CONFIG_ACCELGYRO_LSM6DSM /* Add sensorhub function for LSM6DSM, required if 2nd device attached. */ #undef CONFIG_SENSORHUB_LSM6DSM diff --git a/include/ec_commands.h b/include/ec_commands.h index c51fb7ce17..7f56b38d5b 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -2416,6 +2416,8 @@ enum motionsensor_chip { MOTIONSENSE_CHIP_LIS2DH = 13, MOTIONSENSE_CHIP_LSM6DSM = 14, MOTIONSENSE_CHIP_LIS2DE = 15, + MOTIONSENSE_CHIP_LIS2MDL = 16, + MOTIONSENSE_CHIP_LSM6DS3 = 17, MOTIONSENSE_CHIP_MAX, }; diff --git a/util/ectool.c b/util/ectool.c index 2ad51ffc93..d4430c74af 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -4282,6 +4282,12 @@ static int cmd_motionsense(int argc, char **argv) case MOTIONSENSE_CHIP_LIS2DE: printf("lis2de\n"); break; + case MOTIONSENSE_CHIP_LIS2MDL: + printf("lis2mdl\n"); + break; + case MOTIONSENSE_CHIP_LSM6DS3: + printf("lsm6ds3\n"); + break; default: printf("unknown\n"); } |