Skip to contentSkip to conversation

iio: light: veml6030: fix issues and add support for veml6035

PATCH Applied Javier Carrasco 2 participants 11 messages Oct 1, 2024 – Oct 6, 2024

Subsystems (4)
lore
Share & tools
lore

Javier Carrasco

author maintainer
#0 lore raw

v3 cover iio: light: veml6030: fix issues and add support for veml6035

This series updates the driver for the veml6030 ALS and adds support for the veml6035, which shares most of its functionality with the former.

---
Changes in v3:
- drop applied patch [1/10] (fixes-togreg).
- Fix indentation of the vdd-supply property and make it required.
- Fix formatting (double space).
- Fix array formatting (space after {, space before }).
- Move action to hw_init function and add dev as an argument.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Rebase to iio/testing, dropping applied patches [1/7], [4/7].
- Drop [3/7] (applied to iio/fixes-togreg).
- Add patch to use dev_err_probe() in probe error paths.
- Add patch to use read_avail() for available attributes.
- Add patches to use to support a regulator.
- Add patch to ensure that the device is powered off in error paths after powering it on.
- Add patch to drop processed values from the WHITE channel.
- Use fsleep() instead of usleep_range() in veml6030_als_pwr_on()
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Javier Carrasco (9):
iio: light: veml6030: add set up delay after any power on sequence
iio: light: veml6030: use dev_err_probe()
dt-bindings: iio: light: veml6030: add vdd-supply property
iio: light: veml6030: add support for a regulator
iio: light: veml6030: use read_avail() for available attributes
iio: light: veml6030: drop processed info for white channel
iio: light: veml6030: power off device in probe error paths
dt-bindings: iio: light: veml6030: add veml6035
iio: light: veml6030: add support for veml6035

 .../bindings/iio/light/vishay,veml6030.yaml        |  44 +-
 drivers/iio/light/Kconfig                          |   4 +-
 drivers/iio/light/veml6030.c                       | 464 ++++++++++++++++-----
 3 files changed, 387 insertions(+), 125 deletions(-)

---
base-commit: 19332fe4bd4659b2e3988f17b4d5dc59a86c266d
change-id: 20240903-veml6035-7a91bc088c6f

Best regards,

Signature · 1 line
Javier Carrasco <[email protected]>
author maintainer
#1 lore raw

PATCH v3 1/9 iio: light: veml6030: add set up delay after any power on sequence

The veml6030 requires a delay of 4 ms after activating the sensor. That is done correctly during the hw initialization, but it's missing after resuming.

Move the delay to the power on function to make sure that it is always observerd. When at it, use fsleep() instead of usleep_range() as such a narrow range is not required.

---
 drivers/iio/light/veml6030.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/iio/light/veml6030.c +11 -5
index 4c436c5e0787..94e38a983cf3 100644
@@ -144,8 +144,17 @@ static const struct attribute_group veml6030_event_attr_group = {
 
 static int veml6030_als_pwr_on(struct veml6030_data *data)
 {
-	return regmap_clear_bits(data->regmap, VEML6030_REG_ALS_CONF,
-				 VEML6030_ALS_SD);
+	int ret;
+
+	ret = regmap_clear_bits(data->regmap, VEML6030_REG_ALS_CONF,
+				VEML6030_ALS_SD);
+	if (ret)
+		return ret;
+
+	/* Wait 4 ms to let processor & oscillator start correctly */
+	fsleep(4000);
+
+	return 0;
 }
 
 static int veml6030_als_shut_down(struct veml6030_data *data)
@@ -767,9 +776,6 @@ static int veml6030_hw_init(struct iio_dev *indio_dev)
 		return ret;
 	}
 
