devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] iio: light: veml6070: add integration time
@ 2024-10-24 20:44 Javier Carrasco
  2024-10-24 20:44 ` [PATCH v2 1/2] dt-bindings: iio: light: veml6075: document rset-ohms Javier Carrasco
  2024-10-24 20:44 ` [PATCH v2 2/2] iio: light: veml6070: add support for integration time Javier Carrasco
  0 siblings, 2 replies; 5+ messages in thread
From: Javier Carrasco @ 2024-10-24 20:44 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-iio, linux-kernel, devicetree, Javier Carrasco

This series adds a missing feature in the veml6070 driver to select the
integration time, which also depends on an external restistor that has
been added to the corresponding bindings.

The datasheet provides a Refresh time vs Rset graph (figure 7), which
does not clearly specify the minimum and maximum values for Rset. The
manufacuter has confirmed that no values under 75 kohms should be used
to keep linearity, and the graph does not go beyond 1200 kohms, which is
also the biggest Rset used in the application note. The default value of
270 kohms is the one currently used in the driver to calculate the UVI.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
Changes in v2:
- Rebase onto iio/testing and drop applied patches.
- veml6075.yaml: use documented -ohms, top-level definition and
  per-device restriction.
- veml6075.yaml: add default value.
- veml6075.yaml: fix typo in commit message.
- veml6070.c: adjust rset property name and convert from ohms to kohms
  to avoid overflows and work with the same units as in the datasheet.
- veml6070.c: change default to 270 kohms (already used as default
  value to calculate UVI).
- veml6070.c: calculate UVI according to the current integration time.
- veml6070.c: re-calculate measurement time (i.e. msleep()) with the
  current integration time.
- Link to v1: https://lore.kernel.org/r/20241017-veml6070-integration-time-v1-0-3507d17d562a@gmail.com

---
Javier Carrasco (2):
      dt-bindings: iio: light: veml6075: document rset-ohms
      iio: light: veml6070: add support for integration time

 .../bindings/iio/light/vishay,veml6075.yaml        |  27 ++++
 drivers/iio/light/veml6070.c                       | 137 +++++++++++++++++++--
 2 files changed, 156 insertions(+), 8 deletions(-)
---
base-commit: 9090ececac9ff1e22fb7e042f3c886990a8fb090
change-id: 20241014-veml6070-integration-time-78daf4eaad2f

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] dt-bindings: iio: light: veml6075: document rset-ohms
  2024-10-24 20:44 [PATCH v2 0/2] iio: light: veml6070: add integration time Javier Carrasco
@ 2024-10-24 20:44 ` Javier Carrasco
  2024-10-26 12:23   ` Krzysztof Kozlowski
  2024-10-24 20:44 ` [PATCH v2 2/2] iio: light: veml6070: add support for integration time Javier Carrasco
  1 sibling, 1 reply; 5+ messages in thread
From: Javier Carrasco @ 2024-10-24 20:44 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-iio, linux-kernel, devicetree, Javier Carrasco

The veml6070 provides a configurable integration time by means of an
external resistor (Rset in the datasheet) with values between 75 and
1200 kohms.

Document rset-ohms to select the integration time.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 .../bindings/iio/light/vishay,veml6075.yaml        | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml b/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
index 96c1317541fa..dfd64c411658 100644
--- a/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
+++ b/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
@@ -22,6 +22,10 @@ properties:
   reg:
     maxItems: 1
 
+  rset-ohms:
+    description:
+      Resistor used to select the integration time.
+
   vdd-supply: true
 
 required:
@@ -29,6 +33,29 @@ required:
   - reg
   - vdd-supply
 
+allOf:
+  - if:
+      properties:
+        compatible:
+          enum:
+            - vishay,veml6040
+            - vishay,veml6075
+    then:
+      properties:
+        rset-ohms: false
+
+  - if:
+      properties:
+        compatible:
+          enum:
+            - vishay,veml6070
+    then:
+      properties:
+        rset-ohms:
+          default: 270000
+          minimum: 75000
+          maximum: 1200000
+
 additionalProperties: false
 
 examples:

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] iio: light: veml6070: add support for integration time
  2024-10-24 20:44 [PATCH v2 0/2] iio: light: veml6070: add integration time Javier Carrasco
  2024-10-24 20:44 ` [PATCH v2 1/2] dt-bindings: iio: light: veml6075: document rset-ohms Javier Carrasco
