* [PATCH] iio: imu: st_lsm6dsx: fix PM support for st_lsm6dsx i2c controller [not found] <cover.1558256188.git.lorenzo@kernel.org> @ 2019-05-19 8:58 ` Lorenzo Bianconi 2019-05-19 11:36 ` Jonathan Cameron 0 siblings, 1 reply; 2+ messages in thread From: Lorenzo Bianconi @ 2019-05-19 8:58 UTC (permalink / raw) To: jic23; +Cc: linux-iio Properly suspend/resume i2c slaves connected to st_lsm6dsx master controller if the CPU goes in suspended state Fixes: c91c1c844ebd ("imu: st_lsm6dsx: add i2c embedded controller support") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 ++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 25 +++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 004a8a1a0027..6ef3577234a0 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -271,6 +271,7 @@ struct st_lsm6dsx_sensor { * @conf_lock: Mutex to prevent concurrent FIFO configuration update. * @page_lock: Mutex to prevent concurrent memory page configuration. * @fifo_mode: FIFO operating mode supported by the device. + * @suspend_mask: Suspended sensor bitmask. * @enable_mask: Enabled sensor bitmask. * @ts_sip: Total number of timestamp samples in a given pattern. * @sip: Total number of samples (acc/gyro/ts) in a given pattern. @@ -288,6 +289,7 @@ struct st_lsm6dsx_hw { struct mutex page_lock; enum st_lsm6dsx_fifo_mode fifo_mode; + u8 suspend_mask; u8 enable_mask; u8 ts_sip; u8 sip; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index cf82c9049945..be5c87c8266d 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -1110,8 +1110,6 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) { struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev); struct st_lsm6dsx_sensor *sensor; - const struct st_lsm6dsx_reg *reg; - unsigned int data; int i, err = 0; for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { @@ -1122,12 +1120,16 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) if (!(hw->enable_mask & BIT(sensor->id))) continue; - reg = &st_lsm6dsx_odr_table[sensor->id].reg; - data = ST_LSM6DSX_SHIFT_VAL(0, reg->mask); - err = st_lsm6dsx_update_bits_locked(hw, reg->addr, reg->mask, - data); + if (sensor->id == ST_LSM6DSX_ID_EXT0 || + sensor->id == ST_LSM6DSX_ID_EXT1 || + sensor->id == ST_LSM6DSX_ID_EXT2) + err = st_lsm6dsx_shub_set_enable(sensor, false); + else + err = st_lsm6dsx_sensor_set_enable(sensor, false); if (err < 0) return err; + + hw->suspend_mask |= BIT(sensor->id); } if (hw->fifo_mode != ST_LSM6DSX_FIFO_BYPASS) @@ -1147,12 +1149,19 @@ static int __maybe_unused st_lsm6dsx_resume(struct device *dev) continue; sensor = iio_priv(hw->iio_devs[i]); - if (!(hw->enable_mask & BIT(sensor->id))) + if (!(hw->suspend_mask & BIT(sensor->id))) continue; - err = st_lsm6dsx_set_odr(sensor, sensor->odr); + if (sensor->id == ST_LSM6DSX_ID_EXT0 || + sensor->id == ST_LSM6DSX_ID_EXT1 || + sensor->id == ST_LSM6DSX_ID_EXT2) + err = st_lsm6dsx_shub_set_enable(sensor, true); + else + err = st_lsm6dsx_sensor_set_enable(sensor, true); if (err < 0) return err; + + hw->suspend_mask &= ~BIT(sensor->id); } if (hw->enable_mask) -- 2.21.0 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: imu: st_lsm6dsx: fix PM support for st_lsm6dsx i2c controller 2019-05-19 8:58 ` [PATCH] iio: imu: st_lsm6dsx: fix PM support for st_lsm6dsx i2c controller Lorenzo Bianconi @ 2019-05-19 11:36 ` Jonathan Cameron 0 siblings, 0 replies; 2+ messages in thread From: Jonathan Cameron @ 2019-05-19 11:36 UTC (permalink / raw) To: Lorenzo Bianconi; +Cc: linux-iio On Sun, 19 May 2019 10:58:23 +0200 Lorenzo Bianconi <lorenzo@kernel.org> wrote: > Properly suspend/resume i2c slaves connected to st_lsm6dsx master > controller if the CPU goes in suspended state > > Fixes: c91c1c844ebd ("imu: st_lsm6dsx: add i2c embedded controller support") > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Applied to the fixes-togreg branch of iio.git and marked for stable. Thanks, Jonathan > --- > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 ++ > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 25 +++++++++++++------- > 2 files changed, 19 insertions(+), 8 deletions(-) > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > index 004a8a1a0027..6ef3577234a0 100644 > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > @@ -271,6 +271,7 @@ struct st_lsm6dsx_sensor { > * @conf_lock: Mutex to prevent concurrent FIFO configuration update. > * @page_lock: Mutex to prevent concurrent memory page configuration. > * @fifo_mode: FIFO operating mode supported by the device. > + * @suspend_mask: Suspended sensor bitmask. > * @enable_mask: Enabled sensor bitmask. > * @ts_sip: Total number of timestamp samples in a given pattern. > * @sip: Total number of samples (acc/gyro/ts) in a given pattern. > @@ -288,6 +289,7 @@ struct st_lsm6dsx_hw { > struct mutex page_lock; > > enum st_lsm6dsx_fifo_mode fifo_mode; > + u8 suspend_mask; > u8 enable_mask; > u8 ts_sip; > u8 sip; > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c > index cf82c9049945..be5c87c8266d 100644 > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c > @@ -1110,8 +1110,6 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) > { > struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev); > struct st_lsm6dsx_sensor *sensor; > - const struct st_lsm6dsx_reg *reg; > - unsigned int data; > int i, err = 0; > > for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { > @@ -1122,12 +1120,16 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) > if (!(hw->enable_mask & BIT(sensor->id))) > continue; > > - reg = &st_lsm6dsx_odr_table[sensor->id].reg; > - data = ST_LSM6DSX_SHIFT_VAL(0, reg->mask); > - err = st_lsm6dsx_update_bits_locked(hw, reg->addr, reg->mask, > - data); > + if (sensor->id == ST_LSM6DSX_ID_EXT0 || > + sensor->id == ST_LSM6DSX_ID_EXT1 || > + sensor->id == ST_LSM6DSX_ID_EXT2) > + err = st_lsm6dsx_shub_set_enable(sensor, false); > + else > + err = st_lsm6dsx_sensor_set_enable(sensor, false); > if (err < 0) > return err; > + > + hw->suspend_mask |= BIT(sensor->id); > } > > if (hw->fifo_mode != ST_LSM6DSX_FIFO_BYPASS) > @@ -1147,12 +1149,19 @@ static int __maybe_unused st_lsm6dsx_resume(struct device *dev) > continue; > > sensor = iio_priv(hw->iio_devs[i]); > - if (!(hw->enable_mask & BIT(sensor->id))) > + if (!(hw->suspend_mask & BIT(sensor->id))) > continue; > > - err = st_lsm6dsx_set_odr(sensor, sensor->odr); > + if (sensor->id == ST_LSM6DSX_ID_EXT0 || > + sensor->id == ST_LSM6DSX_ID_EXT1 || > + sensor->id == ST_LSM6DSX_ID_EXT2) > + err = st_lsm6dsx_shub_set_enable(sensor, true); > + else > + err = st_lsm6dsx_sensor_set_enable(sensor, true); > if (err < 0) > return err; > + > + hw->suspend_mask &= ~BIT(sensor->id); > } > > if (hw->enable_mask) ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-19 17:32 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <cover.1558256188.git.lorenzo@kernel.org> 2019-05-19 8:58 ` [PATCH] iio: imu: st_lsm6dsx: fix PM support for st_lsm6dsx i2c controller Lorenzo Bianconi 2019-05-19 11:36 ` Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).