All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] enable LIR and clear_on_read for st_lsm6dsx
@ 2019-09-11  6:50 Lorenzo Bianconi
  2019-09-11  6:50 ` [PATCH 1/2] iio: imu: st_lsm6dsx: enable LIR for sensor events Lorenzo Bianconi
  2019-09-11  6:50 ` [PATCH 2/2] iio: imu: st_lsm6dsx: enable clear on read for latched interrupts Lorenzo Bianconi
  0 siblings, 2 replies; 7+ messages in thread
From: Lorenzo Bianconi @ 2019-09-11  6:50 UTC (permalink / raw)
  To: jic23
  Cc: sean, lorenzo.bianconi, linux-iio, mario.tesi, armando.visconti,
	denis.ciocca

Enable by default Latched interrupts and clear_on_read (when available)
for sensor events.

@Sean: could you please rebase your series on top of this one in order to double
check if it fixes the reported issue between buffered reading and wakeup
events?

Lorenzo Bianconi (2):
  iio: imu: st_lsm6dsx: enable LIR for sensor events
  iio: imu: st_lsm6dsx: enable clear on read for latched interrupts

 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  4 ++
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 59 ++++++++++++++++++++
 2 files changed, 63 insertions(+)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] iio: imu: st_lsm6dsx: enable LIR for sensor events
  2019-09-11  6:50 [PATCH 0/2] enable LIR and clear_on_read for st_lsm6dsx Lorenzo Bianconi
@ 2019-09-11  6:50 ` Lorenzo Bianconi
  2019-09-11 12:37   ` Sean Nyekjaer
  2019-09-11  6:50 ` [PATCH 2/2] iio: imu: st_lsm6dsx: enable clear on read for latched interrupts Lorenzo Bianconi
  1 sibling, 1 reply; 7+ messages in thread
From: Lorenzo Bianconi @ 2019-09-11  6:50 UTC (permalink / raw)
  To: jic23
  Cc: sean, lorenzo.bianconi, linux-iio, mario.tesi, armando.visconti,
	denis.ciocca

Enable Latched interrupt by default for sensor events

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 | 35 ++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index 5e3cd96b0059..3ea0dc13d101 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -215,6 +215,7 @@ struct st_lsm6dsx_ext_dev_settings {
  * @fs_table: Hw sensors gain table (gain + val).
  * @decimator: List of decimator register info (addr + mask).
  * @batch: List of FIFO batching register info (addr + mask).
+ * @lir: Latched interrupt register info (addr + mask).
  * @fifo_ops: Sensor hw FIFO parameters.
  * @ts_settings: Hw timer related settings.
  * @shub_settings: i2c controller related settings.
@@ -237,6 +238,7 @@ struct st_lsm6dsx_settings {
 	struct st_lsm6dsx_fs_table_entry fs_table[2];
 	struct st_lsm6dsx_reg decimator[ST_LSM6DSX_MAX_ID];
 	struct st_lsm6dsx_reg batch[ST_LSM6DSX_MAX_ID];
+	struct st_lsm6dsx_reg lir;
 	struct st_lsm6dsx_fifo_ops fifo_ops;
 	struct st_lsm6dsx_hw_ts_settings ts_settings;
 	struct st_lsm6dsx_shub_settings shub_settings;
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 2d3495560136..a208da865efe 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -237,6 +237,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 				.mask = GENMASK(5, 3),
 			},
 		},
+		.lir = {
+			.addr = 0x58,
+			.mask = BIT(0),
+		},
 		.fifo_ops = {
 			.update_fifo = st_lsm6dsx_update_fifo,
 			.read_fifo = st_lsm6dsx_read_fifo,
@@ -349,6 +353,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 				.mask = GENMASK(5, 3),
 			},
 		},
+		.lir = {
+			.addr = 0x58,
+			.mask = BIT(0),
+		},
 		.fifo_ops = {
 			.update_fifo = st_lsm6dsx_update_fifo,
 			.read_fifo = st_lsm6dsx_read_fifo,
@@ -470,6 +478,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 				.mask = GENMASK(5, 3),
 			},
 		},
+		.lir = {
+			.addr = 0x58,
+			.mask = BIT(0),
+		},
 		.fifo_ops = {
 			.update_fifo = st_lsm6dsx_update_fifo,
 			.read_fifo = st_lsm6dsx_read_fifo,
@@ -585,6 +597,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 				.mask = GENMASK(7, 4),
 			},
 		},
+		.lir = {
+			.addr = 0x56,
+			.mask = BIT(0),
+		},
 		.fifo_ops = {
 			.update_fifo = st_lsm6dsx_update_fifo,
 			.read_fifo = st_lsm6dsx_read_tagged_fifo,
@@ -715,6 +731,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 				.mask = GENMASK(7, 4),
 			},
 		},
+		.lir = {
+			.addr = 0x56,
+			.mask = BIT(0),
+		},
 		.fifo_ops = {
 			.update_fifo = st_lsm6dsx_update_fifo,
 			.read_fifo = st_lsm6dsx_read_tagged_fifo,
@@ -822,6 +842,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 				.mask = GENMASK(7, 4),
 			},
 		},
+		.lir = {
+			.addr = 0x56,
+			.mask = BIT(0),
+		},
 		.fifo_ops = {
 			.update_fifo = st_lsm6dsx_update_fifo,
 			.read_fifo = st_lsm6dsx_read_tagged_fifo,
@@ -1416,6 +1440,17 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw)
 	if (err < 0)
 		return err;
 
+	/* enable Latched interrupts for device events */
+	if (hw->settings->lir.addr) {
+		unsigned int data;
+
+		data = ST_LSM6DSX_SHIFT_VAL(1, hw->settings->lir.mask);
+		err = regmap_update_bits(hw->regmap, hw->settings->lir.addr,
+					 hw->settings->lir.mask, data);
+		if (err < 0)
+			return err;
+	}
+
 	err = st_lsm6dsx_init_shub(hw);
 	if (err < 0)
 		return err;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] iio: imu: st_lsm6dsx: enable clear on read for latched interrupts
  2019-09-11  6:50 [PATCH 0/2] enable LIR and clear_on_read for st_lsm6dsx Lorenzo Bianconi
  2019-09-11  6:50 ` [PATCH 1/2] iio: imu: st_lsm6dsx: enable LIR for sensor events Lorenzo Bianconi
