staging: iio: tsl2x7x: make proximity sensor function correctly
authorBrian Masney <masneyb@onstation.org>
Sun, 4 Mar 2018 01:49:42 +0000 (20:49 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 10 Mar 2018 14:56:06 +0000 (14:56 +0000)
commit2ab5b72453672ea18a176925becc40888df435ce
tree6f50ee68c6ec83cd0a1cf547bc6b3349f88d4491
parent8d923921f9ae2a1bc20ce37a2abcc2dbce16188e
staging: iio: tsl2x7x: make proximity sensor function correctly

The bits for setting up the proximity diode were not setup correctly and
this was causing the proximity sensor to not function correctly. This
patch sets up the correct bit mask in tsl2x7x_chip_on() based on what
the data sheet expects. From page 35 of the TSL2771 data sheet:
https://ams.com/eng/content/download/250264/976045/file/TSL2771_DS000105_3-00.pdf

- Bits 0-1 is the ALS gain control
- Bits 2-3 is reserved (The proximity gain control on other tsl2x7x chips)
- Bits 4-5 is the proximity diode select
- Bits 6-7 is the LED drive strength

tsl2x7x_chip_on() had the power and diode hardcoded, so these are
extracted out into the settings so that these fields can be configured
in the platform data.

The default prox_gain is changed from 1 (2X gain) to 0 (1X gain) since
the proximity gain control on the TSL2771, TMD2771, and other chips have
these fields listed as reserved, and to write 0 into those bits.

Verified that the proximity sensor now works correctly on a TSL2771
hooked up to a Raspberry Pi 2.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/staging/iio/light/tsl2x7x.c
drivers/staging/iio/light/tsl2x7x.h