Commit 01d1f7a9 authored by Marcin Niestroj's avatar Marcin Niestroj Committed by Jonathan Cameron

iio: bmi160: Fix time needed to sleep after command execution

Datasheet specifies typical and maximum execution times for which CMD
register is occupied after previous command execution. We took these
values as minimum and maximum time for usleep_range() call before making
a new command execution.

To be sure, that the CMD register is no longer occupied we need to wait
*at least* the maximum time specified by datasheet.
Signed-off-by: default avatarMarcin Niestroj <m.niestroj@grinn-global.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent e91c3dfc
...@@ -66,10 +66,8 @@ ...@@ -66,10 +66,8 @@
#define BMI160_REG_DUMMY 0x7F #define BMI160_REG_DUMMY 0x7F
#define BMI160_ACCEL_PMU_MIN_USLEEP 3200 #define BMI160_ACCEL_PMU_MIN_USLEEP 3800
#define BMI160_ACCEL_PMU_MAX_USLEEP 3800 #define BMI160_GYRO_PMU_MIN_USLEEP 80000
#define BMI160_GYRO_PMU_MIN_USLEEP 55000
#define BMI160_GYRO_PMU_MAX_USLEEP 80000
#define BMI160_SOFTRESET_USLEEP 1000 #define BMI160_SOFTRESET_USLEEP 1000
#define BMI160_CHANNEL(_type, _axis, _index) { \ #define BMI160_CHANNEL(_type, _axis, _index) { \
...@@ -151,20 +149,9 @@ static struct bmi160_regs bmi160_regs[] = { ...@@ -151,20 +149,9 @@ static struct bmi160_regs bmi160_regs[] = {
}, },
}; };
struct bmi160_pmu_time { static unsigned long bmi160_pmu_time[] = {
unsigned long min; [BMI160_ACCEL] = BMI160_ACCEL_PMU_MIN_USLEEP,
unsigned long max; [BMI160_GYRO] = BMI160_GYRO_PMU_MIN_USLEEP,
};
static struct bmi160_pmu_time bmi160_pmu_time[] = {
[BMI160_ACCEL] = {
.min = BMI160_ACCEL_PMU_MIN_USLEEP,
.max = BMI160_ACCEL_PMU_MAX_USLEEP
},
[BMI160_GYRO] = {
.min = BMI160_GYRO_PMU_MIN_USLEEP,
.max = BMI160_GYRO_PMU_MIN_USLEEP,
},
}; };
struct bmi160_scale { struct bmi160_scale {
...@@ -289,7 +276,7 @@ int bmi160_set_mode(struct bmi160_data *data, enum bmi160_sensor_type t, ...@@ -289,7 +276,7 @@ int bmi160_set_mode(struct bmi160_data *data, enum bmi160_sensor_type t,
if (ret < 0) if (ret < 0)
return ret; return ret;
usleep_range(bmi160_pmu_time[t].min, bmi160_pmu_time[t].max); usleep_range(bmi160_pmu_time[t], bmi160_pmu_time[t] + 1000);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment