Skip to contentSkip to conversation

dt-bindings: iio: light: add ltr390

PATCH Superseded Anshul Dalal 3 participants 7 messages Nov 9, 2023

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Anshul Dalal

author maintainer
#0 lore raw

PATCH 1/2 dt-bindings: iio: light: add ltr390

Add binding for Lite-On LTR390 which is an Ambient/UV light sensor that communicates over i2c with an address of 0x53.

Datasheet:
https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201.pdf

---
 .../bindings/iio/light/liteon,ltr390.yaml     | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml
Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml new file +51 -0
new file mode 100644
index 000000000000..90c20076b6c5
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/light/liteon,ltr390.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Lite-On LTR390 ALS and UV Sensor
+
+description: |
+  The Lite-On LTR390 is an ALS (Ambient Light Sensor) and a UV sensor in a
+  single package with i2c address of 0x53.
+
+  Datasheet: https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201.pdf
+
+maintainers:
+  - Anshul Dalal <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - liteon,ltr390
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+    description: |
+      Level interrupt pin with open drain output.
+      The sensor pulls this pin low when the measured reading is greater than
+      some configured threshold.
+
+  vdd-supply: true
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        light-sensor@53 {
+            compatible = "liteon,ltr390";
+            reg = <0x53>;
+        };
+    };
Signature · 1 line
2.42.0
author maintainer
#1 lore raw

PATCH 2/2 iio: light: driver for Lite-On ltr390

Implements driver for the Ambient/UV Light sensor LTR390. The driver exposes two ways of getting sensor readings:
1. Raw UV Counts directly from the sensor
2. The computed UV Index value with a percision of 2 decimal places

NOTE: Ambient light sensing has not been implemented yet.

Datasheet:
https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201.pdf

Driver tested on RPi Zero 2W

---
 MAINTAINERS                |   7 ++
 drivers/iio/light/Kconfig  |  11 ++
 drivers/iio/light/Makefile |   1 +
 drivers/iio/light/ltr390.c | 224 +++++++++++++++++++++++++++++++++++++
 4 files changed, 243 insertions(+)
 create mode 100644 drivers/iio/light/ltr390.c
MAINTAINERS +7 -0
index 81d5fc0bba68..c9f2238673f0 100644
@@ -12484,6 +12484,13 @@ S:	Maintained
 W:	http://linux-test-project.github.io/
 T:	git https://github.com/linux-test-project/ltp.git
 
+LTR390 AMBIENT/UV LIGHT SENSOR DRIVER
+M:	Anshul Dalal <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml
+F:	drivers/iio/light/ltr390.c
+
 LYNX 28G SERDES PHY DRIVER
 M:	Ioana Ciornei <[email protected]>
 L:	[email protected]
drivers/iio/light/Kconfig +11 -0
index 45edba797e4c..61993ae79afe 100644
@@ -347,6 +347,17 @@ config SENSORS_LM3533
 	  changes. The ALS-control output values can be set per zone for the
 	  three current output channels.
 
+config LTR390
+	tristate "LTR-390UV-01 ambient light and UV sensor"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  If you say yes here you get support for the Lite-On LTR-390UV-01
+	  ambient light and UV sensor.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called ltr390.
+
 config LTR501
 	tristate "LTR-501ALS-01 light sensor"
 	depends on I2C
drivers/iio/light/Makefile +1 -0
index c0db4c4c36ec..550f8b408bc2 100644
@@ -30,6 +30,7 @@ obj-$(CONFIG_SENSORS_ISL29028)	+= isl29028.o
 obj-$(CONFIG_ISL29125)		+= isl29125.o
 obj-$(CONFIG_JSA1212)		+= jsa1212.o
 obj-$(CONFIG_SENSORS_LM3533)	+= lm3533-als.o
+obj-$(CONFIG_LTR390)		+= ltr390.o
 obj-$(CONFIG_LTR501)		+= ltr501.o
 obj-$(CONFIG_LTRF216A)		+= ltrf216a.o
 obj-$(CONFIG_LV0104CS)		+= lv0104cs.o
drivers/iio/light/ltr390.c new file +224 -0

224 lines not on this page · raw message

Signature · 1 line
2.42.0
#2 lore raw

Re: [PATCH 2/2] iio: light: driver for Lite-On ltr390

