* [PATCH 0/4] iio: light: veml6070: add integration time and minor cleanups.
@ 2024-10-17 21:39 Javier Carrasco
2024-10-17 21:39 ` [PATCH 1/4] iio: light: veml6070: use unsigned int instead of unsigned Javier Carrasco
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Javier Carrasco @ 2024-10-17 21:39 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. Its name corresponds to the
one provided in the datasheet (Rset) and its units (kilo Ohms), but I am
open to more descriptive names if required.
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
300 kohms has been obtained from the datasheet, where this value is
given as an example (table 4).
When at it, two minor cleanups have been carried out:
- Unsigned int instead of plain unsigned.
- Use of a field for the integration time, which eases the handling of
the available integration times turning them into a simple [0, 3]
index.
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
Javier Carrasco (4):
iio: light: veml6070: use unsigned int instead of unsigned
iio: light: veml6070: use field to set integration time
dt-bindings: iio: light: veml6075: document rset-kohms
iio: light: veml6070: add support for integration time
.../bindings/iio/light/vishay,veml6075.yaml | 16 +++
drivers/iio/light/veml6070.c | 118 +++++++++++++++++++--
2 files changed, 128 insertions(+), 6 deletions(-)
---
base-commit: 57573ace0c1b142433dfe3d63ebf375269c80fc1
change-id: 20241014-veml6070-integration-time-78daf4eaad2f
Best regards,
--
Javier Carrasco <javier.carrasco.cruz@gmail.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/4] iio: light: veml6070: use unsigned int instead of unsigned
2024-10-17 21:39 [PATCH 0/4] iio: light: veml6070: add integration time and minor cleanups Javier Carrasco
@ 2024-10-17 21:39 ` Javier Carrasco
2024-10-19 14:18 ` Jonathan Cameron
2024-10-17 21:39 ` [PATCH 2/4] iio: light: veml6070: use field to set integration time Javier Carrasco
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Javier Carrasco @ 2024-10-17 21:39 UTC (permalink / raw)
To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: linux-iio, linux-kernel, devicetree, Javier Carrasco
Trivial modification to use the recommended keyword 'int' after
'unsigned' for unsigned integers.
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
drivers/iio/light/veml6070.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c
index 898e285322d4..484b767df481 100644
--- a/drivers/iio/light/veml6070.c
+++ b/drivers/iio/light/veml6070.c
@@ -87,14 +87,14 @@ static const struct iio_chan_spec veml6070_channels[] = {
}
};
-static int veml6070_to_uv_index(unsigned val)
+static int veml6070_to_uv_index(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)
*/
- unsigned uvi[11] = {
+ unsigned int uvi[11] = {
187, 373, 560, /* low */
746, 933, 1120, /* moderate */
1308, 1494, /* high */
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/4] iio: light: veml6070: use field to set integration time
2024-10-17 21:39 [PATCH 0/4] iio: light: veml6070: add integration time and minor cleanups Javier Carrasco
2024-10-17 21:39 ` [PATCH 1/4] iio: light: veml6070: use unsigned int instead of unsigned Javier Carrasco
@ 2024-10-17 21:39 ` Javier Carrasco
2024-10-19 14:19 ` Jonathan Cameron
2024-10-17 21:39 ` [PATCH 3/4] dt-bindings: iio: light: veml6075: document rset-kohms Javier Carrasco
2024-10-17 21:39 ` [PATCH 4/4] iio: light: veml6070: add support for integration time Javier Carrasco
3 siblings, 1 reply; 11+ messages in thread
From: Javier Carrasco @ 2024-10-17 21:39 UTC (permalink / raw)
To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: linux-iio, linux-kernel, devicetree, Javier Carrasco
Define the integration time within the configuration register as a field
to easy its handling as an index, preparing the driver to support
configurable integration times.
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
drivers/iio/light/veml6070.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c
index 484b767df481..d11ae00f61f8 100644
--- a/drivers/iio/light/veml6070.c
+++ b/drivers/iio/light/veml6070.c
@@ -9,6 +9,7 @@
* TODO: integration time, ACK signal
*/
+#include <linux/bitfield.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/mutex.h>
@@ -28,7 +29,7 @@
#define VEML6070_COMMAND_RSRVD BIT(1) /* reserved, set to 1 */
#define VEML6070_COMMAND_SD BIT(0) /* shutdown mode when set */
-#define VEML6070_IT_10 0x04 /* integration time 1x */
+#define VEML6070_IT_10 0x01 /* integration time 1x */
struct veml6070_data {
struct i2c_client *client1;
@@ -172,8 +173,8 @@ static int veml6070_probe(struct i2c_client *client)
return dev_err_probe(&client->dev, PTR_ERR(data->client2),
"i2c device for second chip address failed\n");
- data->config = VEML6070_IT_10 | VEML6070_COMMAND_RSRVD |
- VEML6070_COMMAND_SD;
+ data->config = FIELD_PREP(VEML6070_COMMAND_IT, VEML6070_IT_10) |
+ VEML6070_COMMAND_RSRVD | VEML6070_COMMAND_SD;
ret = i2c_smbus_write_byte(data->client1, data->config);
if (ret < 0)
return ret;
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/4] dt-bindings: iio: light: veml6075: document rset-kohms
2024-10-17 21:39 [PATCH 0/4] iio: light: veml6070: add integration time and minor cleanups Javier Carrasco
2024-10-17 21:39 ` [PATCH 1/4] iio: light: veml6070: use unsigned int instead of unsigned Javier Carrasco
2024-10-17 21:39 ` [PATCH 2/4] iio: light: veml6070: use field to set integration time Javier Carrasco
@ 2024-10-17 21:39 ` Javier Carrasco
2024-10-18 13:29 ` Rob Herring
2024-10-19 14:16 ` Jonathan Cameron
2024-10-17 21:39 ` [PATCH 4/4] iio: light: veml6070: add support for integration time Javier Carrasco
3 siblings, 2 replies; 11+ messages in thread
From: Javier Carrasco @ 2024-10-17 21:39 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
extertnal resistor (Rset in the datasheet) with values between 75 and
1200 kohms.
Document rset-kohms to select the integration time.
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
.../devicetree/bindings/iio/light/vishay,veml6075.yaml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml b/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
index 96c1317541fa..3d3ffeaa22df 100644
--- a/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
+++ b/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
@@ -29,6 +29,22 @@ required:
- reg
- vdd-supply
+allOf:
+ - if:
+ properties:
+ compatible:
+ enum:
+ - vishay,veml6070
+ then:
+ properties:
+ rset-kohms:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: |
+ Value in kilo Ohms of the Rset resistor used to select
+ the integration time.
+ minimum: 75
+ maximum: 1200
+
additionalProperties: false
examples:
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/4] iio: light: veml6070: add support for integration time
2024-10-17 21:39 [PATCH 0/4] iio: light: veml6070: add integration time and minor cleanups Javier Carrasco
` (2 preceding siblings ...)
2024-10-17 21:39 ` [PATCH 3/4] dt-bindings: iio: light: veml6075: document rset-kohms Javier Carrasco
@ 2024-10-17 21:39 ` Javier Carrasco
2024-10-18 14:05 ` Javier Carrasco
2024-10-19 14:21 ` Jonathan Cameron
3 siblings, 2 replies; 11+ messages in thread
From: Javier Carrasco @ 2024-10-17 21:39 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.
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
drivers/iio/light/veml6070.c | 109 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 107 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c
index d11ae00f61f8..87dc3295a656 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,15 +29,78 @@
#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 it[4][2];
};
+static void veml6070_calc_it(struct device *dev, struct veml6070_data *data)
+{
+ u32 rset, tmp_it;
+ int i, ret;
+
+ ret = device_property_read_u32(dev, "rset-kohms", &rset);
+ if (ret) {
+ dev_warn(dev, "no Rset specified, using default 300 kohms\n");
+ rset = 300;
+ }
+
+ if (rset < 75) {
+ dev_warn(dev, "Rset too low, using minimum = 75 kohms\n");
+ rset = 75;
+ }
+
+ if (rset > 1200) {
+ dev_warn(dev, "Rset too high, using maximum = 1200 kohms\n");
+ rset = 1200;
+ }
+
+ tmp_it = VEML6070_MIN_IT_US * (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;
@@ -81,10 +144,14 @@ 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),
}
};
@@ -127,6 +194,40 @@ static int veml6070_read_raw(struct iio_dev *indio_dev,
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 +235,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 +267,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] 11+ messages in thread
* Re: [PATCH 3/4] dt-bindings: iio: light: veml6075: document rset-kohms
2024-10-17 21:39 ` [PATCH 3/4] dt-bindings: iio: light: veml6075: document rset-kohms Javier Carrasco
@ 2024-10-18 13:29 ` Rob Herring
2024-10-19 14:16 ` Jonathan Cameron
1 sibling, 0 replies; 11+ messages in thread
From: Rob Herring @ 2024-10-18 13:29 UTC (permalink / raw)
To: Javier Carrasco
Cc: Jonathan Cameron, Lars-Peter Clausen, Krzysztof Kozlowski,
Conor Dooley, linux-iio, linux-kernel, devicetree
On Thu, Oct 17, 2024 at 11:39:27PM +0200, Javier Carrasco wrote:
> The veml6070 provides a configurable integration time by means of an
> extertnal resistor (Rset in the datasheet) with values between 75 and
> 1200 kohms.
>
> Document rset-kohms to select the integration time.
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
> .../devicetree/bindings/iio/light/vishay,veml6075.yaml | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml b/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
> index 96c1317541fa..3d3ffeaa22df 100644
> --- a/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
> +++ b/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
> @@ -29,6 +29,22 @@ required:
> - reg
> - vdd-supply
>
> +allOf:
> + - if:
> + properties:
> + compatible:
> + enum:
> + - vishay,veml6070
> + then:
> + properties:
> + rset-kohms:
Use the documented '-ohms' suffix.
Properties should be defined at the top-level and then restricted here.
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: |
> + Value in kilo Ohms of the Rset resistor used to select
> + the integration time.
> + minimum: 75
> + maximum: 1200
> +
> additionalProperties: false
>
> examples:
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] iio: light: veml6070: add support for integration time
2024-10-17 21:39 ` [PATCH 4/4] iio: light: veml6070: add support for integration time Javier Carrasco
@ 2024-10-18 14:05 ` Javier Carrasco
2024-10-19 14:21 ` Jonathan Cameron
1 sibling, 0 replies; 11+ messages in thread
From: Javier Carrasco @ 2024-10-18 14:05 UTC (permalink / raw)
To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: linux-iio, linux-kernel, devicetree
On 17/10/2024 23:39, Javier Carrasco 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.
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
> drivers/iio/light/veml6070.c | 109 ++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 107 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c
> index d11ae00f61f8..87dc3295a656 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,15 +29,78 @@
> #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 it[4][2];
> };
>
> +static void veml6070_calc_it(struct device *dev, struct veml6070_data *data)
> +{
> + u32 rset, tmp_it;
> + int i, ret;
> +
> + ret = device_property_read_u32(dev, "rset-kohms", &rset);
> + if (ret) {
> + dev_warn(dev, "no Rset specified, using default 300 kohms\n");
> + rset = 300;
> + }
> +
> + if (rset < 75) {
> + dev_warn(dev, "Rset too low, using minimum = 75 kohms\n");
> + rset = 75;
> + }
> +
> + if (rset > 1200) {
> + dev_warn(dev, "Rset too high, using maximum = 1200 kohms\n");
> + rset = 1200;
> + }
> +
> + tmp_it = VEML6070_MIN_IT_US * (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;
> @@ -81,10 +144,14 @@ 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),
> }
> };
>
> @@ -127,6 +194,40 @@ static int veml6070_read_raw(struct iio_dev *indio_dev,
> 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 +235,8 @@ static int veml6070_read_raw(struct iio_dev *indio_dev,
>
I just noticed that the processed data needs to be updated to take into
account different integration times because in its current form it
provides fixed values for Rset = 270kohm, IT=1T. I will add it to v2,
which is required anyway to address changes in the dt-bindings.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/4] dt-bindings: iio: light: veml6075: document rset-kohms
2024-10-17 21:39 ` [PATCH 3/4] dt-bindings: iio: light: veml6075: document rset-kohms Javier Carrasco
2024-10-18 13:29 ` Rob Herring
@ 2024-10-19 14:16 ` Jonathan Cameron
1 sibling, 0 replies; 11+ messages in thread
From: Jonathan Cameron @ 2024-10-19 14:16 UTC (permalink / raw)
To: Javier Carrasco
Cc: Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, linux-iio, linux-kernel, devicetree
On Thu, 17 Oct 2024 23:39:27 +0200
Javier Carrasco <javier.carrasco.cruz@gmail.com> wrote:
> The veml6070 provides a configurable integration time by means of an
> extertnal resistor (Rset in the datasheet) with values between 75 and
Spell check descriptions. external
> 1200 kohms.
>
> Document rset-kohms to select the integration time.
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
> .../devicetree/bindings/iio/light/vishay,veml6075.yaml | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml b/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
> index 96c1317541fa..3d3ffeaa22df 100644
> --- a/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
> +++ b/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml
> @@ -29,6 +29,22 @@ required:
> - reg
> - vdd-supply
>
> +allOf:
> + - if:
> + properties:
> + compatible:
> + enum:
> + - vishay,veml6070
> + then:
> + properties:
> + rset-kohms:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: |
> + Value in kilo Ohms of the Rset resistor used to select
> + the integration time.
> + minimum: 75
> + maximum: 1200
> +
> additionalProperties: false
>
> examples:
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/4] iio: light: veml6070: use unsigned int instead of unsigned
2024-10-17 21:39 ` [PATCH 1/4] iio: light: veml6070: use unsigned int instead of unsigned Javier Carrasco
@ 2024-10-19 14:18 ` Jonathan Cameron
0 siblings, 0 replies; 11+ messages in thread
From: Jonathan Cameron @ 2024-10-19 14:18 UTC (permalink / raw)
To: Javier Carrasco
Cc: Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, linux-iio, linux-kernel, devicetree
On Thu, 17 Oct 2024 23:39:25 +0200
Javier Carrasco <javier.carrasco.cruz@gmail.com> wrote:
> Trivial modification to use the recommended keyword 'int' after
> 'unsigned' for unsigned integers.
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Applied.
> ---
> drivers/iio/light/veml6070.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c
> index 898e285322d4..484b767df481 100644
> --- a/drivers/iio/light/veml6070.c
> +++ b/drivers/iio/light/veml6070.c
> @@ -87,14 +87,14 @@ static const struct iio_chan_spec veml6070_channels[] = {
> }
> };
>
> -static int veml6070_to_uv_index(unsigned val)
> +static int veml6070_to_uv_index(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)
> */
> - unsigned uvi[11] = {
> + unsigned int uvi[11] = {
> 187, 373, 560, /* low */
> 746, 933, 1120, /* moderate */
> 1308, 1494, /* high */
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/4] iio: light: veml6070: use field to set integration time
2024-10-17 21:39 ` [PATCH 2/4] iio: light: veml6070: use field to set integration time Javier Carrasco
@ 2024-10-19 14:19 ` Jonathan Cameron
0 siblings, 0 replies; 11+ messages in thread
From: Jonathan Cameron @ 2024-10-19 14:19 UTC (permalink / raw)
To: Javier Carrasco
Cc: Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, linux-iio, linux-kernel, devicetree
On Thu, 17 Oct 2024 23:39:26 +0200
Javier Carrasco <javier.carrasco.cruz@gmail.com> wrote:
> Define the integration time within the configuration register as a field
> to easy its handling as an index, preparing the driver to support
> configurable integration times.
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Applied this patch.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] iio: light: veml6070: add support for integration time
2024-10-17 21:39 ` [PATCH 4/4] iio: light: veml6070: add support for integration time Javier Carrasco
2024-10-18 14:05 ` Javier Carrasco
@ 2024-10-19 14:21 ` Jonathan Cameron
1 sibling, 0 replies; 11+ messages in thread
From: Jonathan Cameron @ 2024-10-19 14:21 UTC (permalink / raw)
To: Javier Carrasco
Cc: Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, linux-iio, linux-kernel, devicetree
On Thu, 17 Oct 2024 23:39:28 +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.
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Other than your self review (which I would probably have failed to
notice!), this looks fine to me.
Jonathan
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-10-19 14:21 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-17 21:39 [PATCH 0/4] iio: light: veml6070: add integration time and minor cleanups Javier Carrasco
2024-10-17 21:39 ` [PATCH 1/4] iio: light: veml6070: use unsigned int instead of unsigned Javier Carrasco
2024-10-19 14:18 ` Jonathan Cameron
2024-10-17 21:39 ` [PATCH 2/4] iio: light: veml6070: use field to set integration time Javier Carrasco
2024-10-19 14:19 ` Jonathan Cameron
2024-10-17 21:39 ` [PATCH 3/4] dt-bindings: iio: light: veml6075: document rset-kohms Javier Carrasco
2024-10-18 13:29 ` Rob Herring
2024-10-19 14:16 ` Jonathan Cameron
2024-10-17 21:39 ` [PATCH 4/4] iio: light: veml6070: add support for integration time Javier Carrasco
2024-10-18 14:05 ` Javier Carrasco
2024-10-19 14:21 ` 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).