diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2019-03-21 14:05:36 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-05-30 23:19:38 +0000 |
commit | ab565efc144889dcd7a437e297c0a0fb0a061ec2 (patch) | |
tree | fbec87cd12558f60fb0fddf8fb2c50ac0c265f73 | |
parent | 73c93876daf10f0cf61fea279eded76b56dcbf58 (diff) | |
download | chrome-ec-ab565efc144889dcd7a437e297c0a0fb0a061ec2.tar.gz |
bmm150: lower max frequency to match a frequency supported by BMI160
Be sure the frequency we report does not need to be rounded up by BMI160
when BMM150 is behind BMI160.
For instance, if we set 29Hz as maximum frequency, 29Hz will be rounded
up to 50Hz (BMI160 samples at its own recognized frequency).
At that speed, the BMM150 will lock up.
BUG=b:120942904
BRANCH=none
TEST=On eve with magnetometer check the maximum frequency reported by
the magnetometer is 25Hz.
Check the magnetometer is working with 'ectool motionsense 3'
(cherry picked from commit e726fe4b2c1ea392ed059c4dbdedec253605cd7f)
Reviewed-on: https://chromium-review.googlesource.com/1535161
Reviewed-by: Enrico Granata <egranata@chromium.org>
Reviewed-by: Yilun Lin <yllin@chromium.org>
Change-Id: I7025fe8a400e050907af490784521295d987051a
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1621509
-rw-r--r-- | driver/mag_bmm150.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/driver/mag_bmm150.h b/driver/mag_bmm150.h index 1fba0a7050..402ebabf4f 100644 --- a/driver/mag_bmm150.h +++ b/driver/mag_bmm150.h @@ -84,10 +84,10 @@ * * To be safe, declare only 75% of the value. */ -#define BMM150_MAG_MAX_FREQ(_preset) (750000000 / \ +#define __BMM150_MAG_MAX_FREQ(_preset) (750000000 / \ (145 * BMM150_REP(_preset, XY) + 500 * BMM150_REP(_preset, Z) + 980)) -#if (BMM150_MAG_MAX_FREQ(SPECIAL) > CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ) +#if (__BMM150_MAG_MAX_FREQ(SPECIAL) > CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ) #error "EC too slow for magnetometer" #endif @@ -117,6 +117,18 @@ struct bmm150_private_data { #define BMM150_CAL(_s) \ (&BMI160_GET_DATA(_s)->compass.cal) +#ifdef CONFIG_MAG_BMI160_BMM150 +#include "accelgyro_bmi160.h" +/* + * Behind a BMI160, the BMM150 is in forced mode. Be sure to choose a frequency + * comptible with BMI160. + */ +#define BMM150_MAG_MAX_FREQ(_preset) \ + BMI160_REG_TO_ODR(BMI160_ODR_TO_REG(__BMM150_MAG_MAX_FREQ(_preset))) +#else +#define BMM150_MAG_MAX_FREQ(_preset) __BMM150_MAG_MAX_FREQ(_preset) +#endif + /* Specific initialization of BMM150 when behing BMI160 */ int bmm150_init(const struct motion_sensor_t *s); |