diff options
| author | Evan Wilson <evan@oliodevices.com> | 2016-01-21 18:13:09 -0800 |
|---|---|---|
| committer | Evan Wilson <evan@oliodevices.com> | 2016-01-21 18:13:09 -0800 |
| commit | 6e3548490c09c2abe1cf246a2f6569457d1930fe (patch) | |
| tree | e21d14f7c7c24db666e445fecdfb7439244d57e2 | |
| parent | d1294a7ffe9438c3449b4e74c381c081cc6f786e (diff) | |
| download | olio-linux-3.10-6e3548490c09c2abe1cf246a2f6569457d1930fe.tar.xz olio-linux-3.10-6e3548490c09c2abe1cf246a2f6569457d1930fe.zip | |
Fixing how we power cycle the accelerometer power rail,
and how we keep track of the last irq
Change-Id: Idda33817761cb8e3c96ab2158106814eb0fcfac7
| -rw-r--r-- | drivers/iio/imu/st_lsm6ds3/st_lsm6ds3.h | 2 | ||||
| -rw-r--r-- | drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_core.c | 21 | ||||
| -rw-r--r-- | drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_trigger.c | 1 |
3 files changed, 15 insertions, 9 deletions
diff --git a/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3.h b/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3.h index 3ba58d87a29..2533a9b78de 100644 --- a/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3.h +++ b/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3.h @@ -170,6 +170,8 @@ struct lsm6ds3_data { int64_t accel_timestamp; int64_t gyro_deltatime; int64_t gyro_timestamp; + /* In seconds, using get_monotonic_boottime */ + s64 irq_timestamp; #ifdef CONFIG_ST_LSM6DS3_IIO_MASTER_SUPPORT int64_t ext0_deltatime; int64_t ext0_timestamp; diff --git a/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_core.c b/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_core.c index 7298fdd274e..96cd843b55f 100644 --- a/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_core.c +++ b/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_core.c @@ -2165,8 +2165,9 @@ static int check_wai(struct lsm6ds3_data *cdata) { } get_monotonic_boottime(&ts); - current_time = timespec_to_ns(&ts); - if(current_time-cdata->timestamp > 20*60*1000*1000*1000) { + current_time = ts.tv_sec; + dev_err(cdata->dev, "Last timestamp delta: %d \n", current_time-cdata->irq_timestamp); + if(current_time-cdata->irq_timestamp > 15/*minutes*/*60) { return st_lsm6ds3_reset(cdata, true); } @@ -2189,15 +2190,17 @@ int st_lsm6ds3_reset(struct lsm6ds3_data *cdata, bool hard_reset) { } } - // Power cycle the accelerometer + /* Power cycle the accelerometer + * We need to first call regulator_disable, + * because this accurately keeps track of the reference counting + * Otherwise the enable may fail to enable the regulator + * Then call force_disable to ensure the regulator turns off + * This may cause kernel warnings, but it's to be expected + */ - err = regulator_disable(cdata->reg_accel); - if (err) - return err; + regulator_disable(cdata->reg_accel); - err = regulator_force_disable(cdata->reg_accel); - if (err) - return err; + regulator_force_disable(cdata->reg_accel); msleep(100); diff --git a/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_trigger.c b/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_trigger.c index a818b14b275..7c497447640 100644 --- a/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_trigger.c +++ b/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_trigger.c @@ -55,6 +55,7 @@ irqreturn_t st_lsm6ds3_save_timestamp(int irq, void *private) get_monotonic_boottime(&ts); cdata->timestamp = timespec_to_ns(&ts); cdata->accel_timestamp = cdata->timestamp; + cdata->irq_timestamp = ts.tv_sec; queue_work(st_lsm6ds3_wq, &cdata->data_work); disable_irq_nosync(irq); |