All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Add open drain support to st_lsm6dsx
@ 2017-06-21 19:21 ` Lorenzo Bianconi
  0 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-06-21 19:21 UTC (permalink / raw)
  To: jic23-DgEjT+Ai2ygdnm+yROfE0A
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o

Lorenzo Bianconi (2):
  iio: imu: st_lsm6dsx: support open drain mode
  dt-bindings: iio: imu: st_lsm6dsx: support open drain mode

 .../devicetree/bindings/iio/imu/st_lsm6dsx.txt          |  8 ++++++++
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c          | 17 +++++++++++++++++
 2 files changed, 25 insertions(+)

-- 
2.13.1

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

* [PATCH 0/2] Add open drain support to st_lsm6dsx
@ 2017-06-21 19:21 ` Lorenzo Bianconi
  0 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-06-21 19:21 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, devicetree, lorenzo.bianconi

Lorenzo Bianconi (2):
  iio: imu: st_lsm6dsx: support open drain mode
  dt-bindings: iio: imu: st_lsm6dsx: support open drain mode

 .../devicetree/bindings/iio/imu/st_lsm6dsx.txt          |  8 ++++++++
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c          | 17 +++++++++++++++++
 2 files changed, 25 insertions(+)

-- 
2.13.1

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

* [PATCH 1/2] iio: imu: st_lsm6dsx: support open drain mode
  2017-06-21 19:21 ` Lorenzo Bianconi
@ 2017-06-21 19:21     ` Lorenzo Bianconi
  -1 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-06-21 19:21 UTC (permalink / raw)
  To: jic23-DgEjT+Ai2ygdnm+yROfE0A
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o

Add open drain support in order to share requested IRQ line between
st_lsm6dsx device and other peripherals

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
index 2a72acc6e049..e2737dc71b67 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
@@ -31,6 +31,8 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/buffer.h>
 
+#include <linux/platform_data/st_sensors_pdata.h>
+
 #include "st_lsm6dsx.h"
 
 #define ST_LSM6DSX_REG_FIFO_THL_ADDR		0x06
@@ -39,6 +41,8 @@
 #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_PP_OD_ADDR		0x12
