Skip to contentSkip to conversation

iio: light: add support for ams OSRAM TCS3430

PATCH New Robert Ijtsma 1 participant 3 messages Nov 27

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover iio: light: add support for ams OSRAM TCS3430

Add Devicetree binding documentation and an IIO driver for the ams OSRAM TCS3430 ambient light and CIE 1931 XYZ tristimulus color sensor.

Tested on Microsoft Surface Pro X SQ2 (SC8180X), where the sensor is connected on I2C at 0x39 and used for ambient light sensing.

---
Changes in v3:
- Import the IIO_GTS_HELPER module namespace via MODULE_IMPORT_NS("IIO_GTS_HELPER") so modular builds (CONFIG_TCS3430=m) pass modpost.
- Enable REGCACHE_MAPLE with a volatile register table (0x92..0x9b) and regcache_cache_only()/regcache_mark_dirty()/regcache_sync() across suspend/resume (Andy Shevchenko).
- Align Kconfig tristate prompt, top driver comment, and MODULE_DESCRIPTION(), and keep driver-separation rationale in the commit message rather than Kconfig help (Andy Shevchenko).
- Simplify tcs3430_set_scale() to drop the keep_time boolean, rename in_range to gain_in_range in tcs3430_set_itime(), use local regmap variables for readability, add blank lines after guard(mutex)(), and keep dev_dbg()/DEFINE_SIMPLE_DEV_PM_OPS() on single lines (Andy Shevchenko).
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Replace hardwaregain control with standard IIO _scale and configurable integration time using the IIO GTS helper (Jonathan Cameron).
- Hold data->lock across the entire IIO_CHAN_INFO_SCALE path in tcs3430_read_raw() (Jonathan Cameron).
- Convert register I/O to regmap_i2c (Joshua Crofts).
- Wrap guard(mutex) declarations in tcs3430_read_raw() switch cases in enclosing blocks to fix Clang -Wjump-misses-init / cleanup scoping (kernel test robot, Joshua Crofts).
- Use switch(mask) in tcs3430_read_avail() and tcs3430_write_raw(), and drop unused linux/mod_devicetable.h include (Joshua Crofts).
- Drop redundant L: mailing-list line from MAINTAINERS (Joshua Crofts).
- Pick up Krzysztof Kozlowski's Reviewed-by on dt-bindings.
- Link to v1: https://patch.msgid.link/[email protected]

---
Robert Ijtsma (2):
dt-bindings: iio: light: add ams OSRAM TCS3430
iio: light: add ams OSRAM TCS3430 XYZ and ambient light sensor driver

 .../devicetree/bindings/iio/light/ams,tcs3430.yaml |  52 ++
 MAINTAINERS                                        |   6 +
 drivers/iio/light/Kconfig                          |  12 +
 drivers/iio/light/Makefile                         |   1 +
 drivers/iio/light/tcs3430.c                        | 521 +++++++++++++++++++++
 5 files changed, 592 insertions(+)

---
base-commit: 4843f6873f7c4835e62f2c73ba0fd538e57a2f22
change-id: 20261124-iio-tcs3430-2f53879527ed

Best regards,

Signature · 1 line
Robert Ijtsma <[email protected]>
#1 lore raw

PATCH v3 1/2 dt-bindings: iio: light: add ams OSRAM TCS3430

Add Devicetree binding schema for the ams OSRAM TCS3430 ambient light and CIE 1931 XYZ tristimulus color sensor.

---
 .../devicetree/bindings/iio/light/ams,tcs3430.yaml | 52 ++++++++++++++++++++++
 MAINTAINERS                                        |  5 +++
 2 files changed, 57 insertions(+)
Documentation/devicetree/bindings/iio/light/ams,tcs3430.yaml new file +52 -0
new file mode 100644
index 0000000000000000000000000000000000000000..085a70e5557b1b5201bdd11e00736af065e002de
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/light/ams,tcs3430.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ams OSRAM TCS3430 XYZ Tristimulus Color and Ambient Light Sensor
+
+maintainers:
+  - Robert Ijtsma <[email protected]>
+
+description: |
+  The ams OSRAM TCS3430 is an I2C ambient light and CIE 1931 XYZ tristimulus
+  color sensor with photopic Y, Z, X, and IR channels.
+
+  Datasheet: https://look.ams-osram.com/m/43d518b4cd81e3f2/original/TCS3430-DS000539.pdf
+
+properties:
+  compatible:
+    const: ams,tcs3430
+
+  reg:
+    maxItems: 1
+
+  vdd-supply: true
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - vdd-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        light-sensor@39 {
+            compatible = "ams,tcs3430";
+            reg = <0x39>;
+            vdd-supply = <&vdd_reg>;
+            interrupts = <24 IRQ_TYPE_LEVEL_LOW>;
+        };
+    };
+...
MAINTAINERS +5 -0
index 44540a1eb2b8088f9da95a9b6f83b4bf05188ee1..ea8ebd8ccd849702e82bf6aaeb4d8d60c2255628 100644
@@ -1489,6 +1489,11 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/iio/light/ams,as73211.yaml
 F:	drivers/iio/light/as73211.c
 