@ 2019-09-11  6:50 ` Lorenzo Bianconi
  2019-09-11 12:37   ` Sean Nyekjaer
  1 sibling, 1 reply; 7+ messages in thread
From: Lorenzo Bianconi @ 2019-09-11  6:50 UTC (permalink / raw)
  To: jic23
  Cc: sean, lorenzo.bianconi, linux-iio, mario.tesi, armando.visconti,
	denis.ciocca

Enable clear on read feature for latched interrupts. This bit allows
immediately clearing the latched interrupts of an event detection upon
the read of the corresponding status register.
It must be set to 1 together with LIR.
This feature is available just on LSM6DS0/LSM6DSR/ASM330LHH

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 | 24 ++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index 3ea0dc13d101..fefd9042590a 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -216,6 +216,7 @@ struct st_lsm6dsx_ext_dev_settings {
  * @decimator: List of decimator register info (addr + mask).
  * @batch: List of FIFO batching register info (addr + mask).
  * @lir: Latched interrupt register info (addr + mask).
+ * @clear_on_read: Clear on read register info (addr + mask).
  * @fifo_ops: Sensor hw FIFO parameters.
  * @ts_settings: Hw timer related settings.
  * @shub_settings: i2c controller related settings.
@@ -239,6 +240,7 @@ struct st_lsm6dsx_settings {
 	struct st_lsm6dsx_reg decimator[ST_LSM6DSX_MAX_ID];
 	struct st_lsm6dsx_reg batch[ST_LSM6DSX_MAX_ID];
 	struct st_lsm6dsx_reg lir;
+	struct st_lsm6dsx_reg clear_on_read;
 	struct st_lsm6dsx_fifo_ops fifo_ops;
 	struct st_lsm6dsx_hw_ts_settings ts_settings;
 	struct st_lsm6dsx_shub_settings shub_settings;
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index a208da865efe..b65a6ca775e0 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -601,6 +601,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 			.addr = 0x56,
 			.mask = BIT(0),
 		},
+		.clear_on_read = {
+			.addr = 0x56,
+			.mask = BIT(6),
+		},
 		.fifo_ops = {
 			.update_fifo = st_lsm6dsx_update_fifo,
 			.read_fifo = st_lsm6dsx_read_tagged_fifo,
@@ -735,6 +739,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 			.addr = 0x56,
 			.mask = BIT(0),
 		},
+		.clear_on_read = {
+			.addr = 0x56,
+			.mask = BIT(6),
+		},
 		.fifo_ops = {
 			.update_fifo = st_lsm6dsx_update_fifo,
 			.read_fifo = st_lsm6dsx_read_tagged_fifo,
@@ -846,6 +854,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
 			.addr = 0x56,
 			.mask = BIT(0),
 		},
+		.clear_on_read = {
+			.addr = 0x56,
+			.mask = BIT(6),
+		},
 		.fifo_ops = {
 			.update_fifo = st_lsm6dsx_update_fifo,
 			.read_fifo = st_lsm6dsx_read_tagged_fifo,
@@ -1449,6 +1461,18 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw)
 					 hw->settings->lir.mask, data);
 		if (err < 0)
 			return err;
