[PATCH] iio: light: veml6031x00: Enable internal calibration

Javier Carrasco posted 1 patch an hour ago
drivers/iio/light/veml6031x00.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] iio: light: veml6031x00: Enable internal calibration
Posted by Javier Carrasco an hour ago
Enable the device's factory internal calibration before entering normal
operation to improve ambient light measurements.

Set ALS_CAL during hardware initialization.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
This feature is not documented beyond the bit to set in the CONF1 device
register, but after direct communication with the manufacturer and some
tests I carried out, it should improve the ALS measurements.

I could not tell much of a difference with the first device I tested,
but some other samples have slightly improved its measurements compared
to a reliable reference. The manufacturer could not tell me why this had
to be configurable at all, considering that you can't calibrate the
device on your own, and especially why it is disabled by default. But
fortunately, this feature only needs to be enabled after powering up the
device, and software on/off switches do not affect it.
---
 drivers/iio/light/veml6031x00.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/iio/light/veml6031x00.c b/drivers/iio/light/veml6031x00.c
index 085a6e2ff717..f6308498e422 100644
--- a/drivers/iio/light/veml6031x00.c
+++ b/drivers/iio/light/veml6031x00.c
@@ -52,6 +52,7 @@
 #define VEML6031X00_CONF0_SD        BIT(0)
 #define VEML6031X00_CONF0_AF_TRIG   BIT(2)
 #define VEML6031X00_CONF0_AF        BIT(3)
+#define VEML6031X00_CONF1_ALS_CAL   BIT(0)
 #define VEML6031X00_CONF1_IR_SD     BIT(7)
 #define VEML6031X00_INT_TH_H        BIT(1)
 #define VEML6031X00_INT_TH_L        BIT(2)
@@ -1121,6 +1122,11 @@ static int veml6031x00_hw_init(struct veml6031x00_data *data)
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to disable trigger\n");
 
+	ret = regmap_set_bits(data->regmap, VEML6031X00_REG_CONF1,
+			      VEML6031X00_CONF1_ALS_CAL);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to enable internal calibration\n");
+
 	regval = 0;
 	ret = regmap_bulk_write(map, VEML6031X00_REG_WL_L, &regval, sizeof(regval));
 	if (ret)

---
base-commit: dceba8e581e3e8f475da0efbd7a73f3d9524ddd2
change-id: 20260921-veml6031x00_als_cal-93319bc0be81

Best regards,
-- 
Javier Carrasco <javier.carrasco.cruz@gmail.com>