+AMS TCS3430 DRIVER
+M:	Robert Ijtsma <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/light/ams,tcs3430.yaml
+
 AMT (Automatic Multicast Tunneling)
 M:	Taehee Yoo <[email protected]>
 L:	[email protected]
Signature · 1 line
2.47.3
#2 lore raw

PATCH v3 2/2 iio: light: add ams OSRAM TCS3430 XYZ and ambient light sensor driver

In reply to Robert Ijtsma

Add an IIO driver for the ams OSRAM TCS3430 ambient light and CIE 1931 XYZ tristimulus color sensor (found at I2C address 0x39 on devices such as the Microsoft Surface Pro X).

Unlike the older TAOS RGBC drivers (tcs3414, tcs3472) that use the 0x80 COMMAND-bit SMBus protocol and RGBC channels, and unlike the banked MAZeT/JENCOLOR as73211 driver, the TCS3430 uses ams's direct-addressed 0x80..0xdd register map and exposes Z, Y, IR1, and X tristimulus channels.

The driver exposes:
- Illuminance (photopic Y channel) with raw counts and lux scale
- Modified intensity channels for X, Y, Z, and IR1
- Selectable scale and integration time via the IIO GTS helper across 1x/4x/16x/64x/128x gain and 50.04/100.08/200.16/400.32 ms integration time settings
- Regulator management and system sleep suspend/resume support

Tested on Microsoft Surface Pro X SQ2 (SC8180X).

---
 MAINTAINERS                 |   1 +
 drivers/iio/light/Kconfig   |  12 +
 drivers/iio/light/Makefile  |   1 +
 drivers/iio/light/tcs3430.c | 521 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 535 insertions(+)
MAINTAINERS +1 -0
index ea8ebd8ccd849702e82bf6aaeb4d8d60c2255628..0534464e1d5df51a5ddbc77798143fa1eb03f9cc 100644
@@ -1493,6 +1493,7 @@ AMS TCS3430 DRIVER
 M:	Robert Ijtsma <[email protected]>
 S:	Maintained
 F:	Documentation/devicetree/bindings/iio/light/ams,tcs3430.yaml
+F:	drivers/iio/light/tcs3430.c
 
 AMT (Automatic Multicast Tunneling)
 M:	Taehee Yoo <[email protected]>
drivers/iio/light/Kconfig +12 -0
index 462fff1ddef20700aedf20743c3e8a36017a9151..10723c9fc1fca60c663073f4c69ffebd8b89e135 100644
@@ -609,6 +609,18 @@ config TCS3414
 	  This driver can also be built as a module.  If so, the module
 	  will be called tcs3414.
 
+config TCS3430
+	tristate "ams OSRAM TCS3430 ambient light and CIE 1931 XYZ sensor"
+	depends on I2C
+	select IIO_GTS_HELPER
+	select REGMAP_I2C
+	help
+	  If you say yes here you get support for the ams OSRAM TCS3430
+	  ambient light and CIE 1931 XYZ tristimulus color sensor.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called tcs3430.
+
 config TCS3472
 	tristate "TAOS TCS3472 color light-to-digital converter"
 	depends on I2C
drivers/iio/light/Makefile +1 -0
index 6672ed01a8193b9e96a9c84ba5d069f37b307a08..cd7b42e5524678c112e0ffa1b4dc07222077262d 100644
@@ -56,6 +56,7 @@ obj-$(CONFIG_ST_UVIS25)		+= st_uvis25_core.o
 obj-$(CONFIG_ST_UVIS25_I2C)	+= st_uvis25_i2c.o
 obj-$(CONFIG_ST_UVIS25_SPI)	+= st_uvis25_spi.o
 obj-$(CONFIG_TCS3414)		+= tcs3414.o
+obj-$(CONFIG_TCS3430)		+= tcs3430.o
 obj-$(CONFIG_TCS3472)		+= tcs3472.o
 obj-$(CONFIG_SENSORS_TSL2563)	+= tsl2563.o
 obj-$(CONFIG_TSL2583)		+= tsl2583.o
drivers/iio/light/tcs3430.c new file +521 -0

521 lines not on this page · raw message

Signature · 1 line
2.47.3