linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Add support for falling-low_level interrupts
@ 2017-06-07 18:17 Lorenzo Bianconi
  2017-06-07 18:17 ` [PATCH 1/2] iio: imu: st_lsm6dsx: support active-low interrupts Lorenzo Bianconi
  2017-06-07 18:17 ` [PATCH 2/2] Documentation: dt: " Lorenzo Bianconi
  0 siblings, 2 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2017-06-07 18:17 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, devicetree, lorenzo.bianconi

Lorenzo Bianconi (2):
  iio: imu: st_lsm6dsx: support active-low interrupts
  Documentation: dt: iio: imu: st_lsm6dsx: support active-low interrupts

 Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt |  3 ++-
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c           | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

-- 
2.12.2

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

* [PATCH 1/2] iio: imu: st_lsm6dsx: support active-low interrupts
  2017-06-07 18:17 [PATCH 0/2] Add support for falling-low_level interrupts Lorenzo Bianconi
@ 2017-06-07 18:17 ` Lorenzo Bianconi
  2017-06-11 11:42   ` Jonathan Cameron
  2017-06-07 18:17 ` [PATCH 2/2] Documentation: dt: " Lorenzo Bianconi
  1 sibling, 1 reply; 6+ messages in thread
From: Lorenzo Bianconi @ 2017-06-07 18:17 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, devicetree, lorenzo.bianconi

Add support for active low interrupts (IRQF_TRIGGER_LOW and
IRQF_TRIGGER_FALLING). Configure the device as active high or low
according to the requested irq line.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
index b19a62d8c884..2a72acc6e049 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
@@ -37,6 +37,8 @@
 #define ST_LSM6DSX_REG_FIFO_THH_ADDR		0x07
 #define ST_LSM6DSX_FIFO_TH_MASK			GENMASK(11, 0)
 #define ST_LSM6DSX_REG_FIFO_DEC_GXL_ADDR	0x08
+#define ST_LSM6DSX_REG_HLACTIVE_ADDR		0x12
+#define ST_LSM6DSX_REG_HLACTIVE_MASK		BIT(5)
 #define ST_LSM6DSX_REG_FIFO_MODE_ADDR		0x0a
 #define ST_LSM6DSX_FIFO_MODE_MASK		GENMASK(2, 0)
 #define ST_LSM6DSX_FIFO_ODR_MASK		GENMASK(6, 3)
@@ -417,6 +419,7 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
 {
 	struct iio_buffer *buffer;
 	unsigned long irq_type;
+	bool irq_active_low;
 	int i, err;
 
 	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
@@ -424,12 +427,23 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:
 	case IRQF_TRIGGER_RISING:
+		irq_active_low = false;
+		break;
+	case IRQF_TRIGGER_LOW:
+	case IRQF_TRIGGER_FALLING:
+		irq_active_low = true;
 		break;
 	default:
 		dev_info(hw->dev, "mode %lx unsupported\n", irq_type);
 		return -EINVAL;
 	}
 
+	err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_HLACTIVE_ADDR,
+					 ST_LSM6DSX_REG_HLACTIVE_MASK,
+					 irq_active_low);
+	if (err < 0)
+		return err;
+
 	err = devm_request_threaded_irq(hw->dev, hw->irq,
 					st_lsm6dsx_handler_irq,
 					st_lsm6dsx_handler_thread,
-- 
2.12.2

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

* [PATCH 2/2] Documentation: dt: iio: imu: st_lsm6dsx: support active-low interrupts
  2017-06-07 18:17 [PATCH 0/2] Add support for falling-low_level interrupts Lorenzo Bianconi
  2017-06-07 18:17 ` [PATCH 1/2] iio: imu: st_lsm6dsx: support active-low interrupts Lorenzo Bianconi
@ 2017-06-07 18:17 ` Lorenzo Bianconi
  2017-06-09 14:18   ` Rob Herring
  1 sibling, 1 reply; 6+ messages in thread
From: Lorenzo Bianconi @ 2017-06-07 18:17 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, devicetree, lorenzo.bianconi

Update st_lsm6dsx device binding with active-low interrupts support
(IRQ_TYPE_LEVEL_LOW and IRQ_TYPE_EDGE_FALLING).

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
 Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
index 8305fb05ffda..6f28ff55f3ec 100644
--- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
+++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
@@ -13,7 +13,8 @@ Optional properties:
   "data ready" (valid values: 1 or 2).
 - interrupt-parent: should be the phandle for the interrupt controller
 - interrupts: interrupt mapping for IRQ. It should be configured with
-  flags IRQ_TYPE_LEVEL_HIGH or IRQ_TYPE_EDGE_RISING.
+  flags IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_EDGE_RISING, IRQ_TYPE_LEVEL_LOW or
+  IRQ_TYPE_EDGE_FALLING.
 
   Refer to interrupt-controller/interrupts.txt for generic interrupt
   client node bindings.
-- 
2.12.2

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