+
+		/* enable clear on read for latched interrupts */
+		if (hw->settings->clear_on_read.addr) {
+			data = ST_LSM6DSX_SHIFT_VAL(1,
+					hw->settings->clear_on_read.mask);
+			err = regmap_update_bits(hw->regmap,
+					hw->settings->clear_on_read.addr,
+					hw->settings->clear_on_read.mask,
+					data);
+			if (err < 0)
+				return err;
+		}
 	}
 
 	err = st_lsm6dsx_init_shub(hw);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] iio: imu: st_lsm6dsx: enable clear on read for latched interrupts
  2019-09-11  6:50 ` [PATCH 2/2] iio: imu: st_lsm6dsx: enable clear on read for latched interrupts Lorenzo Bianconi
@ 2019-09-11 12:37   ` Sean Nyekjaer
  2019-09-15 11:03     ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Sean Nyekjaer @ 2019-09-11 12:37 UTC (permalink / raw)
  To: Lorenzo Bianconi, jic23
  Cc: lorenzo.bianconi, linux-iio, mario.tesi, armando.visconti, denis.ciocca



On 11/09/2019 08.50, Lorenzo Bianconi wrote:
> Enable clear on read feature for latched interrupts. This bit allows
> immediately clearing the latched interrupts of an event detection upon
> the read of the corresponding status register.
> It must be set to 1 together with LIR.
> This feature is available just on LSM6DS0/LSM6DSR/ASM330LHH
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Sean Nyekjaer <sean@geanix.com>
> ---
>   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  2 ++
>   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 24 ++++++++++++++++++++
>   2 files changed, 26 insertions(+)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index 3ea0dc13d101..fefd9042590a 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -216,6 +216,7 @@ struct st_lsm6dsx_ext_dev_settings {
>    * @decimator: List of decimator register info (addr + mask).
>    * @batch: List of FIFO batching register info (addr + mask).
>    * @lir: Latched interrupt register info (addr + mask).
> + * @clear_on_read: Clear on read register info (addr + mask).
>    * @fifo_ops: Sensor hw FIFO parameters.
>    * @ts_settings: Hw timer related settings.
>    * @shub_settings: i2c controller related settings.
> @@ -239,6 +240,7 @@ struct st_lsm6dsx_settings {
>   	struct st_lsm6dsx_reg decimator[ST_LSM6DSX_MAX_ID];
>   	struct st_lsm6dsx_reg batch[ST_LSM6DSX_MAX_ID];
>   	struct st_lsm6dsx_reg lir;
> +	struct st_lsm6dsx_reg clear_on_read;
>   	struct st_lsm6dsx_fifo_ops fifo_ops;
>   	struct st_lsm6dsx_hw_ts_settings ts_settings;
>   	struct st_lsm6dsx_shub_settings shub_settings;
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index a208da865efe..b65a6ca775e0 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -601,6 +601,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>   			.addr = 0x56,
>   			.mask = BIT(0),
>   		},
> +		.clear_on_read = {
> +			.addr = 0x56,
> +			.mask = BIT(6),
> +		},
>   		.fifo_ops = {
>   			.update_fifo = st_lsm6dsx_update_fifo,
>   			.read_fifo = st_lsm6dsx_read_tagged_fifo,
> @@ -735,6 +739,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>   			.addr = 0x56,
>   			.mask = BIT(0),
>   		},
> +		.clear_on_read = {
> +			.addr = 0x56,
> +			.mask = BIT(6),
> +		},
>   		.fifo_ops = {
>   			.update_fifo = st_lsm6dsx_update_fifo,
>   			.read_fifo = st_lsm6dsx_read_tagged_fifo,
> @@ -846,6 +854,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>   			.addr = 0x56,
>   			.mask = BIT(0),
>   		},
> +		.clear_on_read = {
> +			.addr = 0x56,
> +			.mask = BIT(6),
> +		},
>   		.fifo_ops = {
>   			.update_fifo = st_lsm6dsx_update_fifo,
>   			.read_fifo = st_lsm6dsx_read_tagged_fifo,
> @@ -1449,6 +1461,18 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw)
>   					 hw->settings->lir.mask, data);
>   		if (err < 0)
>   			return err;
> +
> +		/* enable clear on read for latched interrupts */
> +		if (hw->settings->clear_on_read.addr) {
> +			data = ST_LSM6DSX_SHIFT_VAL(1,
> +					hw->settings->clear_on_read.mask);
> +			err = regmap_update_bits(hw->regmap,
> +					hw->settings->clear_on_read.addr,
> +					hw->settings->clear_on_read.mask,
> +					data);
> +			if (err < 0)
> +				return err;
> +		}
>   	}
>   
>   	err = st_lsm6dsx_init_shub(hw);
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: enable LIR for sensor events
  2019-09-11  6:50 ` [PATCH 1/2] iio: imu: st_lsm6dsx: enable LIR for sensor events Lorenzo Bianconi
@ 2019-09-11 12:37   ` Sean Nyekjaer
  2019-09-15 10:57     ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Sean Nyekjaer @ 2019-09-11 12:37 UTC (permalink / raw)
  To: Lorenzo Bianconi, jic23
  Cc: lorenzo.bianconi, linux-iio, mario.tesi, armando.visconti, denis.ciocca