-	/* Wait 4 ms to let processor & oscillator start correctly */
-	usleep_range(4000, 4002);
-
 	/* Clear stale interrupt status bits if any during start */
 	ret = regmap_read(data->regmap, VEML6030_REG_ALS_INT, &val);
 	if (ret < 0) {
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH v3 2/9 iio: light: veml6030: use dev_err_probe()

In reply to Javier Carrasco

Use the more convenient dev_err_probe() to get rid of the dev_err() + return sequence in the probe error paths.

---
 drivers/iio/light/veml6030.c | 72 ++++++++++++++++++--------------------------
 1 file changed, 30 insertions(+), 42 deletions(-)
drivers/iio/light/veml6030.c +30 -42
index 94e38a983cf3..6646fe2e74a7 100644
@@ -740,49 +740,39 @@ static int veml6030_hw_init(struct iio_dev *indio_dev)
 	struct i2c_client *client = data->client;
 
 	ret = veml6030_als_shut_down(data);
-	if (ret) {
-		dev_err(&client->dev, "can't shutdown als %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&client->dev, ret, "can't shutdown als\n");
 
 	ret = regmap_write(data->regmap, VEML6030_REG_ALS_CONF, 0x1001);
-	if (ret) {
-		dev_err(&client->dev, "can't setup als configs %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&client->dev, ret,
+				     "can't setup als configs\n");
 
 	ret = regmap_update_bits(data->regmap, VEML6030_REG_ALS_PSM,
 				 VEML6030_PSM | VEML6030_PSM_EN, 0x03);
-	if (ret) {
-		dev_err(&client->dev, "can't setup default PSM %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&client->dev, ret,
+				     "can't setup default PSM\n");
 
 	ret = regmap_write(data->regmap, VEML6030_REG_ALS_WH, 0xFFFF);
-	if (ret) {
-		dev_err(&client->dev, "can't setup high threshold %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&client->dev, ret,
+				     "can't setup high threshold\n");
 
 	ret = regmap_write(data->regmap, VEML6030_REG_ALS_WL, 0x0000);
-	if (ret) {
-		dev_err(&client->dev, "can't setup low threshold %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&client->dev, ret,
+				     "can't setup low threshold\n");
 
 	ret = veml6030_als_pwr_on(data);
-	if (ret) {
-		dev_err(&client->dev, "can't poweron als %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&client->dev, ret, "can't poweron als\n");
 
 	/* Clear stale interrupt status bits if any during start */
 	ret = regmap_read(data->regmap, VEML6030_REG_ALS_INT, &val);
-	if (ret < 0) {
-		dev_err(&client->dev,
-			"can't clear als interrupt status %d\n", ret);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(&client->dev, ret,
+				     "can't clear als interrupt status\n");
 
 	/* Cache currently active measurement parameters */
 	data->cur_gain = 3;
@@ -799,16 +789,14 @@ static int veml6030_probe(struct i2c_client *client)
 	struct iio_dev *indio_dev;
 	struct regmap *regmap;
 
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		dev_err(&client->dev, "i2c adapter doesn't support plain i2c\n");
-		return -EOPNOTSUPP;
-	}
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
+		return dev_err_probe(&client->dev, -EOPNOTSUPP,
+				     "i2c adapter doesn't support plain i2c\n");
 
 	regmap = devm_regmap_init_i2c(client, &veml6030_regmap_config);
-	if (IS_ERR(regmap)) {
-		dev_err(&client->dev, "can't setup regmap\n");
-		return PTR_ERR(regmap);
-	}
+	if (IS_ERR(regmap))
+		return dev_err_probe(&client->dev, PTR_ERR(regmap),
+				     "can't setup regmap\n");
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
 	if (!indio_dev)
@@ -829,11 +817,11 @@ static int veml6030_probe(struct i2c_client *client)
 						NULL, veml6030_event_handler,
 						IRQF_TRIGGER_LOW | IRQF_ONESHOT,
 						"veml6030", indio_dev);
-		if (ret < 0) {
-			dev_err(&client->dev,
-					"irq %d request failed\n", client->irq);
-			return ret;
-		}
+		if (ret < 0)
+			return dev_err_probe(&client->dev, ret,
+					     "irq %d request failed\n",
+					     client->irq);
+
 		indio_dev->info = &veml6030_info;
 	} else {
 		indio_dev->info = &veml6030_info_no_irq;
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH v3 3/9 dt-bindings: iio: light: veml6030: add vdd-supply property

In reply to Javier Carrasco

Add vdd-supply to account for the sensor's power source.

---
 Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml +4 -0
index 7f4995557570..42a78cd4f812 100644
@@ -41,9 +41,12 @@ properties:
       interrupt client node bindings.
     maxItems: 1
 
+  vdd-supply: true
+
 required:
   - compatible
   - reg
+  - vdd-supply
 
 additionalProperties: false
 
@@ -59,6 +62,7 @@ examples:
                 compatible = "vishay,veml6030";
                 reg = <0x10>;
                 interrupts = <12 IRQ_TYPE_LEVEL_LOW>;
+                vdd-supply = <&vdd>;
         };
     };
 ...
Signature · 1 line
2.43.0
author maintainer
#4 lore raw

PATCH v3 4/9 iio: light: veml6030: add support for a regulator

In reply to Javier Carrasco

Use the device managed function from the regulator API to get and enable a regulator powering the device.

Use "vdd" as the ID to account for the provided name in the datasheet.

---
 drivers/iio/light/veml6030.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/iio/light/veml6030.c +6 -0
index 6646fe2e74a7..72c1988e48e6 100644
@@ -14,6 +14,7 @@
 #include <linux/regmap.h>
 #include <linux/interrupt.h>
 #include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/iio/events.h>
@@ -807,6 +808,11 @@ static int veml6030_probe(struct i2c_client *client)
 	data->client = client;
 	data->regmap = regmap;
 
+	ret = devm_regulator_get_enable(&client->dev, "vdd");
+	if (ret)
+		return dev_err_probe(&client->dev, ret,
+				     "failed to enable regulator\n");
+
 	indio_dev->name = "veml6030";
 	indio_dev->channels = veml6030_channels;
 	indio_dev->num_channels = ARRAY_SIZE(veml6030_channels);
Signature · 1 line
2.43.0
author maintainer
#5 lore raw

PATCH v3 5/9 iio: light: veml6030: use read_avail() for available attributes

In reply to Javier Carrasco

Drop custom attributes by using the standard read_avail() callback to read scale and integration time. When at it, add the integration time and scale attributes fro the WHITE channel, as they modify its value as well. To avoid breaking the current ABI, these attributes must be kept as separate for both channels even though they are shared under the hood.

---
 drivers/iio/light/veml6030.c | 82 +++++++++++++++++++++++++-------------------
 1 file changed, 47 insertions(+), 35 deletions(-)
drivers/iio/light/veml6030.c +47 -35
index 72c1988e48e6..fe6d2f9a2e01 100644
@@ -58,25 +58,24 @@ struct veml6030_data {
 	int cur_integration_time;
 };
 
-/* Integration time available in seconds */
-static IIO_CONST_ATTR(in_illuminance_integration_time_available,
-				"0.025 0.05 0.1 0.2 0.4 0.8");
+static const int veml6030_it_times[][2] = {
+	{ 0, 25000 },
+	{ 0, 50000 },
+	{ 0, 100000 },
+	{ 0, 200000 },
+	{ 0, 400000 },
+	{ 0, 800000 },
+};
 
 /*
  * Scale is 1/gain. Value 0.125 is ALS gain x (1/8), 0.25 is
  * ALS gain x (1/4), 1.0 = ALS gain x 1 and 2.0 is ALS gain x 2.
  */
-static IIO_CONST_ATTR(in_illuminance_scale_available,
-				"0.125 0.25 1.0 2.0");
-
-static struct attribute *veml6030_attributes[] = {
-	&iio_const_attr_in_illuminance_integration_time_available.dev_attr.attr,
-	&iio_const_attr_in_illuminance_scale_available.dev_attr.attr,
-	NULL
-};
-
-static const struct attribute_group veml6030_attr_group = {
-	.attrs = veml6030_attributes,
+static const int veml6030_scale_vals[][2] = {
+	{ 0, 125000 },
+	{ 0, 250000 },
+	{ 1, 0 },
+	{ 2, 0 },
 };
 
 /*
@@ -200,6 +199,8 @@ static const struct iio_chan_spec veml6030_channels[] = {
 				BIT(IIO_CHAN_INFO_PROCESSED) |
 				BIT(IIO_CHAN_INFO_INT_TIME) |
 				BIT(IIO_CHAN_INFO_SCALE),
+		.info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME) |
+						     BIT(IIO_CHAN_INFO_SCALE),
 		.event_spec = veml6030_event_spec,
 		.num_event_specs = ARRAY_SIZE(veml6030_event_spec),
 	},
@@ -209,7 +210,11 @@ static const struct iio_chan_spec veml6030_channels[] = {
 		.modified = 1,
 		.channel2 = IIO_MOD_LIGHT_BOTH,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
-				BIT(IIO_CHAN_INFO_PROCESSED),
+				BIT(IIO_CHAN_INFO_PROCESSED) |
+				BIT(IIO_CHAN_INFO_INT_TIME) |
+				BIT(IIO_CHAN_INFO_SCALE),
+		.info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME) |
+						     BIT(IIO_CHAN_INFO_SCALE),
 	},
 };
 
@@ -555,37 +560,44 @@ static int veml6030_read_raw(struct iio_dev *indio_dev,
 			return -EINVAL;
 		}
 	case IIO_CHAN_INFO_INT_TIME:
-		if (chan->type == IIO_LIGHT)
-			return veml6030_get_intgrn_tm(indio_dev, val, val2);
-		return -EINVAL;
+		return veml6030_get_intgrn_tm(indio_dev, val, val2);
 	case IIO_CHAN_INFO_SCALE:
-		if (chan->type == IIO_LIGHT)
-			return veml6030_get_als_gain(indio_dev, val, val2);
-		return -EINVAL;
+		return veml6030_get_als_gain(indio_dev, val, val2);
 	default:
 		return -EINVAL;
 	}
 }
 
+static int veml6030_read_avail(struct iio_dev *indio_dev,
+			       struct iio_chan_spec const *chan,
+			       const int **vals, int *type, int *length,
+			       long mask)
+{
+	switch (mask) {
+	case IIO_CHAN_INFO_INT_TIME:
+		*vals = (int *)&veml6030_it_times;
+		*length = 2 * ARRAY_SIZE(veml6030_it_times);
+		*type = IIO_VAL_INT_PLUS_MICRO;
+		return IIO_AVAIL_LIST;
+	case IIO_CHAN_INFO_SCALE:
+		*vals = (int *)&veml6030_scale_vals;
+		*length = 2 * ARRAY_SIZE(veml6030_scale_vals);
+		*type = IIO_VAL_INT_PLUS_MICRO;
+		return IIO_AVAIL_LIST;
+	}
+
+	return -EINVAL;
+}
+
 static int veml6030_write_raw(struct iio_dev *indio_dev,
 				struct iio_chan_spec const *chan,
 				int val, int val2, long mask)
 {
 	switch (mask) {
 	case IIO_CHAN_INFO_INT_TIME:
-		switch (chan->type) {
-		case IIO_LIGHT:
-			return veml6030_set_intgrn_tm(indio_dev, val, val2);
-		default:
-			return -EINVAL;
-		}
+		return veml6030_set_intgrn_tm(indio_dev, val, val2);
 	case IIO_CHAN_INFO_SCALE:
-		switch (chan->type) {
-		case IIO_LIGHT:
-			return veml6030_set_als_gain(indio_dev, val, val2);
-		default:
-			return -EINVAL;
-		}
+		return veml6030_set_als_gain(indio_dev, val, val2);
 	default:
 		return -EINVAL;
 	}
@@ -684,19 +696,19 @@ static int veml6030_write_interrupt_config(struct iio_dev *indio_dev,
 
 static const struct iio_info veml6030_info = {
 	.read_raw  = veml6030_read_raw,
+	.read_avail  = veml6030_read_avail,
 	.write_raw = veml6030_write_raw,
 	.read_event_value = veml6030_read_event_val,
 	.write_event_value	= veml6030_write_event_val,
 	.read_event_config = veml6030_read_interrupt_config,
 	.write_event_config	= veml6030_write_interrupt_config,
-	.attrs = &veml6030_attr_group,
 	.event_attrs = &veml6030_event_attr_group,
 };
 
 static const struct iio_info veml6030_info_no_irq = {
 	.read_raw  = veml6030_read_raw,
+	.read_avail  = veml6030_read_avail,
 	.write_raw = veml6030_write_raw,
-	.attrs = &veml6030_attr_group,
 };
 
 static irqreturn_t veml6030_event_handler(int irq, void *private)
Signature · 1 line
2.43.0
author maintainer
#6 lore raw

PATCH v3 6/9 iio: light: veml6030: drop processed info for white channel

In reply to Javier Carrasco

The resolution of the WHITE channel is not provided by the manufacturer, neither in the datasheet nor in the application note (even their proprietary application only processes the ALS channel, giving raw values for WHITE).

The current implementation assumes that both resolutions are identical, which is extremely unlikely, especially for photodiodes with different spectral responses.

Drop the processed information as it is meaningless.

---
 drivers/iio/light/veml6030.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/iio/light/veml6030.c +0 -6
index fe6d2f9a2e01..677374e401b3 100644
@@ -210,7 +210,6 @@ static const struct iio_chan_spec veml6030_channels[] = {
 		.modified = 1,
 		.channel2 = IIO_MOD_LIGHT_BOTH,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
-				BIT(IIO_CHAN_INFO_PROCESSED) |
 				BIT(IIO_CHAN_INFO_INT_TIME) |
 				BIT(IIO_CHAN_INFO_SCALE),
 		.info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME) |
@@ -549,11 +548,6 @@ static int veml6030_read_raw(struct iio_dev *indio_dev,
 				dev_err(dev, "can't read white data %d\n", ret);
 				return ret;
 			}
-			if (mask == IIO_CHAN_INFO_PROCESSED) {
-				*val = (reg * data->cur_resolution) / 10000;
-				*val2 = (reg * data->cur_resolution) % 10000;
-				return IIO_VAL_INT_PLUS_MICRO;
-			}
 			*val = reg;
 			return IIO_VAL_INT;
 		default:
Signature · 1 line
2.43.0
author maintainer
#7 lore raw

PATCH v3 7/9 iio: light: veml6030: power off device in probe error paths

In reply to Javier Carrasco

Move devm_add_action_or_reset() with a device shut down action to the hardware initialization function to ensure that any error path after powering on the device leads to a power off. Add struct device *dev to the argument list to clarify the device the action is registered against, and use it wherever &client->dev was used.

---
 drivers/iio/light/veml6030.c | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)
drivers/iio/light/veml6030.c +13 -19
index 677374e401b3..0e4c36e8a566 100644
@@ -740,45 +740,44 @@ static irqreturn_t veml6030_event_handler(int irq, void *private)
  * interrupt disabled by default. First shutdown the sensor,
  * update registers and then power on the sensor.
  */
-static int veml6030_hw_init(struct iio_dev *indio_dev)
+static int veml6030_hw_init(struct iio_dev *indio_dev, struct device *dev)
 {
 	int ret, val;
 	struct veml6030_data *data = iio_priv(indio_dev);
-	struct i2c_client *client = data->client;
 
 	ret = veml6030_als_shut_down(data);
 	if (ret)
-		return dev_err_probe(&client->dev, ret, "can't shutdown als\n");
+		return dev_err_probe(dev, ret, "can't shutdown als\n");
 
 	ret = regmap_write(data->regmap, VEML6030_REG_ALS_CONF, 0x1001);
 	if (ret)
-		return dev_err_probe(&client->dev, ret,
-				     "can't setup als configs\n");
+		return dev_err_probe(dev, ret, "can't setup als configs\n");
 
 	ret = regmap_update_bits(data->regmap, VEML6030_REG_ALS_PSM,
 				 VEML6030_PSM | VEML6030_PSM_EN, 0x03);
 	if (ret)
-		return dev_err_probe(&client->dev, ret,
-				     "can't setup default PSM\n");
+		return dev_err_probe(dev, ret, "can't setup default PSM\n");
 
 	ret = regmap_write(data->regmap, VEML6030_REG_ALS_WH, 0xFFFF);
 	if (ret)
-		return dev_err_probe(&client->dev, ret,
-				     "can't setup high threshold\n");
+		return dev_err_probe(dev, ret, "can't setup high threshold\n");
 
 	ret = regmap_write(data->regmap, VEML6030_REG_ALS_WL, 0x0000);
 	if (ret)
-		return dev_err_probe(&client->dev, ret,
-				     "can't setup low threshold\n");
+		return dev_err_probe(dev, ret, "can't setup low threshold\n");
 
 	ret = veml6030_als_pwr_on(data);
 	if (ret)
-		return dev_err_probe(&client->dev, ret, "can't poweron als\n");
+		return dev_err_probe(dev, ret, "can't poweron als\n");
+
+	ret = devm_add_action_or_reset(dev, veml6030_als_shut_down_action, data);
+	if (ret < 0)
+		return ret;
 
 	/* Clear stale interrupt status bits if any during start */
 	ret = regmap_read(data->regmap, VEML6030_REG_ALS_INT, &val);
 	if (ret < 0)
-		return dev_err_probe(&client->dev, ret,
+		return dev_err_probe(dev, ret,
 				     "can't clear als interrupt status\n");
 
 	/* Cache currently active measurement parameters */
@@ -839,12 +838,7 @@ static int veml6030_probe(struct i2c_client *client)
 		indio_dev->info = &veml6030_info_no_irq;
 	}
 
-	ret = veml6030_hw_init(indio_dev);
-	if (ret < 0)
-		return ret;
-
-	ret = devm_add_action_or_reset(&client->dev,
-					veml6030_als_shut_down_action, data);
+	ret = veml6030_hw_init(indio_dev, &client->dev);
 	if (ret < 0)
 		return ret;
 
Signature · 1 line
2.43.0
author maintainer
#8 lore raw

PATCH v3 8/9 dt-bindings: iio: light: veml6030: add veml6035

In reply to Javier Carrasco

The veml6035 is a similar ambient light sensor to the veml6030, and from the bindings point of view, it shares the same properties. Its only difference in that respect is a different I2C address.

Estend the existing bindings to support the veml6035 ALS.

---
 .../bindings/iio/light/vishay,veml6030.yaml        | 40 +++++++++++++++++-----
 1 file changed, 31 insertions(+), 9 deletions(-)
Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml +31 -9
index 42a78cd4f812..6218273b0e86 100644
@@ -4,14 +4,14 @@
 $id: http://devicetree.org/schemas/iio/light/vishay,veml6030.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: VEML6030 Ambient Light Sensor (ALS)
+title: VEML6030 and VEML6035 Ambient Light Sensors (ALS)
 
 maintainers:
   - Rishi Gupta <[email protected]>
 
 description: |
-  Bindings for the ambient light sensor veml6030 from Vishay
-  Semiconductors over an i2c interface.
+  Bindings for the ambient light sensors veml6030 and veml6035 from
+  Vishay Semiconductors over an i2c interface.
 
   Irrespective of whether interrupt is used or not, application
   can get the ALS and White channel reading from IIO raw interface.
@@ -19,20 +19,18 @@ description: |
   If the interrupts are used, application will receive an IIO event
   whenever configured threshold is crossed.
 
-  Specifications about the sensor can be found at:
+  Specifications about the sensors can be found at:
     https://www.vishay.com/docs/84366/veml6030.pdf
+    https://www.vishay.com/docs/84889/veml6035.pdf
 
 properties:
   compatible:
     enum:
       - vishay,veml6030
+      - vishay,veml6035
 
   reg:
-    description:
-      I2C address of the device.
-    enum:
-      - 0x10 # ADDR pin pulled down
-      - 0x48 # ADDR pin pulled up
+    maxItems: 1
 
   interrupts:
     description:
@@ -48,6 +46,30 @@ required:
   - reg
   - vdd-supply
 
+allOf:
+  - if:
+      properties:
+        compatible:
+          enum:
+            - vishay,veml6030
+    then:
+      properties:
+        reg:
+          enum:
+            - 0x10  # ADDR pin pulled down
+            - 0x48  # ADDR pin pulled up
+
+  - if:
+      properties:
+        compatible:
+          enum:
+            - vishay,veml6035
+    then:
+      properties:
+        reg:
+          enum:
+            - 0x29
+
 additionalProperties: false
 
 examples:
Signature · 1 line
2.43.0
author maintainer
#9 lore raw

PATCH v3 9/9 iio: light: veml6030: add support for veml6035

In reply to Javier Carrasco

The veml6035 is an ALS that shares most of its functionality with the veml6030, which allows for some code recycling.

Some chip-specific properties differ and dedicated functions to get and set the sensor gain as well as its initialization are required.

---
 drivers/iio/light/Kconfig    |   4 +-
 drivers/iio/light/veml6030.c | 290 +++++++++++++++++++++++++++++++++++++++----
 2 files changed, 265 insertions(+), 29 deletions(-)
drivers/iio/light/Kconfig +2 -2
index 515ff46b5b82..171ccaecf5b6 100644
@@ -669,12 +669,12 @@ config VCNL4035
 	  module will be called vcnl4035.
 
 config VEML6030
-	tristate "VEML6030 ambient light sensor"
+	tristate "VEML6030 and VEML6035 ambient light sensors"
 	select REGMAP_I2C
 	depends on I2C
 	help
 	  Say Y here if you want to build a driver for the Vishay VEML6030
-	  ambient light sensor (ALS).
+	  and VEML6035 ambient light sensors (ALS).
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called veml6030.
drivers/iio/light/veml6030.c +263 -27

431 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer Applied
#10 lore raw
In reply to Javier Carrasco
Quoted 4 lines · On Tue, 01 Oct 2024 22:21:13 +0200 Javier Carrasco…

This series updates the driver for the veml6030 ALS and adds support for the veml6035, which shares most of its functionality with the former.

Nice series.

Applied to the togreg branch of iio.git and pushed out initially as testing for 0-day to take a look at it.

thanks

Jonathan

Quoted 42 lines

---
Changes in v3:
- drop applied patch [1/10] (fixes-togreg).
- Fix indentation of the vdd-supply property and make it required.
- Fix formatting (double space).
- Fix array formatting (space after {, space before }).
- Move action to hw_init function and add dev as an argument.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Rebase to iio/testing, dropping applied patches [1/7], [4/7].
- Drop [3/7] (applied to iio/fixes-togreg).
- Add patch to use dev_err_probe() in probe error paths.
- Add patch to use read_avail() for available attributes.
- Add patches to use to support a regulator.
- Add patch to ensure that the device is powered off in error paths after powering it on.
- Add patch to drop processed values from the WHITE channel.
- Use fsleep() instead of usleep_range() in veml6030_als_pwr_on()
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Javier Carrasco (9):
iio: light: veml6030: add set up delay after any power on sequence
iio: light: veml6030: use dev_err_probe()
dt-bindings: iio: light: veml6030: add vdd-supply property
iio: light: veml6030: add support for a regulator
iio: light: veml6030: use read_avail() for available attributes
iio: light: veml6030: drop processed info for white channel
iio: light: veml6030: power off device in probe error paths
dt-bindings: iio: light: veml6030: add veml6035
iio: light: veml6030: add support for veml6035

 .../bindings/iio/light/vishay,veml6030.yaml        |  44 +-
 drivers/iio/light/Kconfig                          |   4 +-
 drivers/iio/light/veml6030.c                       | 464 ++++++++++++++++-----
 3 files changed, 387 insertions(+), 125 deletions(-)

---
base-commit: 19332fe4bd4659b2e3988f17b4d5dc59a86c266d
change-id: 20240903-veml6035-7a91bc088c6f

Best regards,