* Re: [PATCH 2/2] Documentation: dt: iio: imu: st_lsm6dsx: support active-low interrupts
  2017-06-07 18:17 ` [PATCH 2/2] Documentation: dt: " Lorenzo Bianconi
@ 2017-06-09 14:18   ` Rob Herring
  2017-06-11 11:47     ` Jonathan Cameron
  0 siblings, 1 reply; 6+ messages in thread
From: Rob Herring @ 2017-06-09 14:18 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: jic23, linux-iio, devicetree, lorenzo.bianconi

On Wed, Jun 07, 2017 at 08:17:11PM +0200, Lorenzo Bianconi wrote:
> Update st_lsm6dsx device binding with active-low interrupts support
> (IRQ_TYPE_LEVEL_LOW and IRQ_TYPE_EDGE_FALLING).
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> ---
>  Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

"dt-bindings: iio: ..." is preferred for subject. Otherwise,

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: support active-low interrupts
  2017-06-07 18:17 ` [PATCH 1/2] iio: imu: st_lsm6dsx: support active-low interrupts Lorenzo Bianconi
@ 2017-06-11 11:42   ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2017-06-11 11:42 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-iio, devicetree, lorenzo.bianconi

On Wed,  7 Jun 2017 20:17:10 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:

> Add support for active low interrupts (IRQF_TRIGGER_LOW and
> IRQF_TRIGGER_FALLING). Configure the device as active high or low
> according to the requested irq line.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Applied to the togreg branch of iio.git.

The recent discussions about inverters in the path (used for level
conversion) does make me wonder if we are handling these sort
of cases well, but this certainly doesn't make things worse
so let's go for it for now and keep that discussion separate.

Jonathan
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> index b19a62d8c884..2a72acc6e049 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> @@ -37,6 +37,8 @@
>  #define ST_LSM6DSX_REG_FIFO_THH_ADDR		0x07
>  #define ST_LSM6DSX_FIFO_TH_MASK			GENMASK(11, 0)
>  #define ST_LSM6DSX_REG_FIFO_DEC_GXL_ADDR	0x08
> +#define ST_LSM6DSX_REG_HLACTIVE_ADDR		0x12
> +#define ST_LSM6DSX_REG_HLACTIVE_MASK		BIT(5)
>  #define ST_LSM6DSX_REG_FIFO_MODE_ADDR		0x0a
>  #define ST_LSM6DSX_FIFO_MODE_MASK		GENMASK(2, 0)
>  #define ST_LSM6DSX_FIFO_ODR_MASK		GENMASK(6, 3)
> @@ -417,6 +419,7 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
>  {
>  	struct iio_buffer *buffer;
>  	unsigned long irq_type;
> +	bool irq_active_low;
>  	int i, err;
>  
>  	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
> @@ -424,12 +427,23 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
>  	switch (irq_type) {
>  	case IRQF_TRIGGER_HIGH:
>  	case IRQF_TRIGGER_RISING:
> +		irq_active_low = false;
> +		break;
> +	case IRQF_TRIGGER_LOW:
> +	case IRQF_TRIGGER_FALLING:
> +		irq_active_low = true;
>  		break;
>  	default:
>  		dev_info(hw->dev, "mode %lx unsupported\n", irq_type);
>  		return -EINVAL;
>  	}
>  
> +	err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_HLACTIVE_ADDR,
> +					 ST_LSM6DSX_REG_HLACTIVE_MASK,
> +					 irq_active_low);
> +	if (err < 0)
> +		return err;
> +
>  	err = devm_request_threaded_irq(hw->dev, hw->irq,
>  					st_lsm6dsx_handler_irq,
>  					st_lsm6dsx_handler_thread,


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

* Re: [PATCH 2/2] Documentation: dt: iio: imu: st_lsm6dsx: support active-low interrupts
  2017-06-09 14:18   ` Rob Herring
@ 2017-06-11 11:47     ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2017-06-11 11:47 UTC (permalink / raw)
  To: Rob Herring; +Cc: Lorenzo Bianconi, linux-iio, devicetree, lorenzo.bianconi

On Fri, 9 Jun 2017 09:18:16 -0500
Rob Herring <robh@kernel.org> wrote:

> On Wed, Jun 07, 2017 at 08:17:11PM +0200, Lorenzo Bianconi wrote:
> > Update st_lsm6dsx device binding with active-low interrupts support
> > (IRQ_TYPE_LEVEL_LOW and IRQ_TYPE_EDGE_FALLING).
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> > ---
> >  Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)  
> 
> "dt-bindings: iio: ..." is preferred for subject. Otherwise,
> 
> Acked-by: Rob Herring <robh@kernel.org>

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

Thanks,

Jonathan

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

end of thread, other threads:[~2017-06-11 11:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-07 18:17 [PATCH 0/2] Add support for falling-low_level interrupts Lorenzo Bianconi
2017-06-07 18:17 ` [PATCH 1/2] iio: imu: st_lsm6dsx: support active-low interrupts Lorenzo Bianconi
2017-06-11 11:42   ` Jonathan Cameron
2017-06-07 18:17 ` [PATCH 2/2] Documentation: dt: " Lorenzo Bianconi
2017-06-09 14:18   ` Rob Herring
2017-06-11 11:47     ` 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).