On 11/09/2019 08.50, Lorenzo Bianconi wrote:
> Enable Latched interrupt by default for sensor events
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Sean Nyekjaer <sean@geanix.com>
> ---
>   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  2 ++
>   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 35 ++++++++++++++++++++
>   2 files changed, 37 insertions(+)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index 5e3cd96b0059..3ea0dc13d101 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -215,6 +215,7 @@ struct st_lsm6dsx_ext_dev_settings {
>    * @fs_table: Hw sensors gain table (gain + val).
>    * @decimator: List of decimator register info (addr + mask).
>    * @batch: List of FIFO batching register info (addr + mask).
> + * @lir: Latched interrupt register info (addr + mask).
>    * @fifo_ops: Sensor hw FIFO parameters.
>    * @ts_settings: Hw timer related settings.
>    * @shub_settings: i2c controller related settings.
> @@ -237,6 +238,7 @@ struct st_lsm6dsx_settings {
>   	struct st_lsm6dsx_fs_table_entry fs_table[2];
>   	struct st_lsm6dsx_reg decimator[ST_LSM6DSX_MAX_ID];
>   	struct st_lsm6dsx_reg batch[ST_LSM6DSX_MAX_ID];
> +	struct st_lsm6dsx_reg lir;
>   	struct st_lsm6dsx_fifo_ops fifo_ops;
>   	struct st_lsm6dsx_hw_ts_settings ts_settings;
>   	struct st_lsm6dsx_shub_settings shub_settings;
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 2d3495560136..a208da865efe 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -237,6 +237,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>   				.mask = GENMASK(5, 3),
>   			},
>   		},
> +		.lir = {
> +			.addr = 0x58,
> +			.mask = BIT(0),
> +		},
>   		.fifo_ops = {
>   			.update_fifo = st_lsm6dsx_update_fifo,
>   			.read_fifo = st_lsm6dsx_read_fifo,
> @@ -349,6 +353,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>   				.mask = GENMASK(5, 3),
>   			},
>   		},
> +		.lir = {
> +			.addr = 0x58,
> +			.mask = BIT(0),
> +		},
>   		.fifo_ops = {
>   			.update_fifo = st_lsm6dsx_update_fifo,
>   			.read_fifo = st_lsm6dsx_read_fifo,
> @@ -470,6 +478,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>   				.mask = GENMASK(5, 3),
>   			},
>   		},
> +		.lir = {
> +			.addr = 0x58,
> +			.mask = BIT(0),
> +		},
>   		.fifo_ops = {
>   			.update_fifo = st_lsm6dsx_update_fifo,
>   			.read_fifo = st_lsm6dsx_read_fifo,
> @@ -585,6 +597,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>   				.mask = GENMASK(7, 4),
>   			},
>   		},
> +		.lir = {
> +			.addr = 0x56,
> +			.mask = BIT(0),
> +		},
>   		.fifo_ops = {
>   			.update_fifo = st_lsm6dsx_update_fifo,
>   			.read_fifo = st_lsm6dsx_read_tagged_fifo,
> @@ -715,6 +731,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>   				.mask = GENMASK(7, 4),
>   			},
>   		},
> +		.lir = {
> +			.addr = 0x56,
> +			.mask = BIT(0),
> +		},
>   		.fifo_ops = {
>   			.update_fifo = st_lsm6dsx_update_fifo,
>   			.read_fifo = st_lsm6dsx_read_tagged_fifo,
> @@ -822,6 +842,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
>   				.mask = GENMASK(7, 4),
>   			},
>   		},
> +		.lir = {
> +			.addr = 0x56,
> +			.mask = BIT(0),
> +		},
>   		.fifo_ops = {
>   			.update_fifo = st_lsm6dsx_update_fifo,
>   			.read_fifo = st_lsm6dsx_read_tagged_fifo,
> @@ -1416,6 +1440,17 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw)
>   	if (err < 0)
>   		return err;
>   
> +	/* enable Latched interrupts for device events */
> +	if (hw->settings->lir.addr) {
> +		unsigned int data;
> +
> +		data = ST_LSM6DSX_SHIFT_VAL(1, hw->settings->lir.mask);
> +		err = regmap_update_bits(hw->regmap, hw->settings->lir.addr,
> +					 hw->settings->lir.mask, data);
> +		if (err < 0)
> +			return err;
> +	}
> +
>   	err = st_lsm6dsx_init_shub(hw);
>   	if (err < 0)
>   		return err;
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: enable LIR for sensor events
  2019-09-11 12:37   ` Sean Nyekjaer
@ 2019-09-15 10:57     ` Jonathan Cameron
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2019-09-15 10:57 UTC (permalink / raw)
  To: Sean Nyekjaer
  Cc: Lorenzo Bianconi, lorenzo.bianconi, linux-iio, mario.tesi,
	armando.visconti, denis.ciocca