+#define ST_LSM6DSX_REG_PP_OD_MASK		BIT(4)
 #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 +421,8 @@ static const struct iio_buffer_setup_ops st_lsm6dsx_buffer_ops = {
 
 int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
 {
+	struct device_node *np = hw->dev->of_node;
+	struct st_sensors_platform_data *pdata;
 	struct iio_buffer *buffer;
 	unsigned long irq_type;
 	bool irq_active_low;
@@ -444,6 +450,17 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
 	if (err < 0)
 		return err;
 
+	pdata = (struct st_sensors_platform_data *)hw->dev->platform_data;
+	if ((np && of_property_read_bool(np, "drive-open-drain")) ||
+	    (pdata && pdata->open_drain)) {
+		err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_PP_OD_ADDR,
+						 ST_LSM6DSX_REG_PP_OD_MASK, 1);
+		if (err < 0)
+			return err;
+
+		irq_type |= IRQF_SHARED;
+	}
+
 	err = devm_request_threaded_irq(hw->dev, hw->irq,
 					st_lsm6dsx_handler_irq,
 					st_lsm6dsx_handler_thread,
-- 
2.13.1

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

* [PATCH 1/2] iio: imu: st_lsm6dsx: support open drain mode
@ 2017-06-21 19:21     ` Lorenzo Bianconi
  0 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-06-21 19:21 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, devicetree, lorenzo.bianconi

Add open drain support in order to share requested IRQ line between
st_lsm6dsx device and other peripherals

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

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
index 2a72acc6e049..e2737dc71b67 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
@@ -31,6 +31,8 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/buffer.h>
 
+#include <linux/platform_data/st_sensors_pdata.h>
+
 #include "st_lsm6dsx.h"
 
 #define ST_LSM6DSX_REG_FIFO_THL_ADDR		0x06
@@ -39,6 +41,8 @@
 #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_PP_OD_ADDR		0x12
+#define ST_LSM6DSX_REG_PP_OD_MASK		BIT(4)
 #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 +421,8 @@ static const struct iio_buffer_setup_ops st_lsm6dsx_buffer_ops = {
 
 int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
 {
+	struct device_node *np = hw->dev->of_node;
+	struct st_sensors_platform_data *pdata;
 	struct iio_buffer *buffer;
 	unsigned long irq_type;
 	bool irq_active_low;
@@ -444,6 +450,17 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
 	if (err < 0)
 		return err;
 
+	pdata = (struct st_sensors_platform_data *)hw->dev->platform_data;
+	if ((np && of_property_read_bool(np, "drive-open-drain")) ||
+	    (pdata && pdata->open_drain)) {
+		err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_PP_OD_ADDR,
+						 ST_LSM6DSX_REG_PP_OD_MASK, 1);
+		if (err < 0)
+			return err;
+
+		irq_type |= IRQF_SHARED;
+	}
+
 	err = devm_request_threaded_irq(hw->dev, hw->irq,
 					st_lsm6dsx_handler_irq,
 					st_lsm6dsx_handler_thread,
-- 
2.13.1


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

* [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: support open drain mode
  2017-06-21 19:21 ` Lorenzo Bianconi
@ 2017-06-21 19:21     ` Lorenzo Bianconi
  -1 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-06-21 19:21 UTC (permalink / raw)
  To: jic23-DgEjT+Ai2ygdnm+yROfE0A
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
---
 Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
index 6f28ff55f3ec..1ff1af799c76 100644
--- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
+++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
@@ -11,6 +11,14 @@ Required properties:
 Optional properties:
 - st,drdy-int-pin: the pin on the package that will be used to signal
   "data ready" (valid values: 1 or 2).
+- drive-open-drain: the interrupt/data ready line will be configured
+  as open drain, which is useful if several sensors share the same
+  interrupt line. This is a boolean property.
+  (This binding is taken from pinctrl/pinctrl-bindings.txt)
+  If the requested interrupt is configured as IRQ_TYPE_LEVEL_HIGH or
+  IRQ_TYPE_EDGE_RISING a pull-down resistor is needed to drive the line
+  when it is not active, whereas a pull-up one is needed when interrupt
+  line is configured as IRQ_TYPE_LEVEL_LOW or IRQ_TYPE_EDGE_FALLING.
 - 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, IRQ_TYPE_EDGE_RISING, IRQ_TYPE_LEVEL_LOW or
-- 
2.13.1

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

* [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: support open drain mode
@ 2017-06-21 19:21     ` Lorenzo Bianconi
  0 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-06-21 19:21 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, devicetree, lorenzo.bianconi

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

diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
index 6f28ff55f3ec..1ff1af799c76 100644
--- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
+++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
@@ -11,6 +11,14 @@ Required properties:
 Optional properties:
 - st,drdy-int-pin: the pin on the package that will be used to signal
   "data ready" (valid values: 1 or 2).
+- drive-open-drain: the interrupt/data ready line will be configured
+  as open drain, which is useful if several sensors share the same
+  interrupt line. This is a boolean property.
+  (This binding is taken from pinctrl/pinctrl-bindings.txt)
+  If the requested interrupt is configured as IRQ_TYPE_LEVEL_HIGH or
+  IRQ_TYPE_EDGE_RISING a pull-down resistor is needed to drive the line
+  when it is not active, whereas a pull-up one is needed when interrupt
+  line is configured as IRQ_TYPE_LEVEL_LOW or IRQ_TYPE_EDGE_FALLING.
 - 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, IRQ_TYPE_EDGE_RISING, IRQ_TYPE_LEVEL_LOW or
-- 
2.13.1


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

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: support open drain mode
  2017-06-21 19:21     ` Lorenzo Bianconi
@ 2017-06-24 20:08         ` Jonathan Cameron
  -1 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-06-24 20:08 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o

On Wed, 21 Jun 2017 21:21:28 +0200
Lorenzo Bianconi <lorenzo.bianconi83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Add open drain support in order to share requested IRQ line between
> st_lsm6dsx device and other peripherals
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
Issue when IRQF_RISING and open drain is set.

Otherwise looks good.
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> index 2a72acc6e049..e2737dc71b67 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> @@ -31,6 +31,8 @@
>  #include <linux/iio/iio.h>
>  #include <linux/iio/buffer.h>
>  
> +#include <linux/platform_data/st_sensors_pdata.h>
> +
>  #include "st_lsm6dsx.h"
>  
>  #define ST_LSM6DSX_REG_FIFO_THL_ADDR		0x06
> @@ -39,6 +41,8 @@
>  #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_PP_OD_ADDR		0x12
> +#define ST_LSM6DSX_REG_PP_OD_MASK		BIT(4)
>  #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 +421,8 @@ static const struct iio_buffer_setup_ops st_lsm6dsx_buffer_ops = {
>  
>  int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
>  {
> +	struct device_node *np = hw->dev->of_node;
> +	struct st_sensors_platform_data *pdata;
>  	struct iio_buffer *buffer;
>  	unsigned long irq_type;
>  	bool irq_active_low;
> @@ -444,6 +450,17 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
>  	if (err < 0)
>  		return err;
>  
> +	pdata = (struct st_sensors_platform_data *)hw->dev->platform_data;
> +	if ((np && of_property_read_bool(np, "drive-open-drain")) ||
> +	    (pdata && pdata->open_drain)) {
> +		err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_PP_OD_ADDR,
> +						 ST_LSM6DSX_REG_PP_OD_MASK, 1);
> +		if (err < 0)
> +			return err;
> +
> +		irq_type |= IRQF_SHARED;
> +	}
> +
In common with the mpu3050 which was the first driver in IIO to do open drain,
I think you need to think about precedence as we allow for IRQF_RISING
and IRQF_FALLING already.  Open drain only allows for shared interrupts
if IRQF_FALLING (I think)
>  	err = devm_request_threaded_irq(hw->dev, hw->irq,
>  					st_lsm6dsx_handler_irq,
>  					st_lsm6dsx_handler_thread,

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

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: support open drain mode
@ 2017-06-24 20:08         ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-06-24 20:08 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-iio, devicetree, lorenzo.bianconi

On Wed, 21 Jun 2017 21:21:28 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:

> Add open drain support in order to share requested IRQ line between
> st_lsm6dsx device and other peripherals
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Issue when IRQF_RISING and open drain is set.

Otherwise looks good.
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> index 2a72acc6e049..e2737dc71b67 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> @@ -31,6 +31,8 @@
>  #include <linux/iio/iio.h>
>  #include <linux/iio/buffer.h>
>  
> +#include <linux/platform_data/st_sensors_pdata.h>
> +
>  #include "st_lsm6dsx.h"
>  
>  #define ST_LSM6DSX_REG_FIFO_THL_ADDR		0x06
> @@ -39,6 +41,8 @@
>  #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_PP_OD_ADDR		0x12
> +#define ST_LSM6DSX_REG_PP_OD_MASK		BIT(4)
>  #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 +421,8 @@ static const struct iio_buffer_setup_ops st_lsm6dsx_buffer_ops = {
>  
>  int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
>  {
> +	struct device_node *np = hw->dev->of_node;
> +	struct st_sensors_platform_data *pdata;
>  	struct iio_buffer *buffer;
>  	unsigned long irq_type;
>  	bool irq_active_low;
> @@ -444,6 +450,17 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
>  	if (err < 0)
>  		return err;
>  
> +	pdata = (struct st_sensors_platform_data *)hw->dev->platform_data;
> +	if ((np && of_property_read_bool(np, "drive-open-drain")) ||
> +	    (pdata && pdata->open_drain)) {
> +		err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_PP_OD_ADDR,
> +						 ST_LSM6DSX_REG_PP_OD_MASK, 1);
> +		if (err < 0)
> +			return err;
> +
> +		irq_type |= IRQF_SHARED;
> +	}
> +
In common with the mpu3050 which was the first driver in IIO to do open drain,
I think you need to think about precedence as we allow for IRQF_RISING
and IRQF_FALLING already.  Open drain only allows for shared interrupts
if IRQF_FALLING (I think)
>  	err = devm_request_threaded_irq(hw->dev, hw->irq,
>  					st_lsm6dsx_handler_irq,
>  					st_lsm6dsx_handler_thread,


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

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: support open drain mode
  2017-06-24 20:08         ` Jonathan Cameron
@ 2017-06-25  9:34             ` Lorenzo Bianconi
  -1 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-06-25  9:34 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Lorenzo BIANCONI,
	Linus Walleij

> On Wed, 21 Jun 2017 21:21:28 +0200
> Lorenzo Bianconi <lorenzo.bianconi83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> Add open drain support in order to share requested IRQ line between
>> st_lsm6dsx device and other peripherals
>>
>> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
> Issue when IRQF_RISING and open drain is set.
>

Hi Jonathan,

> Otherwise looks good.
>> ---
>>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 17 +++++++++++++++++
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
>> index 2a72acc6e049..e2737dc71b67 100644
>> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
>> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
>> @@ -31,6 +31,8 @@
>>  #include <linux/iio/iio.h>
>>  #include <linux/iio/buffer.h>
>>
>> +#include <linux/platform_data/st_sensors_pdata.h>
>> +
>>  #include "st_lsm6dsx.h"
>>
>>  #define ST_LSM6DSX_REG_FIFO_THL_ADDR         0x06
>> @@ -39,6 +41,8 @@
>>  #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_PP_OD_ADDR            0x12
>> +#define ST_LSM6DSX_REG_PP_OD_MASK            BIT(4)
>>  #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 +421,8 @@ static const struct iio_buffer_setup_ops st_lsm6dsx_buffer_ops = {
>>
>>  int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
>>  {
>> +     struct device_node *np = hw->dev->of_node;
>> +     struct st_sensors_platform_data *pdata;
>>       struct iio_buffer *buffer;
>>       unsigned long irq_type;
>>       bool irq_active_low;
>> @@ -444,6 +450,17 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
>>       if (err < 0)
>>               return err;
>>
>> +     pdata = (struct st_sensors_platform_data *)hw->dev->platform_data;
>> +     if ((np && of_property_read_bool(np, "drive-open-drain")) ||
>> +         (pdata && pdata->open_drain)) {
>> +             err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_PP_OD_ADDR,
>> +                                              ST_LSM6DSX_REG_PP_OD_MASK, 1);
>> +             if (err < 0)
>> +                     return err;
>> +
>> +             irq_type |= IRQF_SHARED;
>> +     }
>> +
> In common with the mpu3050 which was the first driver in IIO to do open drain,
> I think you need to think about precedence as we allow for IRQF_RISING
> and IRQF_FALLING already.  Open drain only allows for shared interrupts
> if IRQF_FALLING (I think)
>>       err = devm_request_threaded_irq(hw->dev, hw->irq,
>>                                       st_lsm6dsx_handler_irq,
>>                                       st_lsm6dsx_handler_thread,
>

I have not got the difference between IRQF_RISING and IRQF_FALLING
when the irq line
is marked as shared (when open drain is enabled).
Looking at the code, mpu3050 gyro sensor does not support shared interrupts
with IRQF_RISING and IRQF_TRIGGER_HIGH. Is it a hw limitation?
Speaking with digital designer, lsm6dsx series allows open drain mode
even if the requested irq line
is IRQF_TRIGGER_HIGH or IRQF_RISING, we need to add a pull-down resistor.
Moreover ST framework already supports open drain if the requested
interrupt is IRQF_RISING.

Regards,
Lorenzo


-- 
UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch;
unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp;
umount; make clean; sleep

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

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: support open drain mode
@ 2017-06-25  9:34             ` Lorenzo Bianconi
  0 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-06-25  9:34 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, devicetree, Lorenzo BIANCONI, Linus Walleij

> On Wed, 21 Jun 2017 21:21:28 +0200
> Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
>
>> Add open drain support in order to share requested IRQ line between
>> st_lsm6dsx device and other peripherals
>>
>> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> Issue when IRQF_RISING and open drain is set.
>

Hi Jonathan,

> Otherwise looks good.
>> ---
>>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 17 +++++++++++++++++
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
>> index 2a72acc6e049..e2737dc71b67 100644
>> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
>> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
>> @@ -31,6 +31,8 @@
>>  #include <linux/iio/iio.h>
>>  #include <linux/iio/buffer.h>
>>
>> +#include <linux/platform_data/st_sensors_pdata.h>
>> +
>>  #include "st_lsm6dsx.h"
>>
>>  #define ST_LSM6DSX_REG_FIFO_THL_ADDR         0x06
>> @@ -39,6 +41,8 @@
>>  #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_PP_OD_ADDR            0x12
>> +#define ST_LSM6DSX_REG_PP_OD_MASK            BIT(4)
>>  #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 +421,8 @@ static const struct iio_buffer_setup_ops st_lsm6dsx_buffer_ops = {
>>
>>  int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
>>  {
>> +     struct device_node *np = hw->dev->of_node;
>> +     struct st_sensors_platform_data *pdata;
>>       struct iio_buffer *buffer;
>>       unsigned long irq_type;
>>       bool irq_active_low;
>> @@ -444,6 +450,17 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
>>       if (err < 0)
>>               return err;
>>
>> +     pdata = (struct st_sensors_platform_data *)hw->dev->platform_data;
>> +     if ((np && of_property_read_bool(np, "drive-open-drain")) ||
>> +         (pdata && pdata->open_drain)) {
>> +             err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_PP_OD_ADDR,
>> +                                              ST_LSM6DSX_REG_PP_OD_MASK, 1);
>> +             if (err < 0)
>> +                     return err;
>> +
>> +             irq_type |= IRQF_SHARED;
>> +     }
>> +
> In common with the mpu3050 which was the first driver in IIO to do open drain,
> I think you need to think about precedence as we allow for IRQF_RISING
> and IRQF_FALLING already.  Open drain only allows for shared interrupts
> if IRQF_FALLING (I think)
>>       err = devm_request_threaded_irq(hw->dev, hw->irq,
>>                                       st_lsm6dsx_handler_irq,
>>                                       st_lsm6dsx_handler_thread,
>

I have not got the difference between IRQF_RISING and IRQF_FALLING
when the irq line
is marked as shared (when open drain is enabled).
Looking at the code, mpu3050 gyro sensor does not support shared interrupts
with IRQF_RISING and IRQF_TRIGGER_HIGH. Is it a hw limitation?
Speaking with digital designer, lsm6dsx series allows open drain mode
even if the requested irq line
is IRQF_TRIGGER_HIGH or IRQF_RISING, we need to add a pull-down resistor.
Moreover ST framework already supports open drain if the requested
interrupt is IRQF_RISING.

Regards,
Lorenzo


-- 
UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch;
unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp;
umount; make clean; sleep

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

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: support open drain mode
  2017-06-25  9:34             ` Lorenzo Bianconi
@ 2017-06-25 16:01                 ` Jonathan Cameron
  -1 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-06-25 16:01 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Lorenzo BIANCONI,
	Linus Walleij

On Sun, 25 Jun 2017 11:34:10 +0200
Lorenzo Bianconi <lorenzo.bianconi83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> > On Wed, 21 Jun 2017 21:21:28 +0200
> > Lorenzo Bianconi <lorenzo.bianconi83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> >  
> >> Add open drain support in order to share requested IRQ line between
> >> st_lsm6dsx device and other peripherals
> >>
> >> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>  
> > Issue when IRQF_RISING and open drain is set.
> >  
> 
> Hi Jonathan,
> 
> > Otherwise looks good.  
> >> ---
> >>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 17 +++++++++++++++++
> >>  1 file changed, 17 insertions(+)
> >>
> >> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> >> index 2a72acc6e049..e2737dc71b67 100644
> >> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> >> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> >> @@ -31,6 +31,8 @@
> >>  #include <linux/iio/iio.h>
> >>  #include <linux/iio/buffer.h>
> >>
> >> +#include <linux/platform_data/st_sensors_pdata.h>
> >> +
> >>  #include "st_lsm6dsx.h"
> >>
> >>  #define ST_LSM6DSX_REG_FIFO_THL_ADDR         0x06
> >> @@ -39,6 +41,8 @@
> >>  #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_PP_OD_ADDR            0x12
> >> +#define ST_LSM6DSX_REG_PP_OD_MASK            BIT(4)
> >>  #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 +421,8 @@ static const struct iio_buffer_setup_ops st_lsm6dsx_buffer_ops = {
> >>
> >>  int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
> >>  {
> >> +     struct device_node *np = hw->dev->of_node;
> >> +     struct st_sensors_platform_data *pdata;
> >>       struct iio_buffer *buffer;
> >>       unsigned long irq_type;
> >>       bool irq_active_low;
> >> @@ -444,6 +450,17 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
> >>       if (err < 0)
> >>               return err;
> >>
> >> +     pdata = (struct st_sensors_platform_data *)hw->dev->platform_data;
> >> +     if ((np && of_property_read_bool(np, "drive-open-drain")) ||
> >> +         (pdata && pdata->open_drain)) {
> >> +             err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_PP_OD_ADDR,
> >> +                                              ST_LSM6DSX_REG_PP_OD_MASK, 1);
> >> +             if (err < 0)
> >> +                     return err;
> >> +
> >> +             irq_type |= IRQF_SHARED;
> >> +     }
> >> +  
> > In common with the mpu3050 which was the first driver in IIO to do open drain,
> > I think you need to think about precedence as we allow for IRQF_RISING
> > and IRQF_FALLING already.  Open drain only allows for shared interrupts
> > if IRQF_FALLING (I think)  
> >>       err = devm_request_threaded_irq(hw->dev, hw->irq,
> >>                                       st_lsm6dsx_handler_irq,
> >>                                       st_lsm6dsx_handler_thread,  
> >  
> 
> I have not got the difference between IRQF_RISING and IRQF_FALLING
> when the irq line
> is marked as shared (when open drain is enabled).
> Looking at the code, mpu3050 gyro sensor does not support shared interrupts
> with IRQF_RISING and IRQF_TRIGGER_HIGH. Is it a hw limitation?
> Speaking with digital designer, lsm6dsx series allows open drain mode
> even if the requested irq line
> is IRQF_TRIGGER_HIGH or IRQF_RISING, we need to add a pull-down resistor.
> Moreover ST framework already supports open drain if the requested
> interrupt is IRQF_RISING.
Just looked this up in more detail than I ever have before. I wasn't
thinking beyond the 'canonical form' with the thing set up as pull down.

Sure it will work fine.  My bad!

Applied to the togreg branch of iio.git and pushed out as testing.
As this is a carbon copy binding wise of the existing support
I'm not going to wait for Rob or Mark to have a chance to look at
it (of course their confirmation / feedback is always welcome though!)

Jonathan
> 
> Regards,
> Lorenzo
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: support open drain mode
@ 2017-06-25 16:01                 ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-06-25 16:01 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-iio, devicetree, Lorenzo BIANCONI, Linus Walleij

On Sun, 25 Jun 2017 11:34:10 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:

> > On Wed, 21 Jun 2017 21:21:28 +0200
> > Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
> >  
> >> Add open drain support in order to share requested IRQ line between
> >> st_lsm6dsx device and other peripherals
> >>
> >> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>  
> > Issue when IRQF_RISING and open drain is set.
> >  
> 
> Hi Jonathan,
> 
> > Otherwise looks good.  
> >> ---
> >>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 17 +++++++++++++++++
> >>  1 file changed, 17 insertions(+)
> >>
> >> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> >> index 2a72acc6e049..e2737dc71b67 100644
> >> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> >> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> >> @@ -31,6 +31,8 @@
> >>  #include <linux/iio/iio.h>
> >>  #include <linux/iio/buffer.h>
> >>
> >> +#include <linux/platform_data/st_sensors_pdata.h>
> >> +
> >>  #include "st_lsm6dsx.h"
> >>
> >>  #define ST_LSM6DSX_REG_FIFO_THL_ADDR         0x06
> >> @@ -39,6 +41,8 @@
> >>  #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_PP_OD_ADDR            0x12
> >> +#define ST_LSM6DSX_REG_PP_OD_MASK            BIT(4)
> >>  #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 +421,8 @@ static const struct iio_buffer_setup_ops st_lsm6dsx_buffer_ops = {
> >>
> >>  int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
> >>  {
> >> +     struct device_node *np = hw->dev->of_node;
> >> +     struct st_sensors_platform_data *pdata;
> >>       struct iio_buffer *buffer;
> >>       unsigned long irq_type;
> >>       bool irq_active_low;
> >> @@ -444,6 +450,17 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
> >>       if (err < 0)
> >>               return err;
> >>
> >> +     pdata = (struct st_sensors_platform_data *)hw->dev->platform_data;
> >> +     if ((np && of_property_read_bool(np, "drive-open-drain")) ||
> >> +         (pdata && pdata->open_drain)) {
> >> +             err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_PP_OD_ADDR,
> >> +                                              ST_LSM6DSX_REG_PP_OD_MASK, 1);
> >> +             if (err < 0)
> >> +                     return err;
> >> +
> >> +             irq_type |= IRQF_SHARED;
> >> +     }
> >> +  
> > In common with the mpu3050 which was the first driver in IIO to do open drain,
> > I think you need to think about precedence as we allow for IRQF_RISING
> > and IRQF_FALLING already.  Open drain only allows for shared interrupts
> > if IRQF_FALLING (I think)  
> >>       err = devm_request_threaded_irq(hw->dev, hw->irq,
> >>                                       st_lsm6dsx_handler_irq,
> >>                                       st_lsm6dsx_handler_thread,  
> >  
> 
> I have not got the difference between IRQF_RISING and IRQF_FALLING
> when the irq line
> is marked as shared (when open drain is enabled).
> Looking at the code, mpu3050 gyro sensor does not support shared interrupts
> with IRQF_RISING and IRQF_TRIGGER_HIGH. Is it a hw limitation?
> Speaking with digital designer, lsm6dsx series allows open drain mode
> even if the requested irq line
> is IRQF_TRIGGER_HIGH or IRQF_RISING, we need to add a pull-down resistor.
> Moreover ST framework already supports open drain if the requested
> interrupt is IRQF_RISING.
Just looked this up in more detail than I ever have before. I wasn't
thinking beyond the 'canonical form' with the thing set up as pull down.

Sure it will work fine.  My bad!

Applied to the togreg branch of iio.git and pushed out as testing.
As this is a carbon copy binding wise of the existing support
I'm not going to wait for Rob or Mark to have a chance to look at
it (of course their confirmation / feedback is always welcome though!)

Jonathan
> 
> Regards,
> Lorenzo
> 
> 


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

* Re: [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: support open drain mode
  2017-06-21 19:21     ` Lorenzo Bianconi
@ 2017-06-25 16:03         ` Jonathan Cameron
  -1 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-06-25 16:03 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o

On Wed, 21 Jun 2017 21:21:29 +0200
Lorenzo Bianconi <lorenzo.bianconi83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
Given this is a carbon copy of what we already have for the mpu3030 driver
I'm not going to waste Rob or Marks time pestering them for a review.
(obviously one is welcome if it happens to come along!)

Applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan
> ---
>  Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
> index 6f28ff55f3ec..1ff1af799c76 100644
> --- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
> +++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
> @@ -11,6 +11,14 @@ Required properties:
>  Optional properties:
>  - st,drdy-int-pin: the pin on the package that will be used to signal
>    "data ready" (valid values: 1 or 2).
> +- drive-open-drain: the interrupt/data ready line will be configured
> +  as open drain, which is useful if several sensors share the same
> +  interrupt line. This is a boolean property.
> +  (This binding is taken from pinctrl/pinctrl-bindings.txt)
> +  If the requested interrupt is configured as IRQ_TYPE_LEVEL_HIGH or
> +  IRQ_TYPE_EDGE_RISING a pull-down resistor is needed to drive the line
> +  when it is not active, whereas a pull-up one is needed when interrupt
> +  line is configured as IRQ_TYPE_LEVEL_LOW or IRQ_TYPE_EDGE_FALLING.
>  - 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, IRQ_TYPE_EDGE_RISING, IRQ_TYPE_LEVEL_LOW or

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

* Re: [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: support open drain mode
@ 2017-06-25 16:03         ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-06-25 16:03 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-iio, devicetree, lorenzo.bianconi

On Wed, 21 Jun 2017 21:21:29 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:

> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Given this is a carbon copy of what we already have for the mpu3030 driver
I'm not going to waste Rob or Marks time pestering them for a review.
(obviously one is welcome if it happens to come along!)

Applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan
> ---
>  Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
> index 6f28ff55f3ec..1ff1af799c76 100644
> --- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
> +++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt
> @@ -11,6 +11,14 @@ Required properties:
>  Optional properties:
>  - st,drdy-int-pin: the pin on the package that will be used to signal
>    "data ready" (valid values: 1 or 2).
> +- drive-open-drain: the interrupt/data ready line will be configured
> +  as open drain, which is useful if several sensors share the same
> +  interrupt line. This is a boolean property.
> +  (This binding is taken from pinctrl/pinctrl-bindings.txt)
> +  If the requested interrupt is configured as IRQ_TYPE_LEVEL_HIGH or
> +  IRQ_TYPE_EDGE_RISING a pull-down resistor is needed to drive the line
> +  when it is not active, whereas a pull-up one is needed when interrupt
> +  line is configured as IRQ_TYPE_LEVEL_LOW or IRQ_TYPE_EDGE_FALLING.
>  - 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, IRQ_TYPE_EDGE_RISING, IRQ_TYPE_LEVEL_LOW or


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

* Re: [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: support open drain mode
  2017-06-21 19:21     ` Lorenzo Bianconi
@ 2017-06-26 18:24         ` Rob Herring
  -1 siblings, 0 replies; 20+ messages in thread
From: Rob Herring @ 2017-06-26 18:24 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: jic23-DgEjT+Ai2ygdnm+yROfE0A, linux-iio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o

On Wed, Jun 21, 2017 at 09:21:29PM +0200, Lorenzo Bianconi wrote:
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 8 ++++++++
>  1 file changed, 8 insertions(+)

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: support open drain mode
@ 2017-06-26 18:24         ` Rob Herring
  0 siblings, 0 replies; 20+ messages in thread
From: Rob Herring @ 2017-06-26 18:24 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: jic23, linux-iio, devicetree, lorenzo.bianconi

On Wed, Jun 21, 2017 at 09:21:29PM +0200, Lorenzo Bianconi wrote:
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> ---
>  Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 8 ++++++++
>  1 file changed, 8 insertions(+)

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

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

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: support open drain mode
  2017-06-25  9:34             ` Lorenzo Bianconi
@ 2017-06-29 11:46                 ` Linus Walleij
  -1 siblings, 0 replies; 20+ messages in thread
From: Linus Walleij @ 2017-06-29 11:46 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Jonathan Cameron, linux-iio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Lorenzo BIANCONI

On Sun, Jun 25, 2017 at 11:34 AM, Lorenzo Bianconi
<lorenzo.bianconi83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

>> In common with the mpu3050 which was the first driver in IIO to do open drain,

I think I implemented it on the ST sensors first actually.

>> I think you need to think about precedence as we allow for IRQF_RISING
>> and IRQF_FALLING already.  Open drain only allows for shared interrupts
>> if IRQF_FALLING (I think)
>>>       err = devm_request_threaded_irq(hw->dev, hw->irq,
>>>                                       st_lsm6dsx_handler_irq,
>>>                                       st_lsm6dsx_handler_thread,
>
> I have not got the difference between IRQF_RISING and IRQF_FALLING
> when the irq line
> is marked as shared (when open drain is enabled).
> Looking at the code, mpu3050 gyro sensor does not support shared interrupts
> with IRQF_RISING and IRQF_TRIGGER_HIGH. Is it a hw limitation?

It seems like I have inverted the logic in the MPU3050 driver.
I'll send a patch.

> Speaking with digital designer, lsm6dsx series allows open drain mode
> even if the requested irq line
> is IRQF_TRIGGER_HIGH or IRQF_RISING, we need to add a pull-down resistor.
> Moreover ST framework already supports open drain if the requested
> interrupt is IRQF_RISING.

This seems correct.

Yours,
Linus Walleij

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

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: support open drain mode
@ 2017-06-29 11:46                 ` Linus Walleij
  0 siblings, 0 replies; 20+ messages in thread
From: Linus Walleij @ 2017-06-29 11:46 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Jonathan Cameron, linux-iio, devicetree, Lorenzo BIANCONI

On Sun, Jun 25, 2017 at 11:34 AM, Lorenzo Bianconi
<lorenzo.bianconi83@gmail.com> wrote:

>> In common with the mpu3050 which was the first driver in IIO to do open drain,

I think I implemented it on the ST sensors first actually.

>> I think you need to think about precedence as we allow for IRQF_RISING
>> and IRQF_FALLING already.  Open drain only allows for shared interrupts
>> if IRQF_FALLING (I think)
>>>       err = devm_request_threaded_irq(hw->dev, hw->irq,
>>>                                       st_lsm6dsx_handler_irq,
>>>                                       st_lsm6dsx_handler_thread,
>
> I have not got the difference between IRQF_RISING and IRQF_FALLING
> when the irq line
> is marked as shared (when open drain is enabled).
> Looking at the code, mpu3050 gyro sensor does not support shared interrupts
> with IRQF_RISING and IRQF_TRIGGER_HIGH. Is it a hw limitation?

It seems like I have inverted the logic in the MPU3050 driver.
I'll send a patch.

> Speaking with digital designer, lsm6dsx series allows open drain mode
> even if the requested irq line
> is IRQF_TRIGGER_HIGH or IRQF_RISING, we need to add a pull-down resistor.
> Moreover ST framework already supports open drain if the requested
> interrupt is IRQF_RISING.

This seems correct.

Yours,
Linus Walleij

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

* Re: [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: support open drain mode
  2017-06-26 18:24         ` Rob Herring
@ 2017-06-30 18:22           ` Jonathan Cameron
  -1 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-06-30 18:22 UTC (permalink / raw)
  To: Rob Herring
  Cc: Lorenzo Bianconi, linux-iio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o

On Mon, 26 Jun 2017 13:24:11 -0500
Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:

> On Wed, Jun 21, 2017 at 09:21:29PM +0200, Lorenzo Bianconi wrote:
> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
> > ---
> >  Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 8 ++++++++
> >  1 file changed, 8 insertions(+)  
> 
> Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Added, thanks Rob.

Jonathan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/2] dt-bindings: iio: imu: st_lsm6dsx: support open drain mode
@ 2017-06-30 18:22           ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-06-30 18:22 UTC (permalink / raw)
  To: Rob Herring; +Cc: Lorenzo Bianconi, linux-iio, devicetree, lorenzo.bianconi

On Mon, 26 Jun 2017 13:24:11 -0500
Rob Herring <robh@kernel.org> wrote:

> On Wed, Jun 21, 2017 at 09:21:29PM +0200, Lorenzo Bianconi wrote:
> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> > ---
> >  Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 8 ++++++++
> >  1 file changed, 8 insertions(+)  
> 
> Acked-by: Rob Herring <robh@kernel.org>
Added, thanks Rob.

Jonathan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

end of thread, other threads:[~2017-06-30 18:22 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-21 19:21 [PATCH 0/2] Add open drain support to st_lsm6dsx Lorenzo Bianconi
2017-06-21 19:21 ` Lorenzo Bianconi
     [not found] ` <20170621192129.10226-1-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-06-21 19:21   ` [PATCH 1/2] iio: imu: st_lsm6dsx: support open drain mode Lorenzo Bianconi
2017-06-21 19:21     ` Lorenzo Bianconi
     [not found]     ` <20170621192129.10226-2-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-06-24 20:08       ` Jonathan Cameron
2017-06-24 20:08         ` Jonathan Cameron
     [not found]         ` <20170624210835.56ffdd1c-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-06-25  9:34           ` Lorenzo Bianconi
2017-06-25  9:34             ` Lorenzo Bianconi
     [not found]             ` <CAA2SeNJ5yPqMiW2tVSc9ZSC5Rt=Q+CRoMibzigjvPyw05Qsr5Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-25 16:01               ` Jonathan Cameron
2017-06-25 16:01                 ` Jonathan Cameron
2017-06-29 11:46               ` Linus Walleij
2017-06-29 11:46                 ` Linus Walleij
2017-06-21 19:21   ` [PATCH 2/2] dt-bindings: " Lorenzo Bianconi
2017-06-21 19:21     ` Lorenzo Bianconi
     [not found]     ` <20170621192129.10226-3-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-06-25 16:03       ` Jonathan Cameron
2017-06-25 16:03         ` Jonathan Cameron
2017-06-26 18:24       ` Rob Herring
2017-06-26 18:24         ` Rob Herring
2017-06-30 18:22         ` Jonathan Cameron
2017-06-30 18:22           ` 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.