mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 17:11:42 +00:00
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>
This commit is contained in:
committed by
chrome-bot
parent
52d333662a
commit
a8a67a8073
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user