diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2019-01-31 13:43:04 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-03-11 19:53:06 -0700 |
commit | 554ba87174803e1ae52165ad46b9b22500b1ebb8 (patch) | |
tree | da013d28d7da998255c11cbc120ca549c548a69b | |
parent | 31fb76dc641dfdcdbde2fd6447168967d6c5c1c2 (diff) | |
download | chrome-ec-554ba87174803e1ae52165ad46b9b22500b1ebb8.tar.gz |
driver: lis2dh: Add support for lng2dm
Looking at 4.19 kernel (drivers/iio/accel/st_accel_core.c),
LNG2DM has the same interface as LIS2DH but a resolution of 8 bits only.
In consequence, basic handling of LIS2DE and LNG2DM should be identical.
FIFO and interrupt are not supported.
BUG=b:122281217
BRANCH=none
TEST=TBD
Change-Id: I7b715cfccdaf147dcdc002e9be8f5231a3dd8f98
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1449112
Reviewed-by: Mathew King <mathewk@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r-- | driver/accel_lis2dh.c | 3 | ||||
-rw-r--r-- | driver/accel_lis2dh.h | 27 | ||||
-rw-r--r-- | include/config.h | 21 | ||||
-rw-r--r-- | include/ec_commands.h | 1 | ||||
-rw-r--r-- | util/ectool.c | 3 |
5 files changed, 37 insertions, 18 deletions
diff --git a/driver/accel_lis2dh.c b/driver/accel_lis2dh.c index 762ccaf4a5..771128c4f8 100644 --- a/driver/accel_lis2dh.c +++ b/driver/accel_lis2dh.c @@ -4,7 +4,8 @@ */ /** - * LIS2DH/LIS2DH12 accelerometer module for Chrome EC 3D digital accelerometer + * Accelerometer module driver for Chrome EC 3D digital accelerometers: + * LIS2DH/LIS2DH12/LNG2DM */ #include "accelgyro.h" diff --git a/driver/accel_lis2dh.h b/driver/accel_lis2dh.h index 824127b90c..691cca6865 100644 --- a/driver/accel_lis2dh.h +++ b/driver/accel_lis2dh.h @@ -3,21 +3,30 @@ * found in the LICENSE file. */ -/* LIS2DH accelerometer module for Chrome EC */ +/* LIS2DH/LIS2DE/LNG2DM accelerometer module for Chrome EC */ #ifndef __CROS_EC_ACCEL_LIS2DH_H #define __CROS_EC_ACCEL_LIS2DH_H #include "driver/stm_mems_common.h" -#define LIS2DH_I2C_ADDR(__x) (__x << 1) +/* + * LIS2DH/LIS2DE: + * + * 8-bit address is 0011 00XW b. Where 'X' is determined + * by the voltage on the ADDR pin, and 'W' is read write bit + */ +#define LIS2DH_ADDR0 0x30 +#define LIS2DH_ADDR1 0x32 /* - * 7-bit address is 000110Xb. Where 'X' is determined - * by the voltage on the ADDR pin + * LNG2DM: + * + * 8-bit address is 0101 00XW b. Where 'X' is determined + * by the voltage on the ADDR pin, and 'W' is read write bit */ -#define LIS2DH_ADDR0 LIS2DH_I2C_ADDR(0x18) -#define LIS2DH_ADDR1 LIS2DH_I2C_ADDR(0x19) +#define LNG2DM_ADDR0 0x50 +#define LNG2DM_ADDR1 0x52 /* Who Am I */ #define LIS2DH_WHO_AM_I_REG 0x0f @@ -107,11 +116,13 @@ enum lis2dh_odr { /* * Sensor resolution in number of bits + * * lis2dh has variable precision (8/10/12 bits) depending Power Mode * selected, here Only Normal Power mode supported (10 bits). - * But for lis2de, it has only one 8bit resolution. + * + * lis2de/lng2dm only support 8bit resolution. */ -#ifdef CONFIG_ACCEL_LIS2DE +#if defined(CONFIG_ACCEL_LIS2DE) || defined(CONFIG_ACCEL_LNG2DM) #define LIS2DH_RESOLUTION 8 #elif defined(CONFIG_ACCEL_LIS2DH) #define LIS2DH_RESOLUTION 10 diff --git a/include/config.h b/include/config.h index 5a84742a4b..9ff7306a76 100644 --- a/include/config.h +++ b/include/config.h @@ -65,16 +65,18 @@ #undef CONFIG_ACCEL_KXCJ9 #undef CONFIG_ACCEL_KX022 /* - * lis2dh and lis2de have the same register interface but different + * lis2dh/lis2de/lng2dm have the same register interface but different * supported resolution. In normal mode, lis2dh works in 10-bit resolution, - * but lis2de only supports 8bit resolution. - * define CONFIG_ACCEL_LIS2DH if using lis2dh chip on the board and define - * CONFIG_ACCEL_LIS2DE if using lis2de chip. CONFIG_ACCEL_LIS2D_COMMON get - * automatically defined if either of them get defined. + * but lis2de/lng2dm only support 8bit resolution. + * + * Use the define for your correct chip and the CONFIG_ACCEL_LIS2D_COMMON will + * automatically get defined. */ -#undef CONFIG_ACCEL_LIS2DH #undef CONFIG_ACCEL_LIS2DE +#undef CONFIG_ACCEL_LIS2DH +#undef CONFIG_ACCEL_LNG2DM #undef CONFIG_ACCEL_LIS2D_COMMON + #undef CONFIG_ACCELGYRO_BMI160 #undef CONFIG_ACCELGYRO_LSM6DS0 /* Use CONFIG_ACCELGYRO_LSM6DSM for LSM6DSL, LSM6DSM, and/or LSM6DS3 */ @@ -4232,10 +4234,11 @@ /*****************************************************************************/ /* - * Automatically define CONFIG_ACCEL_LIS2D_COMMON if either child option is - * defined. + * Automatically define CONFIG_ACCEL_LIS2D_COMMON if a child option is defined. */ -#if defined(CONFIG_ACCEL_LIS2DH) || defined(CONFIG_ACCEL_LIS2DE) +#if defined(CONFIG_ACCEL_LIS2DH) || \ + defined(CONFIG_ACCEL_LIS2DE) || \ + defined(CONFIG_ACCEL_LNG2DM) #define CONFIG_ACCEL_LIS2D_COMMON #endif diff --git a/include/ec_commands.h b/include/ec_commands.h index 93dd9b8736..2a4331fb11 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -2434,6 +2434,7 @@ enum motionsensor_chip { MOTIONSENSE_CHIP_LIS2MDL = 16, MOTIONSENSE_CHIP_LSM6DS3 = 17, MOTIONSENSE_CHIP_LSM6DSO = 18, + MOTIONSENSE_CHIP_LNG2DM = 19, MOTIONSENSE_CHIP_MAX, }; diff --git a/util/ectool.c b/util/ectool.c index d86233e33b..35dab22114 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -4347,6 +4347,9 @@ static int cmd_motionsense(int argc, char **argv) case MOTIONSENSE_CHIP_LSM6DSO: printf("lsm6dso\n"); break; + case MOTIONSENSE_CHIP_LNG2DM: + printf("lng2dm\n"); + break; default: printf("unknown\n"); } |