iio: sx9500: optimize power usage
authorVlad Dogaru <vlad.dogaru@intel.com>
Sun, 12 Apr 2015 17:09:19 +0000 (20:09 +0300)
committerJonathan Cameron <jic23@kernel.org>
Sat, 18 Apr 2015 19:11:52 +0000 (20:11 +0100)
commit59bd0427c01cf0172055a1b99457bee6fd75d865
tree85842329c0b6cdecfbb4ebf7f8752df71583df0a
parent6069f47f08ea670e28ae709c645e308e98636d6c
iio: sx9500: optimize power usage

In the interest of lowering power usage, we only activate the proximity
channels and interrupts that we are currently using.

For raw reads, we activate the corresponding channel and the data ready
interrupt and wait for the interrupt to trigger.  If no interrupt is
available, we wait for the documented scan period, as specified in the
datasheet.

The following types of usage patterns may overlap:

* raw proximity reads (need a single data ready interrupt)
* trigger usage (needs data ready interrupts as long as active)
* proximity events (need near/far interrupts)
* triggered buffer reads (don't need any interrupts, but are usually
coupled with our own trigger.

To mitigate all possible patterns, we implement usage counting for all
the resources used: data ready interrupts, near/far interrupts and
individual channels.

The device enters sleep mode as documented in the data sheet when its
buffer, trigger and events are disabled, and no raw reads are currently
running.

Because of this new usage pattern, it is important that we give the
device a chance to perform an initial compensation for all its channels
at probe time.

Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/proximity/sx9500.c
This page took 0.025346 seconds and 5 git commands to generate.