Skip to contentSkip to conversation

iio: light: add support for ams OSRAM TCS3430

PATCH New Robert Ijtsma 1 participant 3 messages Nov 28

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

v4 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 v4:
- Expose IIO_CHAN_INFO_SCALE via info_mask_shared_by_all across both the illuminance and intensity (X, Y, Z, IR1) channels since hardware gain and integration time scale all channels together (Jonathan Cameron).
- Replace <linux/device.h> with <linux/dev_printk.h> and <linux/device/devres.h>, and add blank lines before final return statements (Jonathan Cameron).
- Move devm_regulator_get_enable(dev, "vdd") after devm_iio_device_alloc() in tcs3430_probe() so hardware power is not touched on allocation failure (Andy Shevchenko).
- Pick up Andy Shevchenko's Reviewed-by on patch 2/2.
- Link to v3: https://patch.msgid.link/[email protected]

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                        | 529 +++++++++++++++++++++
 5 files changed, 600 insertions(+)

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

Best regards,

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

PATCH v4 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 000000000000..085a70e5557b
@@ -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 44540a1eb2b8..ea8ebd8ccd84 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.56.0
#2 lore raw

PATCH v4 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) and modified intensity channels for X, Y, Z, and IR1
- Shared scale and integration time controls 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 | 529 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 543 insertions(+)
MAINTAINERS +1 -0
index ea8ebd8ccd84..0534464e1d5d 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 462fff1ddef2..10723c9fc1fc 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 6672ed01a819..cd7b42e55246 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 +529 -0

529 lines not on this page · raw message

Signature · 1 line
2.56.0