summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2019-01-30 10:19:16 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-02-13 14:43:01 -0800
commit573b4bd9b49af15a57ca05f6bd515807a1d58424 (patch)
treebe7224091b0cfb6299c4ba36fe9d7694aec6cdd6
parent13abae16925c01def0a177da5d853f6a416b52cf (diff)
downloadchrome-ec-573b4bd9b49af15a57ca05f6bd515807a1d58424.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>
-rw-r--r--driver/accelgyro_lsm6dsm.c7
-rw-r--r--driver/accelgyro_lsm6dsm.h1
-rw-r--r--include/config.h1
-rw-r--r--include/ec_commands.h1
-rw-r--r--util/ectool.c3
5 files changed, 11 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 ec02b51c68..9ebb0bc4de 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 60ef2d1812..defa9f7edd 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -2432,6 +2432,7 @@ enum motionsensor_chip {
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 33d464138d..cb0de928cb 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -4341,6 +4341,9 @@ static int cmd_motionsense(int argc, char **argv)
case MOTIONSENSE_CHIP_LIS2MDL:
printf("lis2mdl\n");
break;
+ case MOTIONSENSE_CHIP_LSM6DS3:
+ printf("lsm6ds3\n");
+ break;
default:
printf("unknown\n");
}