iio: xadc: Use locked register access where necessary

To avoid race conditions we need to make sure to always hold the xadc mutex when
accessing a register. This patch updates two places which didn't hold the lock
yet.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio:xadc: Fix OT events

To be able to set custom threshold values on the OT channel we need to set the
lower 4 bits to 0x3. Also fix the event to channel mapping and the alarm enable
mapping for the OT channel.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio:xadc: Only update alarm if they changed

Only update the CONF1 register when enabling or disabling an alarm if the
registers value has changed. This avoids some unnecessary writes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio:xadc: Set thresholds to min/max in probe

Since we disable the threshold events in the probe function we should also set
to their values to minimum/maximum. Otherwise we'll get unexpected behavior when
enabling a threshold in only one direction

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio:xadc: Drain FIFO before starting a new transfer

Remove any data that might be left in the receive fifo before starting a new
read transfer.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio:xadc: Add workaround for PS7 event handling

The PS7 XADC threshold interrupts are level sensitive. Since we can't make the
threshold condition go way from within the interrupt handler, this means as soon
as a threshold condition is present we would enter the interrupt handler again
and again. To work around this we mask all active thresholds interrupts in the
interrupt handler and start a timer. In this timer we poll the interrupt status
and only if the interrupt is inactive we unmask it again.

[Lars-Peter Clausen: Style cleanups, minor fixes, use delayed work]
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio:xadc: Add support for reporting when an event goes inactive

Notify userspace when a threshold event goes inactive.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio: More event interface rework

This patch adds support for specifying additional properties for an event.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio: Add a hysteresis event info attribute

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio: xadc: Add support for setting the hysteresis of the temperature channel

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>