Hi Anshul,

thanks for your patch!

Overall this looks good to me.

Quoted 13 lines · Anshul Dalal

Implements driver for the Ambient/UV Light sensor LTR390. The driver exposes two ways of getting sensor readings:
1. Raw UV Counts directly from the sensor
2. The computed UV Index value with a percision of 2 decimal places

NOTE: Ambient light sensing has not been implemented yet.

Datasheet:
https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201.pdf

Driver tested on RPi Zero 2W

(...)

Quoted 1 line

+#define LTR390_FRCTIONAL_PERCISION 100

This define is just too hard for me to read, can you rename it?

Does it mean LTR390_FRACTIONAL_PRECISION? It's fine to spell it out like that instead.

Yours,
Linus Walleij

author maintainer
#3 lore raw

Re: [PATCH 2/2] iio: light: driver for Lite-On ltr390

Hello Linus,

Quoted 21 lines · Linus Walleij

Hi Anshul,

thanks for your patch!

Overall this looks good to me.

Quoted 5 lines · Anshul Dalal

Implements driver for the Ambient/UV Light sensor LTR390. The driver exposes two ways of getting sensor readings:
1. Raw UV Counts directly from the sensor
2. The computed UV Index value with a percision of 2 decimal places

Quoted 8 lines

NOTE: Ambient light sensing has not been implemented yet.

Datasheet:
https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201.pdf

Driver tested on RPi Zero 2W

Quoted 8 lines

(...)

Quoted 1 line

+#define LTR390_FRCTIONAL_PERCISION 100

This define is just too hard for me to read, can you rename it?

Does it mean LTR390_FRACTIONAL_PRECISION? It's fine to spell it out like that instead.

Yes indeed, that typo would be fixed in the next revision.

Thanks for the review.

Best wishes,
Anshul

#4 lore raw
In reply to Anshul Dalal
Quoted 23 lines · Anshul Dalal

Add binding for Lite-On LTR390 which is an Ambient/UV light sensor that communicates over i2c with an address of 0x53.

Datasheet:
https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201.pdf

Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml new file +14 -0
+  interrupts:
+    maxItems: 1
+    description: |
+      Level interrupt pin with open drain output.
+      The sensor pulls this pin low when the measured reading is greater than
+      some configured threshold.
+
+  vdd-supply: true
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false

Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml line 49

Quoted 10 lines
Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml new file +10 -0
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        light-sensor@53 {
+            compatible = "liteon,ltr390";
+            reg = <0x53>;

Please extend the example to be complete - interrupts and vdd-supply.

Best regards,
Krzysztof

author maintainer
#5 lore raw

Hello Krzysztof,

Quoted 28 lines · Krzysztof Kozlowski
Quoted 27 lines · Anshul Dalal

Add binding for Lite-On LTR390 which is an Ambient/UV light sensor that communicates over i2c with an address of 0x53.

Datasheet:
https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201.pdf

Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml new file +18 -0
+  interrupts:
+    maxItems: 1
+    description: |
+      Level interrupt pin with open drain output.
+      The sensor pulls this pin low when the measured reading is greater than
+      some configured threshold.
+
+  vdd-supply: true
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
Quoted 8 lines

Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml line 49

Quoted 6 lines
Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml new file +6 -0
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        light-sensor@53 {
+            compatible = "liteon,ltr390";
+            reg = <0x53>;

Please extend the example to be complete - interrupts and vdd-supply.

Could the following be used as a suitable example.

#include <dt-bindings/interrupt-controller/irq.h>

i2c {
    #address-cells = <1>;
    #size-cells = <0>;

    light-sensor@53 {
        compatible = "liteon,ltr390";
        reg = <0x53>;
        interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
        vdd-supply = <&vdd_regulator>;
    };
};

Thanks for the review.

Best regards,
Anshul

#6 lore raw
Quoted 12 lines · Anshul Dalal
Quoted 11 lines

Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml line 49

Quoted 9 lines
Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml new file +9 -0
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        light-sensor@53 {
+            compatible = "liteon,ltr390";
+            reg = <0x53>;

Please extend the example to be complete - interrupts and vdd-supply.

Quoted 2 lines

Could the following be used as a suitable example.

Yes

Best regards,
Krzysztof