summaryrefslogtreecommitdiffstats
path: root/drivers/iio/common/st_sensors/st_sensors_trigger.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-04-14 10:45:21 +0200
committerJonathan Cameron <jic23@kernel.org>2016-04-19 19:58:13 +0100
commit0e6f6871a1591f4bb0971809c45bc91a991f1967 (patch)
tree45aa87a59f586c7aff129809ca3cc017b4d36895 /drivers/iio/common/st_sensors/st_sensors_trigger.c
parent97865fe41322d83dac4373fe0a0de5b1a1b318c5 (diff)
downloadlinux-0e6f6871a1591f4bb0971809c45bc91a991f1967.tar.bz2
iio: st_sensors: support open drain mode
Some types of ST Sensors can be connected to the same IRQ line as other peripherals using open drain. Add a device tree binding and a sensor data property to flip the right bit in the interrupt control register to enable open drain mode on the INT line. If the line is set to be open drain, also tag on IRQF_SHARED to the IRQ flags when requesting the interrupt, as the whole point of using open drain interrupt lines is to share them with more than one peripheral (wire-or). Cc: devicetree@vger.kernel.org Cc: Giuseppe Barba <giuseppe.barba@st.com> Cc: Denis Ciocca <denis.ciocca@st.com> Acked-by: Rob Herring <rob@kernel.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/common/st_sensors/st_sensors_trigger.c')
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_trigger.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c
index 6a8c98327945..da72279fcf99 100644
--- a/drivers/iio/common/st_sensors/st_sensors_trigger.c
+++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c
@@ -64,6 +64,19 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
"rising edge\n", irq_trig);
irq_trig = IRQF_TRIGGER_RISING;
}
+
+ /*
+ * If the interrupt pin is Open Drain, by definition this
+ * means that the interrupt line may be shared with other
+ * peripherals. But to do this we also need to have a status
+ * register and mask to figure out if this sensor was firing
+ * the IRQ or not, so we can tell the interrupt handle that
+ * it was "our" interrupt.
+ */
+ if (sdata->int_pin_open_drain &&
+ sdata->sensor_settings->drdy_irq.addr_stat_drdy)
+ irq_trig |= IRQF_SHARED;
+
err = request_threaded_irq(irq,
iio_trigger_generic_data_rdy_poll,
NULL,