summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2017-01-10 14:14:35 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-01-10 21:34:32 -0800
commita8a67a8073028bb825a53c74859c688240bd34f3 (patch)
tree62a3d64d9186cdd47c03eb48358e4694075105c2 /driver
parent52d333662a1d463223bcee4792cc7abd3e3482d6 (diff)
downloadchrome-ec-a8a67a8073028bb825a53c74859c688240bd34f3.tar.gz
driver: bmi160: Set odr to 0 at init.
When we switch to a state where the sensor is not powered, we don't call set_data_rate(0), because we may trigger an i2c/spi access to a sensor already powered off. It has the side effect to leave data->odr to the last set sensor frequency. When we init the BMI160, it starts in suspend mode. We will set it to normal mode only if data->odr is 0. Therefore, we must set odr to 0 in the init routine. BUG=chrome-os-partner:61502 BRANCH=reef,kevin TEST=On reef, without this change. When going to S5 (shutdown -h 0) and power back up, sensor is stuck (on EC, accelread 1 reads old value). With this fix, sensor is active and working. This fix a regression due to CL:411964. Check others driver do not check odr for setting suspend/normal mode. Change-Id: Ibc7519d49e55a0b43b4c12ed545bd75ab0260766 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/426766 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/accelgyro_bmi160.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index a92cc1f54c..4ea5a6a66a 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -1087,6 +1087,7 @@ static int read(const struct motion_sensor_t *s, vector_3_t v)
static int init(const struct motion_sensor_t *s)
{
int ret = 0, tmp;
+ struct accelgyro_saved_data_t *data = BMI160_GET_SAVED_DATA(s);
ret = raw_read8(s->port, s->addr, BMI160_CHIP_ID, &tmp);
if (ret)
@@ -1214,6 +1215,11 @@ static int init(const struct motion_sensor_t *s)
}
#endif
+ /*
+ * The sensor is in Suspend mode at init,
+ * so set data rate to 0.
+ */
+ data->odr = 0;
set_range(s, s->default_range, 0);
if (s->type == MOTIONSENSE_TYPE_ACCEL) {