summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2017-10-27 15:07:19 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-11-01 22:13:20 +0000
commitb3a31a1c710271bc3a6ebffa0d35ce9c2fa0114c (patch)
tree36b21c820dfd233cd43d23491157ed54d58fe913
parent679ec2fca47fcc2f8ebf4e07eb7089e6bbc776f1 (diff)
downloadchrome-ec-b3a31a1c710271bc3a6ebffa0d35ce9c2fa0114c.tar.gz
driver: BMM150: Set max frequency based on repetitions setting
The compass uses oversampling to produce accurate values. MAX_ODR is functions of the repetitions setting. 80Hz is too high, calculate the frequency based on preset setting. Currently, we use 'SPECIAL' that was calculated for Ryu. BUG=b:68394559 BRANCH=eve,reef,poppy TEST=Check with ectool motionsense info 3 the frequency is around 30Hz. Before: Min Frequency: 781 mHz Max Frequency: 80000 mHz After: Min Frequency: 781 mHz Max Frequency: 29579 mHz Check with AIDA64 the compass is not stuck and return changing values. Fixup of CL/570482 Change-Id: Idcfed1418f59e755e5647d018351c6a7397ffe1b Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/742146 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 8a2d0a5de6fc03eeea79a65469b361ae0ca694c9) Reviewed-on: https://chromium-review.googlesource.com/749982
-rw-r--r--driver/mag_bmm150.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/driver/mag_bmm150.h b/driver/mag_bmm150.h
index 51b2926e8a..d3c07db11b 100644
--- a/driver/mag_bmm150.h
+++ b/driver/mag_bmm150.h
@@ -76,7 +76,16 @@
/* Min and Max sampling frequency in mHz */
#define BMM150_MAG_MIN_FREQ 781
-#define BMM150_MAG_MAX_FREQ 80000
+
+/*
+ * From Section 4.2.4, max frequency depends on the preset.
+ *
+ * Fmax ~= 1 / (145us * nXY + 500us * nZ + 980us)
+ *
+ * To be safe, declare only 75% of the value.
+ */
+#define BMM150_MAG_MAX_FREQ(_preset) (750000000 / \
+ (145 * BMM150_REP(_preset, XY) + 500 * BMM150_REP(_preset, Z) + 980))
struct bmm150_comp_registers {
/* Local copy of the compensation registers. */