Repository: raspberrypi/linux
Pull request #6448: Add TCS3472 and VEML6040 sensor support (and a few others)
Author: login: pelwell
Created: 2024-10-29T17:16:26Z | Merged: 2025-04-25T15:34:41Z

Add support for the I2C sensors requested in #6446, and a few other related devices.



Diff:
diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README
index da2d0f1c34559d..8ef59f4f8dcc66 100644
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -2567,12 +2567,18 @@ Params: addr                    Set the address for the ADT7410, AS73211,
         sgp30                   Select the Sensirion SGP30 VOC sensor.
                                 Fixed address 0x58.
 
+        tcs3472                 Select the AMS TAOS TCS3472 family of RGBW light
+                                sensors.
+                                Valid addresses 0x48-0x4b, default 0x48
+
         tmp102                  Select the Texas Instruments TMP102 temp sensor
                                 Valid addresses 0x48-0x4b, default 0x48
 
         tsl4531                 Select the AMS TSL4531 digital ambient light
                                 sensor
 
+        veml6040                Select the Vishay VEML6040 RGBW light sensor
+
         veml6070                Select the Vishay VEML6070 ultraviolet light
                                 sensor
 
diff --git a/arch/arm/boot/dts/overlays/i2c-sensor-common.dtsi b/arch/arm/boot/dts/overlays/i2c-sensor-common.dtsi
index 18939e3fc04863..6f4d0675420259 100755
--- a/arch/arm/boot/dts/overlays/i2c-sensor-common.dtsi
+++ b/arch/arm/boot/dts/overlays/i2c-sensor-common.dtsi
@@ -680,6 +680,39 @@
 		};
 	};
 
