iio: mma8452: support either of the available interrupt pins
Subsystems (2)
PATCH v4 1/1 iio: mma8452: support either of the available interrupt pins
This change is important in order for everyone to be easily able to use the driver for one of the supported accelerometer chips!
Until now, the driver blindly assumed that the INT1 interrupt line is wired on a user's board. But these devices have 2 interrupt lines and can route their interrupt sources to one of them. Now, if "INT2" is found and matches i2c_client->irq, INT2 will be used.
The chip's default actually is INT2, which is why probably many boards will have it wired and can make use of this.
Of course, this also falls back to assuming INT1, so for existing users nothing will break. The new functionality is described in the bindings doc.
---
changelog:
v4: use irq that matches client->irq, backwards compatible
v3: correctly assign irq if both pins are described in DT
v2: don't warn but normally handle if both pins are described in dts
thanks Mark Rutland
v1: initial post
.../devicetree/bindings/iio/accel/mma8452.txt | 6 ++++++ drivers/iio/accel/mma8452.c | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/iio/accel/mma8452.txt +6 -0
@@ -7,13 +7,18 @@ Required properties: * "fsl,mma8453" * "fsl,mma8652" * "fsl,mma8653" + - reg: the I2C address of the chip Optional properties: - interrupt-parent: should be the phandle for the interrupt controller + - interrupts: interrupt mapping for GPIO IRQ + - interrupt-names: should contain "INT1" and/or "INT2", the accelerometer's + interrupt line in use. + Example: mma8453fc@1d {
@@ -21,4 +26,5 @@ Example: reg = <0x1d>; interrupt-parent = <&gpio1>; interrupts = <5 0>; + interrupt-names = "INT2"; };
drivers/iio/accel/mma8452.c +15 -6
@@ -29,6 +29,7 @@#include <linux/iio/events.h> #include <linux/delay.h> #include <linux/of_device.h> +#include <linux/of_irq.h> #define MMA8452_STATUS 0x00#define MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0))
@@ -1130,13 +1131,21 @@ static int mma8452_probe(struct i2c_client *client,MMA8452_INT_FF_MT ;int enabled_interrupts =MMA8452_INT_TRANS |MMA8452_INT_FF_MT ; +int irq2; -/* Assume wired to INT1 pin */ - ret =i2c_smbus_write_byte_data (client, -MMA8452_CTRL_REG5 , - supported_interrupts); -if (ret <0 ) -return ret; + irq2 =of_irq_get_byname (client->dev.of_node,"INT2" ); + +if (irq2 == client->irq) { +dev_dbg (&client->dev,"using interrupt line INT2\n" ); + }else { + ret =i2c_smbus_write_byte_data (client, +MMA8452_CTRL_REG5 , + supported_interrupts); +if (ret <0 ) +return ret; + +dev_dbg (&client->dev,"using interrupt line INT1\n" ); + } ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG4,
Signature · 1 line
2.1.4
Am 2015-10-15 um 15:10 schrieb Martin Kepplinger:
Quoted 87 lines
This change is important in order for everyone to be easily able to use the driver for one of the supported accelerometer chips!
Until now, the driver blindly assumed that the INT1 interrupt line is wired on a user's board. But these devices have 2 interrupt lines and can route their interrupt sources to one of them. Now, if "INT2" is found and matches
i2c_client->irq, INT2 will be used.The chip's default actually is INT2, which is why probably many boards will have it wired and can make use of this.
Of course, this also falls back to assuming INT1, so for existing users nothing will break. The new functionality is described in the bindings doc.
---
changelog:
v4: use irq that matchesclient->irq, backwards compatible
v3: correctly assign irq if both pins are described in DT
v2: don't warn but normally handle if both pins are described in dts
thanks Mark Rutland
v1: initial post.../devicetree/bindings/iio/accel/mma8452.txt | 6 ++++++ drivers/iio/accel/mma8452.c | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/iio/accel/mma8452.txt +6
-0@@ -7,13 +7,18 @@ Required properties: * "fsl,mma8453" * "fsl,mma8652" * "fsl,mma8653" + - reg: the I2C address of the chip Optional properties: - interrupt-parent: should be the phandle for the interrupt controller + - interrupts: interrupt mapping for GPIO IRQ + - interrupt-names: should contain "INT1" and/or "INT2", the accelerometer's + interrupt line in use. + Example: mma8453fc@1d {@@ -21,4 +26,5 @@ Example: reg = <0x1d>; interrupt-parent = <&gpio1>; interrupts = <5 0>; + interrupt-names = "INT2"; };drivers/iio/accel/mma8452.c +8
-6@@ -29,6 +29,7 @@#include <linux/iio/events.h> #include <linux/delay.h> #include <linux/of_device.h> +#include <linux/of_irq.h> #define MMA8452_STATUS 0x00#define MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0))@@ -1130,13 +1131,21 @@ static int mma8452_probe(struct i2c_client *client,MMA8452_INT_FF_MT ;int enabled_interrupts =MMA8452_INT_TRANS |MMA8452_INT_FF_MT ; +int irq2; -/* Assume wired to INT1 pin */ - ret =i2c_smbus_write_byte_data (client, -MMA8452_CTRL_REG5 , - supported_interrupts); -if (ret <0 ) -return ret; + irq2 =of_irq_get_byname (client->dev.of_node,"INT2" ); + +if (irq2 == client->irq) { +dev_dbg (&client->dev,"using interrupt line INT2\n" ); + }else { + ret = i2c_smbus_write_byte_data(client,
drivers/iio/accel/mma8452.c static int mma8452_probe(struct i2c_client *client, · line 1151
Quoted 10 lines
drivers/iio/accel/mma8452.c +7
-0+MMA8452_CTRL_REG5 , + supported_interrupts); +if (ret <0 ) +return ret; + +dev_dbg (&client->dev,"using interrupt line INT1\n" ); + } ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG4,
This works fine and would be convenient to have. Any objections?
thanks
martin
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Am 2015-10-20 um 13:03 schrieb Martin Kepplinger:
Quoted 95 lines
Am 2015-10-15 um 15:10 schrieb Martin Kepplinger:
Quoted 94 lines
This change is important in order for everyone to be easily able to use the driver for one of the supported accelerometer chips!
Until now, the driver blindly assumed that the INT1 interrupt line is wired on a user's board. But these devices have 2 interrupt lines and can route their interrupt sources to one of them. Now, if "INT2" is found and matches
i2c_client->irq, INT2 will be used.The chip's default actually is INT2, which is why probably many boards will have it wired and can make use of this.
Of course, this also falls back to assuming INT1, so for existing users nothing will break. The new functionality is described in the bindings doc.
Signed-off-by Martin Kepplinger <[email protected]>---
changelog:
v4: use irq that matchesclient->irq, backwards compatible
v3: correctly assign irq if both pins are described in DT
v2: don't warn but normally handle if both pins are described in dts
thanks Mark Rutland
v1: initial post.../devicetree/bindings/iio/accel/mma8452.txt | 6 ++++++ drivers/iio/accel/mma8452.c | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/iio/accel/mma8452.txt +6
-0@@ -7,13 +7,18 @@ Required properties: * "fsl,mma8453" * "fsl,mma8652" * "fsl,mma8653" + - reg: the I2C address of the chip Optional properties: - interrupt-parent: should be the phandle for the interrupt controller + - interrupts: interrupt mapping for GPIO IRQ + - interrupt-names: should contain "INT1" and/or "INT2", the accelerometer's + interrupt line in use. + Example: mma8453fc@1d {@@ -21,4 +26,5 @@ Example: reg = <0x1d>; interrupt-parent = <&gpio1>; interrupts = <5 0>; + interrupt-names = "INT2"; };drivers/iio/accel/mma8452.c +15
-6@@ -29,6 +29,7 @@#include <linux/iio/events.h> #include <linux/delay.h> #include <linux/of_device.h> +#include <linux/of_irq.h> #define MMA8452_STATUS 0x00#define MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0))@@ -1130,13 +1131,21 @@ static int mma8452_probe(struct i2c_client *client,MMA8452_INT_FF_MT ;int enabled_interrupts =MMA8452_INT_TRANS |MMA8452_INT_FF_MT ; +int irq2; -/* Assume wired to INT1 pin */ - ret =i2c_smbus_write_byte_data (client, -MMA8452_CTRL_REG5 , - supported_interrupts); -if (ret <0 ) -return ret; + irq2 =of_irq_get_byname (client->dev.of_node,"INT2" ); + +if (irq2 == client->irq) { +dev_dbg (&client->dev,"using interrupt line INT2\n" ); + }else { + ret =i2c_smbus_write_byte_data (client, +MMA8452_CTRL_REG5 , + supported_interrupts); +if (ret <0 ) +return ret; + +dev_dbg (&client->dev,"using interrupt line INT1\n" ); + }
Quoted 8 lines
drivers/iio/accel/mma8452.c static int mma8452_probe(struct i2c_client *client, · line 1151
Quoted 3 lines
drivers/iio/accel/mma8452.c +0
-0ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG4,This works fine and would be convenient to have. Any objections?
thanks
martin
yes, no, maybe?
thanks
martin
Quoted 23 lines · Martin Kepplinger
This change is important in order for everyone to be easily able to use the driver for one of the supported accelerometer chips!
Until now, the driver blindly assumed that the INT1 interrupt line is wired on a user's board. But these devices have 2 interrupt lines and can route their interrupt sources to one of them. Now, if "INT2" is found and matches
i2c_client->irq, INT2 will be used.The chip's default actually is INT2, which is why probably many boards will have it wired and can make use of this.
Of course, this also falls back to assuming INT1, so for existing users nothing will break. The new functionality is described in the bindings doc.
---
changelog:
v4: use irq that matchesclient->irq, backwards compatible
v3: correctly assign irq if both pins are described in DT
v2: don't warn but normally handle if both pins are described in dts
thanks Mark Rutland
v1: initial post
Quoted 1 line
.../devicetree/bindings/iio/accel/mma8452.txt | 6 ++++++
For the binding:
Rob Herring <[email protected]>
Quoted 73 lines
drivers/iio/accel/mma8452.c | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/iio/accel/mma8452.txt +6
-0@@ -7,13 +7,18 @@ Required properties: * "fsl,mma8453" * "fsl,mma8652" * "fsl,mma8653" + - reg: the I2C address of the chip Optional properties: - interrupt-parent: should be the phandle for the interrupt controller + - interrupts: interrupt mapping for GPIO IRQ + - interrupt-names: should contain "INT1" and/or "INT2", the accelerometer's + interrupt line in use. + Example: mma8453fc@1d {@@ -21,4 +26,5 @@ Example: reg = <0x1d>; interrupt-parent = <&gpio1>; interrupts = <5 0>; + interrupt-names = "INT2"; };drivers/iio/accel/mma8452.c +15
-7@@ -29,6 +29,7 @@#include <linux/iio/events.h> #include <linux/delay.h> #include <linux/of_device.h> +#include <linux/of_irq.h> #define MMA8452_STATUS 0x00#define MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0))@@ -1130,13 +1131,21 @@ static int mma8452_probe(struct i2c_client *client,MMA8452_INT_FF_MT ;int enabled_interrupts =MMA8452_INT_TRANS |MMA8452_INT_FF_MT ; +int irq2; -/* Assume wired to INT1 pin */ - ret =i2c_smbus_write_byte_data (client, -MMA8452_CTRL_REG5 , - supported_interrupts); -if (ret <0 ) -return ret; + irq2 =of_irq_get_byname (client->dev.of_node,"INT2" ); + +if (irq2 == client->irq) { +dev_dbg (&client->dev,"using interrupt line INT2\n" ); + }else { + ret =i2c_smbus_write_byte_data (client, +MMA8452_CTRL_REG5 , + supported_interrupts); +if (ret <0 ) +return ret; + +dev_dbg (&client->dev,"using interrupt line INT1\n" ); + } ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG4, --
Quoted 2 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerQuoted 24 lines · Rob Herring
Quoted 23 lines · Martin Kepplinger
This change is important in order for everyone to be easily able to use the driver for one of the supported accelerometer chips!
Until now, the driver blindly assumed that the INT1 interrupt line is wired on a user's board. But these devices have 2 interrupt lines and can route their interrupt sources to one of them. Now, if "INT2" is found and matches
i2c_client->irq, INT2 will be used.The chip's default actually is INT2, which is why probably many boards will have it wired and can make use of this.
Of course, this also falls back to assuming INT1, so for existing users nothing will break. The new functionality is described in the bindings doc.
---
changelog:
v4: use irq that matchesclient->irq, backwards compatible
v3: correctly assign irq if both pins are described in DT
v2: don't warn but normally handle if both pins are described in dts
thanks Mark Rutland
v1: initial post
Quoted 5 lines
Quoted 1 line
.../devicetree/bindings/iio/accel/mma8452.txt | 6 ++++++For the binding:
Rob Herring <[email protected]>
I've guessed that was an Acked-by :)
Anyhow, applied to the togreg branch of iio.git.
I'm afraid after my hiatus for a couple of weeks (day job work crisis now over) this has missed going in for the current cycle.
IIO merge closes more than a week before the merge window opens and Linus just announced probably release a week today.
Sorry about that, will be queued up for an early entry into linux next after the merge window closes.
Jonathan
Quoted 81 lines
Quoted 74 lines
drivers/iio/accel/mma8452.c | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/iio/accel/mma8452.txt +6
-0@@ -7,13 +7,18 @@ Required properties: * "fsl,mma8453" * "fsl,mma8652" * "fsl,mma8653" + - reg: the I2C address of the chip Optional properties: - interrupt-parent: should be the phandle for the interrupt controller + - interrupts: interrupt mapping for GPIO IRQ + - interrupt-names: should contain "INT1" and/or "INT2", the accelerometer's + interrupt line in use. + Example: mma8453fc@1d {@@ -21,4 +26,5 @@ Example: reg = <0x1d>; interrupt-parent = <&gpio1>; interrupts = <5 0>; + interrupt-names = "INT2"; };drivers/iio/accel/mma8452.c +15
-7@@ -29,6 +29,7 @@#include <linux/iio/events.h> #include <linux/delay.h> #include <linux/of_device.h> +#include <linux/of_irq.h> #define MMA8452_STATUS 0x00#define MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0))@@ -1130,13 +1131,21 @@ static int mma8452_probe(struct i2c_client *client,MMA8452_INT_FF_MT ;int enabled_interrupts =MMA8452_INT_TRANS |MMA8452_INT_FF_MT ; +int irq2; -/* Assume wired to INT1 pin */ - ret =i2c_smbus_write_byte_data (client, -MMA8452_CTRL_REG5 , - supported_interrupts); -if (ret <0 ) -return ret; + irq2 =of_irq_get_byname (client->dev.of_node,"INT2" ); + +if (irq2 == client->irq) { +dev_dbg (&client->dev,"using interrupt line INT2\n" ); + }else { + ret =i2c_smbus_write_byte_data (client, +MMA8452_CTRL_REG5 , + supported_interrupts); +if (ret <0 ) +return ret; + +dev_dbg (&client->dev,"using interrupt line INT1\n" ); + } ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG4, --Quoted 2 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Am 25. Oktober 2015 12:05:05 MEZ, schrieb Jonathan Cameron <[email protected]>:
Quoted 47 lines · Rob Herring
Quoted 1 line
On Thu, Oct 15, 2015 at 8:10 AM, Martin Kepplinger
Quoted 1 line · <[email protected]> wrote:
Quoted 1 line
This change is important in order for everyone to be easily able to
use the
Quoted 3 lines
Quoted 3 lines
driver for one of the supported accelerometer chips!
Until now, the driver blindly assumed that the INT1 interrupt line
is wired
Quoted 1 line
Quoted 1 line
on a user's board. But these devices have 2 interrupt lines and can
route
Quoted 1 line
Quoted 1 line
their interrupt sources to one of them. Now, if "INT2" is found and
matches
Quoted 3 lines
Quoted 3 lines
i2c_client->irq, INT2 will be used.The chip's default actually is INT2, which is why probably many
boards will
Quoted 3 lines
Quoted 3 lines
have it wired and can make use of this.
Of course, this also falls back to assuming INT1, so for existing
users
Quoted 1 line
Quoted 1 line
nothing will break. The new functionality is described in the
bindings doc.
Quoted 2 lines
Quoted 2 lines
Signed-off-by Martin Kepplinger<martin.kepplinger-SN7IsUiht6C/[email protected]>
Quoted 8 lines
Quoted 8 lines
---
changelog:
v4: use irq that matchesclient->irq, backwards compatible
v3: correctly assign irq if both pins are described in DT
v2: don't warn but normally handle if both pins are described in dts
thanks Mark Rutland
v1: initial postQuoted 5 lines
Quoted 1 line
.../devicetree/bindings/iio/accel/mma8452.txt | 6 ++++++For the binding:
Rob Herring <[email protected]>
I've guessed that was an Acked-by :)
Anyhow, applied to the togreg branch of iio.git.
I'm afraid after my hiatus for a couple of weeks (day job work crisis now
over) this has missed going in for the current cycle.
Quoted 8 lines
IIO merge closes more than a week before the merge window opens and Linus
just announced probably release a week today.Sorry about that, will be queued up for an early entry into linux next after the merge window closes.
Jonathan
That's fine. Thanks
Quoted 84 lines
Quoted 2 lines
Quoted 2 lines
drivers/iio/accel/mma8452.c | 21+++++++++++++++------
Quoted 3 lines
Review
Quoted 3 lines
2 files changed, 21 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/Documentation/devicetree/bindings/iio/accel/mma8452.txtQuoted 10 lines
Quoted 10 lines
index e3c3746..3c10e85 100644
Documentation/devicetree/bindings/iio/accel/mma8452.txt +1
-0@@ -7,13 +7,18 @@ Required properties: * "fsl,mma8453" * "fsl,mma8652" * "fsl,mma8653" + - reg: the I2C address of the chipQuoted 3 lines
Documentation/devicetree/bindings/iio/accel/mma8452.txt Required properties:
Quoted 3 lines
Documentation/devicetree/bindings/iio/accel/mma8452.txt +0
-0Optional properties: - interrupt-parent: should be the phandle for the interruptcontroller
Quoted 4 lines
Documentation/devicetree/bindings/iio/accel/mma8452.txt Required properties:
Quoted 4 lines
Documentation/devicetree/bindings/iio/accel/mma8452.txt +2
-0+ - interrupts: interrupt mapping for GPIO IRQ + - interrupt-names: should contain "INT1" and/or "INT2", theaccelerometer's
Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/iio/accel/mma8452.txt +2
-0+ interrupt line in use. + Example:Quoted 8 lines
Review
Quoted 8 lines
Documentation/devicetree/bindings/iio/accel/mma8452.txt +1
-0mma8453fc@1d {@@ -21,4 +26,5 @@ Example: reg = <0x1d>; interrupt-parent = <&gpio1>; interrupts = <5 0>; + interrupt-names = "INT2"; };(quoted diff) +0
-0
b/drivers/iio/accel/mma8452.cQuoted 11 lines
drivers/iio/accel/mma8452.c line 35
Quoted 11 lines
index 1eccc2d..116a6e4 100644
drivers/iio/accel/mma8452.c +1
-0@@ -29,6 +29,7 @@#include <linux/iio/events.h> #include <linux/delay.h> #include <linux/of_device.h> +#include <linux/of_irq.h> #define MMA8452_STATUS 0x00#define MMA8452_STATUS_DRDY (BIT(2) | BIT(1) |BIT(0))
Quoted 1 line
drivers/iio/accel/mma8452.c static int mma8452_probe(struct i2c_client
Quoted 1 line
drivers/iio/accel/mma8452.c +0
-0@@ -1130,13 +1131,21 @@ static int mma8452_probe(struct i2c_client*client,
Quoted 9 lines
drivers/iio/accel/mma8452.c static int mma8452_probe(struct i2c_client *client,
Quoted 9 lines
drivers/iio/accel/mma8452.c +1
-4MMA8452_INT_FF_MT ;int enabled_interrupts =MMA8452_INT_TRANS |MMA8452_INT_FF_MT ; +int irq2; -/* Assume wired to INT1 pin */ - ret = i2c_smbus_write_byte_data(client, - MMA8452_CTRL_REG5, -
supported_interrupts);Quoted 3 lines
drivers/iio/accel/mma8452.c static int mma8452_probe(struct i2c_client *client,
Quoted 3 lines
drivers/iio/accel/mma8452.c +1
-2-if (ret <0 ) -return ret; + irq2 = of_irq_get_byname(client->dev.of_node,"INT2");
Quoted 3 lines
drivers/iio/accel/mma8452.c static int mma8452_probe(struct i2c_client *client,
Quoted 3 lines
drivers/iio/accel/mma8452.c +3
-0+ +if (irq2 == client->irq) { + dev_dbg(&client->dev, "using interrupt lineINT2\n");
Quoted 3 lines
drivers/iio/accel/mma8452.c static int mma8452_probe(struct i2c_client *client, · line 1146
Quoted 3 lines
drivers/iio/accel/mma8452.c +3
-0+ }else { + ret = i2c_smbus_write_byte_data(client, +
MMA8452_CTRL_REG5,Quoted 1 line
drivers/iio/accel/mma8452.c static int mma8452_probe(struct i2c_client · line 1143
Quoted 1 line
drivers/iio/accel/mma8452.c +1
-0+
supported_interrupts);Quoted 4 lines
drivers/iio/accel/mma8452.c static int mma8452_probe(struct i2c_client *client,
Quoted 4 lines
drivers/iio/accel/mma8452.c +4
-0+if (ret <0 ) +return ret; + + dev_dbg(&client->dev, "using interrupt lineINT1\n");
Quoted 2 lines
Quoted 2 lines
drivers/iio/accel/mma8452.c +1
-0+ }
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
drivers/iio/accel/mma8452.c +0
-1ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG4, --2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-iio"in
Quoted 3 lines
the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html