On Wed, 11 Sep 2019 14:37:23 +0200
Sean Nyekjaer <sean@geanix.com> wrote:

> On 11/09/2019 08.50, Lorenzo Bianconi wrote:
> > Enable Latched interrupt by default for sensor events
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>  
> Tested-by: Sean Nyekjaer <sean@geanix.com>

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> > ---
> >   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  2 ++
> >   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 35 ++++++++++++++++++++
> >   2 files changed, 37 insertions(+)
> > 
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > index 5e3cd96b0059..3ea0dc13d101 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > @@ -215,6 +215,7 @@ struct st_lsm6dsx_ext_dev_settings {
> >    * @fs_table: Hw sensors gain table (gain + val).
> >    * @decimator: List of decimator register info (addr + mask).
> >    * @batch: List of FIFO batching register info (addr + mask).
> > + * @lir: Latched interrupt register info (addr + mask).
> >    * @fifo_ops: Sensor hw FIFO parameters.
> >    * @ts_settings: Hw timer related settings.
> >    * @shub_settings: i2c controller related settings.
> > @@ -237,6 +238,7 @@ struct st_lsm6dsx_settings {
> >   	struct st_lsm6dsx_fs_table_entry fs_table[2];
> >   	struct st_lsm6dsx_reg decimator[ST_LSM6DSX_MAX_ID];
> >   	struct st_lsm6dsx_reg batch[ST_LSM6DSX_MAX_ID];
> > +	struct st_lsm6dsx_reg lir;
> >   	struct st_lsm6dsx_fifo_ops fifo_ops;
> >   	struct st_lsm6dsx_hw_ts_settings ts_settings;
> >   	struct st_lsm6dsx_shub_settings shub_settings;
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > index 2d3495560136..a208da865efe 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > @@ -237,6 +237,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >   				.mask = GENMASK(5, 3),
> >   			},
> >   		},
> > +		.lir = {
> > +			.addr = 0x58,
> > +			.mask = BIT(0),
> > +		},
> >   		.fifo_ops = {
> >   			.update_fifo = st_lsm6dsx_update_fifo,
> >   			.read_fifo = st_lsm6dsx_read_fifo,
> > @@ -349,6 +353,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >   				.mask = GENMASK(5, 3),
> >   			},
> >   		},
> > +		.lir = {
> > +			.addr = 0x58,
> > +			.mask = BIT(0),
> > +		},
> >   		.fifo_ops = {
> >   			.update_fifo = st_lsm6dsx_update_fifo,
> >   			.read_fifo = st_lsm6dsx_read_fifo,
> > @@ -470,6 +478,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >   				.mask = GENMASK(5, 3),
> >   			},
> >   		},
> > +		.lir = {
> > +			.addr = 0x58,
> > +			.mask = BIT(0),
> > +		},
> >   		.fifo_ops = {
> >   			.update_fifo = st_lsm6dsx_update_fifo,
> >   			.read_fifo = st_lsm6dsx_read_fifo,
> > @@ -585,6 +597,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >   				.mask = GENMASK(7, 4),
> >   			},
> >   		},
> > +		.lir = {
> > +			.addr = 0x56,
> > +			.mask = BIT(0),
> > +		},
> >   		.fifo_ops = {
> >   			.update_fifo = st_lsm6dsx_update_fifo,
> >   			.read_fifo = st_lsm6dsx_read_tagged_fifo,
> > @@ -715,6 +731,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >   				.mask = GENMASK(7, 4),
> >   			},
> >   		},
> > +		.lir = {
> > +			.addr = 0x56,
> > +			.mask = BIT(0),
> > +		},
> >   		.fifo_ops = {
> >   			.update_fifo = st_lsm6dsx_update_fifo,
> >   			.read_fifo = st_lsm6dsx_read_tagged_fifo,
> > @@ -822,6 +842,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >   				.mask = GENMASK(7, 4),
> >   			},
> >   		},
> > +		.lir = {
> > +			.addr = 0x56,
> > +			.mask = BIT(0),
> > +		},
> >   		.fifo_ops = {
> >   			.update_fifo = st_lsm6dsx_update_fifo,
> >   			.read_fifo = st_lsm6dsx_read_tagged_fifo,
> > @@ -1416,6 +1440,17 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw)
> >   	if (err < 0)
> >   		return err;
> >   
> > +	/* enable Latched interrupts for device events */
> > +	if (hw->settings->lir.addr) {
> > +		unsigned int data;
> > +
> > +		data = ST_LSM6DSX_SHIFT_VAL(1, hw->settings->lir.mask);
> > +		err = regmap_update_bits(hw->regmap, hw->settings->lir.addr,
> > +					 hw->settings->lir.mask, data);
> > +		if (err < 0)
> > +			return err;
> > +	}
> > +
> >   	err = st_lsm6dsx_init_shub(hw);
> >   	if (err < 0)
> >   		return err;
> >   


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] iio: imu: st_lsm6dsx: enable clear on read for latched interrupts
  2019-09-11 12:37   ` Sean Nyekjaer
@ 2019-09-15 11:03     ` Jonathan Cameron
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2019-09-15 11:03 UTC (permalink / raw)
  To: Sean Nyekjaer
  Cc: Lorenzo Bianconi, lorenzo.bianconi, linux-iio, mario.tesi,
	armando.visconti, denis.ciocca

