summaryrefslogtreecommitdiff
path: root/drivers/iio/light
AgeCommit message (Collapse)AuthorFilesLines
2024-02-17iio: hid-sensor-als: Add light chromaticity supportBasavaraj Natikar1-0/+46
On some platforms, ambient color sensors also support the x and y light colors, which represent the coordinates on the CIE 1931 chromaticity diagram. Add light chromaticity x and y. Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://lore.kernel.org/r/20240205185926.3030521-5-srinivas.pandruvada@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-02-17iio: hid-sensor-als: Add light color temperature supportBasavaraj Natikar1-0/+21
On some platforms, ambient color sensors also support light color temperature. Add support of light color temperature. Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://lore.kernel.org/r/20240205185926.3030521-4-srinivas.pandruvada@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-02-17iio: hid-sensor-als: Remove hardcoding of values for enumsSrinivas Pandruvada1-2/+2
Remove hardcoding of values for enum CHANNEL_SCAN_INDEX_INTENSITY and CHANNEL_SCAN_INDEX_ILLUM. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://lore.kernel.org/r/20240205185926.3030521-3-srinivas.pandruvada@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-02-17iio: hid-sensor-als: Assign channels dynamicallySrinivas Pandruvada1-16/+35
Instead of assuming that every channel defined statically by als_channels[] is present, assign dynamically based on presence of the respective usage id in the descriptor. This will allow to register ALS with limited channel support. Append the timestamp as the last channel. Update available_scan_mask to specify all channels which are present. There is no intentional function changes done. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://lore.kernel.org/r/20240205185926.3030521-2-srinivas.pandruvada@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-02-17iio: light: vcnl4000: Set ps high definition for 4040/4200Mårten Lindahl1-1/+35
The vcnl4040/vcnl4200 proximity sensor defaults to 12 bit data resolution, but the chip also supports 16 bit data resolution, which is called proximity high definition (PS_HD). Make the vcnl4040/vcnl4200 proximity sensor use the high definition for all data readings. Please note that in order to preserve the 12 bit integer part of the in_proximity_raw output, the format is changed from integer to fixed point. Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com> Link: https://lore.kernel.org/r/20231221-vcnl4000-ps-hd-v3-1-6dcc889372be@axis.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-01-24iio: light: max44000: drop ACPI_PTR() and CONFIG_ACPI guardsJonathan Cameron1-4/+2
The complexity of config guards needed for ACPI_PTR() is not worthwhile for the small amount of saved data. This example was doing it correctly but I am proposing dropping this so as to reduce chance of cut and paste where it is done wrong. Also drop now unneeded linux/acpi.h include and added linux/mod_devicetable.h for struct acpi_device_id definition. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20231231183514.566609-24-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-01-24iio: light: us5182d: Drop ACPI_PTR() usageJonathan Cameron1-2/+2
Avoiding unused variable warnings when using this macro adds complexity that in simple cases like this one is not justified for the small saving in data. Switch include from acpi.h to mod_devicetable.h which includes the definition of struct acpi_device_id. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202311190738.gldzuIXo-lkp@intel.com/ Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20231231183514.566609-18-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-01-24iio: light: stk3310: Drop ACPI_PTR() usageJonathan Cameron1-2/+2
Avoiding unused variable warnings when using this macro adds complexity that in simple cases like this one is not justified for the small saving in data. Switch include from acpi.h to mod_devicetable.h which includes the definition of struct acpi_device_id. Reported-by: kernel test robot <lkp@intel.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20231231183514.566609-17-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-01-24iio: light: rpr0521: Drop ACPI_PTR() usageJonathan Cameron1-2/+2
Avoiding unused variable warnings when using this macro adds complexity that in simple cases like this one is not justified for the small saving in data. Switch include from acpi.h to mod_devicetable.h which includes the definition of struct acpi_device_id. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20231231183514.566609-16-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-01-24iio: light: ltr501: Drop ACPI_PTR() usageJonathan Cameron1-1/+2
Avoiding unused variable warnings when using this macro adds complexity that in simple cases like this one is not justified for the small saving in data. Include linux/mod_devicetable.h which includes the definition of struct acpi_device_id (hence somewhat related to the main change) Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20231231183514.566609-15-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-01-24iio: light: jsa1212: Drop ACPI_PTR() usageJonathan Cameron1-2/+2
Avoiding unused variable warnings when using this macro adds complexity that in simple cases like this one is not justified for the small saving in data. Switch include from acpi.h to mod_devicetable.h which includes the definition of struct acpi_device_id. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20231231183514.566609-14-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-01-22iio: light: as73211: add support for as7331Javier Carrasco2-28/+118
The AMS AS7331 is a UV light sensor with three channels: UVA, UVB and UVC (also known as deep UV and referenced as DUV in the iio core). Its internal structure and forming blocks are practically identical to the ones the AS73211 contains: API, internal DAC, I2C interface and registers, measurement modes, number of channels and pinout. The only difference between them is the photodiodes used to acquire light, which means that only some modifications are required to add support for the AS7331 in the existing driver. The temperature channel is identical for both devices and only the channel modifiers of the IIO_INTENSITY channels need to account for the device type. The scale values have been obtained from the chapter "7.5 Transfer Function" of the official datasheet[1] for the configuration chosen as basis (Nclk = 1024 and GAIN = 1). Those values keep the units from the datasheet (nW/cm^2), as opposed to the units used for the AS73211 (nW/m^2). Add a new device-specific data structure to account for the device differences: channel types and scale of LSB per channel. [1] https://ams.com/documents/20143/9106314/AS7331_DS001047_4-00.pdf Tested-by: Christian Eggers <ceggers@arri.de> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-01-22iio: light: as73211: use IIO_VAL_FRACTIONAL for intensity scalesJavier Carrasco1-8/+7
The scale values associated to the light channels are calculated as a division that can be better expressed as an IIO_VAL_FRACTIONAL type instead of the current IIO_VAL_INT. Note that the constant values used for the calculation were scaled up to work with integers, turning the nW/cm^2 units from the datasheet into nW/m^2, which would not be necessary with the IIO_VAL_FRACTIONAL type. But to avoid issues from current users of the driver, the units must be kept. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-01-18Merge tag 'char-misc-6.8-rc1' of ↵Linus Torvalds8-11/+1257
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc Pull char/misc and other driver updates from Greg KH: "Here is the big set of char/misc and other driver subsystem changes for 6.8-rc1. Other than lots of binder driver changes (as you can see by the merge conflicts) included in here are: - lots of iio driver updates and additions - spmi driver updates - eeprom driver updates - firmware driver updates - ocxl driver updates - mhi driver updates - w1 driver updates - nvmem driver updates - coresight driver updates - platform driver remove callback api changes - tags.sh script updates - bus_type constant marking cleanups - lots of other small driver updates All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (341 commits) android: removed duplicate linux/errno uio: Fix use-after-free in uio_open drivers: soc: xilinx: add check for platform firmware: xilinx: Export function to use in other module scripts/tags.sh: remove find_sources scripts/tags.sh: use -n to test archinclude scripts/tags.sh: add local annotation scripts/tags.sh: use more portable -path instead of -wholename scripts/tags.sh: Update comment (addition of gtags) firmware: zynqmp: Convert to platform remove callback returning void firmware: turris-mox-rwtm: Convert to platform remove callback returning void firmware: stratix10-svc: Convert to platform remove callback returning void firmware: stratix10-rsu: Convert to platform remove callback returning void firmware: raspberrypi: Convert to platform remove callback returning void firmware: qemu_fw_cfg: Convert to platform remove callback returning void firmware: mtk-adsp-ipc: Convert to platform remove callback returning void firmware: imx-dsp: Convert to platform remove callback returning void firmware: coreboot_table: Convert to platform remove callback returning void firmware: arm_scpi: Convert to platform remove callback returning void firmware: arm_scmi: Convert to platform remove callback returning void ...
2023-12-19Revert "iio: hid-sensor-als: Add light color temperature support"Srinivas Pandruvada1-35/+2
This reverts commit 5f05285df691b1e82108eead7165feae238c95ef. This commit assumes that every HID descriptor for ALS sensor has presence of usage id ID HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE. When the above usage id is absent, driver probe fails. This breaks ALS sensor functionality on many platforms. Till we have a good solution, revert this commit. Reported-by: Thomas Weißschuh <thomas@t-8ch.de> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218223 Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Cc: <stable@vger.kernel.org> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/20231217200703.719876-3-srinivas.pandruvada@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-12-19Revert "iio: hid-sensor-als: Add light chromaticity support"Srinivas Pandruvada1-63/+0
This reverts commit ee3710f39f9d0ae5137a866138d005fe1ad18132. This commit assumes that every HID descriptor for ALS sensor has presence of usage id ID HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X and HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y. When the above usage ids are absent, driver probe fails. This breaks ALS sensor functionality on many platforms. Till we have a good solution, revert this commit. Reported-by: Thomas Weißschuh <thomas@t-8ch.de> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218223 Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Cc: <stable@vger.kernel.org> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/20231217200703.719876-2-srinivas.pandruvada@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-12-11iio: light: driver for Lite-On ltr390Anshul Dalal3-0/+208
Implements driver for the Ambient/UV Light sensor LTR390. The driver exposes two ways of getting sensor readings: 1. Raw UV Counts directly from the sensor 2. The computed UV Index value with a percision of 2 decimal places [NOTE] Ambient light sensing has not been implemented yet. Driver tested on RPi Zero 2W Datasheet: https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201.pdf Signed-off-by: Anshul Dalal <anshulusr@gmail.com> Link: https://lore.kernel.org/r/20231208102211.413019-2-anshulusr@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-12-11iio: light: isl76682: remove unreachable codeJiapeng Chong1-1/+0
The function isl76682_read_raw cannot execute return -EINVAL up to 145 lines, delete the invalid code. drivers/iio/light/isl76682.c:145 isl76682_read_raw() warn: ignoring unreachable code. Reported-by: Abaci Robot <abaci@linux.alibaba.com> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7698 Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> Link: https://lore.kernel.org/r/20231208021715.32450-1-jiapeng.chong@linux.alibaba.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-12-06iio: light: pa1203001: Drop ACPI_PTR() protection.Jonathan Cameron1-1/+1
The extra cost of always including the acpi_device_id table is trivial vs the complexity of adding guards or __maybe_unused markings so just stop using the ACPI_PTR() macro. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202311160851.FDA4CDVE-lkp@intel.com/ Link: https://lore.kernel.org/r/20231116192711.366441-1-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-12-06iio: light: isl76682: Add ISL76682 driverMarek Vasut3-0/+362
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 <andriy.shevchenko@linux.intel.com> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Signed-off-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20231127212726.77707-2-marex@denx.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-12-04iio: light: add VEML6075 UVA and UVB light sensor driverJavier Carrasco3-0/+486
The Vishay VEMl6075 is a low power, 16-bit resolution UVA and UVB light sensor with I2C interface and noise compensation (visible and infrarred). Every UV channel generates an output signal measured in counts per integration period, where the integration time is configurable. This driver adds support for both UV channels and the ultraviolet index (UVI) inferred from them according to the device application note with open-air (no teflon) coefficients. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://lore.kernel.org/r/20231110-veml6075-v3-3-6ee46775b422@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-11-26iio: light: ltrf216a: Return floating point valuesShreeya Patel1-5/+5
For better precision of input light intesity, return floating point values through sysfs instead of an integer value Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com> Link: https://lore.kernel.org/r/20231107192005.285534-1-shreeya.patel@collabora.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-11-16iio: bu27008: Add illuminance channelMatti Vaittinen1-5/+196
The RGB + IR data can be used to calculate the illuminance value (luxes). Implement the equation obtained from the ROHM HW colleagues and add a raw light data channel outputting illuminance values in (nano) Luxes. Both the read_raw and buffering values are supported, with the limitation that buffering is only allowed when a suitable scan-mask is used. (RGB+IR, no clear). The equation has been developed by ROHM HW colleagues for open air sensor. Adding any lens to the sensor is likely to impact to used c1, c2, c3 coefficients. Also, the output values have only been tested on BU27008. According to the HW colleagues, the very same equation should work on BU27010 as well. Calculate and output illuminance values from BU27008 and BU27010. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://lore.kernel.org/r/ZTJcOxSb/WHzdN8h@dc78bmyyyyyyyyyyyyydt-3.rev.dnainternet.fi Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-10-20Merge tag 'iio-for-6.7a' of ↵Greg Kroah-Hartman5-33/+123
https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Jonathan writes: IIO: 1st set of new device support, features and cleanup for 6.7 Particularly great to see a resolver driver move out of staging via a massive set of changes. Only took 13 years :) One small patch added then reverted due to a report of test breakage (ashai-kasei,ak8975: Drop deprecated enums.) An immutable branch was used for some hid-senors changes in case there was a need to take them into the HID tree as well. New device support ----------------- adi,hmc425a - Add support for HMC540SLP3E broadband 4-bit digital attenuator. kionix,kx022a - Add support for the kx132-1211 accelerometer. Require significant driver rework to enable this including add a chip type specific structure to deal with the chip differences. - Add support for the kx132acr-lbz accelerometer (subset of the kx022a feature set). lltc,ltc2309 - New driver for this 8 channel ADC. microchip,mcp3911 - Add support for rest of mcp391x family of ADCs (there are various differences beyond simple channel count variation. Series includes some general driver cleanup. microchip,mcp3564 - New driver for MCP3461, MCP3462, MCP3464, MCP3541, MCP3562, MCP3564 and their R variants of 16/24bit ADCs. A few minor fixed followed. rohm,bu1390 - New driver for this pressure sensor. Staging graduation ------------------ adi,ad1210 (after 13 or so years :) - More or less a complete (step-wise) rewrite of this resolver driver to bring it up to date with modern IIO standards. The fault signal handling mapping to event channels was particularly complex and significant part of the changes. Features -------- iio-core - Add chromacity and color temperature channel types. adi,ad7192 - Oversampling ratio control (called fast settling in datasheet). adi,adis16475 - Add core support and then driver support for delta angle and delta velocity channels. These are intended for summation to establish angle and velocity changes over larger timescales. Fix was needed for alignment after the temperature channel. Further fix reduced set of devices for which the buffer support was applicable as seems burst reads don't cover these on all devices. hid-sensors-als - Chromacity and color temperatures support including in amd sfh. stx104 - Add support for counter subsystem to this multipurpose device. ti,twl6030 - Add missing device tree binding description. Clean up and minor fixes. ------------------------ treewide - Drop some unused declarations across IIO. - Make more use of device_get_match_data() instead of OF specific approaches. Similar cleanup to sets of drivers. - Stop platform remove callbacks returning anything by using the temporary remove_new() callback. - Use i2c_get_match_data() to cope nicely with all types of ID table entry. - Use device_get_match_data() for various platform device to cope with more types of firmware. - Convert from enum to pointer in ID tables allowing use of i2c_get_match_data(). - Fix sorting on some ID tables. - Include specific string helper headers rather than simply string_helpers.h docs - Better description of the ordering requirements etc for available_scan_masks. tools - Handle alignment of mixed sizes where the last element isn't the biggest correctly. Seems that doesn't happen often! adi,ad2s1210 - Lots of work from David Lechner on this driver including a few fixes that are going with the rework to avoid slowing that down. adi,ad4310 - Replace deprecated devm_clk_register() adi,ad74413r - Bring the channel function setting inline with the datasheet. adi,ad7192 - Change to FIELD_PREP(), FIELD_GET(). - Calculate f_order from the sinc filter and chop filter states. - Move more per chip config into data in struct ad7192_chip_info - Cleanup unused parameter in channel macros. adi,adf4350 - Make use of devm_* to simplify error handling for many of the setup calls in probe() / tear down in remove() and error paths. Some more work to be done on this one. - Use dev_err_probe() for errors in probe() callback. adi,adf4413 - Typo in function name prefix. adi,adxl345 - Add channel scale to the chip type specific structure and drop using a type field previously used for indirection. asahi,ak8985 - Fix a mismatch introduced when switching from enum->pointers in the match tables. amlogic,meson - Expand error logging during probe. invensense,mpu6050 - Support level-shifter control. Whilst no one is sure exactly what this is doing it is needed for some old boards. - Document mount-matrix dt-binding. mediatek,mt6577 - Use devm_clk_get_enabled() to replace open coded version and move everything over to being device managed. Drop now empty remove() callback. Fix follows to put the drvdata back. - Use dev_err_probe() for error reporting in probe() callback. memsic,mxc4005 - Add of_match_table. microchip,mcp4725 - Move various chip specific data from being looked up by chip ID to data in the chip type specific structure. silicon-labs,si7005 - Add of_match_table and entry in trivial-devices.yaml st,lsm6dsx - Add missing mount-matrix dt binding documentation. st,spear - Use devm_clk_get_enabled() and some other devm calls to move everything over to being device managed. Drop now empty remove() callback. - Use dev_err_probe() to better handled deferred probing and tidy up error reporting in probe() callback. st,stm32-adc - Add a bit of additional checking in probe() to protect against a NULL pointer (no known path to trigger it today). - Replace deprecated strncpy() ti,ads1015 - Allow for edge triggers. - Document interrupt in dt-bindings. * tag 'iio-for-6.7a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (201 commits) iio: Use device_get_match_data() iio: adc: MCP3564: fix warn: unsigned '__x' is never less than zero. dt-bindings: trivial-devices: add silabs,si7005 iio: si7005: Add device tree support drivers: imu: adis16475.c: Remove scan index from delta channels dt-bindings: iio: imu: st,lsm6dsx: add mount-matrix property iio: resolver: ad2s1210: remove of_match_ptr() iio: resolver: ad2s1210: remove DRV_NAME macro iio: resolver: ad2s1210: move out of staging staging: iio: resolver: ad2s1210: simplify code with guard(mutex) staging: iio: resolver: ad2s1210: clear faults after soft reset staging: iio: resolver: ad2s1210: refactor sample toggle staging: iio: resolver: ad2s1210: remove fault attribute staging: iio: resolver: ad2s1210: add label attribute support staging: iio: resolver: ad2s1210: add register/fault support summary staging: iio: resolver: ad2s1210: implement fault events iio: event: add optional event label support staging: iio: resolver: ad2s1210: rename DOS reset min/max attrs staging: iio: resolver: ad2s1210: convert DOS mismatch threshold to event attr staging: iio: resolver: ad2s1210: convert DOS overrange threshold to event attr ...
2023-10-05iio: light: vcnl4000: Don't power on/off chip in configMårten Lindahl1-1/+0
After enabling/disabling interrupts on the vcnl4040 chip the als and/or ps sensor is powered on or off depending on the interrupt enable bits. This is made as a last step in write_event_config. But there is no reason to do this as the runtime PM handles the power state of the sensors. Interfering with this may impact sensor readings. Consider the following: 1. Userspace makes sensor data reading which triggers RPM resume (sensor powered on) and a RPM suspend timeout. The timeout is 2000ms before RPM suspend powers the sensor off if no new reading is made within the timeout period. 2. Userspace disables interrupts => powers sensor off 3. Userspace reads sensor data = 0 because sensor is off and the suspend timeout has not passed. For each new reading made within the timeout period the timeout is renewed with 2000ms and RPM will not make a new resume (device was not suspended). So the sensor will not be powered on. 4. No further userspace reading for 2000ms ends RPM suspend timeout and triggers suspend (powers off already powered off sensor). Powering sensor off in (2) makes all consecutive readings made within 2000ms to the previous reading (3) return invalid data. Skip setting power state when writing new event config. Fixes: 546676121cb9 ("iio: light: vcnl4000: Add interrupt support for vcnl4040") Fixes: bc292aaf9cb4 ("iio: light: vcnl4000: add illuminance irq vcnl4040/4200") Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com> Link: https://lore.kernel.org/r/20230907-vcnl4000-pm-fix-v2-1-298e01f54db4@axis.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-24Merge branch 'ib-iio-hid-sensors-v6.6-rc1' into togregJonathan Cameron1-16/+114
The deta angle and deta velocity channels were added in parallel with color temperature and chromacity so this merge had to assign a consistent order. I put the color related ones second. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-24iio: hid-sensor-als: Add light chromaticity supportBasavaraj Natikar1-0/+63
In most cases, ambient color sensors also support the x and y light colors, which represent the coordinates on the CIE 1931 chromaticity diagram. Thus, add light chromaticity x and y. Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com> Acked-by: Srinivas Pandruvada<srinivas.pandruvada@linux.intel.com> Link: https://lore.kernel.org/r/20230919081054.2050714-8-Basavaraj.Natikar@amd.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-24iio: hid-sensor-als: Add light color temperature supportBasavaraj Natikar1-2/+35
In most cases, ambient color sensors also support light color temperature. As a result, add support of light color temperature. Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com> Acked-by: Srinivas Pandruvada<srinivas.pandruvada@linux.intel.com> Link: https://lore.kernel.org/r/20230919081054.2050714-4-Basavaraj.Natikar@amd.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-24iio: hid-sensor-als: Use channel index to support more hub attributesBasavaraj Natikar1-18/+20
Sensor hub attributes can be extended to support more channels. Repeat the reading for the two existing channels and store them separately. It still operates in the same manner as before where there was just one entry. So in order to support more sensor hub attributes for ALS use channel index to get specific sensor hub attributes. Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com> Acked-by: Srinivas Pandruvada<srinivas.pandruvada@linux.intel.com> Link: https://lore.kernel.org/r/20230919081054.2050714-2-Basavaraj.Natikar@amd.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-23iio: light: lm3533-als: Convert to platform remove callback returning voidUwe Kleine-König1-4/+2
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230919174931.1417681-40-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-23iio: light: hid-sensor-prox: Convert to platform remove callback returning voidUwe Kleine-König1-4/+2
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230919174931.1417681-39-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-23iio: light: hid-sensor-als: Convert to platform remove callback returning voidUwe Kleine-König1-4/+2
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230919174931.1417681-38-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-23iio: light: cm3605: Convert to platform remove callback returning voidUwe Kleine-König1-4/+2
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230919174931.1417681-37-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-12iio: light: opt4001: Use i2c_get_match_data()Biju Das1-1/+1
Replace device_get_match_data()->i2c_get_match_data() to extend matching support for ID table. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Stefan Windfeldt-Prytz <stefan.windfeldt-prytz@axis.com> Tested-by: Stefan Windfeldt-Prytz <stefan.windfeldt-prytz@axis.com> Link: https://lore.kernel.org/r/20230812151908.188696-1-biju.das.jz@bp.renesas.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-13Merge 6.5-rc6 into char-misc-nextGreg Kroah-Hartman2-6/+38
We need the char/misc fixes in here as well to build on top of. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-08iio: light: bd27008: Support BD27010 RGBMatti Vaittinen1-2/+311
The ROHM BU27010 is an RGBC sensor with a flickering detection FIFO. The RGBC+IR sensor functionality is largely similar to what the BU27008 has. There are some notable things though: - gain setting is once again new and exotic. Now, there is 6bit gain setting where 4 of the bits are common to all channels and 2 bits can be configured separately for each channel. The BU27010 has similar "1X on other channels vs 2X on IR when selector is 0x0" gain design as BU27008 had. So, we use same gain setting policy for BU27010 as we did for BU27008 - driver sets same gain selector for all channels but shows the gains separately for all channels so users can (at least in theory) detect this 1X vs 2X madness... - BU27010 has suffled all the control register bitfields to new addresses and bit positions while still keeping the register naming same. - Some more power/reset control is added. - FIFO for "flickering detection" is added. The control register suffling made this slightly nasty. Still, it is easier for maintenance perspective to add the BU27010 support in BU27008 driver because - even though the bit positions/addresses were changed - most of the driver structure can be re-used. Writing own driver for BU27010 would mean plenty of duplicate code albeit a tad more clarity. The flickering FIFO is not supported by the driver. Add BU27010 RGBC+IR support to rohm-bu27008 driver. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://lore.kernel.org/r/111cd217ccece1c1f16ab4287532dc4e1ddb8a3f.1690958450.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-08iio: light: bu27008: add chip infoMatti Vaittinen1-114/+207
The ROHM BU27010 RGB + flickering sensor is in many regards similar to the BU27008. Prepare for adding support for BU27010 by allowing chip-specific properties to be brought from the of_device_id data. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://lore.kernel.org/r/d5994648033d5513993b8d72eb186ddda211b5ac.1690958450.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-29iio: adc: Remove redundant dev_err_probe()Ruan Jinjie1-1/+1
There is no need to call the dev_err() function directly to print a custom message when handling an error from either the platform_get_irq() or platform_get_irq_byname() functions as both are going to display an appropriate error message in case of a failure. Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Heiko Stuebner <heiko@sntech.de> Link: https://lore.kernel.org/r/20230727073912.4178659-1-ruanjinjie@huawei.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20iio: light: vcnl4000: Add calibration bias for 4040/4200Astrid Rost1-2/+91
The calibration bias is setting the LED current to change the detection distance. Add read/write attribute for proximity calibration bias and read attribute for available values. This is supported for vcnl4040 and vcnl4200. Signed-off-by: Astrid Rost <astrid.rost@axis.com> Link: https://lore.kernel.org/r/20230613135025.2596641-9-astrid.rost@axis.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20iio: light: vcnl4000: Add oversampling_ratio for 4040/4200Astrid Rost1-2/+81
Add the proximity multi pulse (PS_MPS) as oversampling_ratio. Instead of one single pulse per every defined time frame, one can program2, 4, or even 8 pulses. This leads to a longer IRED on-time for each proximity measurement value, which also results in a higher detection range. Add read/write attribute for proximity oversampling-ratio and read attribute for available oversampling-ratio. This is supported for vcnl4040 and vcnl4200. Signed-off-by: Astrid Rost <astrid.rost@axis.com> Link: https://lore.kernel.org/r/20230613135025.2596641-8-astrid.rost@axis.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20iio: light: vcnl4000: Add period for vcnl4040/4200Astrid Rost1-2/+159
Add read/write attribute for proximity and illuminance period. The period is set in the interrupt persistence flags(PS_PERS and ALS_PERS). An interrupt will not be asserted if the raw value is not over (or lower) than the threshold for the set continued amount of measurements. The time in seconds is calculated by the number of continued refreshes multiplied with the integration time. It will always pick the next lower possible value. The period changes, if the integration time is changed. Signed-off-by: Astrid Rost <astrid.rost@axis.com> Link: https://lore.kernel.org/r/20230613135025.2596641-7-astrid.rost@axis.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20iio: light: vcnl4000: add illuminance irq vcnl4040/4200Astrid Rost1-2/+92
Add support to configure ambient light sensor interrupts and threshold limits for vcnl4040 and vcnl4200. If an interrupt is detected an event will be pushed to the event interface. Signed-off-by: Astrid Rost <astrid.rost@axis.com> Link: https://lore.kernel.org/r/20230613135025.2596641-6-astrid.rost@axis.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20iio: light: vcnl4000: Add als_it for vcnl4040/4200Astrid Rost1-3/+91
Add illuminance integration time for vcnl4040 and vcnl4200. Add read/write attribute for illuminance integration time and read attribute for available integration times. Set scale and sampling rate according to the integration time. Signed-off-by: Astrid Rost <astrid.rost@axis.com> Link: https://lore.kernel.org/r/20230613135025.2596641-5-astrid.rost@axis.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20iio: light: vcnl4000: Check type with switch caseAstrid Rost1-52/+100
Check IIO_PROXIMITY with switch case in order to make it easier to add further types like light. Add check for IIO_EV_INFO_VALUE for writing rising or falling events. Signed-off-by: Astrid Rost <astrid.rost@axis.com> Link: https://lore.kernel.org/r/20230613135025.2596641-4-astrid.rost@axis.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20iio: light: vcnl4000: Add proximity ps_it for vcnl4200Astrid Rost1-7/+26
Add ps_it attributes for vcnl4200 (similar to vcnl4040). Add read/write attribute for proximity integration time. Read attribute for available proximity integration times. Change sampling rate depending on integration time. Signed-off-by: Astrid Rost <astrid.rost@axis.com> Link: https://lore.kernel.org/r/20230613135025.2596641-3-astrid.rost@axis.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20iio: light: vcnl4000: Add proximity irq for vcnl4200Astrid Rost1-3/+9
Add proximity interrupt support for vcnl4200 (similar to vcnl4040). Add support to configure proximity sensor interrupts and threshold limits. If an interrupt is detected an event will be pushed to the event interface. Signed-off-by: Astrid Rost <astrid.rost@axis.com> Link: https://lore.kernel.org/r/20230613135025.2596641-2-astrid.rost@axis.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-15iio: light: bu27008: Fix intensity data typeMatti Vaittinen1-1/+1
The intensity data from bu27008 is unsigned. The type of the scan data was incorrectly marked as signed resulting large intensity values to be interpreted as negative ones. Fix the scan data type. Fixes: 41ff93d14f78 ("iio: light: ROHM BU27008 color sensor") Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://lore.kernel.org/r/240a7ca5fc1b76da20d81f930d00f31a54b1fdf8.1686648422.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-15iio: light: bu27008: Fix scale formatMatti Vaittinen1-2/+18
The driver is expecting accuracy of NANOs for intensity scale in raw_write. The IIO core is however defaulting to MICROs. This leads the raw-write of smallest scales to never succeed as correct selector(s) are not found. Fix this by implementing the .write_raw_get_fmt callback to use NANO accuracy for writes of IIO_CHAN_INFO_SCALE. Fixes: 41ff93d14f78 ("iio: light: ROHM BU27008 color sensor") Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://lore.kernel.org/r/e4778b74cde41431f77bc8dd88ec18605da0b400.1686648422.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-15iio: light: bu27034: Fix scale formatMatti Vaittinen1-3/+19
The driver is expecting accuracy of NANOs for intensity scale in raw_write. The IIO core is however defaulting to MICROs. This leads the raw-write of smallest scales to never succeed as correct selector(s) are not found. Fix this by implementing the .write_raw_get_fmt callback to use NANO accuracy for writes of IIO_CHAN_INFO_SCALE. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Fixes: e52afbd61039 ("iio: light: ROHM BU27034 Ambient Light Sensor") Link: https://lore.kernel.org/r/5369117315cf05b88cf0ccb87373fd77190f6ca2.1686648422.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-15Merge tag 'iio-for-6.5a' of ↵Greg Kroah-Hartman51-47/+1576
https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Jonathan writes: 1st set of IIO new device support, features and cleanup for the 6.5 cycle. New device support - honeywell,mprls0025pa * New driver and dt-bindings for this series of pressure sensors. - invensense,mpu6050 * Add support for ICM 20600 IMU (ID, bindings and device data). - melexis,mlx90614 * Add support for mlx90615 Infra Red Thermometer after driver cleanup and refactoring to support the differences in this device. - renesas,x9250 * New driver and bindings for this quad potentiometer. - rockchip,saradc * Add support for RK3588. Also included is a bunch of refactoring and cleanup for that driver. - rohm,bu27008 * New driver bindings etc for this 5 photodiode color sensor. - st,lsm9ds0/st,st-sensors * ID added for LSM303D accelerometer and magnetometer including ACPI binding. - ti,opt4001 * New driver and bindings for this ambient light sensor. Features - core * Introduce iio_validate_own_trigger() for cases where a driver can only consumer a trigger it registered (detected via same parent device). Use it in the kionix,kx022a driver and new rohm,by27008 driver. - dynaimage,al3320a * ACPI binding CALS0001 seen on Lenovo Yoga Table 2 devices. - kionix,kx002a * Enable asynchronous probe. - rohm,bu27034 * Enable asynchronous probe. - ti,tmp006 * Explicit support for DT including binding documentation. Cleanups, minor fixes and misc improvements. - treewide * Switch I2C drivers from probe_new() back to probe() - part of the long process of getting rid of a parameter from probe() * Various whitespace and typo fixes not otherwise called out. - core * industrialio-buffer,Style cleanup. * Add documentation to extend_name field of struct iio_chan_spec to direct people using it towards the label infrastructure instead. extend_name was a design mistake a long time back so directly people away from it may be useful. - adi,ad7606 * Add HAS_IOPORT dependency to prepare for some Kconfig changes. - bosch,bma400 * Drop pointless print of ret in a dev_err_probe() message. - invensense,icm42600 * Rework timestamp handling to reduce jitter. - mediatek,mt7986-auxdac * Add DT binding for this part. - qcom,spmi-vadc * Allow for 1/16th prescaling used on a few devices. * Various changes to channel labeling and naming, including dropping use of fwnode_name which generates odd channel names. Small ABI change as a result, but not thought to be a problem for users of this platform. - st,lsm6dsx * dt-binding: Use common schema for mount-matrix via a reference. - st,stm32 * Add a debug print for when legacy channel config is used. - ti,palmas-adc * Drop unused i2c.h include. * tag 'iio-for-6.5a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (59 commits) dt-bindings: iio: rockchip: Fix 'oneOf' condition failed warning dt-bindings: iio: afe: voltage-divider: Spelling s/curcuit/circuit/ dt-bindings: iio: adc: Add rockchip,rk3588-saradc string iio: adc: rockchip_saradc: Use dev_err_probe iio: adc: rockchip_saradc: Match alignment with open parenthesis iio: adc: rockchip_saradc: Use of_device_get_match_data iio: adc: rockchip_saradc: Make use of devm_clk_get_enabled iio: adc: rockchip_saradc: Add support for RK3588 iio: adc: rockchip_saradc: Add callback functions iio: temperature: tmp006: Add OF device matching support dt-bindings: iio: temperature: Add support for tmp006 staging: iio: Switch i2c drivers back to use .probe() iio: amplifiers: ad8366 Fix whitespace issue iio: imu: inv_icm42600: avoid frequent timestamp jitter MAINTAINERS: Add ROHM BU27008 iio: light: ROHM BU27008 color sensor iio: kx022a: Use new iio_validate_own_trigger() iio: trigger: Add simple trigger_validation helper dt-bindings: iio: light: ROHM BU27008 iio: mlx90614: Add MLX90615 support ...