@ 2024-10-24 20:44 ` Javier Carrasco
  2024-10-26 10:59   ` Jonathan Cameron
  1 sibling, 1 reply; 5+ messages in thread
From: Javier Carrasco @ 2024-10-24 20:44 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-iio, linux-kernel, devicetree, Javier Carrasco

The integration time of the veml6070 depends on an external resistor
(called Rset in the datasheet) and the value configured in the IT
field of the command register, whose supported values are 1/2x, 1x,
2x and 4x.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/iio/light/veml6070.c | 137 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 129 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c
index d11ae00f61f8..d4d024e1b171 100644
--- a/drivers/iio/light/veml6070.c
+++ b/drivers/iio/light/veml6070.c
@@ -6,7 +6,7 @@
  *
  * IIO driver for VEML6070 (7-bit I2C slave addresses 0x38 and 0x39)
  *
- * TODO: integration time, ACK signal
+ * TODO: ACK signal
  */
 
 #include <linux/bitfield.h>
@@ -29,18 +29,88 @@
 #define VEML6070_COMMAND_RSRVD	BIT(1) /* reserved, set to 1 */
 #define VEML6070_COMMAND_SD	BIT(0) /* shutdown mode when set */
 
-#define VEML6070_IT_10	0x01 /* integration time 1x */
+#define VEML6070_IT_05		0x00
+#define VEML6070_IT_10		0x01
+#define VEML6070_IT_20		0x02
+#define VEML6070_IT_40		0x03
+
+#define VEML6070_MIN_RSET_KOHM	75
+#define VEML6070_MIN_IT_US	15625 /* Rset = 75 kohm, IT = 1/2 */
 
 struct veml6070_data {
 	struct i2c_client *client1;
 	struct i2c_client *client2;
 	u8 config;
 	struct mutex lock;
+	u32 rset;
+	u32 it[4][2];
 };
 
+static void veml6070_calc_it(struct device *dev, struct veml6070_data *data)
+{
+	u32 tmp_it;
+	int i, ret;
+
+	ret = device_property_read_u32(dev, "rset-ohms", &data->rset);
+	if (ret) {
+		dev_warn(dev, "no Rset specified, using default 270 kohms\n");
+		data->rset = 270000;
+	}
+
+	if (data->rset < 75000) {
+		dev_warn(dev, "Rset too low, using minimum = 75 kohms\n");
+		data->rset = 75000;
+	}
+
+	if (data->rset > 1200000) {
+		dev_warn(dev, "Rset too high, using maximum = 1200 kohms\n");
+		data->rset = 1200000;
+	}
+
+	/**
+	 * convert to kohm to avoid overflows and work with the same units as
+	 * in the datasheet and simplify UVI operations.
+	 */
+	data->rset /= 1000;
+
+	tmp_it = VEML6070_MIN_IT_US * data->rset / VEML6070_MIN_RSET_KOHM;
+	for (i = 0; i < ARRAY_SIZE(data->it); i++) {
+		data->it[i][0] = (tmp_it << i) / 1000000;
+		data->it[i][1] = (tmp_it << i) % 1000000;
+	}
+}
+
+static int veml6070_get_it(struct veml6070_data *data, int *val, int *val2)
+{
+	int it_idx = FIELD_GET(VEML6070_COMMAND_IT, data->config);
+
+	*val = data->it[it_idx][0];
+	*val2 = data->it[it_idx][1];
+
+	return IIO_VAL_INT_PLUS_MICRO;
+}
+
+static int veml6070_set_it(struct veml6070_data *data, int val, int val2)
+{
+	int it_idx;
+
+	for (it_idx = 0; it_idx < ARRAY_SIZE(data->it); it_idx++) {
+		if (data->it[it_idx][0] == val && data->it[it_idx][1] == val2)
+			break;
+	}
+
+	if (it_idx >= ARRAY_SIZE(data->it))
+		return -EINVAL;
+
+	data->config = (data->config & ~VEML6070_COMMAND_IT) |
+		FIELD_PREP(VEML6070_COMMAND_IT, it_idx);
+
+	return i2c_smbus_write_byte(data->client1, data->config);
+}
+
 static int veml6070_read(struct veml6070_data *data)
 {
-	int ret;
+	int ret, it_ms, val, val2;
 	u8 msb, lsb;
 
 	guard(mutex)(&data->lock);
@@ -51,7 +121,9 @@ static int veml6070_read(struct veml6070_data *data)
 	if (ret < 0)
 		return ret;
 
-	msleep(125 + 10); /* measurement takes up to 125 ms for IT 1x */
+	veml6070_get_it(data, &val, &val2);
+	it_ms = val * 1000 + val2 / 1000;
+	msleep(it_ms + 10);
 
 	ret = i2c_smbus_read_byte(data->client2); /* read MSB, address 0x39 */
 	if (ret < 0)
@@ -81,26 +153,37 @@ static const struct iio_chan_spec veml6070_channels[] = {
 		.modified = 1,
 		.channel2 = IIO_MOD_LIGHT_UV,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME),
+		.info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME),
 	},
 	{
 		.type = IIO_UVINDEX,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
+		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME),
+		.info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME),
 	}
 };
 
