Commit graph

4763 commits

Author SHA1 Message Date
Linus Torvalds
5d26c176d5 - 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. Please note those changes rely on an immutable branch:
   iio-thermal-5.11-rc1/ib-iio-thermal-5.11-rc1 from the iio tree
   (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)
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEGn3N4YVz0WNVyHskqDIjiipP6E8FAmAvkKMACgkQqDIjiipP
 6E9yFggAmXy8t2j1mRvn/KLU+teTGIoSFkZ8mBnY2Sgip97IRZRhCwAZbUKOW0eI
 bvpAzBjacxdZHT7OxxvGzCOq/zlAh4UoStI8bMpzdUWPdkAj4ippArLYGvagLym8
 WEQysWnrr8V1RCZbQuBNjyLwjf0fcXkzIBU1mbZXA8T8Y6Yn646TdtsrVT4Idg1j
 MOg7PAHBcTSY/wOReZKJ5TB1yvo2tNOuGOqUVbrIAHlRkiNTVHirVUq6aZGtTTKp
 7ukcu8EI/o7XKBdQ5d9MZaHdwkcyAIJj4jdjmjkUJpa8VYQFPjayNyN3I+Py9lH2
 jtWVYHQxZbY166IZP2yeXFjPzd6elw==
 =Jmz4
 -----END PGP SIGNATURE-----

