aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-03-15Merge tag 'iio-fixes-for-5.12a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linusGreg Kroah-Hartman9-18/+35
Jonathan writes: First set of IIO and counter fixes for the 5.12 cycle adi,ad7949 * Fix a wrong bitmask that could lead to an undefined bit being included. adi,adi-axi-adc * Add missing Kconfig dependencies adi,adis16400 * Wrong error code handling in adis16400 that could lead to failed probe. hid-sensor-humidity, temperature * Fix alignment and space for timestamp channel. hid-sensor-prox * Fix an issue with handling of exponent on the channel scaling. invensense,mpu3050 * Fix a hole in error handling. qcom,spi-vadc * Correct scaling st,ab8500-adc * Fix wrong scaling (by factor of 1000) st,stm32-adc * Add missing HAS_IOMEM dependency st,stm32-timer-cnt * Report count when running off internal clock * Fix issue with not checking ceiling before trying to write to hardware * Ensure driver doesn't have stashed state which doesn't match hardware by rereading from hardware in a slow path. * tag 'iio-fixes-for-5.12a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: gyro: mpu3050: Fix error handling in mpu3050_trigger_handler iio: hid-sensor-temperature: Fix issues of timestamp channel iio: hid-sensor-humidity: Fix alignment issue of timestamp channel counter: stm32-timer-cnt: fix ceiling miss-alignment with reload register counter: stm32-timer-cnt: fix ceiling write max value counter: stm32-timer-cnt: Report count function when SLAVE_MODE_DISABLED iio: adc: ab8500-gpadc: Fix off by 10 to 3 iio:adc:stm32-adc: Add HAS_IOMEM dependency iio: adis16400: Fix an error code in adis16400_initial_setup() iio: adc: adi-axi-adc: add proper Kconfig dependencies iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask iio: hid-sensor-prox: Fix scale not correct issue iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channel
2021-03-06iio: gyro: mpu3050: Fix error handling in mpu3050_trigger_handlerDinghao Liu1-0/+2
There is one regmap_bulk_read() call in mpu3050_trigger_handler that we have caught its return value bug lack further handling. Check and terminate the execution flow just like the other three regmap_bulk_read() calls in this function. Fixes: 3904b28efb2c7 ("iio: gyro: Add driver for the MPU-3050 gyroscope") Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20210301080421.13436-1-dinghao.liu@zju.edu.cn Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-06iio: hid-sensor-temperature: Fix issues of timestamp channelYe Xiang1-6/+8
This patch fixes 2 issues of timestamp channel: 1. This patch ensures that there is sufficient space and correct alignment for the timestamp. 2. Correct the timestamp channel scan index. Fixes: 59d0f2da3569 ("iio: hid: Add temperature sensor support") Signed-off-by: Ye Xiang <xiang.ye@intel.com> Cc: <Stable@vger.kernel.org> Link: https://lore.kernel.org/r/20210303063615.12130-4-xiang.ye@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-06iio: hid-sensor-humidity: Fix alignment issue of timestamp channelYe Xiang1-5/+7
This patch ensures that, there is sufficient space and correct alignment for the timestamp. Fixes: d7ed89d5aadf ("iio: hid: Add humidity sensor support") Signed-off-by: Ye Xiang <xiang.ye@intel.com> Cc: <Stable@vger.kernel.org> Link: https://lore.kernel.org/r/20210303063615.12130-2-xiang.ye@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-02-22Merge tag 'thermal-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linuxLinus Torvalds1-0/+50
Pull thermal updates from Daniel Lezcano: - Use the newly introduced 'hot' and 'critical' ops for the acpi thermal driver (Daniel Lezcano) - Remove the notify ops as it is no longer used (Daniel Lezcano) - Remove the 'forced passive' option and the unused bind/unbind functions (Daniel Lezcano) - Remove the THERMAL_TRIPS_NONE and the code cleanup around this macro (Daniel Lezcano) - Rework the delays to make them pre-computed instead of computing them again and again at each polling interval (Daniel Lezcano) - Remove the pointless 'thermal_zone_device_reset' function (Daniel Lezcano) - Use the critical and hot ops to prevent an unexpected system shutdown on int340x (Kai-Heng Feng) - Make the cooling device state private to the thermal subsystem (Daniel Lezcano) - Prevent to use not-power-aware actor devices with the power allocator governor (Lukasz Luba) - Remove 'zx' and 'tango' support along with the corresponding platforms (Arnd Bergman) - Fix several issues on the Omap thermal driver (Tony Lindgren) - Add support for adc-tm5 PMIC thermal monitor for Qcom platforms (Dmitry Baryshkov) - Fix an initialization loop in the adc-tm5 (Colin Ian King) - Fix a return error check in the cpufreq cooling device (Viresh Kumar) * tag 'thermal-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux: (26 commits) thermal: cpufreq_cooling: freq_qos_update_request() returns < 0 on error thermal: qcom: Fix comparison with uninitialized variable channels_available thermal: qcom: add support for adc-tm5 PMIC thermal monitor dt-bindings: thermal: qcom: add adc-thermal monitor bindings thermal: ti-soc-thermal: Use non-inverted define for omap4 thermal: ti-soc-thermal: Simplify polling with iopoll thermal: ti-soc-thermal: Fix stuck sensor with continuous mode for 4430 thermal: ti-soc-thermal: Skip pointless register access for dra7 thermal/drivers/zx: Remove zx driver thermal/drivers/tango: Remove tango driver thermal: power allocator: fail binding for non-power actor devices thermal/core: Make cooling device state change private thermal: intel: pch: Fix unexpected shutdown at critical temperature thermal: int340x: Fix unexpected shutdown at critical temperature thermal/core: Remove pointless thermal_zone_device_reset() function thermal/core: Remove ms based delay fields thermal/core: Use precomputed jiffies for the polling thermal/core: Precompute the delays from msecs to jiffies thermal/core: Remove unused macro THERMAL_TRIPS_NONE thermal/core: Remove THERMAL_TRIPS_NONE test ...
2021-02-21iio: adc: ab8500-gpadc: Fix off by 10 to 3Linus Walleij1-1/+1
Fix an off by three orders of magnitude error in the AB8500 GPADC driver. Luckily it showed up quite quickly when trying to make use of it. The processed reads were returning microvolts, microamperes and microcelsius instead of millivolts, milliamperes and millicelsius as advertised. Cc: stable@vger.kernel.org Fixes: 07063bbfa98e ("iio: adc: New driver for the AB8500 GPADC") Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20201224011700.1059659-1-linus.walleij@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-02-21iio:adc:stm32-adc: Add HAS_IOMEM dependencyJonathan Cameron1-0/+1
Seems that there are config combinations in which this driver gets enabled and hence selects the MFD, but with out HAS_IOMEM getting pulled in via some other route. MFD is entirely contained in an if HAS_IOMEM block, leading to the build issue in this bugzilla. https://bugzilla.kernel.org/show_bug.cgi?id=209889 Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/20210124195034.22576-1-jic23@kernel.org
2021-02-21iio: adis16400: Fix an error code in adis16400_initial_setup()Dan Carpenter1-2/+1
This is to silence a new Smatch warning: drivers/iio/imu/adis16400.c:492 adis16400_initial_setup() warn: sscanf doesn't return error codes If the condition "if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {" is false then we return 1 instead of returning 0 and probe will fail. Fixes: 72a868b38bdd ("iio: imu: check sscanf return value") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: <Stable@vger.kernel.org> Link: https://lore.kernel.org/r/YCwgFb3JVG6qrlQ+@mwanda Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-02-15thermal: qcom: add support for adc-tm5 PMIC thermal monitorDmitry Baryshkov1-0/+50
Add support for Thermal Monitoring part of PMIC5. This part is closely coupled with ADC, using it's channels directly. ADC-TM support generating interrupts on ADC value crossing low or high voltage bounds, which is used to support thermal trip points. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20210205000118.493610-3-dmitry.baryshkov@linaro.org
2021-02-14iio: adc: adi-axi-adc: add proper Kconfig dependenciesAlexandru Ardelean1-0/+2
The ADI AXI ADC driver requires IO mem access and OF to work. This change adds these dependencies to the Kconfig symbol of the driver. This was also found via the lkp bot, as the devm_platform_ioremap_resource() symbol was not found at link-time on the S390 architecture. Fixes: ef04070692a21 ("iio: adc: adi-axi-adc: add support for AXI ADC IP core") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Cc: <Stable@vger.kernel.org> Link: https://lore.kernel.org/r/20210210105044.48914-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-02-12iio: adc: ad7949: fix wrong ADC result due to incorrect bit maskWilfried Wessner1-1/+1
Fixes a wrong bit mask used for the ADC's result, which was caused by an improper usage of the GENMASK() macro. The bits higher than ADC's resolution are undefined and if not masked out correctly, a wrong result can be given. The GENMASK() macro indexing is zero based, so the mask has to go from [resolution - 1 , 0]. Fixes: 7f40e0614317f ("iio:adc:ad7949: Add AD7949 ADC driver family") Signed-off-by: Wilfried Wessner <wilfried.wessner@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Charles-Antoine Couret <charles-antoine.couret@essensium.com> Cc: <Stable@vger.kernel.org> Link: https://lore.kernel.org/r/20210208142705.GA51260@ubuntu Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-30iio: hid-sensor-prox: Fix scale not correct issueYe Xiang1-2/+11
Currently, the proxy sensor scale is zero because it just return the exponent directly. To fix this issue, this patch use hid_sensor_format_scale to process the scale first then return the output. Fixes: 39a3a0138f61 ("iio: hid-sensors: Added Proximity Sensor Driver") Signed-off-by: Ye Xiang <xiang.ye@intel.com> Link: https://lore.kernel.org/r/20210130102530.31064-1-xiang.ye@intel.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-25Merge 5.11-rc5 into staging-nextGreg Kroah-Hartman5-23/+29
We need the IIO/Staging fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-22Merge branch 'ib-iio-thermal-5.11-rc1' into togregJonathan Cameron6-367/+174
Immutable branch to allow for additional patches to thermal that may be applied in this cycle.
2021-01-22iio: adc: stm32-dfsdm: Remove redundant null check before clk_disable_unprepareXu Wang1-2/+1
ecause clk_disable_unprepare() already checked NULL clock parameter, so the additional check is unnecessary, just remove it. Signed-off-by: Xu Wang <vulab@iscas.ac.cn> Link: https://lore.kernel.org/r/20201231085322.24398-1-vulab@iscas.ac.cn Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio:pressure:ms5637: add ms5803 supportAlexandre Belloni1-0/+8
The ms5803 is very similar to the ms5805 but has less resolution options and has the 128bit PROM layout. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Acked-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20210109231148.1168104-7-alexandre.belloni@bootlin.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio:common:ms_sensors:ms_sensors_i2c: add support for alternative PROM layoutAlexandre Belloni1-11/+59
Currently, only the 112bit PROM with 7 words is supported. However the ms58xx family also have devices with a 128bit PROM on 8 words. See AN520: C-CODE EXAMPLE FOR MS56XX, MS57XX (EXCEPT ANALOG SENSOR), AND MS58XX SERIES PRESSURE SENSORS and the various device datasheets. The difference is that the CRC is the 4 LSBs of word7 instead of being the 4 MSBs of word0. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20210109231148.1168104-6-alexandre.belloni@bootlin.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio:common:ms_sensors:ms_sensors_i2c: rework CRC calculation helperAlexandre Belloni2-9/+7
The CRC calculation always happens on 8 words which is why there is an extra element in the prom array of struct ms_tp_dev. However, on ms5637 and similar, only 7 words are readable. Then, set MS_SENSORS_TP_PROM_WORDS_NB to 8 and stop passing a len parameter to ms_sensors_tp_crc_valid as this simply hide the fact that it is hardcoded. Finally, use the newly introduced hw->prom_len to know how many words can be read. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20210109231148.1168104-5-alexandre.belloni@bootlin.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio:pressure:ms5637: limit available sample frequenciesAlexandre Belloni1-4/+15
Avoid exposing all the sampling frequencies for chip that only support a subset. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20210109231148.1168104-4-alexandre.belloni@bootlin.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio:pressure:ms5637: introduce hardware differentiationAlexandre Belloni2-10/+51
Some sensors in the ms58xx family have a different PROM length and a different number of available resolution. introduce struct ms_tp_hw_data to handle those differences. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20210109231148.1168104-3-alexandre.belloni@bootlin.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio: dac: ad5766: add driver support for AD5766Cristian Pop3-0/+654
The AD5766/AD5767 are 16-channel, 16-bit/12-bit, voltage output dense DACs Digital-to-Analog converters. This change adds support for these DACs. Signed-off-by: Cristian Pop <cristian.pop@analog.com> Link: https://lore.kernel.org/r/20210115112105.58652-3-cristian.pop@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio: hid-sensor-rotation: Add timestamp channelYe Xiang1-20/+26
Each sample has a timestamp field with this change. This timestamp may be from the sensor hub when present or local kernel timestamp. And the unit of timestamp is nanosecond. Signed-off-by: Ye Xiang <xiang.ye@intel.com> Link: https://lore.kernel.org/r/20210105093515.19135-7-xiang.ye@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio: hid-sensor-incl-3d: Add timestamp channelYe Xiang1-16/+27
Each sample has a timestamp field with this change. This timestamp may be from the sensor hub when present or local kernel timestamp. And the unit of timestamp is nanosecond. Signed-off-by: Ye Xiang <xiang.ye@intel.com> Link: https://lore.kernel.org/r/20210105093515.19135-6-xiang.ye@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio: hid-sensor-magn-3d: Add timestamp channelYe Xiang1-18/+30
Each sample has a timestamp field with this change. This timestamp may be from the sensor hub when present or local kernel timestamp. And the unit of timestamp is nanosecond. Signed-off-by: Ye Xiang <xiang.ye@intel.com> Link: https://lore.kernel.org/r/20210105093515.19135-5-xiang.ye@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio: hid-sensor-als: Add timestamp channelYe Xiang1-16/+23
Each sample has a timestamp field with this change. This timestamp may be from the sensor hub when present or local kernel timestamp. And the unit of timestamp is nanosecond. Signed-off-by: Ye Xiang <xiang.ye@intel.com> Link: https://lore.kernel.org/r/20210105093515.19135-4-xiang.ye@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio: hid-sensor-gyro-3d: Add timestamp channelYe Xiang1-16/+24
Each sample has a timestamp field with this change. This timestamp may be from the sensor hub when present or local kernel timestamp. And the unit of timestamp is nanosecond. Signed-off-by: Ye Xiang <xiang.ye@intel.com> Link: https://lore.kernel.org/r/20210105093515.19135-3-xiang.ye@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio: hid-sensor-accel-3d: Add timestamp channel for gravity sensorYe Xiang1-2/+4
The accel_3d sensor already has a timestamp channel, this patch just replicate that for gravity sensor. Signed-off-by: Ye Xiang <xiang.ye@intel.com> Link: https://lore.kernel.org/r/20210105093515.19135-2-xiang.ye@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio: magnetometer: bmc150: Add rudimentary regulator supportStephan Gerhold1-1/+25
BMC150 needs VDD and VDDIO regulators that might need to be explicitly enabled. Add some rudimentary support to obtain and enable these regulators during probe() and disable them during remove() or on the error path. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Stephan Gerhold <stephan@gerhold.net> Link: https://lore.kernel.org/r/20210109152327.512538-2-stephan@gerhold.net Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio: Handle enumerated properties with gapsLars-Peter Clausen1-3/+36
Some enums might have gaps or reserved values in the middle of their value range. E.g. consider a 2-bit enum where the values 0, 1 and 3 have a meaning, but 2 is a reserved value and can not be used. Add support for such enums to the IIO enum helper functions. A reserved values is marked by setting its entry in the items array to NULL rather than the normal descriptive string value. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210107112049.10815-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio: hid-sensors: Add hinge sensor driverYe Xiang4-0/+404
The Hinge sensor is a common custom sensor on laptops. It calculates the angle between the lid (screen) and the base (keyboard). In addition, it also exposes screen and the keyboard angles with respect to the ground. Applications can easily get laptop's status in space through this sensor, in order to display appropriate user interface. Signed-off-by: Ye Xiang <xiang.ye@intel.com> Link: https://lore.kernel.org/r/20201215054444.9324-3-xiang.ye@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio: gyro: bmg160: Add rudimentary regulator supportStephan Gerhold1-0/+25
BMG160 needs VDD and VDDIO regulators that might need to be explicitly enabled. Add some rudimentary support to obtain and enable these regulators during probe() and disable them using a devm action. Signed-off-by: Stephan Gerhold <stephan@gerhold.net> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20201211183815.51269-2-stephan@gerhold.net Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-22iio: accel: kxcjk1013: Add rudimentary regulator supportDevajith V S1-0/+32
kxcjk1013 devices have VDD and VDDIO power lines. Need to make sure the regulators are enabled before any communication with kxcjk1013. This patch introduces vdd/vddio regulators for kxcjk1013. Signed-off-by: Devajith V S <devajithvs@gmail.com> Link: https://lore.kernel.org/r/20201213172437.2779-2-devajithvs@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-16iio: adc: qcom-vadc-common: scale adcmap_100k_104ef_104fbDmitry Baryshkov1-36/+34
Scale adcmap_100k_104ef_104fb temp values by the factor of 1000 to remove extra multiplication in qcom_vadc_scale_therm(). Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20201204025509.1075506-12-dmitry.baryshkov@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-16iio: adc: qcom-vadc-common: simplify qcom_vadc_map_voltage_tempDmitry Baryshkov1-20/+1
All volt-temp tables here are sorted in descending order. There is no need to accout for (unused) ascending table sorting case, so simplify the conversion function. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20201204025509.1075506-11-dmitry.baryshkov@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-16iio: adc: qcom-vadc-common: rewrite vadc7 die temp calculationDmitry Baryshkov1-35/+15
qcom_vadc7_scale_hw_calib_die_temp() uses a table format different from the rest of volt/temp conversion functions in this file. Also the conversion functions results in non-monothonic values conversion, which seems wrong. Rewrite qcom_vadc7_scale_hw_calib_die_temp() to use qcom_vadc_map_voltage_temp() directly, like the rest of conversion functions do. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20201204025509.1075506-10-dmitry.baryshkov@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-16iio: adc: move vadc_map_pt from header to the source fileDmitry Baryshkov1-0/+11
struct vadc_map_pt is not used outside of qcom-vadc-common.c, so move it there from the global header file. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20201204025509.1075506-9-dmitry.baryshkov@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-16iio: provide of_iio_channel_get_by_name() and devm_ version itDmitry Baryshkov1-8/+26
There might be cases when the IIO channel is attached to the device subnode instead of being attached to the main device node. Allow drivers to query IIO channels by using device tree nodes. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20201204025509.1075506-8-dmitry.baryshkov@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-16iio: adc: qcom-spmi-adc5: use of_device_get_match_dataDmitry Baryshkov1-11/+7
Use of_device_get_match_data() instead of hand-coding it manually. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Link: https://lore.kernel.org/r/20201204025509.1075506-7-dmitry.baryshkov@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-16iio: adc: move qcom-vadc-common.h to include dirDmitry Baryshkov5-192/+4
qcom-vadc-common module will be used by ADC thermal monitoring driver, so move it to global include dir. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20201204025509.1075506-6-dmitry.baryshkov@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-16iio: adc: qcom-vadc-common: use fixp_linear_interpolateDmitry Baryshkov1-4/+4
Use new function fixp_linear_interpolate() instead of hand-coding the linear interpolation. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20201204025509.1075506-5-dmitry.baryshkov@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-16iio: adc: qcom-vadc: move several adc5 functions to common fileDmitry Baryshkov3-71/+82
ADC-TM5 driver will make use of several functions from ADC5 driver. Move them to qcom-vadc-common driver. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20201204025509.1075506-4-dmitry.baryshkov@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-16iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channelJonathan Albrieux1-1/+1
Checking at both msm8909-pm8916.dtsi and msm8916.dtsi from downstream it is indicated that "batt_id" channel has to be scaled with the default function: chan@31 { label = "batt_id"; reg = <0x31>; qcom,decimation = <0>; qcom,pre-div-channel-scaling = <0>; qcom,calibration-type = "ratiometric"; qcom,scale-function = <0>; qcom,hw-settle-time = <0xb>; qcom,fast-avg-setup = <0>; }; Change LR_MUX2_BAT_ID scaling accordingly. Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com> Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org> Fixes: 7c271eea7b8a ("iio: adc: spmi-vadc: Changes to support different scaling") Link: https://lore.kernel.org/r/20210113151808.4628-2-jonathan.albrieux@gmail.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-14iio: sx9310: Fix semtech,avg-pos-strength setting when > 16Stephen Boyd1-1/+2
This DT property can be 0, 16, and then 64, but not 32. The math here doesn't recognize this slight bump in the power of 2 numbers and translates a DT property of 64 into the register value '3' when it really should be '2'. Fix it by subtracting one more if the number being translated is larger than 31. Also use clamp() because we're here. Cc: Daniel Campello <campello@chromium.org> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Cc: Douglas Anderson <dianders@chromium.org> Cc: Gwendal Grignou <gwendal@chromium.org> Cc: Evan Green <evgreen@chromium.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20201202200252.986230-1-swboyd@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-14iio: common: st_sensors: fix possible infinite loop in st_sensors_irq_threadLorenzo Bianconi1-14/+17
Return a boolean value in st_sensors_new_samples_available routine in order to avoid an infinite loop in st_sensors_irq_thread if stat_drdy.addr is not defined or stat_drdy read fails Fixes: 90efe05562921 ("iio: st_sensors: harden interrupt handling") Reported-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/c9ec69ed349e7200c779fd7a5bf04c1aaa2817aa.1607438132.git.lorenzo@kernel.org Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-14iio: ad5504: Fix setting power-down stateLars-Peter Clausen1-2/+2
The power-down mask of the ad5504 is actually a power-up mask. Meaning if a bit is set the corresponding channel is powered up and if it is not set the channel is powered down. The driver currently has this the wrong way around, resulting in the channel being powered up when requested to be powered down and vice versa. Fixes: 3bbbf150ffde ("staging:iio:dac:ad5504: Use strtobool for boolean values") Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Link: https://lore.kernel.org/r/20201209104649.5794-1-lars@metafoo.de Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-14drivers: iio: temperature: Add delay after the addressed reset command in mlx90632.cSlaveyko Slaveykov1-0/+6
After an I2C reset command, the mlx90632 needs some time before responding to other I2C commands. Without that delay, there is a chance that the I2C command(s) after the reset will not be accepted. Signed-off-by: Slaveyko Slaveykov <sis@melexis.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Crt Mori <cmo@melexis.com> Fixes: e02472f74a81 ("iio:temperature:mlx90632: Adding extended calibration option") Link: https://lore.kernel.org/r/20201216115720.12404-2-sis@melexis.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-14iio: adc: ti_am335x_adc: remove omitted iio_kfifo_free()Alexandru Ardelean1-5/+1
When the conversion was done to use devm_iio_kfifo_allocate(), a call to iio_kfifo_free() was omitted (to be removed). This change removes it. Fixes: 3c5308058899 ("iio: adc: ti_am335x_adc: alloc kfifo & IRQ via devm_ functions") Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Link: https://lore.kernel.org/r/20201203072650.24128-1-alexandru.ardelean@analog.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-14iio: sx9310: Off by one in sx9310_read_thresh()Dan Carpenter1-1/+1
This > should be >= to prevent reading one element beyond the end of the sx9310_pthresh_codes[] array. Fixes: ad2b473e2ba3 ("iio: sx9310: Support setting proximity thresholds") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/X8XqwK0z//8sSWJR@mwanda Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09iio: adc: ad7476: Add LTC2314-14 supportDragos Bogdan1-0/+6
The LTC2314-14 is a 14-bit, 4.5Msps, serial sampling A/D converter that draws only 6.2mA from a wide range analog supply adjustable from 2.7V to 5.25V. Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com> Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com> Link: https://lore.kernel.org/r/20201216083639.89425-1-mircea.caprioru@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09iio: adc: stm32-adc: Remove redundant null check before clk_prepare_enable/clk_disable_unprepareXu Wang2-27/+16
Because clk_prepare_enable() and clk_disable_unprepare() already checked NULL clock parameter, so the additional checks are unnecessary, just remove them. Signed-off-by: Xu Wang <vulab@iscas.ac.cn> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Link: https://lore.kernel.org/r/20201218093512.871-1-vulab@iscas.ac.cn Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>