On Wed, 11 Sep 2019 14:37:16 +0200
Sean Nyekjaer <sean@geanix.com> wrote:

> On 11/09/2019 08.50, Lorenzo Bianconi wrote:
> > Enable clear on read feature for latched interrupts. This bit allows
> > immediately clearing the latched interrupts of an event detection upon
> > the read of the corresponding status register.
> > It must be set to 1 together with LIR.
> > This feature is available just on LSM6DS0/LSM6DSR/ASM330LHH
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>  
> Tested-by: Sean Nyekjaer <sean@geanix.com>

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> > ---
> >   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  2 ++
> >   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 24 ++++++++++++++++++++
> >   2 files changed, 26 insertions(+)
> > 
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > index 3ea0dc13d101..fefd9042590a 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > @@ -216,6 +216,7 @@ struct st_lsm6dsx_ext_dev_settings {
> >    * @decimator: List of decimator register info (addr + mask).
> >    * @batch: List of FIFO batching register info (addr + mask).
> >    * @lir: Latched interrupt register info (addr + mask).
> > + * @clear_on_read: Clear on read register info (addr + mask).
> >    * @fifo_ops: Sensor hw FIFO parameters.
> >    * @ts_settings: Hw timer related settings.
> >    * @shub_settings: i2c controller related settings.
> > @@ -239,6 +240,7 @@ struct st_lsm6dsx_settings {
> >   	struct st_lsm6dsx_reg decimator[ST_LSM6DSX_MAX_ID];
> >   	struct st_lsm6dsx_reg batch[ST_LSM6DSX_MAX_ID];
> >   	struct st_lsm6dsx_reg lir;
> > +	struct st_lsm6dsx_reg clear_on_read;
> >   	struct st_lsm6dsx_fifo_ops fifo_ops;
> >   	struct st_lsm6dsx_hw_ts_settings ts_settings;
> >   	struct st_lsm6dsx_shub_settings shub_settings;
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > index a208da865efe..b65a6ca775e0 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > @@ -601,6 +601,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >   			.addr = 0x56,
> >   			.mask = BIT(0),
> >   		},
> > +		.clear_on_read = {
> > +			.addr = 0x56,
> > +			.mask = BIT(6),
> > +		},
> >   		.fifo_ops = {
> >   			.update_fifo = st_lsm6dsx_update_fifo,
> >   			.read_fifo = st_lsm6dsx_read_tagged_fifo,
> > @@ -735,6 +739,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >   			.addr = 0x56,
> >   			.mask = BIT(0),
> >   		},
> > +		.clear_on_read = {
> > +			.addr = 0x56,
> > +			.mask = BIT(6),
> > +		},
> >   		.fifo_ops = {
> >   			.update_fifo = st_lsm6dsx_update_fifo,
> >   			.read_fifo = st_lsm6dsx_read_tagged_fifo,
> > @@ -846,6 +854,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> >   			.addr = 0x56,
> >   			.mask = BIT(0),
> >   		},
> > +		.clear_on_read = {
> > +			.addr = 0x56,
> > +			.mask = BIT(6),
> > +		},
> >   		.fifo_ops = {
> >   			.update_fifo = st_lsm6dsx_update_fifo,
> >   			.read_fifo = st_lsm6dsx_read_tagged_fifo,
> > @@ -1449,6 +1461,18 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw)
> >   					 hw->settings->lir.mask, data);
> >   		if (err < 0)
> >   			return err;
> > +
> > +		/* enable clear on read for latched interrupts */
> > +		if (hw->settings->clear_on_read.addr) {
> > +			data = ST_LSM6DSX_SHIFT_VAL(1,
> > +					hw->settings->clear_on_read.mask);
> > +			err = regmap_update_bits(hw->regmap,
> > +					hw->settings->clear_on_read.addr,
> > +					hw->settings->clear_on_read.mask,
> > +					data);
> > +			if (err < 0)
> > +				return err;
> > +		}
> >   	}
> >   
> >   	err = st_lsm6dsx_init_shub(hw);
> >   


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-09-15 11:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11  6:50 [PATCH 0/2] enable LIR and clear_on_read for st_lsm6dsx Lorenzo Bianconi
2019-09-11  6:50 ` [PATCH 1/2] iio: imu: st_lsm6dsx: enable LIR for sensor events Lorenzo Bianconi
2019-09-11 12:37   ` Sean Nyekjaer
2019-09-15 10:57     ` Jonathan Cameron
2019-09-11  6:50 ` [PATCH 2/2] iio: imu: st_lsm6dsx: enable clear on read for latched interrupts Lorenzo Bianconi
2019-09-11 12:37   ` Sean Nyekjaer
2019-09-15 11:03     ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.