Skip to contentSkip to conversation

Added AMS tsl2591 driver implementation

PATCH Superseded Joe Sandom 3 participants 7 messages Mar 25, 2021 – Apr 2, 2021

Subsystems (2)

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Joe Sandom

author
#0 lore raw

PATCH v6 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: https://ams.com/tsl25911#tab/documents

---

Changes in v6;
- Separated tsl2591_set_als_thresholds into tsl2591_set_als_lower_threshold and tsl2591_set_upper_threshold for cleaner handling of forcing values when thresholds are met
- Added als persist value as an argument to tsl2591_set_als_persist_cycle to assign to chip from within the function. Cleaner approach.
- Cleaned up power_state handling in tsl2591_resume function
- Corrected interrupt handler to return IRQ_NONE in case of spurious interrupt

 drivers/iio/light/Kconfig   |   11 +
 drivers/iio/light/Makefile  |    1 +
 drivers/iio/light/tsl2591.c | 1215 +++++++++++++++++++++++++++++++++++
 3 files changed, 1227 insertions(+)
 create mode 100644 drivers/iio/light/tsl2591.c
drivers/iio/light/Kconfig +11 -0
index 33ad4dd0b5c7..6a69a9a3577a 100644
@@ -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 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
index ea376deaca54..d10912faf964 100644
@@ -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 +1215 -0

1,215 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v6 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: https://ams.com/tsl25911#tab/documents

---
Changes in v6:
- No changes

Notes:
- Re-submitted to align the version with part 1 of the patch series

 .../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
new file mode 100644
index 000000000000..596a3bc770f4
@@ -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
maintainer
#2 lore raw

Re: [PATCH v6 2/2] Added AMS tsl2591 device tree binding

Quoted 18 lines · Joe Sandom

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: https://ams.com/tsl25911#tab/documents

---
Changes in v6:
- No changes

Quoted 7 lines

Notes:
- Re-submitted to align the version with part 1 of the patch series

 .../bindings/iio/light/amstaos,tsl2591.yaml   | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/light/amstaos,tsl2591.yaml

Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.

If a tag was not added on purpose, please state why and what changed.

author
#3 lore raw

Re: [PATCH v6 2/2] Added AMS tsl2591 device tree binding

Quoted 28 lines · Rob Herring
Quoted 18 lines · Joe Sandom

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: https://ams.com/tsl25911#tab/documents

---
Changes in v6:
- No changes

Quoted 7 lines

Notes:
- Re-submitted to align the version with part 1 of the patch series

 .../bindings/iio/light/amstaos,tsl2591.yaml   | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/light/amstaos,tsl2591.yaml
Quoted 6 lines

Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.

If a tag was not added on purpose, please state why and what changed.

Thanks for pointing that out Rob, will amend that now and resend for this version.

#4 lore raw

Re: [PATCH v6 2/2] Added AMS tsl2591 device tree binding

In reply to Rob Herring
Quoted 1 line · Rob Herring

On Thu, 25 Mar 2021 22:05:04 +0000, Joe Sandom wrote:

...

Quoted 1 line
Quoted 1 line

Datasheet: https://ams.com/tsl25911#tab/documents

Not necessarily needed in this patch, but it's harmless.

...

Quoted 3 lines

However,
there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.

Joe, seems you missed this part of Rob's message when resending.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
In reply to Joe Sandom
Quoted 11 lines · Joe Sandom

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.

I'm under the impression that you ignored at least half of my comments [1]. Have you seen them?

[1]: https://lore.kernel.org/linux-iio/CAHp75VcSW2xXdH--rXaN7xt0Ju+qfw9c_va0gGRGPgpBua0H-Q@mail.gmail.com/

Please. address and come again.
NAK for this version, sorry.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#6 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Joe Sandom

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.

Quoted 4 lines
Quoted 2 lines

This is a very-high sensitivity light-to-digital converter that transforms light intensity into a digital signal.

I'm under the impression that you ignored at least half of my comments

The majority of your comments were applied in V5 as far as I can see. Some of them I recognised as optional at the time. I had another sweep through and have seen value in enforcing a few of the other points you mentioned. I've added them to V7 and will release shortly. Thanks for the feedback Andy.

Quoted 10 lines

[1]. Have you seen them?

[1]: https://lore.kernel.org/linux-iio/CAHp75VcSW2xXdH--rXaN7xt0Ju+qfw9c_va0gGRGPgpBua0H-Q@mail.gmail.com/

Please. address and come again.
NAK for this version, sorry.

Signature · 2 lines
With Best Regards,
Andy Shevchenko