+	fragment@44 {
+		target = <&i2cbus>;
+		__dormant__ {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "okay";
+
+			tcs3472: tcs3472@29 {
+				compatible = "amstaos,tcs3472";
+				reg = <0x29>;
+				interrupt-parent = <&gpio>;
+				interrupts = <4 IRQ_TYPE_EDGE_RISING>;
+				pinctrl-0 = <&int_pins>;
+				pinctrl-names = "default";
+			};
+		};
+	};
+
+	fragment@45 {
+		target = <&i2cbus>;
+		__dormant__ {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "okay";
+
+			veml6040: veml6040@10 {
+				compatible = "vishay,veml6040";
+				reg = <0x10>;
+				status = "okay";
+			};
+		};
+	};
+
 	fragment@99 {
 		target = <&gpio>;
 		__dormant__ {
@@ -736,6 +769,8 @@
 		as7331 = <0>,"+41+99";
 		adxl345 = <0>,"+42+99";
 		aht20 = <0>,"+43";
+		tcs3472 = <0>,"+44+99";
+		veml6040 = <0>,"+45";
 
 		addr =	<&bme280>,"reg:0", <&bmp280>,"reg:0", <&tmp102>,"reg:0",
 			<&lm75>,"reg:0", <&hdc100x>,"reg:0", <&sht3x>,"reg:0",
@@ -757,7 +792,8 @@
 			<&hdc3020>, "interrupts:0",
 			<&as73211>, "interrupts:0",
 			<&as7331>, "interrupts:0",
-			<&adxl345>, "interrupts:0";
+			<&adxl345>, "interrupts:0",
+			<&tcs3472>, "interrupts:0";
 		no_timeout = <&jc42>, "smbus-timeout-disable?";
 		reset_pin = <&bno055>,"reset-gpios:4", <0>,"+30";
 		shunt_resistor = <&ina238>,"shunt-resistor:0";
diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig
index e332696c85cafd..8592e0ab6b40cc 100644
--- a/arch/arm/configs/bcm2709_defconfig
+++ b/arch/arm/configs/bcm2709_defconfig
@@ -1437,7 +1437,9 @@ CONFIG_INV_MPU6050_I2C=m
 CONFIG_APDS9960=m
 CONFIG_AS73211=m
 CONFIG_BH1750=m
+CONFIG_TCS3472=m
 CONFIG_TSL4531=m
+CONFIG_VEML6040=m
 CONFIG_VEML6070=m
 CONFIG_VEML6075=m
 CONFIG_IIO_HRTIMER_TRIGGER=m
diff --git a/arch/arm/configs/bcm2711_defconfig b/arch/arm/configs/bcm2711_defconfig
index 60092939599e4b..f4bcb2d44216e0 100644
--- a/arch/arm/configs/bcm2711_defconfig
+++ b/arch/arm/configs/bcm2711_defconfig
@@ -1471,7 +1471,9 @@ CONFIG_INV_MPU6050_I2C=m
 CONFIG_APDS9960=m
 CONFIG_AS73211=m
 CONFIG_BH1750=m
+CONFIG_TCS3472=m
 CONFIG_TSL4531=m
+CONFIG_VEML6040=m
 CONFIG_VEML6070=m
 CONFIG_VEML6075=m
 CONFIG_IIO_HRTIMER_TRIGGER=m
diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig
index cfc3ebd641790e..7c842fae9b3e2f 100644
--- a/arch/arm/configs/bcmrpi_defconfig
+++ b/arch/arm/configs/bcmrpi_defconfig
@@ -1429,7 +1429,9 @@ CONFIG_INV_MPU6050_I2C=m
 CONFIG_APDS9960=m
 CONFIG_AS73211=m
 CONFIG_BH1750=m
+CONFIG_TCS3472=m
 CONFIG_TSL4531=m
+CONFIG_VEML6040=m
 CONFIG_VEML6070=m
 CONFIG_VEML6075=m
 CONFIG_IIO_HRTIMER_TRIGGER=m
diff --git a/arch/arm64/configs/bcm2711_defconfig b/arch/arm64/configs/bcm2711_defconfig
index ac43e21b1c1936..05abfbed9a1acf 100644
--- a/arch/arm64/configs/bcm2711_defconfig
+++ b/arch/arm64/configs/bcm2711_defconfig
@@ -1534,7 +1534,9 @@ CONFIG_INV_MPU6050_I2C=m
 CONFIG_APDS9960=m
 CONFIG_AS73211=m
 CONFIG_BH1750=m
+CONFIG_TCS3472=m
 CONFIG_TSL4531=m
+CONFIG_VEML6040=m
 CONFIG_VEML6070=m
 CONFIG_VEML6075=m
 CONFIG_IIO_HRTIMER_TRIGGER=m
diff --git a/arch/arm64/configs/bcm2711_rt_defconfig b/arch/arm64/configs/bcm2711_rt_defconfig
index 15ad23b51e987f..c29c0dd3092a03 100644
--- a/arch/arm64/configs/bcm2711_rt_defconfig
+++ b/arch/arm64/configs/bcm2711_rt_defconfig
@@ -1533,7 +1533,9 @@ CONFIG_INV_MPU6050_I2C=m
 CONFIG_APDS9960=m
 CONFIG_AS73211=m
 CONFIG_BH1750=m
+CONFIG_TCS3472=m
 CONFIG_TSL4531=m
+CONFIG_VEML6040=m
 CONFIG_VEML6070=m
 CONFIG_VEML6075=m
 CONFIG_IIO_HRTIMER_TRIGGER=m
diff --git a/arch/arm64/configs/bcm2712_defconfig b/arch/arm64/configs/bcm2712_defconfig
index be8e16567d083b..483dd8b529b5f9 100644
--- a/arch/arm64/configs/bcm2712_defconfig
+++ b/arch/arm64/configs/bcm2712_defconfig
@@ -1536,7 +1536,9 @@ CONFIG_INV_MPU6050_I2C=m
 CONFIG_APDS9960=m
 CONFIG_AS73211=m
 CONFIG_BH1750=m
+CONFIG_TCS3472=m
 CONFIG_TSL4531=m
+CONFIG_VEML6040=m
 CONFIG_VEML6070=m
 CONFIG_VEML6075=m
 CONFIG_IIO_HRTIMER_TRIGGER=m


Reviews:
user: login: gnustomp
body: With `sudo rpi-update pulls/6448`, the devicetree node of VEML6040 is present but there is no driver loaded.

```
$ uname -a
Linux dispi 6.12.22-v8-16k+ #1 SMP PREEMPT Thu Apr 24 17:25:53 UTC 2025 aarch64 GNU/Linux
$ cat /boot/firmware/config.txt
<snipped>
dtoverlay=i2c-sensor,bme280,veml6040
$ cat /sys/firmware/devicetree/base/axi/pcie@1000120000/rp1/i2c@74000/veml6040@10/status; echo
okay
$ lsmod | grep veml6040
$ ls /lib/modules/6.12.22-v8-16k+/kernel/drivers/iio/light
apds9960.ko.xz  as73211.ko.xz  bh1750.ko.xz  tcs3472.ko.xz  tsl4531.ko.xz  veml6070.ko.xz  veml6075.ko.xz
```
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-25T01:40:03Z
user: login: pelwell
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-25T14:01:00Z

Review comments:
diff_hunk: @@ -1536,6 +1536,7 @@ CONFIG_INV_MPU6050_I2C=m
 CONFIG_APDS9960=m
 CONFIG_AS73211=m
 CONFIG_BH1750=m
+CONFIG_TCS3472=m
 CONFIG_TSL4531=m
 CONFIG_VEML6070=m
path: arch/arm64/configs/bcm2712_defconfig
user: login: gnustomp
body: I think `CONFIG_VEML6040=m` needs to be added to the defconfigs.
created_at: 2025-04-25T01:35:38Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1536,6 +1536,7 @@ CONFIG_INV_MPU6050_I2C=m
 CONFIG_APDS9960=m
 CONFIG_AS73211=m
 CONFIG_BH1750=m
+CONFIG_TCS3472=m
 CONFIG_TSL4531=m
 CONFIG_VEML6070=m
path: arch/arm64/configs/bcm2712_defconfig
user: login: pelwell
body: Indeed - it's been missing from the start, but not tested. It's there now, and there will be another test build in about 40 minutes.
created_at: 2025-04-25T14:01:00Z
author_association: CONTRIBUTOR

PR comments:
user: login: gnustomp
created_at: 2025-04-22T12:27:54Z
body: Hi, might it be possible to update this for 6.12.y? There should be no need to backport patches, just add the sensors to the devicetree overlay and defconfigs. I can test for VEML6040.
author_association: CONTRIBUTOR
user: login: pelwell
created_at: 2025-04-22T13:07:14Z
body: Are you in a position to test it? The reason the PR was never merged is that the original requester stopped responding.
author_association: CONTRIBUTOR
user: login: gnustomp
created_at: 2025-04-22T13:10:00Z
body: I only have a VEML6040, but yes I am happy to test. (In fact, I had manually added it to the devicetree locally, only to discover the kernel driver wasn't built.)
author_association: CONTRIBUTOR
user: login: gnustomp
created_at: 2025-04-26T00:56:12Z
body: Confirmed that veml6040 is loaded and functional:

```
$ uname -a
Linux dispi 6.12.22-v8-16k+ #1 SMP PREEMPT Fri Apr 25 14:43:02 UTC 2025 aarch64 GNU/Linux
$ cat /sys/bus/iio/devices/iio\:device0/name
veml6040
$ cat /sys/bus/iio/devices/iio\:device0/in_intensity_clear_raw 
120
```

Thanks!
author_association: CONTRIBUTOR