dt-bindings: iio: light: isl76682: Document ISL76682
Subsystems (2)
PATCH v6 1/2 dt-bindings: iio: light: isl76682: Document ISL76682
The ISL76682 is very basic ALS which only supports ALS or IR mode in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any other fancy functionality. Document it as trivial device.
---
Cc: Alexander Stein <[email protected]>
Cc: Andre Werner <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Bjorn Helgaas <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Guenter Roeck <[email protected]>
Cc: Jonathan Cameron <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Lars-Peter Clausen <[email protected]>
Cc: Luca Ceresoli <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Matti Vaittinen <[email protected]>
Cc: Naresh Solanki <[email protected]>
Cc: Patrick Rudolph <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Stefan Windfeldt-Prytz <[email protected]>
Cc: Vincent Tremblay <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
V2: Add AB from Conor
V3: No change
V4: No change
V5: No change
V6: No change
--- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/trivial-devices.yaml +2 -0
@@ -181,6 +181,8 @@ properties: - isil,isl29030 # Intersil ISL68137 Digital Output Configurable PWM Controller - isil,isl68137 + # Intersil ISL76682 Ambient Light Sensor + - isil,isl76682 # Linear Technology LTC2488 - lineartechnology,ltc2488 # 5 Bit Programmable, Pulse-Width Modulator
Signature · 1 line
2.42.0
PATCH v6 2/2 iio: light: isl76682: Add ISL76682 driver
The ISL76682 is very basic ALS which only supports ALS or IR mode in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any other fancy functionality.
---
Cc: Alexander Stein <[email protected]>
Cc: Andre Werner <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Bjorn Helgaas <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Guenter Roeck <[email protected]>
Cc: Jonathan Cameron <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Lars-Peter Clausen <[email protected]>
Cc: Luca Ceresoli <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Matti Vaittinen <[email protected]>
Cc: Naresh Solanki <[email protected]>
Cc: Patrick Rudolph <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Stefan Windfeldt-Prytz <[email protected]>
Cc: Vincent Tremblay <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
V2: - Overhaul the driver
- Cache the entire 8-bit command register instead of parts of it and build up and rewrite the entire register if necessary
- Fix illumination scale, add intensity scale, add integration time
V3: - Limit the read data to 16bit ADC range
- Update Kconfig description
- Update macros, drop bitshifts
- Switch over to table lookup for lux ranges
- Switch over to .read_avail instead of attributes
- Use guard where applicable
- Drop remove function in favor of reset action
V4: - Address feedback from Andy
- Add missing includes
- Change ISL76682_ADC_MAX to BIT(16) - 1
- Drop initial ret assignment in isl76682_read_raw()
- Move return -EINVAL to default: switch-case branch
- Use switch-case consistenly instead of if/else
- Drop trailing commas
- Add comment to isl76682_clear_configure_reg on command zeroing on failure
- Drop i2c_set_clientdata
- Update devm_regmap_init_i2c return value handling
V5: - Remove newline, add newline, around module_i2c_driver
- Combine if:s
- Drop inner comma in isl76682_of_match
- Replace one more break with return -EINVAL
- Add RB from Andy and Matti
- Dispose of dependency on i2c_device_id, use ISL76682_DRIVER_NAME
V6: - Inline ISL76682_DRIVER_NAME, drop the macro
- Fix continue indent in isl76682_write_raw()
- Drop channel type pre check in read_raw / write_raw
--- drivers/iio/light/Kconfig | 15 ++ drivers/iio/light/Makefile | 1 + drivers/iio/light/isl76682.c | 353 +++++++++++++++++++++++++++++++++++ 3 files changed, 369 insertions(+) create mode 100644 drivers/iio/light/isl76682.c
drivers/iio/light/Kconfig +15 -0
@@ -252,6 +252,21 @@ config ISL29125 To compile this driver as a module, choose M here: the module will be called isl29125. +config ISL76682 + tristate "Intersil ISL76682 Light Sensor" + depends on I2C + select REGMAP_I2C + help + Say Y here if you want to build a driver for the Intersil ISL76682 + Ambient Light Sensor and IR Intensity sensor. This driver provides + the readouts via standard IIO sysfs and device interface. Both ALS + illuminance and IR illuminance are provided raw with separate scale + setting which can be configured via sysfs, the default scale is 1000 + lux, other options are 4000/16000/64000 lux. + + To compile this driver as a module, choose M here: the module will be + called isl76682. + config HID_SENSOR_ALS depends on HID_SENSOR_HUB select IIO_BUFFER
drivers/iio/light/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_IQS621_ALS) += iqs621-als.o obj-$(CONFIG_SENSORS_ISL29018) += isl29018.o obj-$(CONFIG_SENSORS_ISL29028) += isl29028.o obj-$(CONFIG_ISL29125) += isl29125.o +obj-$(CONFIG_ISL76682) += isl76682.o obj-$(CONFIG_JSA1212) += jsa1212.o obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o obj-$(CONFIG_LTR501) += ltr501.o
drivers/iio/light/isl76682.c new file +353 -0
353 lines not on this page · raw message
Signature · 1 line
2.42.0
Jonathan Cameron
maintainerRe: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
Quoted 7 lines · On Mon, 27 Nov 2023 22:26:53 +0100 Marek Vasut <[email protected]> wrote:
The ISL76682 is very basic ALS which only supports ALS or IR mode in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any other fancy functionality.
Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Matti Vaittinen <[email protected]>Signed-off-by Marek Vasut <[email protected]>
Hi Marek,
Discussion around available on v5 made me look closer at that aspect. You are providing all the available entries in the callback but they shouldn't be exposed to actually read unless the *_available bitmap bits corresponding to them are set.
If you like I can just rip the unused code out whilst applying? Or if you'd prefer to send a v7 that's great too.
Otherwise everything looks good to me.
Jonathan
Quoted 14 lines
drivers/iio/light/isl76682.c new file +14
-0+static int integration_time_available[] = {0 ,ISL76682_INT_TIME_US }; + +static int isl76682_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_SCALE : +switch (chan->type) { +case IIO_LIGHT : + *vals = illuminance_scale_available; + *length =ARRAY_SIZE (illuminance_scale_available); + *type =IIO_VAL_INT_PLUS_MICRO ;
drivers/iio/light/isl76682.c line 210
Quoted 10 lines
drivers/iio/light/isl76682.c new file +10
-0+return IIO_AVAIL_LIST ; +case IIO_INTENSITY : + *vals = intensity_scale_available; + *length =ARRAY_SIZE (intensity_scale_available); + *type =IIO_VAL_INT_PLUS_MICRO ; +return IIO_AVAIL_LIST ; +default : +return -EINVAL ; + } +case IIO_CHAN_INFO_INT_TIME :
Never used. So can just drop this case which tidies up the question I h ad earlier on what the single entry array was conveying.
Quoted 6 lines
drivers/iio/light/isl76682.c new file +6
-0+ *vals = integration_time_available; + *length =ARRAY_SIZE (integration_time_available); + *type =IIO_VAL_INT_PLUS_MICRO ; +return IIO_AVAIL_LIST ; +default : +return -EINVAL ;
drivers/iio/light/isl76682.c line 226
Quoted 10 lines
drivers/iio/light/isl76682.c new file +10
-0+ } +} + +static const struct iio_chan_spec isl76682_channels[] = { + { + .type =IIO_LIGHT , + .info_mask_separate =BIT (IIO_CHAN_INFO_RAW ) | +BIT (IIO_CHAN_INFO_SCALE ), + .info_mask_shared_by_type_available =BIT (IIO_CHAN_INFO_SCALE ), + .info_mask_shared_by_all =BIT (IIO_CHAN_INFO_INT_TIME ),
Without setting .info_mask_shared_by_all_available (unless we have a bug)
you won't see the available attributes for INT_TIME.
Quoted 15 lines
drivers/iio/light/isl76682.c new file +14
-0+ }, { + .type = IIO_INTENSITY, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME), + } +}; + +static const struct iio_info isl76682_info = { + .read_avail = isl76682_read_avail, + .read_raw = isl76682_read_raw, + .write_raw = isl76682_write_raw, +};
drivers/iio/light/isl76682.c line 337
Quoted 10 lines
drivers/iio/light/isl76682.c new file +9
-0+static const struct i2c_device_id isl76682_id[] = { + {"isl76682" }, + {} +}; +MODULE_DEVICE_TABLE (i2c, isl76682_id); + +static const struct of_device_id isl76682_of_match[] = { + { .compatible ="isil,isl76682" }, + { }
Completely trivial but why { } here and {} in the similar case above? Pick one!
Quoted 2 lines
(quoted diff) +2
-0+}; +MODULE_DEVICE_TABLE(of, isl76682_of_match);
Re: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
Quoted 17 lines · Jonathan Cameron
Quoted 7 lines · On Mon, 27 Nov 2023 22:26:53 +0100 Marek Vasut <[email protected]> wrote:
The ISL76682 is very basic ALS which only supports ALS or IR mode in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any other fancy functionality.
Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Matti Vaittinen <[email protected]>Signed-off-by Marek Vasut <[email protected]>Hi Marek,
Discussion around available on v5 made me look closer at that aspect. You are providing all the available entries in the callback but they shouldn't be exposed to actually read unless the
*_availablebitmap bits corresponding to them are set.
Quoted 4 lines
If you like I can just rip the unused code out whilst applying? Or if you'd prefer to send a v7 that's great too.
Otherwise everything looks good to me.
Maybe just do that while applying and I'll test it right after to see whether something broke, that's probably fastest. Just let me know where this got applied. I have the device on my desk .
Jonathan Cameron
maintainerRe: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
Quoted 18 lines · On Mon, 4 Dec 2023 12:23:06 +0100 Marek Vasut <[email protected]> wrote:
Quoted 17 lines · Jonathan Cameron
Quoted 7 lines · On Mon, 27 Nov 2023 22:26:53 +0100 Marek Vasut <[email protected]> wrote:
The ISL76682 is very basic ALS which only supports ALS or IR mode in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any other fancy functionality.
Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Matti Vaittinen <[email protected]>Signed-off-by Marek Vasut <[email protected]>Hi Marek,
Discussion around available on v5 made me look closer at that aspect. You are providing all the available entries in the callback but they shouldn't be exposed to actually read unless the
*_availablebitmap bits corresponding to them are set.
Quoted 8 lines
Quoted 4 lines
If you like I can just rip the unused code out whilst applying? Or if you'd prefer to send a v7 that's great too.
Otherwise everything looks good to me.
Maybe just do that while applying and I'll test it right after to see whether something broke, that's probably fastest. Just let me know where this got applied. I have the device on my desk .
Diff is below. Applied to the togreg branch of iio.git and initially pushed out as testing for normal reasons + for you to test.
Thanks,
Jonathan
drivers/iio/light/isl76682.c +0 -7
@@ -184,8 +184,6 @@ static int intensity_scale_available[] = { 0, 673000, }; -static int integration_time_available[] = {0 ,ISL76682_INT_TIME_US }; - static int isl76682_read_avail(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, const int **vals, int *type,
@@ -207,11 +205,6 @@ static int isl76682_read_avail(struct iio_dev *indio_dev,default :return -EINVAL ; } -case IIO_CHAN_INFO_INT_TIME : - *vals = integration_time_available; - *length =ARRAY_SIZE (integration_time_available); - *type =IIO_VAL_INT_PLUS_MICRO ; -return IIO_AVAIL_LIST ;default :return -EINVAL ; }
Re: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
Quoted 24 lines · Jonathan Cameron
Quoted 21 lines · On Mon, 4 Dec 2023 12:23:06 +0100 Marek Vasut <[email protected]> wrote:
Quoted 20 lines · Jonathan Cameron
Quoted 7 lines · On Mon, 27 Nov 2023 22:26:53 +0100 Marek Vasut <[email protected]> wrote:
The ISL76682 is very basic ALS which only supports ALS or IR mode in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any other fancy functionality.
Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Matti Vaittinen <[email protected]>Signed-off-by Marek Vasut <[email protected]>Hi Marek,
Discussion around available on v5 made me look closer at that aspect. You are providing all the available entries in the callback but they shouldn't be exposed to actually read unless the
*_availablebitmap bits corresponding to them are set.If you like I can just rip the unused code out whilst applying? Or if you'd prefer to send a v7 that's great too.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Otherwise everything looks good to me.
Maybe just do that while applying and I'll test it right after to see whether something broke, that's probably fastest. Just let me know where this got applied. I have the device on my desk .
Diff is below. Applied to the togreg
I only found the commit in 'testing' branch , so I used that one .
Quoted 23 lines
branch of iio.git and initially pushed out
as testing for normal reasons + for you to test.Thanks,
Jonathan
drivers/iio/light/isl76682.c +0
-2@@ -184,8 +184,6 @@ static int intensity_scale_available[] = { 0, 673000, }; -static int integration_time_available[] = {0 ,ISL76682_INT_TIME_US }; - static int isl76682_read_avail(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, const int **vals, int *type,@@ -207,11 +205,6 @@ static int isl76682_read_avail(struct iio_dev *indio_dev,default :
drivers/iio/light/isl76682.c static int isl76682_read_avail(struct iio_dev *indio_dev, · line 210
Quoted 10 lines
drivers/iio/light/isl76682.c +0
-5return -EINVAL ; } -case IIO_CHAN_INFO_INT_TIME : - *vals = integration_time_available; - *length =ARRAY_SIZE (integration_time_available); - *type =IIO_VAL_INT_PLUS_MICRO ; -return IIO_AVAIL_LIST ;default :return -EINVAL ; }
Ah, looking at the attrs before and after, now I get it:
$ grep -H . /sys/bus/iio/devices/iio\:device0/* /sys/bus/iio/devices/iio:device0/in_illuminance_raw:21 /sys/bus/iio/devices/iio:device0/in_illuminance_scale:0.015000 /sys/bus/iio/devices/iio:device0/in_illuminance_scale_available:0.015 0.06 0.24 0.96 /sys/bus/iio/devices/iio:device0/in_intensity_raw:33 /sys/bus/iio/devices/iio:device0/in_intensity_scale:0.010500 /sys/bus/iio/devices/iio:device0/in_intensity_scale_available:0.0105 0.042 0.168 0.673 /sys/bus/iio/devices/iio:device0/integration_time_available:0.090 /sys/bus/iio/devices/iio:device0/name:isl76682
/sys/bus/iio/devices/iio:device0/in_illuminance_raw:22 /sys/bus/iio/devices/iio:device0/in_illuminance_scale:0.015000 /sys/bus/iio/devices/iio:device0/in_illuminance_scale_available:0.015000 0.060000 0.240000 0.960000 /sys/bus/iio/devices/iio:device0/in_intensity_raw:24 /sys/bus/iio/devices/iio:device0/in_intensity_scale:0.010500 /sys/bus/iio/devices/iio:device0/in_intensity_scale_available:0.010500 0.042000 0.168000 0.673000 /sys/bus/iio/devices/iio:device0/integration_time:0.090000 /sys/bus/iio/devices/iio:device0/name:isl76682
Thanks !
Jonathan Cameron
maintainerRe: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
Quoted 27 lines · On Tue, 5 Dec 2023 02:24:51 +0100 Marek Vasut <[email protected]> wrote:
Quoted 26 lines · Jonathan Cameron
Quoted 23 lines · On Mon, 4 Dec 2023 12:23:06 +0100 Marek Vasut <[email protected]> wrote:
Quoted 21 lines · Jonathan Cameron
Quoted 7 lines · On Mon, 27 Nov 2023 22:26:53 +0100 Marek Vasut <[email protected]> wrote:
The ISL76682 is very basic ALS which only supports ALS or IR mode in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any other fancy functionality.
Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Matti Vaittinen <[email protected]>Signed-off-by Marek Vasut <[email protected]>Hi Marek,
Discussion around available on v5 made me look closer at that aspect. You are providing all the available entries in the callback but they shouldn't be exposed to actually read unless the
*_availablebitmap bits corresponding to them are set.If you like I can just rip the unused code out whilst applying? Or if you'd prefer to send a v7 that's great too.
Otherwise everything looks good to me.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Maybe just do that while applying and I'll test it right after to see whether something broke, that's probably fastest. Just let me know where this got applied. I have the device on my desk .
Diff is below. Applied to the togreg
I only found the commit in 'testing' branch , so I used that one .
I messed up it seems and didn't actually push the updated version. Done so now along with squashing in the bracket tidy up.
Quoted 62 lines
Quoted 24 lines
branch of iio.git and initially pushed out
as testing for normal reasons + for you to test.Thanks,
Jonathan
drivers/iio/light/isl76682.c +0
-2@@ -184,8 +184,6 @@ static int intensity_scale_available[] = { 0, 673000, }; -static int integration_time_available[] = {0 ,ISL76682_INT_TIME_US }; - static int isl76682_read_avail(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, const int **vals, int *type,@@ -207,11 +205,6 @@ static int isl76682_read_avail(struct iio_dev *indio_dev,default :drivers/iio/light/isl76682.c static int isl76682_read_avail(struct iio_dev *indio_dev, · line 210
Quoted 10 lines
drivers/iio/light/isl76682.c +0
-5return -EINVAL ; } -case IIO_CHAN_INFO_INT_TIME : - *vals = integration_time_available; - *length =ARRAY_SIZE (integration_time_available); - *type =IIO_VAL_INT_PLUS_MICRO ; -return IIO_AVAIL_LIST ;default :return -EINVAL ; }Ah, looking at the attrs before and after, now I get it:
$ grep -H . /sys/bus/iio/devices/iio\:device0/* /sys/bus/iio/devices/iio:device0/in_illuminance_raw:21 /sys/bus/iio/devices/iio:device0/in_illuminance_scale:0.015000 /sys/bus/iio/devices/iio:device0/in_illuminance_scale_available:0.015 0.06 0.24 0.96 /sys/bus/iio/devices/iio:device0/in_intensity_raw:33 /sys/bus/iio/devices/iio:device0/in_intensity_scale:0.010500 /sys/bus/iio/devices/iio:device0/in_intensity_scale_available:0.0105 0.042 0.168 0.673 /sys/bus/iio/devices/iio:device0/integration_time_available:0.090 /sys/bus/iio/devices/iio:device0/name:isl76682/sys/bus/iio/devices/iio:device0/in_illuminance_raw:22 /sys/bus/iio/devices/iio:device0/in_illuminance_scale:0.015000 /sys/bus/iio/devices/iio:device0/in_illuminance_scale_available:0.015000 0.060000 0.240000 0.960000 /sys/bus/iio/devices/iio:device0/in_intensity_raw:24 /sys/bus/iio/devices/iio:device0/in_intensity_scale:0.010500 /sys/bus/iio/devices/iio:device0/in_intensity_scale_available:0.010500 0.042000 0.168000 0.673000 /sys/bus/iio/devices/iio:device0/integration_time:0.090000 /sys/bus/iio/devices/iio:device0/name:isl76682
Thanks !
Re: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
Quoted 34 lines · Jonathan Cameron
Quoted 31 lines · On Tue, 5 Dec 2023 02:24:51 +0100 Marek Vasut <[email protected]> wrote:
Quoted 30 lines · Jonathan Cameron
Quoted 26 lines · On Mon, 4 Dec 2023 12:23:06 +0100 Marek Vasut <[email protected]> wrote:
Quoted 17 lines · Jonathan Cameron
Quoted 7 lines · On Mon, 27 Nov 2023 22:26:53 +0100 Marek Vasut <[email protected]> wrote:
The ISL76682 is very basic ALS which only supports ALS or IR mode in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any other fancy functionality.
Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Matti Vaittinen <[email protected]>Signed-off-by Marek Vasut <[email protected]>Hi Marek,
Discussion around available on v5 made me look closer at that aspect. You are providing all the available entries in the callback but they shouldn't be exposed to actually read unless the
*_availablebitmap bits corresponding to them are set.Quoted 4 lines
If you like I can just rip the unused code out whilst applying? Or if you'd prefer to send a v7 that's great too.
Otherwise everything looks good to me.
Maybe just do that while applying and I'll test it right after to see whether something broke, that's probably fastest. Just let me know where this got applied. I have the device on my desk .
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Diff is below. Applied to the togreg
I only found the commit in 'testing' branch , so I used that one .
I messed up it seems and didn't actually push the updated version. Done so now along with squashing in the bracket tidy up.
Driver works just fine, still, thank you.
Re: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
In reply to Jonathan CameronQuoted 43 lines · Jonathan Cameron
Quoted 7 lines · On Mon, 27 Nov 2023 22:26:53 +0100 Marek Vasut <[email protected]> wrote:
The ISL76682 is very basic ALS which only supports ALS or IR mode in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any other fancy functionality.
Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Matti Vaittinen <[email protected]>Signed-off-by Marek Vasut <[email protected]>Hi Marek,
Discussion around available on v5 made me look closer at that aspect. You are providing all the available entries in the callback but they shouldn't be exposed to actually read unless the
*_availablebitmap bits corresponding to them are set.If you like I can just rip the unused code out whilst applying? Or if you'd prefer to send a v7 that's great too.
Otherwise everything looks good to me.
Jonathan
Quoted 19 lines
drivers/iio/light/isl76682.c new file +19
-0+static int integration_time_available[] = {0 ,ISL76682_INT_TIME_US }; + +static int isl76682_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_SCALE : +switch (chan->type) { +case IIO_LIGHT : + *vals = illuminance_scale_available; + *length =ARRAY_SIZE (illuminance_scale_available); + *type =IIO_VAL_INT_PLUS_MICRO ; +return IIO_AVAIL_LIST ; +case IIO_INTENSITY : + *vals = intensity_scale_available; + *length =ARRAY_SIZE (intensity_scale_available); + *type =IIO_VAL_INT_PLUS_MICRO ;
Quoted 8 lines
drivers/iio/light/isl76682.c line 210
Quoted 5 lines
drivers/iio/light/isl76682.c new file +5
-0+return IIO_AVAIL_LIST ; +default : +return -EINVAL ; + } +case IIO_CHAN_INFO_INT_TIME :Never used. So can just drop this case which tidies up the question I h ad earlier on what the single entry array was conveying.
Seeing the diff, that now totally makes sense, thanks !
Quoted 36 lines
Quoted 6 lines
drivers/iio/light/isl76682.c new file +6
-0+ *vals = integration_time_available; + *length =ARRAY_SIZE (integration_time_available); + *type =IIO_VAL_INT_PLUS_MICRO ; +return IIO_AVAIL_LIST ; +default : +return -EINVAL ;drivers/iio/light/isl76682.c line 226
Quoted 10 lines
drivers/iio/light/isl76682.c new file +10
-0+ } +} + +static const struct iio_chan_spec isl76682_channels[] = { + { + .type =IIO_LIGHT , + .info_mask_separate =BIT (IIO_CHAN_INFO_RAW ) | +BIT (IIO_CHAN_INFO_SCALE ), + .info_mask_shared_by_type_available =BIT (IIO_CHAN_INFO_SCALE ), + .info_mask_shared_by_all =BIT (IIO_CHAN_INFO_INT_TIME ),Without setting .info_mask_shared_by_all_available (unless we have a bug)
you won't see the available attributes forINT_TIME.Quoted 14 lines
drivers/iio/light/isl76682.c new file +14
-0+ }, { + .type = IIO_INTENSITY, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME), + } +}; + +static const struct iio_info isl76682_info = { + .read_avail = isl76682_read_avail, + .read_raw = isl76682_read_raw, + .write_raw = isl76682_write_raw, +};
Quoted 12 lines
drivers/iio/light/isl76682.c line 337
Quoted 9 lines
drivers/iio/light/isl76682.c new file +9
-0+static const struct i2c_device_id isl76682_id[] = { + {"isl76682" }, + {} +}; +MODULE_DEVICE_TABLE (i2c, isl76682_id); + +static const struct of_device_id isl76682_of_match[] = { + { .compatible ="isil,isl76682" }, + { }Completely trivial but why { } here and {} in the similar case above? Pick one!
I sent a one-liner for this , it might make sense to squash it if possible .
Jonathan Cameron
maintainerRe: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
In reply to Marek VasutQuoted 7 lines · On Mon, 27 Nov 2023 22:26:53 +0100 Marek Vasut <[email protected]> wrote:
The ISL76682 is very basic ALS which only supports ALS or IR mode in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any other fancy functionality.
Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Matti Vaittinen <[email protected]>Signed-off-by Marek Vasut <[email protected]>
There is a additional question on what scale means for an IR channel. There aren't any well defined units (as it depends on the sensitivity curve) so in general we avoid providing scale for intensity readings.
The datasheet has a vague go at working around this problem by using counts relative to IR measurement in daylight which would measure 210 LUX. (via faking that with a 850nm green led??)
That's far from a standard..
We do have precedence of scale applied to intensity channels so I guess the ship has sailed.
Perhaps we should just add an explicit not to the ABI docs to cover that changing the scale in these sensors will result in the counts changing, but multiplying raw by scale isn't going to give any sensible units.
So probably not a thing to fix in this series, but to address separately.
Jonathan
Re: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
Quoted 25 lines · Jonathan Cameron
Quoted 7 lines · On Mon, 27 Nov 2023 22:26:53 +0100 Marek Vasut <[email protected]> wrote:
The ISL76682 is very basic ALS which only supports ALS or IR mode in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any other fancy functionality.
Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Matti Vaittinen <[email protected]>Signed-off-by Marek Vasut <[email protected]>There is a additional question on what scale means for an IR channel. There aren't any well defined units (as it depends on the sensitivity curve) so in general we avoid providing scale for intensity readings.
The datasheet has a vague go at working around this problem by using counts relative to IR measurement in daylight which would measure 210 LUX. (via faking that with a 850nm green led??)
That's far from a standard..
We do have precedence of scale applied to intensity channels so I guess the ship has sailed.
Quoted 7 lines
Perhaps we should just add an explicit not to the ABI docs to cover that changing the scale in these sensors will result in the counts changing, but multiplying raw by scale isn't going to give any sensible units.
So probably not a thing to fix in this series, but to address separately.
Is something like this what you have in mind ?
Documentation/ABI/testing/sysfs-bus-iio +3 -1
@@ -618,7 +618,9 @@ KernelVersion: 2.6.35 Contact: [email protected] Description: If a discrete set of scale values is available, they - are listed in this attribute. + are listed in this attribute. Unlike illumination, + multiplying intensity by intensity_scale does not + yield value with any standardized unit . What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_hardwaregain What: /sys/bus/iio/devices/iio:deviceX/in_intensity_hardwaregain
Re: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
Quoted 3 lines · Marek Vasut
Quoted 2 lines · Jonathan Cameron
On Mon, 27 Nov 2023 22:26:53 +0100
Marek Vasut <[email protected]> wrote:
...
Documentation/ABI/testing/sysfs-bus-iio KernelVersion: 2.6.35 · line 623
Quoted 5 lines
If a discrete set of scale values is available, they
Documentation/ABI/testing/sysfs-bus-iio +3
-1- are listed in this attribute. + are listed in this attribute. Unlike illumination, + multiplying intensity by intensity_scale does not + yield value with any standardized unit .
(Do not forget to drop extra space)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
Quoted 7 lines · Andy Shevchenko
Quoted 3 lines · Marek Vasut
Quoted 2 lines · Jonathan Cameron
On Mon, 27 Nov 2023 22:26:53 +0100
Marek Vasut <[email protected]> wrote:...
Quoted 7 lines
Documentation/ABI/testing/sysfs-bus-iio KernelVersion: 2.6.35 · line 623
Quoted 5 lines
If a discrete set of scale values is available, they
Documentation/ABI/testing/sysfs-bus-iio +3
-1- are listed in this attribute. + are listed in this attribute. Unlike illumination, + multiplying intensity by intensity_scale does not + yield value with any standardized unit .(Do not forget to drop extra space)
Which extra space ?
Re: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
Quoted 2 lines · Marek Vasut
Quoted 1 line · Andy Shevchenko
On Tue, Dec 05, 2023 at 02:43:30AM +0100, Marek Vasut wrote:
...
Quoted 5 lines
Quoted 3 lines
...unit .
(Do not forget to drop extra space)
Which extra space ?
Like in your question :-)
(I left the only relevant context, easy to notice.)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Marek Vasut
Quoted 1 line · Andy Shevchenko
On Tue, Dec 05, 2023 at 02:43:30AM +0100, Marek Vasut wrote:
...
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
...unit .
(Do not forget to drop extra space)
Which extra space ?
Like in your question :-)
(I left the only relevant context, easy to notice.)
Added, thanks.
Jonathan Cameron
maintainerRe: [PATCH v6 2/2] iio: light: isl76682: Add ISL76682 driver
In reply to Marek VasutQuoted 31 lines · On Tue, 5 Dec 2023 02:43:30 +0100 Marek Vasut <[email protected]> wrote:
Quoted 30 lines · Jonathan Cameron
Quoted 7 lines · On Mon, 27 Nov 2023 22:26:53 +0100 Marek Vasut <[email protected]> wrote:
The ISL76682 is very basic ALS which only supports ALS or IR mode in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any other fancy functionality.
Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Matti Vaittinen <[email protected]>Signed-off-by Marek Vasut <[email protected]>There is a additional question on what scale means for an IR channel. There aren't any well defined units (as it depends on the sensitivity curve) so in general we avoid providing scale for intensity readings.
The datasheet has a vague go at working around this problem by using counts relative to IR measurement in daylight which would measure 210 LUX. (via faking that with a 850nm green led??)
That's far from a standard..
We do have precedence of scale applied to intensity channels so I guess the ship has sailed.
Perhaps we should just add an explicit not to the ABI docs to cover that changing the scale in these sensors will result in the counts changing, but multiplying raw by scale isn't going to give any sensible units.
Quoted 4 lines
Quoted 2 lines
So probably not a thing to fix in this series, but to address separately.
Is something like this what you have in mind ?
Yes, something along those lines. We could add more detail on why but perhaps that would just confuse things more than just stating it is the case.
Quoted 18 lines
Documentation/ABI/testing/sysfs-bus-iio +3
-1@@ -618,7 +618,9 @@ KernelVersion: 2.6.35 Contact: [email protected] Description: If a discrete set of scale values is available, they - are listed in this attribute. + are listed in this attribute. Unlike illumination, + multiplying intensity by intensity_scale does not + yield value with any standardized unit . What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_hardwaregain What: /sys/bus/iio/devices/iio:deviceX/in_intensity_hardwaregain