Skip to contentSkip to conversation

iio: light: add support for TI's opt3001 light sensor

PATCH New Andreas Dannenberg 1 participant 1 message Jun 24, 2015 IIO

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iio: light: add support for TI's opt3001 light sensor

TI's opt3001 light sensor is a simple and yet powerful little device. The device provides 99% IR rejection, automatic full-scale, very low power consumption and measurements from 0.01 to 83k lux.

This patch adds support for that device using the IIO framework.

See http://www.ti.com/product/opt3001 for more information.

---
This is the second version of the patch with feedback incorporated and additional improvements made as follows:

* Fix restoring of IRQ mutex functionality in error case
* Use managed IIO device alloc/registration
* Add parenthesis to improve formula readability
* Fix error message number formatting
* Improve integration time parameter checks
* Clean up redundant return value assignments
* Fix broken lookup table algorithm
* Fix duplicate lookup table entry
* Disallow writing of negative event values

The individual commits can be reviewed at:
http://git.ti.com/cgit/cgit.cgi/ti-analog-linux-kernel/adannenb-analog.git/log/?h=opt3001

Also (and I'm somewhat new to this), looks like I will need to provide DT binding documentation. I do have a working configuration I could document however while researching I found other drivers using a .of_match_table element inside the struct i2c_driver to define a proper .compatible string. Is this something new/required for drivers? My driver doesn't do this yet but I can certainly update it.

 drivers/iio/light/Kconfig   |  10 +
 drivers/iio/light/Makefile  |   1 +
 drivers/iio/light/opt3001.c | 798 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 809 insertions(+)
 create mode 100644 drivers/iio/light/opt3001.c
drivers/iio/light/Kconfig +10 -0
index 01a1a16..665b182 100644
@@ -186,6 +186,16 @@ config TCS3414
 	 This driver can also be built as a module.  If so, the module
 	 will be called tcs3414.
 
+config OPT3001
+	tristate "Texas Instruments OPT3001 Light Sensor"
+	depends on I2C
+	help
+	  If you say Y or M here, you get support for Texas Instruments
+	  OPT3001 Ambient Light Sensor.
+
+	  If built as a dynamically linked module, it will be called
+	  opt3001.
+
 config TCS3472
 	tristate "TAOS TCS3472 color light-to-digital converter"
 	depends on I2C
drivers/iio/light/Makefile +1 -0
index ad7c30f..a498631 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_ISL29125)		+= isl29125.o
 obj-$(CONFIG_JSA1212)		+= jsa1212.o
 obj-$(CONFIG_SENSORS_LM3533)	+= lm3533-als.o
 obj-$(CONFIG_LTR501)		+= ltr501.o
+obj-$(CONFIG_OPT3001)		+= opt3001.o
 obj-$(CONFIG_SENSORS_TSL2563)	+= tsl2563.o
 obj-$(CONFIG_TCS3414)		+= tcs3414.o
 obj-$(CONFIG_TCS3472)		+= tcs3472.o
drivers/iio/light/opt3001.c new file +798 -0

798 lines not on this page · raw message

Signature · 1 line
1.9.1