Skip to content

Commit e2e6d24

Browse files
Rubuschjic23
authored andcommitted
iio: accel: adxl345: introduce interrupt handling
Add the possibility to claim an interrupt. Init the state structure with an interrupt line obtained from the DT. The adxl345 can use two different interrupt lines for event handling. Only one is used. Signed-off-by: Lothar Rubusch <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 82e1ced commit e2e6d24

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/iio/accel/adxl345_core.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ADXL345.pdf
88
*/
99

10+
#include <linux/interrupt.h>
1011
#include <linux/module.h>
1112
#include <linux/property.h>
1213
#include <linux/regmap.h>
@@ -17,9 +18,15 @@
1718

1819
#include "adxl345.h"
1920

21+
#define ADXL345_INT_NONE 0xff
22+
#define ADXL345_INT1 0
23+
#define ADXL345_INT2 1
24+
2025
struct adxl345_state {
2126
const struct adxl345_chip_info *info;
2227
struct regmap *regmap;
28+
int irq;
29+
u8 intio;
2330
};
2431

2532
#define ADXL345_CHANNEL(index, axis) { \
@@ -262,6 +269,15 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap,
262269
if (ret < 0)
263270
return ret;
264271

272+
st->intio = ADXL345_INT1;
273+
st->irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT1");
274+
if (st->irq < 0) {
275+
st->intio = ADXL345_INT2;
276+
st->irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT2");
277+
if (st->irq < 0)
278+
st->intio = ADXL345_INT_NONE;
279+
}
280+
265281
return devm_iio_device_register(dev, indio_dev);
266282
}
267283
EXPORT_SYMBOL_NS_GPL(adxl345_core_probe, "IIO_ADXL345");

0 commit comments

Comments
 (0)