-static int veml6070_to_uv_index(unsigned int val)
+static int veml6070_to_uv_index(struct veml6070_data *data, unsigned int val)
 {
 	/*
 	 * conversion of raw UV intensity values to UV index depends on
 	 * integration time (IT) and value of the resistor connected to
-	 * the RSET pin (default: 270 KOhm)
+	 * the RSET pin (default: 270 KOhm, IT = 1x)
 	 */
 	unsigned int uvi[11] = {
 		187, 373, 560, /* low */
 		746, 933, 1120, /* moderate */
 		1308, 1494, /* high */
 		1681, 1868, 2054}; /* very high */
-	int i;
+	int i, it_idx;
+
+	it_idx = FIELD_GET(VEML6070_COMMAND_IT, data->config);
+
+	if (!it_idx)
+		val = (val * 270  / data->rset) << 1;
+	else
+		val = (val * 270 / data->rset) >> (it_idx - 1);
 
 	for (i = 0; i < ARRAY_SIZE(uvi); i++)
 		if (val <= uvi[i])
@@ -123,10 +206,44 @@ static int veml6070_read_raw(struct iio_dev *indio_dev,
 		if (ret < 0)
 			return ret;
 		if (mask == IIO_CHAN_INFO_PROCESSED)
-			*val = veml6070_to_uv_index(ret);
+			*val = veml6070_to_uv_index(data, ret);
 		else
 			*val = ret;
 		return IIO_VAL_INT;
+	case IIO_CHAN_INFO_INT_TIME:
+		return veml6070_get_it(data, val, val2);
+	default:
+		return -EINVAL;
+	}
+}
+
+static int veml6070_read_avail(struct iio_dev *indio_dev,
+			       struct iio_chan_spec const *chan,
+			       const int **vals, int *type, int *length,
+			       long mask)
+{
+	struct veml6070_data *data = iio_priv(indio_dev);
+
+	switch (mask) {
+	case IIO_CHAN_INFO_INT_TIME:
+		*vals = (int *)data->it;
+		*length = 2 * ARRAY_SIZE(data->it);
+		*type = IIO_VAL_INT_PLUS_MICRO;
+		return IIO_AVAIL_LIST;
+	default:
+		return -EINVAL;
+	}
+}
+
+static int veml6070_write_raw(struct iio_dev *indio_dev,
+			      struct iio_chan_spec const *chan,
+			      int val, int val2, long mask)
+{
+	struct veml6070_data *data = iio_priv(indio_dev);
+
+	switch (mask) {
+	case IIO_CHAN_INFO_INT_TIME:
+		return veml6070_set_it(data, val, val2);
 	default:
 		return -EINVAL;
 	}
@@ -134,6 +251,8 @@ static int veml6070_read_raw(struct iio_dev *indio_dev,
 
 static const struct iio_info veml6070_info = {
 	.read_raw = veml6070_read_raw,
+	.read_avail  = veml6070_read_avail,
+	.write_raw = veml6070_write_raw,
 };
 
 static void veml6070_i2c_unreg(void *p)
@@ -164,6 +283,8 @@ static int veml6070_probe(struct i2c_client *client)
 	indio_dev->name = VEML6070_DRV_NAME;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
+	veml6070_calc_it(&client->dev, data);
+
 	ret = devm_regulator_get_enable(&client->dev, "vdd");
 	if (ret < 0)
 		return ret;

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] iio: light: veml6070: add support for integration time
  2024-10-24 20:44 ` [PATCH v2 2/2] iio: light: veml6070: add support for integration time Javier Carrasco
@ 2024-10-26 10:59   ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2024-10-26 10:59 UTC (permalink / raw)
  To: Javier Carrasco
  Cc: Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-iio, linux-kernel, devicetree

On Thu, 24 Oct 2024 22:44:49 +0200
Javier Carrasco <javier.carrasco.cruz@gmail.com> wrote:

> The integration time of the veml6070 depends on an external resistor
> (called Rset in the datasheet) and the value configured in the IT
> field of the command register, whose supported values are 1/2x, 1x,
> 2x and 4x.
> 
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>

Hi Javier,

A few comments inline below.

Thanks,

Jonathan
> ---
>  drivers/iio/light/veml6070.c | 137 ++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 129 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c
> index d11ae00f61f8..d4d024e1b171 100644
> --- a/drivers/iio/light/veml6070.c
> +++ b/drivers/iio/light/veml6070.c
> @@ -6,7 +6,7 @@
>   *
>   * IIO driver for VEML6070 (7-bit I2C slave addresses 0x38 and 0x39)
>   *
> - * TODO: integration time, ACK signal
> + * TODO: ACK signal
>   */
>  
>  #include <linux/bitfield.h>
> @@ -29,18 +29,88 @@
>  #define VEML6070_COMMAND_RSRVD	BIT(1) /* reserved, set to 1 */
>  #define VEML6070_COMMAND_SD	BIT(0) /* shutdown mode when set */
>  
> -#define VEML6070_IT_10	0x01 /* integration time 1x */
> +#define VEML6070_IT_05		0x00
> +#define VEML6070_IT_10		0x01
> +#define VEML6070_IT_20		0x02
> +#define VEML6070_IT_40		0x03
> +
> +#define VEML6070_MIN_RSET_KOHM	75
> +#define VEML6070_MIN_IT_US	15625 /* Rset = 75 kohm, IT = 1/2 */
>  
>  struct veml6070_data {
>  	struct i2c_client *client1;
>  	struct i2c_client *client2;
>  	u8 config;
>  	struct mutex lock;
> +	u32 rset;
> +	u32 it[4][2];

int given how it is cast to an int * later. Should be no where near the point
where that makes any functional difference of course.


>  };
>  
> +static void veml6070_calc_it(struct device *dev, struct veml6070_data *data)
> +{
> +	u32 tmp_it;
> +	int i, ret;
> +
> +	ret = device_property_read_u32(dev, "rset-ohms", &data->rset);
> +	if (ret) {
> +		dev_warn(dev, "no Rset specified, using default 270 kohms\n");
> +		data->rset = 270000;
Where the dt-binding defines a default (and that is sensible) don't print
a warning if someone uses it.  Even dev_info is probably too noisy for this.

A simple pattern for default cass is
	data->rset = 270000;
	device_property_read_u32(dev, "rset-ohms", &data->rset);

That is don't check the error return and make sue of the lack of side effects
on the value in &data->rset if there is an error (typically property not found).

> +	}
> +
> +	if (data->rset < 75000) {
> +		dev_warn(dev, "Rset too low, using minimum = 75 kohms\n");
> +		data->rset = 75000;
> +	}
> +
> +	if (data->rset > 1200000) {
> +		dev_warn(dev, "Rset too high, using maximum = 1200 kohms\n");
> +		data->rset = 1200000;
> +	}
> +
> +	/**

Not kernel-doc. So /* only.

> +	 * convert to kohm to avoid overflows and work with the same units as
> +	 * in the datasheet and simplify UVI operations.
> +	 */
> +	data->rset /= 1000;
> +
> +	tmp_it = VEML6070_MIN_IT_US * data->rset / VEML6070_MIN_RSET_KOHM;
> +	for (i = 0; i < ARRAY_SIZE(data->it); i++) {
> +		data->it[i][0] = (tmp_it << i) / 1000000;
> +		data->it[i][1] = (tmp_it << i) % 1000000;
> +	}
> +}
> +
> +static int veml6070_get_it(struct veml6070_data *data, int *val, int *val2)
> +{
> +	int it_idx = FIELD_GET(VEML6070_COMMAND_IT, data->config);
> +
> +	*val = data->it[it_idx][0];
> +	*val2 = data->it[it_idx][1];
> +
> +	return IIO_VAL_INT_PLUS_MICRO;
> +}
> +
> +static int veml6070_set_it(struct veml6070_data *data, int val, int val2)
> +{
> +	int it_idx;
> +
> +	for (it_idx = 0; it_idx < ARRAY_SIZE(data->it); it_idx++) {
> +		if (data->it[it_idx][0] == val && data->it[it_idx][1] == val2)
> +			break;
> +	}
> +
> +	if (it_idx >= ARRAY_SIZE(data->it))
> +		return -EINVAL;
> +
> +	data->config = (data->config & ~VEML6070_COMMAND_IT) |
> +		FIELD_PREP(VEML6070_COMMAND_IT, it_idx);
> +
> +	return i2c_smbus_write_byte(data->client1, data->config);
> +}
> +
>  static int veml6070_read(struct veml6070_data *data)
>  {
> -	int ret;
> +	int ret, it_ms, val, val2;
>  	u8 msb, lsb;
>  
>  	guard(mutex)(&data->lock);
> @@ -51,7 +121,9 @@ static int veml6070_read(struct veml6070_data *data)
>  	if (ret < 0)
>  		return ret;
>  
> -	msleep(125 + 10); /* measurement takes up to 125 ms for IT 1x */
> +	veml6070_get_it(data, &val, &val2);
> +	it_ms = val * 1000 + val2 / 1000;

Perhaps some unit.h defines would make this slightly more self documenting.

	int_ms = val * MILLI + val2 / (MICRO / MILLI);

> +	msleep(it_ms + 10);
>  
>  	ret = i2c_smbus_read_byte(data->client2); /* read MSB, address 0x39 */
>  	if (ret < 0)
> @@ -81,26 +153,37 @@ static const struct iio_chan_spec veml6070_channels[] = {
>  		.modified = 1,
>  		.channel2 = IIO_MOD_LIGHT_UV,
>  		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> +		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME),
> +		.info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME),
>  	},
>  	{
>  		.type = IIO_UVINDEX,
>  		.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
> +		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME),
> +		.info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME),
>  	}
>  };
>  
> -static int veml6070_to_uv_index(unsigned int val)
> +static int veml6070_to_uv_index(struct veml6070_data *data, unsigned int val)
>  {
>  	/*
>  	 * conversion of raw UV intensity values to UV index depends on
>  	 * integration time (IT) and value of the resistor connected to
> -	 * the RSET pin (default: 270 KOhm)
> +	 * the RSET pin (default: 270 KOhm, IT = 1x)

I'm not sure documenting the default KOhm here is useful as that's
a board wiring thing we don't control. IT isn't that useful documented
here either so I'd just drop the bit in brackets.


>  	 */
>  	unsigned int uvi[11] = {
>  		187, 373, 560, /* low */
>  		746, 933, 1120, /* moderate */
>  		1308, 1494, /* high */
>  		1681, 1868, 2054}; /* very high */
> -	int i;
> +	int i, it_idx;
> +
> +	it_idx = FIELD_GET(VEML6070_COMMAND_IT, data->config);
> +
> +	if (!it_idx)
> +		val = (val * 270  / data->rset) << 1;
> +	else
> +		val = (val * 270 / data->rset) >> (it_idx - 1);
>  
>  	for (i = 0; i < ARRAY_SIZE(uvi); i++)
>  		if (val <= uvi[i])
> @@ -123,10 +206,44 @@ static int veml6070_read_raw(struct iio_dev *indio_dev,
>  		if (ret < 0)
>  			return ret;
>  		if (mask == IIO_CHAN_INFO_PROCESSED)
> -			*val = veml6070_to_uv_index(ret);
> +			*val = veml6070_to_uv_index(data, ret);
>  		else
>  			*val = ret;
>  		return IIO_VAL_INT;
> +	case IIO_CHAN_INFO_INT_TIME:
> +		return veml6070_get_it(data, val, val2);
> +	default:
> +		return -EINVAL;
> +	}
> +}
> +
> +static int veml6070_read_avail(struct iio_dev *indio_dev,
> +			       struct iio_chan_spec const *chan,
> +			       const int **vals, int *type, int *length,
> +			       long mask)
> +{
> +	struct veml6070_data *data = iio_priv(indio_dev);
> +
> +	switch (mask) {
> +	case IIO_CHAN_INFO_INT_TIME:
> +		*vals = (int *)data->it;
As above, it data type should just be an int not u32 array.
> +		*length = 2 * ARRAY_SIZE(data->it);
> +		*type = IIO_VAL_INT_PLUS_MICRO;
> +		return IIO_AVAIL_LIST;
> +	default:
> +		return -EINVAL;
> +	}
> +}
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: iio: light: veml6075: document rset-ohms
  2024-10-24 20:44 ` [PATCH v2 1/2] dt-bindings: iio: light: veml6075: document rset-ohms Javier Carrasco
@ 2024-10-26 12:23   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-26 12:23 UTC (permalink / raw)
  To: Javier Carrasco
  Cc: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, linux-iio, linux-kernel,
	devicetree

On Thu, Oct 24, 2024 at 10:44:48PM +0200, Javier Carrasco wrote:
> The veml6070 provides a configurable integration time by means of an
> external resistor (Rset in the datasheet) with values between 75 and
> 1200 kohms.
> 
> Document rset-ohms to select the integration time.
> 
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
>  .../bindings/iio/light/vishay,veml6075.yaml        | 27 ++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml b/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
> index 96c1317541fa..dfd64c411658 100644
> --- a/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
> +++ b/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
> @@ -22,6 +22,10 @@ properties:
>    reg:
>      maxItems: 1
>  
> +  rset-ohms:
> +    description:
> +      Resistor used to select the integration time.

Widest constraints should go here. If only one device supports them,
then it even simplifies the if:then.

> +
>    vdd-supply: true
>  
>  required:
> @@ -29,6 +33,29 @@ required:
>    - reg
>    - vdd-supply
>  
> +allOf:
> +  - if:
> +      properties:
> +        compatible:
> +          enum:
> +            - vishay,veml6040
> +            - vishay,veml6075
> +    then:
> +      properties:
> +        rset-ohms: false
> +
> +  - if:
> +      properties:
> +        compatible:
> +          enum:
> +            - vishay,veml6070
> +    then:
> +      properties:
> +        rset-ohms:
> +          default: 270000
> +          minimum: 75000
> +          maximum: 1200000

Move these three to top-level and then you can drop this if:.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-10-26 12:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-24 20:44 [PATCH v2 0/2] iio: light: veml6070: add integration time Javier Carrasco
2024-10-24 20:44 ` [PATCH v2 1/2] dt-bindings: iio: light: veml6075: document rset-ohms Javier Carrasco
2024-10-26 12:23   ` Krzysztof Kozlowski
2024-10-24 20:44 ` [PATCH v2 2/2] iio: light: veml6070: add support for integration time Javier Carrasco
2024-10-26 10:59   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).