]> git.karo-electronics.de Git - linux-beck.git/commit
iio: ltr501: Add interrupt rate control support
authorKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Sun, 19 Apr 2015 09:10:03 +0000 (02:10 -0700)
committerJonathan Cameron <jic23@kernel.org>
Sun, 19 Apr 2015 12:43:33 +0000 (13:43 +0100)
commiteea53b4a2562e439bfc1a6d13b231f902d9b9e5f
tree9b0eb8587158211ae8083ceafb2e1f68403dfb58
parent7ac702b3144b635a8f7770e628d88ea1cbeda7ee
iio: ltr501: Add interrupt rate control support

Added rate control support for ALS and proximity
threshold interrupts.Also, Added support to modify
and read ALS & proximity sensor sampling frequency.

LTR-501 supports interrupt rate control using persistence
register settings. Writing <n> to persistence register
would generate interrupt only if there are <n> consecutive
data values outside the threshold range.

Since we don't have any existing ABI's to directly
control the persistence register count, we have implemented
the rate control using IIO_EV_INFO_PERIOD. _period event
attribute represents the amount of time in seconds an
event should be true for the device to generate the
interrupt. So using _period value and device frequency,
persistence count is calculated in driver using following
logic.

count =  period / measurement_rate

If the given period is not a multiple of measurement rate then
we round up the value to next multiple.

This patch also handles change to persistence count whenever
there is change in frequency.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/light/ltr501.c