Added AMS tsl2591 driver implementation
Subsystems (2)
PATCH v4 1/2 Added AMS tsl2591 driver implementation
Driver implementation for AMS/TAOS tsl2591 ambient light sensor.
This driver supports configuration via device tree and sysfs. Supported channels for raw infrared light intensity, raw combined light intensity and illuminance in lux. The driver additionally supports iio events on lower and upper thresholds.
This is a very-high sensitivity light-to-digital converter that transforms light intensity into a digital signal.
Datasheet Available at: https://ams.com/tsl25911
---
Changes in v4:
- Moved binding document to a separate patch and is now formed as a patch series
- Ensure vendor prefix is included in macros and that macros have appropriate naming
- Made use of BIT, GENMASK and FIELD_GET where appropriate for improved readability
- Corrected data channels terminology to more appropriate data register naming
- Removed tsl2591_als_readings and return data directly depending on the channel being read. See tsl2591_read_channel_data.
- Add more detailed comment on mutex definition
- Read als data as a block read instead of 4 separate byte reads
- Reserve *_compatible functions for checking compatibility, not for assigning the setting value
- Enforce setting corresponding upper/lower threshold to avoid issues in ordering when modifying thresholds
- Remove tsl2591_sysfs_attrs_ctrl and use info_mask to handle sysfs configuration where applicable
- Use .read_avail callback for *_available functions
- In .write_event_value, clean up period calculation handling. Removed some redundant code.
- Cleaned up some debug prints
- Cleaned up mutex handling for improved readability
- Ensured not to swallow return code in if statements in function calls
drivers/iio/light/Kconfig | 11 + drivers/iio/light/Makefile | 1 + drivers/iio/light/tsl2591.c | 1217 +++++++++++++++++++++++++++++++++++ 3 files changed, 1229 insertions(+) create mode 100644 drivers/iio/light/tsl2591.c
drivers/iio/light/Kconfig +11 -0
@@ -501,6 +501,17 @@ config TSL2583 Provides support for the TAOS tsl2580, tsl2581 and tsl2583 devices. Access ALS data via iio, sysfs. +config TSL2591 + tristate "TAOS TSL2591 ambient light sensor" + depends on I2C + help + Select Y here for support of the AMS/TAOS TSL2591 ambient light sensor, + featuring channels for combined visible + IR intensity and lux illuminance. + Access als data via iio and sysfs. Supports iio_events. + + To compile this driver as a module, select M: the + module will be called tsl2591. + config TSL2772 tristate "TAOS TSL/TMD2x71 and TSL/TMD2x72 Family of light and proximity sensors" depends on I2C
drivers/iio/light/Makefile +1 -0
@@ -48,6 +48,7 @@ obj-$(CONFIG_ST_UVIS25_SPI) += st_uvis25_spi.o obj-$(CONFIG_TCS3414) += tcs3414.o obj-$(CONFIG_TCS3472) += tcs3472.o obj-$(CONFIG_TSL2583) += tsl2583.o +obj-$(CONFIG_TSL2591) += tsl2591.o obj-$(CONFIG_TSL2772) += tsl2772.o obj-$(CONFIG_TSL4531) += tsl4531.o obj-$(CONFIG_US5182D) += us5182d.o
drivers/iio/light/tsl2591.c new file +1217 -0
1,217 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 2/2 Added AMS tsl2591 device tree binding
Device tree binding for AMS/TAOS tsl2591 ambient light sensor.
This driver supports configuration via device tree and sysfs. Supported channels for raw infrared light intensity, raw combined light intensity and illuminance in lux. The driver additionally supports iio events on lower and upper thresholds.
This is a very-high sensitivity light-to-digital converter that transforms light intensity into a digital signal.
Datasheet Available at: https://ams.com/tsl25911
---
Changes in v4:
- Corrected id field to include vendor name in prefix
Notes:
- Previously incorrectly included binding in same patch as driver. This was pointed out by the maintainer and has now been changed to a patch series. Sorry for the confusion!
.../bindings/iio/light/amstaos,tsl2591.yaml | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/amstaos,tsl2591.yaml
Documentation/devicetree/bindings/iio/light/amstaos,tsl2591.yaml new file +50 -0
@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/amstaos,tsl2591.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMS/TAOS TSL2591 Ambient Light Sensor (ALS) + +maintainers: + - Joe Sandom <[email protected]> + +description: | + AMS/TAOS TSL2591 is a very-high sensitivity + light-to-digital converter that transforms light intensity into a digital + signal. + +properties: + compatible: + const: amstaos,tsl2591 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + description: + Interrupt (INT:Pin 2) Active low. Should be set to IRQ_TYPE_EDGE_FALLING. + interrupt is used to detect if the light intensity has fallen below + or reached above the configured threshold values. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + + tsl2591@29 { + compatible = "amstaos,tsl2591"; + reg = <0x29>; + interrupts = <20 IRQ_TYPE_EDGE_FALLING>; + }; + }; +...
Signature · 1 line
2.17.1