|
@@ -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,
|