summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2019-03-21 14:05:36 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2019-05-08 00:39:47 +0000
commit524c07eb28115b3f6d295fac9d3706c581c6a2f6 (patch)
tree6678959a419b1d8c464d11706869ac749c7249d9
parentf117a5e61d238a5184d9ab2bb306d7f068e5d5bc (diff)
downloadchrome-ec-524c07eb28115b3f6d295fac9d3706c581c6a2f6.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' Change-Id: I7025fe8a400e050907af490784521295d987051a Reviewed-on: https://chromium-review.googlesource.com/1535161 Reviewed-by: Enrico Granata <egranata@chromium.org> Reviewed-by: Yilun Lin <yllin@chromium.org> (cherry picked from commit e726fe4b2c1ea392ed059c4dbdedec253605cd7f) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1597796
-rw-r--r--driver/mag_bmm150.h16
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);