Merge tag 'thermal-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux

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-22 09:39:11 -08:00
Dmitry Baryshkov
ca66dca5ed thermal: qcom: add support for adc-tm5 PMIC thermal monitor
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-15 21:28:53 +01:00
Greg Kroah-Hartman
ec52736c35 Merge 5.11-rc5 into staging-next
We need the IIO/Staging fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-25 10:37:59 +01:00
Jonathan Cameron
1994a922eb Merge branch 'ib-iio-thermal-5.11-rc1' into togreg
Immutable branch to allow for additional patches to thermal that may
be applied in this cycle.
2021-01-22 08:52:26 +00:00
Xu Wang
aa15e68409 iio: adc: stm32-dfsdm: Remove redundant null check before clk_disable_unprepare
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-22 08:52:07 +00:00
Alexandre Belloni
649ef114a0 iio:pressure:ms5637: add ms5803 support
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-22 08:52:07 +00:00
Alexandre Belloni
9ea7c79097 iio:common:ms_sensors:ms_sensors_i2c: add support for alternative PROM layout
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-22 08:52:07 +00:00
Alexandre Belloni
7ae7f75080 iio:common:ms_sensors:ms_sensors_i2c: rework CRC calculation helper
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-22 08:52:06 +00:00
Alexandre Belloni
07498719be iio:pressure:ms5637: limit available sample frequencies
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-22 08:52:06 +00:00
Alexandre Belloni
8c125f5f32 iio:pressure:ms5637: introduce hardware differentiation
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-22 08:52:06 +00:00
Cristian Pop
fd9373e41b iio: dac: ad5766: add driver support for AD5766
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-22 08:52:05 +00:00
Ye Xiang
4a3582c84a iio: hid-sensor-rotation: Add timestamp channel
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-22 08:52:05 +00:00
Ye Xiang
04fe70d1b8 iio: hid-sensor-incl-3d: Add timestamp channel
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-22 08:52:04 +00:00
Ye Xiang
a6bea3d5fe iio: hid-sensor-magn-3d: Add timestamp channel
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-22 08:52:04 +00:00
Ye Xiang
314f7cad1a iio: hid-sensor-als: Add timestamp channel
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-22 08:52:04 +00:00
Ye Xiang
4648cbd8fb iio: hid-sensor-gyro-3d: Add timestamp channel
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-22 08:52:04 +00:00
Ye Xiang
4c2617207e iio: hid-sensor-accel-3d: Add timestamp channel for gravity sensor
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-22 08:52:03 +00:00
Stephan Gerhold
cce4f160ea iio: magnetometer: bmc150: Add rudimentary regulator support
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-22 08:52:03 +00:00
Lars-Peter Clausen
d9a0e73c0c iio: Handle enumerated properties with gaps
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-22 08:52:03 +00:00
Ye Xiang
660987e125 iio: hid-sensors: Add hinge sensor driver
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-22 08:52:02 +00:00
Stephan Gerhold
ce69361ab7 iio: gyro: bmg160: Add rudimentary regulator support
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-22 08:52:02 +00:00
Devajith V S
1d2e91a2db iio: accel: kxcjk1013: Add rudimentary regulator support
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-22 08:52:01 +00:00
Dmitry Baryshkov
24a7dc6fdb iio: adc: qcom-vadc-common: scale adcmap_100k_104ef_104fb
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-16 18:36:06 +00:00
Dmitry Baryshkov
48d2e2ff85 iio: adc: qcom-vadc-common: simplify qcom_vadc_map_voltage_temp
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-16 18:34:29 +00:00
Dmitry Baryshkov
3bd0ceb566 iio: adc: qcom-vadc-common: rewrite vadc7 die temp calculation
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-16 18:32:36 +00:00
Dmitry Baryshkov
bb01e26374 iio: adc: move vadc_map_pt from header to the source file
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-16 18:28:18 +00:00
Dmitry Baryshkov
6e39b145ce iio: provide of_iio_channel_get_by_name() and devm_ version it
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-16 18:27:51 +00:00
Dmitry Baryshkov
9695a2a52c iio: adc: qcom-spmi-adc5: use of_device_get_match_data
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-16 18:23:36 +00:00
Dmitry Baryshkov
ec82edb258 iio: adc: move qcom-vadc-common.h to include dir
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-16 18:20:56 +00:00
Dmitry Baryshkov
e2621acd6d iio: adc: qcom-vadc-common: use fixp_linear_interpolate
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-16 18:19:00 +00:00
Dmitry Baryshkov
c7ba98fc40 iio: adc: qcom-vadc: move several adc5 functions to common file
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-16 18:17:26 +00:00
Stephen Boyd
b8653aff1c iio: sx9310: Fix semtech,avg-pos-strength setting when > 16
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-14 21:01:22 +00:00
Lorenzo Bianconi
40c48fb79b iio: common: st_sensors: fix possible infinite loop in st_sensors_irq_thread
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: 90efe05562 ("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-14 20:56:57 +00:00
Lars-Peter Clausen
efd597b283 iio: ad5504: Fix setting power-down state
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: 3bbbf150ff ("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-14 20:56:56 +00:00
Slaveyko Slaveykov
cf5b1385d7 drivers: iio: temperature: Add delay after the addressed reset command in mlx90632.c
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: e02472f74a ("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-14 20:56:55 +00:00
Alexandru Ardelean
7e6d9788aa iio: adc: ti_am335x_adc: remove omitted iio_kfifo_free()
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: 3c53080588 ("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-14 20:56:54 +00:00
Dan Carpenter
a06b63a120 iio: sx9310: Off by one in sx9310_read_thresh()
This > should be >= to prevent reading one element beyond the end of
the sx9310_pthresh_codes[] array.

Fixes: ad2b473e2b ("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-14 20:54:42 +00:00
Dragos Bogdan
28e37a92e3 iio: adc: ad7476: Add LTC2314-14 support
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-09 21:52:47 +00:00
Xu Wang
58a5e29c5b iio: adc: stm32-adc: Remove redundant null check before clk_prepare_enable/clk_disable_unprepare
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>
2021-01-09 21:52:46 +00:00
Xu Wang
07fe995f94 iio: frequency: adf4350: Remove redundant null check before clk_disable_unprepare
Because 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/20201218094647.1386-1-vulab@iscas.ac.cn
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09 21:52:46 +00:00
Linus Walleij
cef49e5ea1 iio: adc: ab8500-gpadc: Support non-hw-conversion
The hardware conversion mode only exists in the AB8500
version of the chip, as it is lacking in the AB8505 it
will not be in the device tree and we should just not
even try to obtain it.

The driver already contains code to avoid using a
non-existing hardware conversion IRQ at conversion time.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20201218222013.383704-1-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09 21:52:46 +00:00
Lars-Peter Clausen
138daca30e iio: sc27xx_adc: Use DIV_ROUND_CLOSEST() instead of open-coding it
Use DIV_ROUND_CLOSEST() instead of open-coding it. This makes it more clear
what is going on for the casual reviewer.

Generated using the following the Coccinelle semantic patch.

// <smpl>
@@
expression x, y;
@@
-((x) + ((y) / 2)) / (y)
+DIV_ROUND_CLOSEST(x, y)
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Chunyan Zhang <zhang.lyra@gmail.com>
Link: https://lore.kernel.org/r/20201222191618.3433-1-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09 21:52:46 +00:00
Linus Walleij
de8860b1ed iio: magnetometer: Add driver for Yamaha YAS530
This adds an IIO magnetometer driver for the Yamaha
YAS530 family of magnetometer/compass chips YAS530,
YAS532 and YAS533.

A quick survey of the source code released by different
vendors reveal that we have these variants in the family
with some deployments listed:

 * YAS529 MS-3C (2005 Samsung Aries)
 * YAS530 MS-3E (2011 Samsung Galaxy S Advance)
 * YAS532 MS-3R (2011 Samsung Galaxy S4)
 * YAS533 MS-3F (Vivo 1633, 1707, V3, Y21L)
 * (YAS534 is a magnetic switch)
 * YAS535 MS-6C
 * YAS536 MS-3W
 * YAS537 MS-3T (2015 Samsung Galaxy S6, Note 5)
 * YAS539 MS-3S (2018 Samsung Galaxy A7 SM-A750FN)

The YAS529 is so significantly different from the
YAS53x variants that it will require its own driver.
The YAS537 and YAS539 have slightly different register
sets but have strong similarities so a common driver
patching this one will probably be reasonable.

The source code for Samsung Galaxy A7's YAS539 is not
that is significantly different from the YAS530 in the
Galaxy S Advance, so I believe we will only need this
one driver with quirks to handle all of them.

The YAS539 is actively announced on Yamaha's devices
site:
https://device.yamaha.com/en/lsi/products/e_compass/

This is a driver written from scratch using buffered
IIO and runtime PM handling regulators and reset.

Thanks to Andy Shevchenko for great help in finding all
the special kernel infrastructure functions and quirks
during review of this driver.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: phone-devel@vger.kernel.org
Cc: Jonathan Bakker <xc-racer2@live.ca>
Link: https://lore.kernel.org/r/20201224120820.1120099-2-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09 21:52:46 +00:00
Lars-Peter Clausen
9f094829ea iio: tsl2583: Use DIV_ROUND_CLOSEST() instead of open-coding it
Use DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent
and makes it more clear what is going on for the casual reviewer.

Generated using the following the Coccinelle semantic patch.

// <smpl>
@r1@
expression x;
constant C1;
constant C2;
@@
 ((x) + C1) / C2

@script:python@
C1 << r1.C1;
C2 << r1.C2;
@@
try:
	if int(C1) * 2 != int(C2):
		cocci.include_match(False)
except:
	cocci.include_match(False)

@@
expression r1.x;
constant r1.C1;
constant r1.C2;
@@
-(((x) + C1) / C2)
+DIV_ROUND_CLOSEST(x, C2)
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20201227171126.28216-3-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09 21:52:45 +00:00
Lars-Peter Clausen
166549bb1e iio: bme680: Use DIV_ROUND_CLOSEST() instead of open-coding it
Use DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent
and makes it more clear what is going on for the casual reviewer.

Generated using the following the Coccinelle semantic patch.

// <smpl>
@r1@
expression x;
constant C1;
constant C2;
@@
 ((x) + C1) / C2

@script:python@
C1 << r1.C1;
C2 << r1.C2;
@@
try:
	if int(C1) * 2 != int(C2):
		cocci.include_match(False)
except:
	cocci.include_match(False)

@@
expression r1.x;
constant r1.C1;
constant r1.C2;
@@
-(((x) + C1) / C2)
+DIV_ROUND_CLOSEST(x, C2)
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20201227171126.28216-2-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09 21:52:45 +00:00
Lars-Peter Clausen
ed0ccf6d22 iio: vl6180: Use DIV_ROUND_CLOSEST() instead of open-coding it
Use DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent
and makes it more clear what is going on for the casual reviewer.

Generated using the following the Coccinelle semantic patch.

// <smpl>
@r1@
expression x;
constant C1;
constant C2;
@@
 ((x) + C1) / C2

@script:python@
C1 << r1.C1;
C2 << r1.C2;
@@
try:
	if int(C1) * 2 != int(C2):
		cocci.include_match(False)
except:
	cocci.include_match(False)

@@
expression r1.x;
constant r1.C1;
constant r1.C2;
@@
-(((x) + C1) / C2)
+DIV_ROUND_CLOSEST(x, C2)
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://lore.kernel.org/r/20201227171126.28216-1-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09 21:52:45 +00:00
Max Leiter
b9968e16ad iio:light:apds9960 add detection for MSHW0184 ACPI device in apds9960 driver
The device is used in the Microsoft Surface Book 3 and Surface Pro 7

Signed-off-by: Max Leiter <maxwell.leiter@gmail.com>
Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>
Link: https://lore.kernel.org/r/20201220015057.107246-1-maxwell.leiter@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09 21:52:45 +00:00
Stephan Gerhold
4df685091d iio: imu: inv_mpu6050: Add support for MPU-6880
MPU-6880 seems to be very similar to MPU-6500 and it works
fine with some minor additions for the mpu6050 driver.

Add the necessary defines for it and make it use the same registers
as MPU-6500 but with a FIFO size of 4096.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20201202104656.5119-2-stephan@gerhold.net
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09 14:25:30 +00:00
Zheng Yongjun
b0621d2151 iio: chemical: pms7003: convert comma to semicolon
Replace a comma between expression statements by a semicolon.

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
Link: https://lore.kernel.org/r/20201211085700.3037-1-zhengyongjun3@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09 14:25:28 +00:00
Hans de Goede
18b4c9cd96 iio: core: Copy iio_info.attrs->is_visible into iio_dev_opaque.chan_attr_group.is_visible
The iio-core extends the attr_group provided by the driver with its
own attributes. To be able to do this it:

1. Has its own (non const) io_dev_opaque.chan_attr_group attr_group struct
2. It allocates a new attrs array with room for both the drivers and its
   own attributes
3. It copies over the driver provided attributes into the newly allocated
   attrs array.

But the drivers attr_group may contain more then just the attrs array, it
may also contain an is_visible callback and at least the adi-axi-adc.c
is currently defining such a callback.

Change the attr_group copying code to also copy over the is_visible
callback, so that drivers can define one and have it workins as is
normal for attr_group-s all over the kernel.

Note that the is_visible callback takes an index into the array as
argument, so that indices of the driver's attributes must not change,
this is not a problem as the driver's own attributes are added first
to the newly allocated attrs array and the attributes handled by the
core are appended after the driver's attributes.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Link: https://lore.kernel.org/r/20201125084606.11404-2-hdegoede@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09 14:25:27 +00:00