Commit graph

687 commits

Author SHA1 Message Date
Lorenzo Bianconi
3f9bce7a22 iio: imu: st_lsm6dsx: fix edge-trigger interrupts
If we are using edge IRQs, new samples can arrive while processing
current interrupt since there are no hw guarantees the irq line
stays "low" long enough to properly detect the new interrupt.
In this case the new sample will be missed.
Polling FIFO status register in st_lsm6dsx_handler_thread routine
allow us to read new samples even if the interrupt arrives while
processing previous data and the timeslot where the line is "low"
is too short to be properly detected.

Fixes: 89ca88a7cd ("iio: imu: st_lsm6dsx: support active-low interrupts")
Fixes: 290a6ce11d ("iio: imu: add support to lsm6dsx driver")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/5e93cda7dc1e665f5685c53ad8e9ea71dbae782d.1605378871.git.lorenzo@kernel.org
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-12-03 19:40:31 +00:00
Jonathan Cameron
7b6b51234d iio:imu:bmi160: Fix alignment and data leak issues
One of a class of bugs pointed out by Lars in a recent review.
iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
to the size of the timestamp (8 bytes).  This is not guaranteed in
this driver which uses an array of smaller elements on the stack.
As Lars also noted this anti pattern can involve a leak of data to
userspace and that indeed can happen here.  We close both issues by
moving to a suitable array in the iio_priv() data with alignment
explicitly requested.  This data is allocated with kzalloc() so no
data can leak apart from previous readings.

In this driver, depending on which channels are enabled, the timestamp
can be in a number of locations.  Hence we cannot use a structure
to specify the data layout without it being misleading.

Fixes: 77c4ad2d6a ("iio: imu: Add initial support for Bosch BMI160")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: Daniel Baluta  <daniel.baluta@gmail.com>
Cc: Daniel Baluta <daniel.baluta@oss.nxp.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-6-jic23@kernel.org
2020-12-03 19:40:28 +00:00
Jonathan Cameron
dc7de42d6b iio:imu:bmi160: Fix too large a buffer.
The comment implies this device has 3 sensor types, but it only
has an accelerometer and a gyroscope (both 3D).  As such the
buffer does not need to be as long as stated.

Note I've separated this from the following patch which fixes
the alignment for passing to iio_push_to_buffers_with_timestamp()
as they are different issues even if they affect the same line
of code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: Daniel Baluta <daniel.baluta@oss.nxp.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200920112742.170751-5-jic23@kernel.org
2020-12-03 19:40:27 +00:00
Jonathan Cameron
eca8523a38 iio:trigger: rename try_reenable() to reenable() plus return void
As we no longer support a try again if we cannot reenable the trigger
rename the function to reflect this.   Also we don't do anything with
the value returned so stop it returning anything.  For the few drivers
that didn't already print an error message in this patch, add such
a print.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Christian Oder <me@myself5.de>
Cc: Eugen Hristev <eugen.hristev@microchip.com>
Cc: Nishant Malpani <nish.malpani25@gmail.com>
Cc: Daniel Baluta <daniel.baluta@oss.nxp.com>
Link: https://lore.kernel.org/r/20200920132548.196452-3-jic23@kernel.org
2020-12-03 19:40:26 +00:00
Lorenzo Bianconi
2c57d26505 iio: imu: st_lsm6dsx: add support to LSM6DSOP
Add support to STM LSM6DSOP (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/lsm6dsop.pdf

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/d3c459ad945ccd1a256f4a217128be214b0c024e.1606642528.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-12-03 19:40:24 +00:00
Lorenzo Bianconi
98c3544a11 iio: imu: st_lsmdsx: compact st_lsm6dsx_sensor_settings table
Shrink st_lsm6dsx_sensor_settings table size moving wai address info in
id array and remove duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/c43286938b2fe03ab3abdb5fc095ea6b950abcb1.1606557946.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-12-03 19:40:24 +00:00
Lorenzo Bianconi
f346b16f94 iio: imu: st_lsm6dsx: add vdd-vddio voltage regulator
Like all other ST sensors, st_lsm6dsx devices have VDD and VDDIO power
lines. Introduce voltage regulators to control them.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/a0427a66360bdec73c3b1fb536a46240f96b2ae7.1605631305.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-11-25 14:36:16 +00:00
Greg Kroah-Hartman
749c1e1481 First set of new device support, features and cleanups for IIO in the 5.11 cycle
Usual mixed bag of new drivers / device support + cleanups etc with the
 addition of a fairly big set of yaml conversions.
 
 Txt to yaml format conversions.
 In some cases dropped separate binding and moved to trivial devices (drop).
 
 Listed by manufacturer
   - dht11 temperature(drop)
   - adi,ad2s90 adi,ad5272 adi,ad5592r adi,ad5758 adi,ad5933 adi,ad7303
     adi,adis16480 adi,adf4350
   - ams,as3935
   - asahi-kasei,ak8974
   - atmel,sama5d2-adc
   - avago,apds9300 avago,apds9960
   - bosch,bma180 bosch,bmc150_magn bosch,bme680 bosch,bmg180
   - brcm,iproc-static-adc
   - capella,cm36651
   - domintech,dmard06(drop)
   - fsl,mag3110 fsl,mma8452 fsl,vf610-dac
   - hoperf,hp03
   - honeywell,hmc5843
   - kionix,kxcjk1013
   - maxim,ds1803(drop) maxim,ds4424 maxim,max30100 maxim,max30102
     maxim,max31856 maxim,max31855k maxim,max44009
     maxim,max5481 maxim,max5821
   - meas,htu21(drop) meas,ms5367(drop) meas,ms5611 meas,tsys01(drop)
   - mediatek,mt2701-auxadc
   - melexis,mlx90614 melexis,mlx90632
   - memsic,mmc35240(drop)
   - microchip,mcp41010 microchip,mcp4131 microchip,mcp4725
   - murata,zap2326
   - nxp,fxas21002c nxp,lpc1850-dac
   - pni,rm3100
   - qcom,pm8018-adc qcom,spmi-iadc
   - renesas,isl29501 renesas,rcar-gyroadc
   - samsung,sensorhub-rinato
   - sensiron,sgp30
   - sentech,sx9500
   - sharp,gp2ap020a00f
   - st,hts221 st,lsm6dsx st,st-sensors(many!) st,uvis25 st,vcl53l0x st,vl6180
   - ti,adc084s021 ti,ads124s08
     ti,dac5571 ti,dac7311 ti,dac7512 ti,dac7612
     ti,hdc1000(drop) ti,palmas-gpadc ti,opt3001 ti,tmp07
   - upisemi,us51882
   - vishay,vcnl4035
   - x-powers,axp209
 
 New device support
 * adi,ad5685
   - Add support for AD5338R dual output 10-bit DAC
   - Add DT-binding doc.
 * mediatek,mt6360
   - New driver for this SoC ADC with bindings and using new channel label
     support in the IIO core.
 * st,lsm6dsx
   - Add support for LSM6DST
 
 Core:
 * Add "label" to device channels, provided via a new core callback. Including
   DT docs for when that is the source, and ABI docs.
 * Add devm_iio_triggered_buffer_setup_ext to take extra attributes.
 * dmaengine, unwrap use of iio_buffer_set_attrs()
 * Drop iio_buffer_set_attrs()
 * Centralize ioctl call handling. Later fix to ensure -EINVAL returned if
   no handler has run.
 * Fix an issue with IIO_VAL_FRACTIONAL and negative values - doesn't affect
   any known existing drivers, but will impact a future one.
 * kernel-doc fix in trigger.h
 * file-ops ordering cleanup
 
 Features
 * semtech,sx9310
   - Add control of hardware gain, proximity thresholds, hysteresis and
     debounce.
   - Increase what information on hardware configuration can be provided
     via DT.
 
 Cleanup and minor features
 * adi,ad5685
   - Add of_match_table
 * adi,ad7292
   - Drop pointless spi_set_drvdata() call
 * adi,ad7298
   - Drop platform data and tidy up external reference config.
 * adi,ad7303
   - Drop platform data handling as unused.
 * adi,ad7768
   - Add new label attribute for channels provided from dt.
 * adi,ad7887
   - devm_ usage in probe simplifying remove and error handling.
 * adi,adis16201
   - Drop pointless spi_set_drvdata() call
 * adi,adis16209
   - Drop pointless spi_set_drvdata() call
 * adi,adis16240
   - White space fixup
 * adi,adxl372
   - use new devm_iio_triggered-buffer_setup_ext()
 * amlogic,meson-saradc
   - Drop pointless semicolon.
 * amstaos,tsl2563
   - Put back i2c_device_id table as needed for greybus probing.
 * atmel,at91_adc
   - Use of_device_get_match_data() instead of open coding it.
   - Constify some driver data
   - Add KCONFIG dep on CONFIG_OF and drop of_match_ptr()
   - Drop platform data as mostly dead code.
   - Tidy up reference voltage logic
 * atmel-sama5d2
   - Drop a pointless semicolon
   - Merge buffer and trigger init into a separate function
   - Use new devm_iio_triggered_buff_setup_ext()
 * avago,apds9960
   - Drop a pointless semicolon
 * bosch,bmc150
   - Drop a pointless semicolon
   - Use new iio_triggered_buffer_setup_ext()
 * bosch,bmp280
   - Drop a pointless semicolon
 * fsl,mma8452
   - Constification
 * (google),cros_ec
   - Use new devm_iio_triggered_buffer_setup_ext()
 * hid-sensors
   - Use new iio_triggered_buffer_setup_ext()
 * ingenic,adc
   - Drop a pointless semicolon
 * invensense,icm426xx
   - Fix MAINTAINERS entry missing :
 * mediatek,mt6577_audxac
   - Add binding doc for mt8516 compatible with mt8173
 * motorola,cpcap-adc
   - Fix an implicit fallthrough marking that clang needs to avoid warning.
 * samsung,exynos-adc
   - Stop relying on users counter form input device in ISR.
 * st,lsm6dsx
   - add vdd and vddio regulator control (including binding update)
 * st,stm32-adc
   - Tidy up code for dma transfers.
   - Adapt clock duty cycle for proper functioning. Note no known problems
     with existing boards.
 * st,vl53l0x-i2c
   - Put back i2c_device_id table as needed for greybus probing.
 * vishay,vcnl4035
   - Put back i2c_device_id table as needed for greybus probing.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl+8H3IRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FogLLA//cE+rUI0ztkE5KD1DY5mu8dy3GotLJe2y
 kVlYao/8H4n3qL9Sm+i47v7pZZfB6UH5jaPa3BqXcGU3HaBaTSza5VhP/hDyfpgD
 Nt46UyE0FxcNEpwqiiyVuVFFx9ifUOayzKwL9ckyPs7n1X6ecZA+sPdmSQLmFzoZ
 IYDR148UxlAr33j7DVF1DLiIdObCIpNc3pn7YDflT/NnXvRY2XgIjqeOiPbldVgm
 8nGgeSQXTyYBKaSyv6seE2qaxyDAhjkz7SVOidWZxPgMjiJJmpRdL3yCn2wVCCCy
 eLh9Ez0zPhywOhsRImICZ9ds0+Wq1Ke2kVqo0N8FJtB+JVZig+R1ElTaUKhES7B2
 zKW1PR3nknP2oo3LWoXL6QR4vm0RcasRYnE2Qmtv6y04Hv3vbdyx6ZW+WCwrlsM8
 fCxHV/m/NN4piTHEFFFkW912GMZM4XqnJ/H4bLd4oA+HP/2vzMuzdBLKZPZRdYYf
 Xd2YTF+iyNYlbN+ZLDd9840cAcKabPsd+ptaJh7lb0MUPPcv5qukhwIBs1/vqrE6
 9/AnJ/Wj/oQZoDbcrgnMVoRn8dxqnQkd883sxiHZAvztEn1CQ9dDyUfKlHHB5BOD
 GhtrEyMn87VWM19yqArW/3ZU7dPBbXHkzlw6FQ67gIYbqaCRwfRi26FCJh0C6Kzi
 auCmjubaALo=
 =kkcj
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.11a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

First set of new device support, features and cleanups for IIO in the 5.11 cycle

Usual mixed bag of new drivers / device support + cleanups etc with the
addition of a fairly big set of yaml conversions.

Txt to yaml format conversions.
In some cases dropped separate binding and moved to trivial devices (drop).

Listed by manufacturer
  - dht11 temperature(drop)
  - adi,ad2s90 adi,ad5272 adi,ad5592r adi,ad5758 adi,ad5933 adi,ad7303
    adi,adis16480 adi,adf4350
  - ams,as3935
  - asahi-kasei,ak8974
  - atmel,sama5d2-adc
  - avago,apds9300 avago,apds9960
  - bosch,bma180 bosch,bmc150_magn bosch,bme680 bosch,bmg180
  - brcm,iproc-static-adc
  - capella,cm36651
  - domintech,dmard06(drop)
  - fsl,mag3110 fsl,mma8452 fsl,vf610-dac
  - hoperf,hp03
  - honeywell,hmc5843
  - kionix,kxcjk1013
  - maxim,ds1803(drop) maxim,ds4424 maxim,max30100 maxim,max30102
    maxim,max31856 maxim,max31855k maxim,max44009
    maxim,max5481 maxim,max5821
  - meas,htu21(drop) meas,ms5367(drop) meas,ms5611 meas,tsys01(drop)
  - mediatek,mt2701-auxadc
  - melexis,mlx90614 melexis,mlx90632
  - memsic,mmc35240(drop)
  - microchip,mcp41010 microchip,mcp4131 microchip,mcp4725
  - murata,zap2326
  - nxp,fxas21002c nxp,lpc1850-dac
  - pni,rm3100
  - qcom,pm8018-adc qcom,spmi-iadc
  - renesas,isl29501 renesas,rcar-gyroadc
  - samsung,sensorhub-rinato
  - sensiron,sgp30
  - sentech,sx9500
  - sharp,gp2ap020a00f
  - st,hts221 st,lsm6dsx st,st-sensors(many!) st,uvis25 st,vcl53l0x st,vl6180
  - ti,adc084s021 ti,ads124s08
    ti,dac5571 ti,dac7311 ti,dac7512 ti,dac7612
    ti,hdc1000(drop) ti,palmas-gpadc ti,opt3001 ti,tmp07
  - upisemi,us51882
  - vishay,vcnl4035
  - x-powers,axp209

New device support
* adi,ad5685
  - Add support for AD5338R dual output 10-bit DAC
  - Add DT-binding doc.
* mediatek,mt6360
  - New driver for this SoC ADC with bindings and using new channel label
    support in the IIO core.
* st,lsm6dsx
  - Add support for LSM6DST

Core:
* Add "label" to device channels, provided via a new core callback. Including
  DT docs for when that is the source, and ABI docs.
* Add devm_iio_triggered_buffer_setup_ext to take extra attributes.
* dmaengine, unwrap use of iio_buffer_set_attrs()
* Drop iio_buffer_set_attrs()
* Centralize ioctl call handling. Later fix to ensure -EINVAL returned if
  no handler has run.
* Fix an issue with IIO_VAL_FRACTIONAL and negative values - doesn't affect
  any known existing drivers, but will impact a future one.
* kernel-doc fix in trigger.h
* file-ops ordering cleanup

Features
* semtech,sx9310
  - Add control of hardware gain, proximity thresholds, hysteresis and
    debounce.
  - Increase what information on hardware configuration can be provided
    via DT.

Cleanup and minor features
* adi,ad5685
  - Add of_match_table
* adi,ad7292
  - Drop pointless spi_set_drvdata() call
* adi,ad7298
  - Drop platform data and tidy up external reference config.
* adi,ad7303
  - Drop platform data handling as unused.
* adi,ad7768
  - Add new label attribute for channels provided from dt.
* adi,ad7887
  - devm_ usage in probe simplifying remove and error handling.
* adi,adis16201
  - Drop pointless spi_set_drvdata() call
* adi,adis16209
  - Drop pointless spi_set_drvdata() call
* adi,adis16240
  - White space fixup
* adi,adxl372
  - use new devm_iio_triggered-buffer_setup_ext()
* amlogic,meson-saradc
  - Drop pointless semicolon.
* amstaos,tsl2563
  - Put back i2c_device_id table as needed for greybus probing.
* atmel,at91_adc
  - Use of_device_get_match_data() instead of open coding it.
  - Constify some driver data
  - Add KCONFIG dep on CONFIG_OF and drop of_match_ptr()
  - Drop platform data as mostly dead code.
  - Tidy up reference voltage logic
* atmel-sama5d2
  - Drop a pointless semicolon
  - Merge buffer and trigger init into a separate function
  - Use new devm_iio_triggered_buff_setup_ext()
* avago,apds9960
  - Drop a pointless semicolon
* bosch,bmc150
  - Drop a pointless semicolon
  - Use new iio_triggered_buffer_setup_ext()
* bosch,bmp280
  - Drop a pointless semicolon
* fsl,mma8452
  - Constification
* (google),cros_ec
  - Use new devm_iio_triggered_buffer_setup_ext()
* hid-sensors
  - Use new iio_triggered_buffer_setup_ext()
* ingenic,adc
  - Drop a pointless semicolon
* invensense,icm426xx
  - Fix MAINTAINERS entry missing :
* mediatek,mt6577_audxac
  - Add binding doc for mt8516 compatible with mt8173
* motorola,cpcap-adc
  - Fix an implicit fallthrough marking that clang needs to avoid warning.
* samsung,exynos-adc
  - Stop relying on users counter form input device in ISR.
* st,lsm6dsx
  - add vdd and vddio regulator control (including binding update)
* st,stm32-adc
  - Tidy up code for dma transfers.
  - Adapt clock duty cycle for proper functioning. Note no known problems
    with existing boards.
* st,vl53l0x-i2c
  - Put back i2c_device_id table as needed for greybus probing.
* vishay,vcnl4035
  - Put back i2c_device_id table as needed for greybus probing.

* tag 'iio-for-5.11a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (126 commits)
  dt-bindings:iio:adc:x-powers,axp209-adc: txt to yaml conversion
  dt-bindings:iio:adc:renesas,rcar-gyroadc: txt to yaml conversion.
  dt-bindings:iio:adc:atmel,sama5d2-adc: txt to yaml conversion
  dt-bindings:iio:magnetometer:pni,rm3100: txt to yaml conversion.
  dt-bindings:iio:magnetometer:honeywell,hmc5843: txt to yaml format conversion
  dt-bindings:iio:magnetometer:bosch,bmc150_magn: txt to yaml conversion.
  dt-bindings:iio:magnetometer:asahi-kasei,ak8974: txt to yaml format conversion
  dt-bindings:iio:magnetometer:fsl,mag3110: txt to yaml conversion
  dt-bindings:iio:light:st,vl6180: txt to yaml format conversion.
  dt-bindings:iio:light:vishay,vcnl4035: txt to yaml conversion
  dt-bindings:iio:light:st,uvis25: txt to yaml conversion for this UV sensor
  dt-bindings:iio:light:upisemi,us51882: txt to yaml conversion.
  dt-bindings:iio:light:ti,opt3001: txt to yaml conversion
  dt-bindings:iio:light:maxim,max44009: txt to yaml conversion.
  dt-bindings:iio:light:sharp,gp2ap020a00f: txt to yaml conversion.
  dt-bindings:iio:light:capella,cm36651: txt to yaml conversion.
  dt-bindings:iio:light:avago,apds9960: txt to yaml conversion
  dt-bindings:iio:light:avago,apds9300: txt to yaml conversion.
  dt-bindings:iio:imu:st,lsm6dsx: txt to yaml conversion
  dt-bindings:iio:imu:adi,adis16480: txt to yaml conversion
  ...
2020-11-24 08:30:08 +01:00
Lorenzo Bianconi
fe0b980ffd iio: imu: st_lsm6dsx: set 10ms as min shub slave timeout
Set 10ms as minimum i2c slave configuration timeout since st_lsm6dsx
relies on accel ODR for i2c master clock and at high sample rates
(e.g. 833Hz or 416Hz) the slave sensor occasionally may need more cycles
than i2c master timeout (2s/833Hz + 1 ~ 3ms) to apply the configuration
resulting in an uncomplete slave configuration and a constant reading
from the i2c slave connected to st_lsm6dsx i2c master.

Fixes: 8f9a5249e3 ("iio: imu: st_lsm6dsx: enable 833Hz sample frequency for tagged sensors")
Fixes: c91c1c844e ("iio: imu: st_lsm6dsx: add i2c embedded controller support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/a69c8236bf16a1569966815ed71710af2722ed7d.1604247274.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-11-01 20:54:15 +00:00
Tom Rix
a3c089b9cf iio: remove unneeded break
A break is not needed if it is preceded by a return

Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/20201019172824.32166-1-trix@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-11-01 15:31:56 +00:00
Lorenzo Bianconi
4393e4c533 iio: imu: st_lsm6dsx: add support to LSM6DST
Add support to STM LSM6DST (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/lsm6dst.pdf

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/835127b76ef5ad05aa2aac58298aee5f3073fb71.1601985763.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-10-10 17:38:36 +01:00
Greg Kroah-Hartman
b290f902b8 Second set of features and cleanups for IIO in 5.10
We have a couple of changes that apply to large sets of drivers, so
 I have grouped those to keep this short.
 
 There are a few late breaking fixes in here that can wait for the
 merge window.
 
 dt yaml conversions
 -------------------
 
 * adi,ad7768-1
 * adi,ad7949
 * aspeed,ast2400
 * cosmic,10001-adc
 * dlg,da9150-gpadc
 * fsl,imx25-gcq
 * fsl,imx7d-adc
 * fsl,vf610
 * holt,hi8435
 * marvell,berlin2-adc
 * motorola,cpcap-adc
 * nuvoton,nau7802
 * nuvoton,npcm750-adc
 * nxp,lpc1850-adc
 * nxp,lpc3220
 * sprd,sc2720-adc
 * st,stmpe-adc
 * ti,adc12138
 * ti,ads1015
 * ti,ads7950
 * ti,twl4030-madc
 
 Features
 --------
 
 * adxrs290
   - Add triggered buffer support and expose data ready signal as a possible
     trigger. Includes updating bindings.
   - Add debugfs hooks for register access.
 * mlx90632
   - Add a clear user interface to override the measured ambient temperature.
 * vl53l0x
   - Add IRQ support including dt bindings.
 
 Cleanups and minor fixes
 ------------------------
 (groups)
 Replace mlock with local lock:
   * adf4350
   * exynos-adc
   * fls-imx25-gcq
   * stm32-dac
 
 devm use to simplify probe error handling and remove functions.
   * adis16201
   * adis16203
   * adis16209
   * adis16240
   * adis16136
   * adis16260
   * adis16400
   * adis16460
   * adis16480
   * adis library - drop unused adis_setup_buffer_and_trigger()
 
 of_match_ptr removal and incorrect ACPI binding removal
   of_match_ptr() rarely makes sense in an IIO driver as space saving
   is trivial and it breaks ACPI PRP0001 based instantiation.
   Mostly this series is about removing examples that get copied into new
   drivers.
   * ad2s1200
   * ad5272
   * ad5446
   * ad5592r
   * ad5593r
   * ad5703
   * ak8974
   * ak8975
   * ams-iaq-core
   * as3935
   * atlas-sensor
   * ds1803
   * hdc100x
   * htu21
   * icp10100
   * lmp91000
   * pulsedlight
   * max30102
   * max5432
   * max5481
   * mcp4018
   * mcp4131
   * mcp4531
   * mcp4725
   * ms5611
   * ms5637
   * si7020
   * sgp30
   * ti-dac082s085
   * ti-dac5571
   * tmp007
   * tsys01
   * vz89x
   * zpa2326
 
 kernel-doc fixes
   * iio-core
   * ad7303
   * ad7947
   * adis16080
   * adis16400
   * iio_dummy_evgen
   * sgp30
 
 Fixes for buffer alignment when passed to iio_push_to_buffers_with_timestamp()
 This is a long running effort.  There are a few more drivers to come.
   * inv_mpu6050
   * itg3200
   * si1145
   * st_lsm6dsx
   * ti-adc0832
   * ti-adc12138
 
 (not driver focused)
 * MAINTAINERS
   - Consolidate Analog Device IIO entries whilst removing Beniamin Bia.
   - Remove Hartmut Knaack as a listed IIO maintainer as he hasn't been
     active for a long time and people are getting intermitted bounces.
 * Add __printf() markings to a few functions that were missing them.
 * drop some rotted documentation from staging.
 * rework buffer sysfs file creation (precursor to multiple buffer support)
 
 (individual drivers)
 * ad5592r
   - Fix use of true for IIO_SHARED_BY_TYPE
   - Tidy up locking and indentation.
 * ad9467
   - Improve error message on chip-id missmatch.
   - Use more appropriate error value if chip-id not recognised.
 * adis-library
   - Simplify burst mode handling.
 * adxrs290
   - Make sure to switch device to standby mode during remove.
 * as73211
   - Increase measurement timeout as seems some devices are slower.
 * bma180
   - Fix use of true fo IIO_SHARED_BY_TYPE
 * exynos_adc
   - Update binding to require second interrut with touch screen.
   - Update binding to not require syscon on S5Pv210
 * hmc5843
   - Fix use of true for IIO_SHARED_BY_TYPE
 * inv_mpu6050
   - Use regmap_noinc_read() for fifo reading.
 * palmas_gpadc
   - Use module_platform_driver() to remove boilerplate.
 * meson-saradc
   - style consistency fixes
 * rockchip_saradc
   - Allow compile testing with !ARM.
 * st_lsm6dsx
   - Changing scaling factor to use IIO_VAL_INT_PLUS_NANO to improve precision.
   - Fix an issue with unchecked return value.
 * stm32-adc
   - Fix a missing return introduced in dev_err_probe() patch earlier in
     cycle.
 * sx9310
   - Prefer async mode for probe as paticularly slow startup.
 * vcnl4000
   - Add missing interrupt property to dt binding.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl9o+P4RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohJyRAAjEa6RhQkoJMn4QRp5gNj+BhWoYeM4yeL
 kjOTI9WIfi5acuJiQK/bscqPjVoa9xkp33Za6gRYLFHtxiY0M1c7IKxK7jdDIxyT
 ak5JkmhbklhpAqAaXtGhngBQ/pmctunefjfJbV6ltlZP4W+7aHhGgVEW74Qiagn0
 +FuT3g23pcaCelm7uf1hynxkPUSvH0HlYPUdCptuYhE1YeFSsaCxSVl8DxIK0a52
 MC/rVl4Psjn01mTtVTcwD/JlcO2LnoGC3kJThYguvY52mDqNZBYCseUKwB9ribAT
 AUj7X9rxbAsdQAoN/RF0umD6hxoTnEePf0B29NfdXM/6sn/nhMzWMpVPEPRPRN3B
 /g+WDBPCdOKs5mdyHgfSKhJko0p4jQ5dhGFbzBVA75Uq0yxxRrdXLI2D4rdBjUmF
 6MXgAqaaAGRMq7qg3t3Kt9scR5J0CoPTY7oQvcetu/ZItFmaLEP4zM6wpYp1YXQg
 4GnUKFmwSAb1/Ah4x4XWKkgtvAgJ0RjfebTifa0u/kqi4ZBjacdP7dd4ttEY/3pH
 Zg7OQuMZCF70tDkksSkdAWXEdTJuCZtzaCTdck3NS7yZv0d/MYq2aqDqmON1GbEU
 18yTcGQYGvCJgUq2IlMOpFmlzCzA32+FS5/d2VIiL9xPtS0/weEmIJqY7ONvkQ+A
 VQq0c2u9Xck=
 =yrII
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.10b-take2' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Second set of features and cleanups for IIO in 5.10

We have a couple of changes that apply to large sets of drivers, so
I have grouped those to keep this short.

There are a few late breaking fixes in here that can wait for the
merge window.

dt yaml conversions
-------------------

* adi,ad7768-1
* adi,ad7949
* aspeed,ast2400
* cosmic,10001-adc
* dlg,da9150-gpadc
* fsl,imx25-gcq
* fsl,imx7d-adc
* fsl,vf610
* holt,hi8435
* marvell,berlin2-adc
* motorola,cpcap-adc
* nuvoton,nau7802
* nuvoton,npcm750-adc
* nxp,lpc1850-adc
* nxp,lpc3220
* sprd,sc2720-adc
* st,stmpe-adc
* ti,adc12138
* ti,ads1015
* ti,ads7950
* ti,twl4030-madc

Features
--------

* adxrs290
  - Add triggered buffer support and expose data ready signal as a possible
    trigger. Includes updating bindings.
  - Add debugfs hooks for register access.
* mlx90632
  - Add a clear user interface to override the measured ambient temperature.
* vl53l0x
  - Add IRQ support including dt bindings.

Cleanups and minor fixes
------------------------
(groups)
Replace mlock with local lock:
  * adf4350
  * exynos-adc
  * fls-imx25-gcq
  * stm32-dac

devm use to simplify probe error handling and remove functions.
  * adis16201
  * adis16203
  * adis16209
  * adis16240
  * adis16136
  * adis16260
  * adis16400
  * adis16460
  * adis16480
  * adis library - drop unused adis_setup_buffer_and_trigger()

of_match_ptr removal and incorrect ACPI binding removal
  of_match_ptr() rarely makes sense in an IIO driver as space saving
  is trivial and it breaks ACPI PRP0001 based instantiation.
  Mostly this series is about removing examples that get copied into new
  drivers.
  * ad2s1200
  * ad5272
  * ad5446
  * ad5592r
  * ad5593r
  * ad5703
  * ak8974
  * ak8975
  * ams-iaq-core
  * as3935
  * atlas-sensor
  * ds1803
  * hdc100x
  * htu21
  * icp10100
  * lmp91000
  * pulsedlight
  * max30102
  * max5432
  * max5481
  * mcp4018
  * mcp4131
  * mcp4531
  * mcp4725
  * ms5611
  * ms5637
  * si7020
  * sgp30
  * ti-dac082s085
  * ti-dac5571
  * tmp007
  * tsys01
  * vz89x
  * zpa2326

kernel-doc fixes
  * iio-core
  * ad7303
  * ad7947
  * adis16080
  * adis16400
  * iio_dummy_evgen
  * sgp30

Fixes for buffer alignment when passed to iio_push_to_buffers_with_timestamp()
This is a long running effort.  There are a few more drivers to come.
  * inv_mpu6050
  * itg3200
  * si1145
  * st_lsm6dsx
  * ti-adc0832
  * ti-adc12138

(not driver focused)
* MAINTAINERS
  - Consolidate Analog Device IIO entries whilst removing Beniamin Bia.
  - Remove Hartmut Knaack as a listed IIO maintainer as he hasn't been
    active for a long time and people are getting intermitted bounces.
* Add __printf() markings to a few functions that were missing them.
* drop some rotted documentation from staging.
* rework buffer sysfs file creation (precursor to multiple buffer support)

(individual drivers)
* ad5592r
  - Fix use of true for IIO_SHARED_BY_TYPE
  - Tidy up locking and indentation.
* ad9467
  - Improve error message on chip-id missmatch.
  - Use more appropriate error value if chip-id not recognised.
* adis-library
  - Simplify burst mode handling.
* adxrs290
  - Make sure to switch device to standby mode during remove.
* as73211
  - Increase measurement timeout as seems some devices are slower.
* bma180
  - Fix use of true fo IIO_SHARED_BY_TYPE
* exynos_adc
  - Update binding to require second interrut with touch screen.
  - Update binding to not require syscon on S5Pv210
* hmc5843
  - Fix use of true for IIO_SHARED_BY_TYPE
* inv_mpu6050
  - Use regmap_noinc_read() for fifo reading.
* palmas_gpadc
  - Use module_platform_driver() to remove boilerplate.
* meson-saradc
  - style consistency fixes
* rockchip_saradc
  - Allow compile testing with !ARM.
* st_lsm6dsx
  - Changing scaling factor to use IIO_VAL_INT_PLUS_NANO to improve precision.
  - Fix an issue with unchecked return value.
* stm32-adc
  - Fix a missing return introduced in dev_err_probe() patch earlier in
    cycle.
* sx9310
  - Prefer async mode for probe as paticularly slow startup.
* vcnl4000
  - Add missing interrupt property to dt binding.

* tag 'iio-for-5.10b-take2' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (126 commits)
  dt-bindings: iio: vishay,vcnl4000: add interrupts property
  iio:imu:inv_mpu6050: Use regmap_noinc_read for fifo reads.
  iio:imu:inv_mpu6050 Fix dma and ts alignment and data leak issues.
  iio:adc:ti-adc12138 Fix alignment issue with timestamp
  iio:adc:ti-adc0832 Fix alignment issue with timestamp
  iio:imu:st_lsm6dsx Fix alignment and data leak issues
  iio:light:si1145: Fix timestamp alignment and prevent data leak.
  iio:gyro:itg3200: Fix timestamp alignment and prevent data leak.
  iio:imu:st_lsm6dsx: check st_lsm6dsx_shub_read_output return
  iio: adc: exynos_adc: Replace indio_dev->mlock with own device lock
  dt-bindings:iio:adc:holt,hi8435 yaml conversion
  dt-bindings:iio:adc:adi,ad7768-1 yaml conversion
  dt-bindings:iio:adc:adi,ad7949 yaml conversion
  dt-bindings:iio:adc:dlg,da9150-gpadc yaml conversion
  dt-bindings:iio:adc:motorola,cpcap-adc yaml conversion
  dt-bindings:iio:adc:nxp,lpc3220-adc yaml conversion
  dt-bindings:iio:adc:nxp,lpc1850-adc yaml conversion
  dt-bindings:iio:adc:fsl,imx25-gcq yaml conversion
  dt-bindings:iio:adc:fsl,imx7d-adc yaml conversion
  dt-bindings:iio:adc:ti,ads1015 yaml conversion
  ...
2020-09-22 09:45:11 +02:00
Jonathan Cameron
da83df6626 iio:imu:inv_mpu6050: Use regmap_noinc_read for fifo reads.
We should not be assuming that we are reading a sequence of
registers as here we are doing a read of a lot of data from
a single register address.

Not marked for stable as by coincidence it being wrong doesn't
make any difference.

Suggested-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20200722155103.979802-19-jic23@kernel.org
2020-09-21 20:01:51 +01:00
Jonathan Cameron
6b0cc5dce0 iio:imu:inv_mpu6050 Fix dma and ts alignment and data leak issues.
This case is a bit different to the rest of the series.  The driver
was doing a regmap_bulk_read into a buffer that wasn't dma safe
as it was on the stack with no guarantee of it being in a cacheline
on it's own.   Fixing that also dealt with the data leak and
alignment issues that Lars-Peter pointed out.

Also removed some unaligned handling as we are now aligned.

Fixes tag is for the dma safe buffer issue. Potentially we would
need to backport timestamp alignment futher but that is a totally
different patch.

Fixes: fd64df16f4 ("iio: imu: inv_mpu6050: Add SPI support for MPU6000")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200722155103.979802-18-jic23@kernel.org
2020-09-21 20:01:51 +01:00
Jonathan Cameron
c14edb4d0b iio:imu:st_lsm6dsx Fix alignment and data leak issues
One of a class of bugs pointed out by Lars in a recent review.
iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
to the size of the timestamp (8 bytes).  This is not guaranteed in
this driver which uses an array of smaller elements on the stack.
As Lars also noted this anti pattern can involve a leak of data to
userspace and that indeed can happen here.  We close both issues by
moving to an array of suitable structures in the iio_priv() data.

This data is allocated with kzalloc so no data can leak apart from
previous readings.

For the tagged path the data is aligned by using __aligned(8) for
the buffer on the stack.

There has been a lot of churn in this driver, so likely backports
may be needed for stable.

Fixes: 290a6ce11d ("iio: imu: add support to lsm6dsx driver")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200722155103.979802-17-jic23@kernel.org
2020-09-21 20:01:51 +01:00
Tom Rix
f71e41e23e iio:imu:st_lsm6dsx: check st_lsm6dsx_shub_read_output return
Potential error return is not checked.  This can lead to use
of undefined data.

Detected by clang static analysis.

st_lsm6dsx_shub.c:540:8: warning: Assigned value is garbage or undefined
        *val = (s16)le16_to_cpu(*((__le16 *)data));
             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixes: c91c1c844e ("iio: imu: st_lsm6dsx: add i2c embedded controller support")
Signed-off-by: Tom Rix <trix@redhat.com
Cc: <Stable@vger.kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20200809175551.6794-1-trix@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-21 20:01:50 +01:00
Mario Tesi
44a76de8ca iio: imu: st_lsm6dsx: Scaling factor type set to IIO_VAL_INT_PLUS_NANO
Scaling factor values for Acc lead to an unacceptable rounding of the
full scale (FS) calculated by some SensorHAL on Android devices. For examples
setting FS to 4g the in_accel_x_scale, in_accel_y_scale and in_accel_z_scale
are 0.001196 on 6 decimal digits and the FS is
0.001196 × ((2^15) − 1) ~= 39.1893 m/s^2.

Android CTS R10 SensorParameterRangeTest test expects a value greater than
39.20 m/s^2 so this test fails (ACCELEROMETER_MAX_RANGE = 4 * 9.80).

Using 9 decimal digits the new scale factor is 0.001196411 and the FS now
is 0.001196411 × ((2^15)−1) ~= 39.2028 m/s^2.

This patch extends to IIO_VAL_INT_PLUS_NANO type the scaling factor to all
IMU devices where SensorParameterRangeTest CTS test fails.

Signed-off-by: Mario Tesi <mario.tesi@st.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/1600361236-2285-1-git-send-email-martepisa@gmail.com
2020-09-21 20:01:45 +01:00
Nuno Sá
0dfaa465fc iio: adis16475: Drop adis_burst usage
Burst mode variables are now part of the `adis_data` struct. The driver
also has now to explicitly define the length of the burst buffer.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20200917155223.218500-4-nuno.sa@analog.com
2020-09-21 20:01:45 +01:00
Nuno Sá
f81d053bb4 iio: adis16400: Drop adis_burst usage
Burst mode variables are now part of the `adis_data` struct. The driver
also has now to explicitly define the length of the burst buffer.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20200917155223.218500-3-nuno.sa@analog.com
2020-09-21 20:01:45 +01:00
Nuno Sá
36e322ec5d iio: adis: Move burst mode into adis_data
Add burst mode variables in the per device specific data structure. As
some drivers support multiple devices with different burst sizes it
makes sense this data to be in `adis_data`. While moving the variables,
there are two main differences:

1. The `en`variable is dropped. If a device supports burst mode, it will
just use it as it will has better performance for almost all real use
cases.
2. Replace `extra_len` by `burst_len`. Users should now explicitly
define the length of the burst buffer as it is typically constant. This
also allows to remove the following line from the library:

```
/* All but the timestamp channel */
burst_length = (indio_dev->num_channels - 1) * sizeof(u16);
```

The library should not assume that a timestamp channel is defined.
Moreover, most parts also include some diagnostic data, crc, etc.. in
the burst buffer that needed to be included in an `extra_len` variable
which is not that nice. On top of this, some devices already start to
have some 32bit size channels ...

This patch is also a move to completely drop the `struct adis_burst`
from the library.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20200917155223.218500-2-nuno.sa@analog.com
2020-09-21 20:01:45 +01:00
Jonathan Cameron
d563d4d834 iio:imu:adis16400: Sort out missing kernel doc.
I'd like to be enable W=1 for all IIO builds as it catches real issues as well
as more minor documentation issues such as this (also good to fix though!)

drivers/iio/imu/adis16400.c:183: warning: Function parameter or member 'avail_scan_mask' not described in 'adis16400_state'

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200913132115.800131-2-jic23@kernel.org
2020-09-17 19:02:20 +01:00
Nuno Sá
d8f0cd7668 iio: adis: Drop non Managed device functions
Drop `adis_setup_buffer_and_trigger()`. All users were updated to use
the devm version of this function. This avoids having almost the same
code repeated.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20200915120258.161587-11-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-16 19:06:10 +01:00
Nuno Sá
514f641b3b iio: adis16480: Use Managed device functions
Use the adis managed device functions to setup the buffer and the trigger.
The ultimate goal will be to completely drop the non devm version from
the lib.

Since we are here, drop the `.remove` callback by further using devm
functions.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20200915120258.161587-8-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-16 19:06:09 +01:00
Nuno Sá
fa623cddc0 iio: adis16460: Use Managed device functions
Use the adis managed device functions to setup the buffer and the trigger.
The ultimate goal will be to completely drop the non devm version from
the lib.

Since we are here, drop the `.remove` callback by further using devm
functions.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20200915120258.161587-7-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-16 19:06:09 +01:00
Nuno Sá
f13aa06442 iio: adis16400: Use Managed device functions
Use the adis managed device functions to setup the buffer and the trigger.
The ultimate goal will be to completely drop the non devm version from
the lib.

Since we are here, drop the `.remove` callback by further using devm
functions.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20200915120258.161587-6-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-16 19:06:09 +01:00
Greg Kroah-Hartman
1622d35453 Merge 5.9-rc5 into staging-next
We want the staging/iio changes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-14 06:57:52 +02:00
Krzysztof Kozlowski
75e13a76bf iio: imu: inv_mpu6050: Simplify with dev_err_probe()
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20200829064726.26268-13-krzk@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-09-03 19:40:50 +01:00
Gustavo A. R. Silva
df561f6688 treewide: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2020-08-23 17:36:59 -05:00
Lorenzo Bianconi
a1bab9396c iio: imu: st_lsm6dsx: reset hw ts after resume
Reset hw time samples generator after system resume in order to avoid
disalignment between system and device time reference since FIFO
batching and time samples generator are disabled during suspend.

Fixes: 213451076b ("iio: imu: st_lsm6dsx: add hw timestamp support")
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-22 14:55:43 +01:00
Lee Jones
82cf139f26 iio: imu: st_lsm6dsx: st_lsm6dsx: Mark 'st_lsm6dsx_accel_ext_info' as __maybe_unused
It doesn't make sense to move it into '*core*' as it's co-located with
other, similar definitions which are used in multiple locations.

Fixes the following W=1 kernel build warning(s):

 In file included from drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c:17:
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h:497:44: warning: ‘st_lsm6dsx_accel_ext_info’ defined but not used [-Wunused-const-variable=]
 497 | static const struct iio_chan_spec_ext_info st_lsm6dsx_accel_ext_info[] = {
 | ^~~~~~~~~~~~~~~~~~~~~~~~~
 In file included from drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c:17:
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h:497:44: warning: ‘st_lsm6dsx_accel_ext_info’ defined but not used [-Wunused-const-variable=]
 497 | static const struct iio_chan_spec_ext_info st_lsm6dsx_accel_ext_info[] = {
 | ^~~~~~~~~~~~~~~~~~~~~~~~~
 In file included from drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c:16:
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h:497:44: warning: ‘st_lsm6dsx_accel_ext_info’ defined but not used [-Wunused-const-variable=]
 497 | static const struct iio_chan_spec_ext_info st_lsm6dsx_accel_ext_info[] = {
 | ^~~~~~~~~~~~~~~~~~~~~~~~~

Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-20 09:03:35 +01:00
Lee Jones
83625defae iio: imu: st_lsm6dsx: st_lsm6dsx_shub: Demote obvious misuse of kerneldoc to standard comment blocks
No attempt has been made to document any of the demoted functions here.

Fixes the following W=1 kernel build warning(s):

 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:174: warning: Function parameter or member 'hw' not described in 'st_lsm6dsx_shub_read_output'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:174: warning: Function parameter or member 'data' not described in 'st_lsm6dsx_shub_read_output'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:174: warning: Function parameter or member 'len' not described in 'st_lsm6dsx_shub_read_output'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:205: warning: Function parameter or member 'hw' not described in 'st_lsm6dsx_shub_write_reg'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:205: warning: Function parameter or member 'addr' not described in 'st_lsm6dsx_shub_write_reg'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:205: warning: Function parameter or member 'data' not described in 'st_lsm6dsx_shub_write_reg'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:205: warning: Function parameter or member 'len' not described in 'st_lsm6dsx_shub_write_reg'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:285: warning: Function parameter or member 'sensor' not described in 'st_lsm6dsx_shub_read'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:285: warning: Function parameter or member 'addr' not described in 'st_lsm6dsx_shub_read'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:285: warning: Function parameter or member 'data' not described in 'st_lsm6dsx_shub_read'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:285: warning: Function parameter or member 'len' not described in 'st_lsm6dsx_shub_read'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:335: warning: Function parameter or member 'sensor' not described in 'st_lsm6dsx_shub_write'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:335: warning: Function parameter or member 'addr' not described in 'st_lsm6dsx_shub_write'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:335: warning: Function parameter or member 'data' not described in 'st_lsm6dsx_shub_write'
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:335: warning: Function parameter or member 'len' not described in 'st_lsm6dsx_shub_write'

Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-20 09:03:33 +01:00
Lee Jones
3c979784ef iio: imu: inv_mpu6050: inv_mpu_ring: Demote seemingly unintentional kerneldoc header
This is the only use of kerneldoc in the source file and no
descriptions are provided.

Fixes the following W=1 kernel build warning(s):

 drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c:118: warning: Function parameter or member 'irq' not described in 'inv_mpu6050_read_fifo'
 drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c:118: warning: Function parameter or member 'p' not described in 'inv_mpu6050_read_fifo'

Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-20 09:03:30 +01:00
Lee Jones
ecf8d08fa2 iio: imu: inv_mpu6050: inv_mpu_core: Demote obvious misuse of kerneldoc to standard comment blocks
No attempt has been made to document any of the demoted functions here.

Fixes the following W=1 kernel build warning(s):

 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:444: warning: Function parameter or member 'st' not described in 'inv_mpu6050_set_lpf_regs'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:444: warning: Function parameter or member 'val' not described in 'inv_mpu6050_set_lpf_regs'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:480: warning: Function parameter or member 'indio_dev' not described in 'inv_mpu6050_init_config'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:862: warning: Function parameter or member 'st' not described in 'inv_mpu6050_set_lpf'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:862: warning: Function parameter or member 'rate' not described in 'inv_mpu6050_set_lpf'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:893: warning: Function parameter or member 'dev' not described in 'inv_mpu6050_fifo_rate_store'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:893: warning: Function parameter or member 'attr' not described in 'inv_mpu6050_fifo_rate_store'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:893: warning: Function parameter or member 'buf' not described in 'inv_mpu6050_fifo_rate_store'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:893: warning: Function parameter or member 'count' not described in 'inv_mpu6050_fifo_rate_store'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:954: warning: Function parameter or member 'dev' not described in 'inv_fifo_rate_show'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:954: warning: Function parameter or member 'attr' not described in 'inv_fifo_rate_show'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:954: warning: Function parameter or member 'buf' not described in 'inv_fifo_rate_show'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:975: warning: Function parameter or member 'dev' not described in 'inv_attr_show'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:975: warning: Function parameter or member 'attr' not described in 'inv_attr_show'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:975: warning: Function parameter or member 'buf' not described in 'inv_attr_show'
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:1282: warning: Function parameter or member 'st' not described in 'inv_check_and_setup_chip'

Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-20 09:03:30 +01:00
Lee Jones
deb38af452 iio: imu: st_lsm6dsx: st_lsm6dsx: Reorder 'inline' declaration
Fixes the following W=1 kernel build warning(s):

 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h:487:1: warning: ‘inline’ is not at beginning of declaration [-Wold-style-declaration]
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h:497:44: warning: ‘st_lsm6dsx_accel_ext_info’ defined but not used [-Wunused-const-variable=]

Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-20 09:03:26 +01:00
Lee Jones
0d674449f4 iio: imu: kmx61: Fix formatting in kerneldoc function headers
Kerneldoc expects attributes/parameters to be in '@*.: ' format.

Fixes the following W=1 kernel build warning(s):

 drivers/iio/imu/kmx61.c:327: warning: Function parameter or member 'data' not described in 'kmx61_set_mode'
 drivers/iio/imu/kmx61.c:327: warning: Function parameter or member 'mode' not described in 'kmx61_set_mode'
 drivers/iio/imu/kmx61.c:327: warning: Function parameter or member 'device' not described in 'kmx61_set_mode'
 drivers/iio/imu/kmx61.c:327: warning: Function parameter or member 'update' not described in 'kmx61_set_mode'
 drivers/iio/imu/kmx61.c:731: warning: Function parameter or member 'data' not described in 'kmx61_set_power_state'
 drivers/iio/imu/kmx61.c:731: warning: Function parameter or member 'on' not described in 'kmx61_set_power_state'
 drivers/iio/imu/kmx61.c:731: warning: Function parameter or member 'device' not described in 'kmx61_set_power_state'

Cc: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-20 09:03:09 +01:00
Nuno Sá
471622c92d iio: adis16480: Use irq types instead of flags
The value retrieved by `irqd_get_trigger_type()` is not an irq flag.
While the values are the same, the meaning is different.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-07 20:24:07 +01:00
Jean-Baptiste Maneyrol
ec74ae9fd3 iio: imu: inv_icm42600: add accurate timestamping
Add a timestamping mechanism for buffer that provides accurate
event timestamps when using watermark. This mechanism estimates
device internal clock by comparing FIFO interrupts delta time and
device elapsed time computed by parsing FIFO data.

Take interrupt timestamp in hard irq handler and add IIO device
specific timestamp structures in device private allocation.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:24:42 +01:00
Jean-Baptiste Maneyrol
7f85e42a6c iio: imu: inv_icm42600: add buffer support in iio devices
Add all FIFO parsing and reading functions. Add accel and gyro
kfifo buffer and FIFO data parsing. Use device interrupt for
reading data FIFO and launching accel and gyro parsing.

Support hwfifo watermark by multiplexing gyro and accel settings.
Support hwfifo flush.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:23:18 +01:00
Jean-Baptiste Maneyrol
e5efa1049b iio: imu: inv_icm42600: add device interrupt
Add INT1 interrupt support. Support interrupt edge and level,
active high or low. Push-pull or open-drain configurations.

Interrupt will be used to read data from the FIFO.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:21:45 +01:00
Jean-Baptiste Maneyrol
8237945dbc iio: imu: add Kconfig and Makefile for inv_icm42600 driver
Add 3 modules: inv-icm42600, inv-icm42600-i2c, inv-icm42600-spi.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:20:25 +01:00
Jean-Baptiste Maneyrol
bc3eb0207f iio: imu: inv_icm42600: add temperature sensor support
Add temperature channel in gyroscope and accelerometer devices.

Temperature is available in full 16 bits resolution when reading
register and in low 8 bits resolution in the FIFO. Return full
precision raw temperature with corresponding scale and offset.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:20:16 +01:00
Jean-Baptiste Maneyrol
a47c1cdcb9 iio: imu: inv_icm42600: add accelerometer IIO device
Add IIO device for accelerometer sensor with data polling
interface.
Attributes: raw, scale, sampling_frequency, calibbias.

Accelerometer in low noise mode.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:20:13 +01:00
Jean-Baptiste Maneyrol
a095fadb44 iio: imu: inv_icm42600: add gyroscope IIO device
Add IIO device for gyroscope sensor with data polling interface.
Attributes: raw, scale, sampling_frequency, calibbias.

Gyroscope in low noise mode.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:20:11 +01:00
Jean-Baptiste Maneyrol
9f9ff91b77 iio: imu: inv_icm42600: add SPI driver for inv_icm42600 driver
Add SPI driver for InvenSense ICM-426xxx devices.

Configure bus signal slew rates as indicated in the datasheet.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:20:08 +01:00
Jean-Baptiste Maneyrol
7297ef1e26 iio: imu: inv_icm42600: add I2C driver for inv_icm42600 driver
Add I2C driver for InvenSense ICM-426xxx devices.

Configure bus signal slew rates as indicated in the datasheet.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:18:42 +01:00
Jean-Baptiste Maneyrol
31c24c1e93 iio: imu: inv_icm42600: add core of new inv_icm42600 driver
Core component of a new driver for InvenSense ICM-426xx devices.
It includes registers definition, main probe/setup, and device
utility functions.

ICM-426xx devices are latest generation of 6-axis IMU,
gyroscope+accelerometer and temperature sensor. This device
includes a 2K FIFO, supports I2C/I3C/SPI, and provides
intelligent motion features like pedometer, tilt detection,
and tap detection.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:17:24 +01:00
Alexandru Ardelean
8f73a13f74 iio: remove left-over parent assignments
These were found by doing some shell magic:
------------
for file in $(git grep -w devm_iio_device_alloc | cut -d: -f1 | sort | uniq) ; do
	if grep 'parent =' $file | grep -v trig | grep -vq devm_; then
		echo "$file -> $(grep "parent =" $file)"
	fi
done
-----------

The output is bearable [after the semantic patch is applied].
There is a mix of trigger assignments with some iio device parent
assignments that are removed via this patch.

JC: A few more added via inspection of all parent =
statements in drivers/iio. Some of these may just have crossed with this
series, others were less obvious to scripting due to some cross
file / module boundary calls.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:50:04 +01:00
Alexandru Ardelean
d3be83244c iio: remove explicit IIO device parent assignment
This patch applies the semantic patch:
@@
expression I, P, SP;
@@
   I = devm_iio_device_alloc(P, SP);
   ...
-  I->dev.parent = P;

It updates 302 files and does 307 deletions.
This semantic patch also removes some comments like
'/* Establish that the iio_dev is a child of the i2c device */'

But this is is only done in case where the block is left empty.

The patch does not seem to cover all cases. It looks like in some cases a
different variable is used in some cases to assign the parent, but it
points to the same reference.
In other cases, the block covered by ... may be just too big to be covered
by the semantic patch.

However, this looks pretty good as well, as it does cover a big bulk of the
drivers that should remove the parent assignment.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:59 +01:00
Jonathan Albrieux
812a46b7ff iio: imu: bmi160: added mount-matrix support
Add mount-matrix binding support. As chip could have different orientations
a mount matrix support is needed to correctly translate these differences.

Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:46 +01:00
Jonathan Albrieux
5dea3fb066 iio: imu: bmi160: added regulator support
Add vdd-supply and vddio-supply support.

While working on an msm8916 device and having explicit declarations for
regulators, without setting these regulators to regulators-always-on it
happened those lines weren't ready because they could have been controlled
by other components, causing failure in module's probe.

This patch aim is to solve this situation by adding regulators control
during bmi160_chip_init() and bmi160_chip_uninit(), assuring power to
this component.

Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:45 +01:00
Jonathan Albrieux
fb7749661a iio: imu: bmi160: fix typo
Fix a typo in MODULE_AUTHOR() argument.

Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:43 +01:00
Andy Shevchenko
ab4dd0128f iio: imu: inv_mpu6050: Drop double check for ACPI companion device
acpi_dev_get_resources() does perform the NULL pointer check against
ACPI companion device which is given as function parameter. Thus,
there is no need to duplicate this check in the caller.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:32 +01:00
Greg Kroah-Hartman
c2312ff575 Merge 5.7-rc7 into staging-next
We need the staging/iio fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-25 09:11:19 +02:00
Greg Kroah-Hartman
cef077e6aa Second set of new device support, cleanups and features for IIO in the 5.8 cycle
Usual mixed back but with a few subsystem wide or device type
 wide cleanups.
 
 New device support
 
 * adis16475
   - New driver supporting adis16470, adis16475, adis16477, adis16465,
     adis16467, adis16500, adis16505 and adis16507.
     Includes some rework of the adis library to simplify using it
     for this new driver.
 * ak8974
   - Add support for Alps hscdt008a. ID only. Related patches add support
     for scale.
 * atlas-sensor
   - Add support for RTD-SM OEM temperature sensor.
 * cm32181
   - Add support for CM3218 including support for SMBUS alert via
     ACPI resources.
 * ltc2632
   - Add support for ltc2634-12/10/8 DACS including handling per
     device type numbers of channels.
 
 Major Features
 
 * cm32181
   - ACPI bindings including parsing CPM0 and CPM1 custom ACPI tables.
     Includes minor tidy ups and fixes.
 * vcnl4000
   - Add event support
   - Add buffered data capture support
   - Add control of sampling frequency
 
 Cleanups and minor fixes.
 
 * core
   - Trivial rework of iio_device_alloc to use an early return and
     improve readability.
   - Precursors to addition of multiple buffer support. So far
     minor refactoring.
 * subsystem wide
   - Use get_unaligned_be24 slightly improve readability over open
     coding it.
 * adis drivers
   - Use iio_get_debugfs_dentry access function.
 * bh1780, cm32181, cm3232, gp2ap02a00f, opt3001, st_uvis25, vl6180,
   dmard06, kxsd9
   - Drop use of of_match_ptr to allow ACPI based probing via PRP0001.
     Part of clear out of this to avoid cut and paste into new drivers.
 * ad5592r, ad5593r
   - Fix typos
 * ad5933
   - Use managed interfaces to automate error handling and remove.
 * ak8974
   - Fix wrong number of 'real bits' for buffered data.
   - Refactor to pull measurement code out as separate function.
     bmp280
   - Fix lack of clamp on range during data capture.
 * at91-sama5d2_adc
   - Handle unfinished conversions correctly.
   - Allow use of triggers other than it's own.
   - Reorganize buffer setup and tear down as part of long running
     subsystem wide rework.
 * ccs811
   - Add DT binding docs and match table.
   - Support external reset and wakeup pins.
 * hid-sensors
   - Reorganize buffer setup and tear down as part of long running
     subsystem wide rework.
 * ltr501
   - Constify some structs.
 * vcnl4000
   - Fix an endian issue by using explicit byte swapped i2c accessors.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl666PYRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohMRQ//ZvDdYRB883lW11iRZJhnzpFhClNbzEp1
 2wxEqMOaLQmf6MntRX6LWmN15EGmQw1Eu2SBCt3G5XRMWKvtxaLnERKYxds67qtP
 uhTJDnfcDUYa6ACEHYs0FSfdmUL3S/7qmdKsABU+86o4LGzyb/jblWruB+6jOWyJ
 vRtMGUC8QP2RA2hq5UNJ3au1tlIS3IYqkmh1A1IXD8OtNW/EGpwFUMsmtRGd99gI
 lJb9VtlAF2bxqUBJuvludrRs8HMHafKRm9WM7+pJX7w2waSsiMMFojB7jDlJTAW/
 J2Zb5UGSUHMwJNLmhr+t1BjeAtO9AVzQsK80e+GXxjyb7rv1IKSt9eFUfev1jCuR
 lws3+QhwamGrxh7sFG4NFaWkZmmj5SSPTMqI+GCjm1VTL+vb3rh0MBjgn9/RNPux
 lEhscgEmq0w3BJPX08G8tZ4yipZbO4ZMmuQC3Gx2iPqO80xJqD+XpD5jz4MciGBC
 MDfWMamlnGk3n1sb4TIm0vPCtkz471DX5TyVLPLatcPnwWtu1zH380BD9HGVfnBN
 Fommp6YKvlpOCHOgl4vNg9pLKyUAukQbM8V0lPfk3NWQdswABmzDYJqh4HJWADxT
 uLiW8VgDfeq7CVPL+wwfWV3S9edu/REZa2f9y6qV/3eCyK0XId2CVHr8WpqbQIOR
 p6jjJHfzPNU=
 =mYqq
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Second set of new device support, cleanups and features for IIO in the 5.8 cycle

Usual mixed back but with a few subsystem wide or device type
wide cleanups.

New device support

* adis16475
  - New driver supporting adis16470, adis16475, adis16477, adis16465,
    adis16467, adis16500, adis16505 and adis16507.
    Includes some rework of the adis library to simplify using it
    for this new driver.
* ak8974
  - Add support for Alps hscdt008a. ID only. Related patches add support
    for scale.
* atlas-sensor
  - Add support for RTD-SM OEM temperature sensor.
* cm32181
  - Add support for CM3218 including support for SMBUS alert via
    ACPI resources.
* ltc2632
  - Add support for ltc2634-12/10/8 DACS including handling per
    device type numbers of channels.

Major Features

* cm32181
  - ACPI bindings including parsing CPM0 and CPM1 custom ACPI tables.
    Includes minor tidy ups and fixes.
* vcnl4000
  - Add event support
  - Add buffered data capture support
  - Add control of sampling frequency

Cleanups and minor fixes.

* core
  - Trivial rework of iio_device_alloc to use an early return and
    improve readability.
  - Precursors to addition of multiple buffer support. So far
    minor refactoring.
* subsystem wide
  - Use get_unaligned_be24 slightly improve readability over open
    coding it.
* adis drivers
  - Use iio_get_debugfs_dentry access function.
* bh1780, cm32181, cm3232, gp2ap02a00f, opt3001, st_uvis25, vl6180,
  dmard06, kxsd9
  - Drop use of of_match_ptr to allow ACPI based probing via PRP0001.
    Part of clear out of this to avoid cut and paste into new drivers.
* ad5592r, ad5593r
  - Fix typos
* ad5933
  - Use managed interfaces to automate error handling and remove.
* ak8974
  - Fix wrong number of 'real bits' for buffered data.
  - Refactor to pull measurement code out as separate function.
    bmp280
  - Fix lack of clamp on range during data capture.
* at91-sama5d2_adc
  - Handle unfinished conversions correctly.
  - Allow use of triggers other than it's own.
  - Reorganize buffer setup and tear down as part of long running
    subsystem wide rework.
* ccs811
  - Add DT binding docs and match table.
  - Support external reset and wakeup pins.
* hid-sensors
  - Reorganize buffer setup and tear down as part of long running
    subsystem wide rework.
* ltr501
  - Constify some structs.
* vcnl4000
  - Fix an endian issue by using explicit byte swapped i2c accessors.

* tag 'iio-for-5.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (74 commits)
  iio: light: ltr501: Constify structs
  staging: iio: ad5933: attach life-cycle of kfifo buffer to parent device and use managed calls throughout
  iio: bmp280: fix compensation of humidity
  iio: light: cm32181: Fix integartion time typo
  iio: light: cm32181: Add support for parsing CPM0 and CPM1 ACPI tables
  iio: light: cm32181: Make lux_per_bit and lux_per_bit_base_it runtime settings
  iio: light: cm32181: Use units of 1/100000th for calibscale and lux_per_bit
  iio: light: cm32181: Change reg_init to use a bitmap of which registers to init
  iio: light: cm32181: Handle CM3218 ACPI devices with 2 I2C resources
  iio: light: cm32181: Clean up the probe function a bit
  iio: light: cm32181: Add support for the CM3218
  iio: light: cm32181: Add some extra register defines
  iio: light: cm32181: Add support for ACPI enumeration
  iio: light: cm32181: Switch to new style i2c-driver probe function
  iio: hid-sensors: move triggered buffer setup into hid_sensor_setup_trigger
  iio: vcnl4000: Add buffer support for VCNL4010/20.
  iio: vcnl4000: Add sampling frequency support for VCNL4010/20.
  iio: vcnl4000: Add event support for VCNL4010/20.
  iio: vcnl4000: Factorize data reading and writing.
  iio: vcnl4000: Fix i2c swapped word reading.
  ...
2020-05-15 16:03:28 +02:00
Alexandru Ardelean
b7190859ab iio: imu: adis16xxx: use helper to access iio core debugfs dir
The IIO core provides a iio_get_debugfs_dentry() helper.
It seems that the ADIS IMU drivers access that field directly.

This change converts them to use iio_get_debugfs_dentry() instead.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 14:47:56 +01:00
Lorenzo Bianconi
8f9a5249e3 iio: imu: st_lsm6dsx: enable 833Hz sample frequency for tagged sensors
Enable 833Hz ODR for sensors that supports tagged hw FIFO:
- LSM6DSO/LSM6DSOX
- LSM6DSR/LSM6DSRX
- ASM330LHH

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 09:47:21 +01:00
Nuno Sá
fff7352bf7 iio: imu: Add support for adis16475
Support ADIS16475 and similar IMU devices. These devices are
a precision, miniature MEMS inertial measurement unit (IMU) that
includes a triaxial gyroscope and a triaxial accelerometer. Each
inertial sensor combines with signal conditioning that optimizes
dynamic performance.

The driver adds support for the following devices:
* adis16470, adis16475, adis16477, adis16465, adis16467, adis16500,
  adis16505, adis16507.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 09:47:18 +01:00
Greg Kroah-Hartman
e8014d83f6 Merge 5.7-rc3 into staging-next
We need the staging fixes in here too, and this resolves a merge issue
with the vt6656 driver.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-27 12:20:40 +02:00
Dan Carpenter
115c215a7e iio: imu: st_lsm6dsx: unlock on error in st_lsm6dsx_shub_write_raw()
We need to release a lock if st_lsm6dsx_check_odr() fails, we can't
return directly.

Fixes: 76551a3c3d ("iio: imu: st_lsm6dsx: specify slave odr in slv_odr")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 18:33:54 +01:00
Nuno Sá
3e04cb60e8 iio: adis: Support different burst sizes
Add burst_max_len to `adis_burst`. This is useful for devices which
support different burst modes with different sizes. The buffer to be
used in the spi transfer is allocated with this variable making sure
that has space for all burst modes. The spi transfer length should hold
the "real" burst length depending on the current burst mode configured
in the device.

Moreover, `extra_len` in `adis_burst` is made const and it should
contain the smallest extra length necessary for a burst transfer. In
`struct adis` was added a new `burst_extra_len` that should hold the
extra bytes needed depending on the device instance being used.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 16:11:56 +01:00
Nuno Sá
b9c5eec725 iio: adis: Add adis_update_bits() APIs
This patch adds a `regmap_update_bits()` like API to the ADIS library.
It provides locked and unlocked variant.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 16:10:44 +01:00
Nuno Sá
698211065d iio: imu: adis: Add irq flag variable
There are some ADIS devices that can configure the data ready pin
polarity. Hence, we cannot hardcode our IRQ mask as IRQF_TRIGGER_RISING
since we might want to have it as IRQF_TRIGGER_FALLING.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 16:09:30 +01:00
Nuno Sá
fec86c6b83 iio: imu: adis: Add Managed device functions
This patch adds support for a managed device version of
adis_setup_buffer_and_trigger. It works exactly as the original
one but it calls all the devm_iio_* functions to setup an iio
buffer and trigger. Hence we do not need to care about cleaning those
and we do not need to support a remove() callback for every driver using
the adis library.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 16:08:06 +01:00
Jean-Baptiste Maneyrol
0a2bf9200a iio: imu: inv_mpu6050: fix suspend/resume with runtime power
Suspend/resume were not working correctly with pm runtime.
Now suspend check if the chip is already suspended, and
resume put runtime pm in the correct state.

Issues seen prior to this were:

When entering suspend, there was an error in logs because we
were disabling vddio regulator although it was already disabled.
And when resuming, the chip was pull back to full power but the
pm_runtime state was not updated. So it was believing it was
still suspended.

Fixes: 4599cac846 ("iio: imu: inv_mpu6050: use runtime pm with autosuspend")
Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 17:50:02 +01:00
Lorenzo Bianconi
3a63da26db iio: imu: st_lsm6dsx: flush hw FIFO before resetting the device
flush hw FIFO before device reset in order to avoid possible races
on interrupt line 1. If the first interrupt line is asserted during
hw reset the device will work in I3C-only mode (if it is supported)

Fixes: 801a6e0af0 ("iio: imu: st_lsm6dsx: add support to LSM6DSO")
Fixes: 43901008fd ("iio: imu: st_lsm6dsx: add support to LSM6DSR")
Reported-by: Mario Tesi <mario.tesi@st.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Vitor Soares <vitor.soares@synopsys.com>
Tested-by: Vitor Soares <vitor.soares@synopsys.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 17:50:01 +01:00
Jonathan Cameron
d7d3a1327b iio:imu:mpu6050: Tidy up parameters to regmap_bulk functions.
A mixture of:
* Casts to u8 * for the val parameter which is void * and so needs no cast.
* Explicit sizes when we can use sizeof on the destination / source variable.

Not broken in anyway, I'm just trying to tidy up the is in the subsystem to
avoid it getting cut and paste into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-04-19 16:56:39 +01:00
Lorenzo Bianconi
780f1c1761 iio: imu: st_lsm6dsx: drop huge include in sensor-hub driver
st_lsm6dsx is a standalone driver for STM IMU sensors and does not rely
on st_sensor common framework, so it does not include st_sensor common
definitions.
In st_lsm6dsx_shub driver st_sensors.h is used just to introduce the
default wai address for LIS3MDL sensor.
Drop this largely unconnected include file and introduce the default wai
address for LIS3MDL in st_lsm6dsx_ext_dev_settings register map

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:38 +01:00
Christophe JAILLET
97f1755ee2 iio: imu: adis: Add a missing '\n' in a log message
Message logged by 'dev_xxx()' or 'pr_xxx()' should end with a '\n'.

Fixes: 1fd4567026 ("iio: imu: adis: add support product ID check in adis_initial_startup")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:34 +01:00
Jimmy Assarsson
394dedec77 iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL
Add LIS3MDL register map to sensor hub device table.
Tested with LSM6DSM.

Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:26 +01:00
Jimmy Assarsson
a0e35e2416 iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZE
Support for sensor with up to 8 different ODR settings.
Required for supporting LIS3MDL as sensor hub slave device.

Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:25 +01:00
Rohit Sarkar
2ca73823d0 iio: imu: adis16460: use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE
debugfs_create_file_unsafe does not protect the fops handed to it
against file removal. DEFINE_DEBUGFS_ATTRIBUTE makes the fops aware of
the file lifetime and thus protects it against removal.

Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
Tested-by Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:25 +01:00
Rohit Sarkar
ae1d37a9bb iio: imu: adis16400: use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE
debugfs_create_file_unsafe does not protect the fops handed to it
against file removal. DEFINE_DEBUGFS_ATTRIBUTE makes the fops aware of
the file lifetime and thus protects it against removal.

Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
Tested-by Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:25 +01:00
Lorenzo Bianconi
4ab717d9e8 iio: imu: st_lsm6dsx: configure full scale on slave device if supported
Introduce st_lsm6dsx_shub_set_full_scale routine in order to configure
the i2c slave device sensitivity

Tested-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:24 +01:00
Rohit Sarkar
4b7ef6040f iio: imu: inv_mpu6050: add debugfs register r/w interface
The debugfs interface provides direct access to read and write device
registers if debugfs is enabled.

Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:20 +01:00
Wolfram Sang
b5fbf0568c iio: imu: inv_mpu6050: convert to use i2c_new_client_device()
Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:18 +01:00
Nishant Malpani
02566b459f iio: imu: inv_mpu6050_spi: Use vsprintf extension %pe for symbolic error name
Utilize %pe format specifier from vsprintf while printing error logs
with dev_err(). Discards the use of unnecessary explicit casting and
prints symbolic error name which might prove to be convenient during
debugging.

Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:18 +01:00
Nishant Malpani
fb3f7ab773 iio: imu: inv_mpu6050_i2c: Use vsprintf extension %pe for symbolic error name
Utilize %pe format specifier from vsprintf while printing error logs
with dev_err(). Discards the use of unnecessary explicit casting and
prints symbolic error name which might prove to be convenient during
debugging.

Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:17 +01:00
Nishant Malpani
35c9c8d5ec iio: imu: bmi160_spi: Use vsprintf extension %pe for symbolic error name
Utilize %pe format specifier from vsprintf while printing error logs
with dev_err(). Discards the use of unnecessary explicit casting and
prints symbolic error name which might prove to be convenient during
debugging.

Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:17 +01:00
Nishant Malpani
6e924c526a iio: imu: bmi160_i2c: Use vsprintf extension %pe for symbolic error name
Utilize %pe format specifier from vsprintf while printing error logs
with dev_err(). Discards the use of unnecessary explicit casting and
prints symbolic error name which might prove to be convenient during
debugging.

Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:16 +01:00
Lorenzo Bianconi
76551a3c3d iio: imu: st_lsm6dsx: specify slave odr in slv_odr
Introduce slv_odr in ext_info data structure in order to distinguish
between sensor hub trigger (accel sensor) odr and i2c slave odr and
properly compute samples in FIFO pattern

Fixes: e485e2a2cf ("iio: imu: st_lsm6dsx: enable sensor-hub support for lsm6dsm")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-28 16:35:03 +00:00
Lorenzo Bianconi
7762902c89 iio: imu: st_lsm6dsx: fix read misalignment on untagged FIFO
st_lsm6dsx suffers of a read misalignment on untagged FIFO when
all 3 supported sensors (accel, gyro and ext device) are running
at different ODRs (the use-case is reported in the LSM6DSM Application
Note at pag 100).
Fix the issue taking into account decimation factor reading the FIFO
pattern.

Fixes: e485e2a2cf ("iio: imu: st_lsm6dsx: enable sensor-hub support for lsm6dsm")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-28 16:35:02 +00:00
Sergiu Cuciurean
61e618be6a iio: imu: adis_buffer: Use new structure for SPI transfer delays
In a recent change to the SPI subsystem [1], a new `delay` struct was added
to replace the `delay_usecs`. This change replaces the current
`delay_usecs` with `delay` for this driver.

The `spi_transfer_delay_exec()` function [in the SPI framework] makes sure
that both `delay_usecs` & `delay` are used (in this order to preserve
backwards compatibility).

[1] commit bebcfd272d ("spi: introduce `delay` field for
`spi_transfer` + spi_transfer_delay_exec()")

Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:45 +00:00
Jean-Baptiste Maneyrol
74a40e19f9 iio: imu: inv_mpu6050: temperature only work with accel/gyro
Temperature sensor works correctly only when accel and/or gyro
is turned on. Prevent polling value if they are not running.
Anyway it doesn't make sense to use it without sensor engines
on.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:40 +00:00
Jean-Baptiste Maneyrol
4599cac846 iio: imu: inv_mpu6050: use runtime pm with autosuspend
Use runtime power management for handling chip power and
sensor engines on/off. Simplifies things a lot since pm
runtime already has reference counter.
Usage of autosuspend reduces the number of power on/off. This
makes polling interface now usable to get data at low
frequency.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:39 +00:00
Jean-Baptiste Maneyrol
5e95ca3637 iio: imu: inv_mpu6050: dynamic sampling rate change
Sampling rate can be changed while the chip is running. It can
be useful thus do not prevent it.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:39 +00:00
Jean-Baptiste Maneyrol
4c1e014701 iio: imu: inv_mpu6050: factorize fifo enable/disable
Rework fifo enable/disable in a separate function.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:39 +00:00
Jean-Baptiste Maneyrol
ffc9648a52 iio: imu: inv_mpu6050: fix data polling interface
When reading data with the polling interface, we need to wait
at 1 sampling period to have a sample.
For gyroscope and magnetometer, we need to wait for 2 periods
before having a correct sample.

Not suitable for stable or backporting.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:38 +00:00
Jean-Baptiste Maneyrol
92e7407ab1 iio: imu: inv_mpu6050: rewrite power and engine management
Rewrite clock management to use automatic clock switching
present since MPU6500.
Sensors engine management can now turn on or off a batch of
sensors which simplifies usage a lot.
Temperature sensor is now turned on/off depending on usage.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:38 +00:00
Jean-Baptiste Maneyrol
398da99423 iio: imu: inv_mpu6050: reduce sleep time when turning regulators on
Turning vdd regulator on requires a consequent sleep for the
chip to power on correctly.
Turning vddio regulator is much faster.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:38 +00:00
Jean-Baptiste Maneyrol
c1bfe9c818 iio: imu: inv_mpu6050: add all signal path resets at init
Old chips using spi require for a full reset to manually reset
all signal path. This does not harm when using i2c so do it
inconditionally. Exclude i2c only chips.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:37 +00:00
Jean-Baptiste Maneyrol
5621a63a01 iio: imu: inv_mpu6050: early init of chip_config for use at setup
Init chip_config early and use its values for initial setup.
More coherent, prevent possible mistakes.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:37 +00:00
Jean-Baptiste Maneyrol
3c1024aa99 iio: imu: inv_mpu6050: simplify polling magnetometer
Do not change the sampling rate value. Let userspace decide what
is the sampling rate to use.
Read only the requested axis.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:37 +00:00
Jean-Baptiste Maneyrol
a3aaf7770a iio: imu: inv_mpu6050: set power on/off only once during all init
This way there is no need anymore to export the power function to
i2c and spi modules.
Bus setup is done inside init when power is on and the result is
now checked.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:37 +00:00
Jean-Baptiste Maneyrol
14c046ed17 iio: imu: inv_mpu6050: delete useless check
If we are here it means we have fifo enabled for 1 sensor
at least. And interrupt is always required for using trigger.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:36 +00:00
Jean-Baptiste Maneyrol
ddfd781dc4 iio: imu: inv_mpu6050: enable i2c aux mux bypass only once
i2c auxiliary mux is done by analog switches. You do not need to
set them for every i2c transfer.
Just set i2c bypass bit at init and do noting in i2c de/select.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:36 +00:00
Nuno Sá
62504d1b44 iio: adis16460: Make use of __adis_initial_startup
All of the actions done in `adis16460_initial_setup()` are now done in
`__adis_initial_startup()` so, there's no need for code duplication.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:31 +00:00
Nuno Sá
366a543421 iio: adis16480: Make use of __adis_initial_startup
All actions done in `adis16480_initial_setup()` are now done in
`__adis_initial_startup()` so, there's no need for code duplication.
Furthermore, the call to `adis16480_initial_setup()` is done before any
device configuration since the device will be reset if not already (via
rst pin). This is actually fixing a potential bug since `adis_reset()` was
being called after configuring the device which is obviously a problem.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:31 +00:00
Alexandru Ardelean
1fd4567026 iio: imu: adis: add support product ID check in adis_initial_startup
Each driver/chip that wants to validate it's product id, can now
specify a 'prod_id_reg' and an expected 'prod_id' value.
The 'prod_id' value is intentionally left 0 (uninitialized). There aren't
(yet) any product IDs with value 0; this enforces that both 'prod_id_reg'
and 'prod_id' are specified.

At the very least, this routine validates that the SPI connection to the
ADIS chip[s] works well.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:31 +00:00
Nuno Sá
ecb010d441 iio: imu: adis: Refactor adis_initial_startup
All the ADIS devices perform, at the beginning, a self test to make sure
the device is in a sane state. Previously, the logic was that the self-test
was performed in adis_initial_startup() and if that failed a reset was done
and then a self-test was attempted again.

This change unifies the reset mechanism under the adis_initial_startup()
call. A HW reset will be done if  GPIO is configured, or a SW reset
otherwise. This should make sure that the chip is in a sane state for
self-test. Once the reset is done, the self-test operation will be
performed. If anything goes wrong with self-test, the driver should just
bail/error-out (i.e. no second attempt). The chip would likely not be a in
a sane state state if the self-test fails after a reset.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:30 +00:00
Nuno Sá
fdcf6bbb4e iio: imu: adis: Add self_test_reg variable
This patch adds a dedicated self_test_reg variable. This is also a step
to let new drivers make use of `adis_initial_startup()`. Some devices
use MSG_CTRL reg to request a self_test command while others use the
GLOB_CMD register.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:30 +00:00
Alexandru Ardelean
3f17ada8f3 iio: imu: adis: add unlocked __adis_initial_startup()
This change splits the __adis_initial_startup() away from
adis_initial_startup(). The unlocked version can be used in certain calls
during probe, where races won't happen since the ADIS driver may not be
registered yet with IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:29 +00:00
Alexandru Ardelean
99460853a8 iio: imu: adis16400: initialize adis_data statically
This change overrides commit 380b107bbf ("iio: adis: Introduce timeouts
structure"). It removes the memory allocation and moves the 'adis_data'
information to be static on the chip_info struct.

This also adds a timeout structure to ADIS16334, since it was initially
omitted. This was omitted (by accident) when the change was done.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:29 +00:00
Alexandru Ardelean
97928677fe iio: imu: adis16480: initialize adis_data statically
This change overrides commit 380b107bbf ("iio: adis: Introduce timeouts
structure"). It removes the memory allocation and moves the 'adis_data'
information to be static on the chip_info struct.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:29 +00:00
Lorenzo Bianconi
f20dbe11e2 iio: imu: st_lsm6dsx: check return value from st_lsm6dsx_sensor_set_enable
Add missing return value check in st_lsm6dsx_shub_read_oneshot disabling
the slave device connected to the st_lsm6dsx i2c controller.
The issue is reported by coverity with the following error:

Unchecked return value:
If the function returns an error value, the error value may be mistaken
for a normal value.

Addresses-Coverity-ID: 1456767 ("Unchecked return value")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:28 +00:00
Jean-Baptiste Maneyrol
9fc89f7965 iio: imu: inv_mpu6050: update LPF bandwidth settings
As every chip has some little variant in LPF bandwidth values,
use common values that are working for all chips.
Simplify the LPF setting function.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-02-14 15:06:25 +00:00
Jean-Baptiste Maneyrol
8abce87d39 iio: imu: inv_mpu6050: add support of ICM20690
Same generation as ICM20602 but different registers.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-02-14 15:06:25 +00:00
Jean-Baptiste Maneyrol
d31f74e608 iio: imu: inv_mpu6050: add support of IAM20680
Automotive certified IMU, similar to ICM20608.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-02-14 15:06:25 +00:00
Jean-Baptiste Maneyrol
23db8d6959 iio: imu: inv_mpu6050: add support of ICM20609 & ICM20689
They are similar to ICM20608 chip.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-02-14 15:06:25 +00:00
Jean-Baptiste Maneyrol
4235cc30c9 iio: imu: inv_mpu6050: cleanup of/acpi support
Use device_get_match_data for using of and acpi tables.
In spi support add missing mpu6515 and of match table.
Reorganize Kconfig to display chips grouped by generations.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-02-14 15:06:24 +00:00
JieunKim
5de6570b8a iio: imu: st_lsm6dsx: Fix mismatched comments
odr to odr_table
gain to fs_table

'gain' is actually in 'st_lsm6dsx_fs' structure of 'fs_table'

Signed-off-by: JieunKim <jieun.kim4758@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-02-14 12:08:11 +00:00
Greg Kroah-Hartman
c318f074d9 Merge 5.5-rc7 into staging-next
We want the staging fixes in here as well

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-01-22 09:05:34 +01:00
Martin Kepplinger
04e6fedb18 iio: imu: st_lsm6dsx: add mount matrix support
Allow to read the mount-matrix device tree property and provide the
mount_matrix file for userspace to read.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-18 14:23:53 +00:00
Stefan Popa
80cbc848c4 iio: imu: adis16480: Add support for ADIS16490
The ADIS16490 is part of the same family with ADIS16495 and ADIS16497,
the main difference is the temperature, accelerometer and gyroscope
scales.

Datasheet:
Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adis16490.pdf

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-18 13:35:18 +00:00
Michał Mirosław
84961af78c iio: imu/mpu6050: support dual-edge IRQ
Make mpu6050 usable on platforms which provide only any-edge interrupts.
One example of this kind of platform is AT91SAM9G45

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-18 13:31:35 +00:00
Jean-Baptiste Maneyrol
2e4c0a5e25 iio: imu: inv_mpu6050: add fifo temperature data support
Add support of temperature data in fifo for all chips.
Enable unification of scan elements for icm20602.
Add macros for generating scan elements.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-18 11:43:37 +00:00
Alexandru Ardelean
a4e6f40c77 iio: imu: adis: use new delay structure for SPI transfer delays
In a recent change to the SPI subsystem [1], a new `delay` struct was added
to replace the `delay_usecs`. This change replaces the current `delay_usecs`
with `delay` for this driver.

The `spi_transfer_delay_exec()` function [in the SPI framework] makes sure
that both `delay_usecs` & `delay` are used (in this order to preserve
backwards compatibility).

[1] commit bebcfd272d ("spi: introduce `delay` field for
`spi_transfer` + spi_transfer_delay_exec()")

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-13 22:03:36 +00:00
Lorenzo Bianconi
a2dd9bd933 iio: imu: st_lsm6dsx: check return value from st_lsm6dsx_sensor_set_enable
Add missing return value check in st_lsm6dsx_read_oneshot disabling the
sensor. The issue is reported by coverity with the following error:

Unchecked return value:
If the function returns an error value, the error value may be mistaken
for a normal value.

Addresses-Coverity-ID: 1446733 ("Unchecked return value")
Fixes: b5969abfa8 ("iio: imu: st_lsm6dsx: add motion events")
Fixes: 290a6ce11d ("iio: imu: add support to lsm6dsx driver")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-13 21:41:43 +00:00
Stephan Gerhold
fb4fbc8904 iio: imu: st_lsm6dsx: Fix selection of ST_LSM6DS3_ID
At the moment, attempting to probe a device with ST_LSM6DS3_ID
(e.g. using the st,lsm6ds3 compatible) fails with:

    st_lsm6dsx_i2c 1-006b: unsupported whoami [69]

... even though 0x69 is the whoami listed for ST_LSM6DS3_ID.

This happens because st_lsm6dsx_check_whoami() also attempts
to match unspecified (zero-initialized) entries in the "id" array.
ST_LSM6DS3_ID = 0 will therefore match any entry in
st_lsm6dsx_sensor_settings (here: the first), because none of them
actually have all 12 entries listed in the "id" array.

Avoid this by additionally checking if "name" is set,
which is only set for valid entries in the "id" array.

Note: Although the problem was introduced earlier it did not surface until
commit 52f4b1f196 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
because ST_LSM6DS3_ID was the first entry in st_lsm6dsx_sensor_settings.

Fixes: d068e4a0f9 ("iio: imu: st_lsm6dsx: add support to multiple devices with the same settings")
Cc: <stable@vger.kernel.org> # 5.4
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-01-13 12:08:28 +01:00
Nuno Sá
77038bd01c iio: adis: Remove startup_delay
All timeouts are now handled by a dedicated timeout struct. This
variable is no longer needed.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-12 11:34:13 +00:00
Nuno Sá
380b107bbf iio: adis: Introduce timeouts structure
The adis library only allows to define a `startup_delay` which for some
devices is enough. However, other devices define different timeouts with
significantly different timings which could lead to devices to not wait
enough time or to wait a lot more than necessary (which is not
efficient). This patch introduces a new timeout struct that must be
passed into `adis_init()`. There are mainly, for now, three timeouts
used. This is also an introductory patch with the goal of refactoring
`adis_initial_startup()`. New driver's (eg: adis16480, adis16460) are
replicating code for the device initial setup. With some changes (being
this the first one) we can pass this to `adis_initial_startup()`.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-12 11:34:12 +00:00
Greg Kroah-Hartman
821f7ce79f First set of new device support, features and cleanups for IIO in the 5.6 cycle
New device support
 
 * ad7091r5 ADC
   - New driver with follow up patch adding scale and vref support.
   - DT bindings
 * ad7923
   - Support for ad7908, ad7918 and ad7928 added to driver.
 * bma180
   - Support the BMA254 accelerometer. Required fairly substantial rework
     to allow for small differences between this an existing parts.
 * bma400 accelerometer
   - New driver with follow up patch for regulator support.
   - DT bindings.
 * asc dlhl60d
   - New driver support this range of pressure and temperature sensors.
   - DT bindings.
 * ltc2496 ADC
   - New driver to support this ADC.
   - Split the existing LTC2497 driver generic component out and reuse.
   - DT bindings.
 * parallax ping
   - New driver supporting ultrasonic and laser tof distance sensors.
   - Bindings for these sensors.
 
 New features
 
 * core
   - New char type for read_raw returns, used for thermocouple types.
   - Rename read_first_n callback to read.   The reasons behind the original
     naming are lost to the mists of time.
 * ad799x
   - Allow pm_ops to disable device completely allowing regulator power down.
 * bma180
   - Enable basic regulator support.
 * dmaengine buffer
   - Report platform data alignment requirements via new ABI.
 * max31856
   - Add option to set mains filter rejection frequency and document
     new in_temp_filter_notch_center_frequency ABI.
   - Add support for configuring HW averaging (oversampling ratio)
   - Add runtime configuration of thermocouple type and document new ABI.
 * maxim-thermocouple
   - Add read only access to thermocouple type using new ABI, includes
     adding more specific compatibles to reflect which variant of the
     chip is being used.
 * mpu6050
   - Provide option to support the PMU9150 in package magnetometer directly
     rather than via auxiliary bus.
 * stm32_adc
   - Add overrun interrupt checks to detect if this happens.
 * st_lsm6dsx
   - Enable the sensor-hub support for lsm6dsm. Includes various reworks to
     allow this.
 
 Cleanups and minor fixes
 
 * Subsystem wide
   - Tidy up indentation in Kconfig and fix alphabetical order of AD7091R5.
   - Drop linux/gpio.h and linux/of_gpio.h from drivers that don't use them.
 * ad7266
   - Convert to GPIO descriptors.
 * ad7303
   - Avoid a dance with checking if the regulator is supplied by just
     using the optional request interface.
 * ad7887
   - Simplify channel specification assignment to enable adding more devices.
 * ad7923
   - Drop some unused and largely pointless defines of BOB_N==N variety.
   - Tidy up checkpatch warnings.
   - Add missing of_device_id table.
 * adf4350
   - Convert to GPIO descriptors.
 * ak8975
   - Convert to GPIO descriptors.
 * ADIS library and drivers
   - Expand scope of txrx_lock to cover all state and rename as state_lock
   - Add unlocked read / write to allow grouping of consecutive calls under
     single lock / unlock.
   - Add unlocked check_status, reset to allow grouping under single
     lock / unlock.
   - Remove remaining uses of core mlock for local state protection.
     mlock should never be used directly as it protects tightly defined
     core IIO device management state.
 * adis16240
   - Enforce only supported SPI mode on driver load + add DT binding doc.
 * atlas-ph-sensor
   - Rename to atlas-sensor given it now covers things beyond ph sensors.
 * bma180
   - Use local dev variable to tidy up code.
   - Use c99 style explicity .member assignment to make driver more readable.
 * bmp280
   - Drop ACPI support. No evidence this was used and appropriate ID is not
     registered.
   - Allow ACPI to bind device via PRP0001
 * dmaengine buffer
   - Use dma_request_chan instead of dma_request_slave_channel_reason as that
     ABI is going away.
   - Add module info to avoid tainting the kernel.
 * hts221
   - Avoid magic number defines when only used to fill structure elements
     that are self describing.
 * lm3533
   - Drop a stray semicolon.
 * max9611
   - Cleanup enum handling to be more resilient to future changes.
 * mpu6050
   - Delete MPU9150 from supported SPI devices as doesn't provide SPI.
   - Select I2C_MUX again after kbuild issue fixed elsewhere.
 * stm32-timer
   - Drop an unnecessary register update.
 * ssp_sensors
   - Convert to GPIO descriptors.
 * st_sensors
   - drop !CONFIG_ACPI defines as ACPI_PTR() will stop them being used
     anyway.
   - Make default platform data structures __maybe_unsued.
   - Fill in some missing kernel-doc function parameters.
 * st_lsm6dsx
   - white space fixes.
   - Mark some constants that aren't always used as __maybe_unused.
   - Drop of ID table guards as they just pervent use under ACPI.
   - Switch to device properties to allow ACPI usage.
 * st_uvis25
   - Drop acpi.h include as no ACPI APIs used.
 * ti-ads1015
   - Drop legacy platform data as no one seems to be using it.
   - Use the device property API instead of OF specific.
 * ti-ads7950
   - typo fix in error message.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl4R2mwRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Fogfow//Rfsrd2oiAwy4ypm70ZWGnr84C3O/Vpic
 Agwdd2/lHiCA2Gjg+n7ZT6XkKQmKiojuBMT05PuskEm5onJVQuSAKMVppXwU6UDP
 uOUS5MAbo87GLogzXJnAR/eCrx/VkC4UqFRBSi7IUIj+lTpjiOhmoqm78VTMxkgT
 hvp5PVN/mLNxNV3eVrR9uILjZLpbBjKjWil00IS2zj0o78sGtd2QtMIdTbn3iBLp
 m0ngCDww1KDH+idwbOIn8YX8GSK8mTjNV5q4r9+xnjoAk8RPk+H317idyRHCKfCM
 wWFSFB6u/oqtHXRgQVi3ndRrZnPLTycA/R20f3ezzhVYZzf3RpH8Upcx0lqqCmrB
 +ZTbYW1L7KL6zCSR4ZYIEmw2TeQngfCGy0yDoEDXm9V8/B2nGWFc3Iknq+fK415V
 7OgJCWAw6ybF2LZfJHpcuJTb0EPxCKnInHbRsaxCsSAPRyERSdAz8RLn3lpH/k2D
 X32Q9hz/6sXKzIAD1Y0jv8ll28D5S7d2FgaWufy1tpB+CMb0Mp0RQn+Ho8lNMh70
 Zh9SF8RvknAiCT9iHeVIdbJxoYEtMuCaDwScliukVcg12gVViY5VzXMbSV/4jCnZ
 bAVZDpcM3LVLxCGbWqCNxjQ9wle99LsVHRld/KDpOfI6VIYDb8Y900Nf6efkQkAs
 a6z6rhpVdDg=
 =8FmM
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.6a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

First set of new device support, features and cleanups for IIO in the 5.6 cycle

New device support

* ad7091r5 ADC
  - New driver with follow up patch adding scale and vref support.
  - DT bindings
* ad7923
  - Support for ad7908, ad7918 and ad7928 added to driver.
* bma180
  - Support the BMA254 accelerometer. Required fairly substantial rework
    to allow for small differences between this an existing parts.
* bma400 accelerometer
  - New driver with follow up patch for regulator support.
  - DT bindings.
* asc dlhl60d
  - New driver support this range of pressure and temperature sensors.
  - DT bindings.
* ltc2496 ADC
  - New driver to support this ADC.
  - Split the existing LTC2497 driver generic component out and reuse.
  - DT bindings.
* parallax ping
  - New driver supporting ultrasonic and laser tof distance sensors.
  - Bindings for these sensors.

New features

* core
  - New char type for read_raw returns, used for thermocouple types.
  - Rename read_first_n callback to read.   The reasons behind the original
    naming are lost to the mists of time.
* ad799x
  - Allow pm_ops to disable device completely allowing regulator power down.
* bma180
  - Enable basic regulator support.
* dmaengine buffer
  - Report platform data alignment requirements via new ABI.
* max31856
  - Add option to set mains filter rejection frequency and document
    new in_temp_filter_notch_center_frequency ABI.
  - Add support for configuring HW averaging (oversampling ratio)
  - Add runtime configuration of thermocouple type and document new ABI.
* maxim-thermocouple
  - Add read only access to thermocouple type using new ABI, includes
    adding more specific compatibles to reflect which variant of the
    chip is being used.
* mpu6050
  - Provide option to support the PMU9150 in package magnetometer directly
    rather than via auxiliary bus.
* stm32_adc
  - Add overrun interrupt checks to detect if this happens.
* st_lsm6dsx
  - Enable the sensor-hub support for lsm6dsm. Includes various reworks to
    allow this.

Cleanups and minor fixes

* Subsystem wide
  - Tidy up indentation in Kconfig and fix alphabetical order of AD7091R5.
  - Drop linux/gpio.h and linux/of_gpio.h from drivers that don't use them.
* ad7266
  - Convert to GPIO descriptors.
* ad7303
  - Avoid a dance with checking if the regulator is supplied by just
    using the optional request interface.
* ad7887
  - Simplify channel specification assignment to enable adding more devices.
* ad7923
  - Drop some unused and largely pointless defines of BOB_N==N variety.
  - Tidy up checkpatch warnings.
  - Add missing of_device_id table.
* adf4350
  - Convert to GPIO descriptors.
* ak8975
  - Convert to GPIO descriptors.
* ADIS library and drivers
  - Expand scope of txrx_lock to cover all state and rename as state_lock
  - Add unlocked read / write to allow grouping of consecutive calls under
    single lock / unlock.
  - Add unlocked check_status, reset to allow grouping under single
    lock / unlock.
  - Remove remaining uses of core mlock for local state protection.
    mlock should never be used directly as it protects tightly defined
    core IIO device management state.
* adis16240
  - Enforce only supported SPI mode on driver load + add DT binding doc.
* atlas-ph-sensor
  - Rename to atlas-sensor given it now covers things beyond ph sensors.
* bma180
  - Use local dev variable to tidy up code.
  - Use c99 style explicity .member assignment to make driver more readable.
* bmp280
  - Drop ACPI support. No evidence this was used and appropriate ID is not
    registered.
  - Allow ACPI to bind device via PRP0001
* dmaengine buffer
  - Use dma_request_chan instead of dma_request_slave_channel_reason as that
    ABI is going away.
  - Add module info to avoid tainting the kernel.
* hts221
  - Avoid magic number defines when only used to fill structure elements
    that are self describing.
* lm3533
  - Drop a stray semicolon.
* max9611
  - Cleanup enum handling to be more resilient to future changes.
* mpu6050
  - Delete MPU9150 from supported SPI devices as doesn't provide SPI.
  - Select I2C_MUX again after kbuild issue fixed elsewhere.
* stm32-timer
  - Drop an unnecessary register update.
* ssp_sensors
  - Convert to GPIO descriptors.
* st_sensors
  - drop !CONFIG_ACPI defines as ACPI_PTR() will stop them being used
    anyway.
  - Make default platform data structures __maybe_unsued.
  - Fill in some missing kernel-doc function parameters.
* st_lsm6dsx
  - white space fixes.
  - Mark some constants that aren't always used as __maybe_unused.
  - Drop of ID table guards as they just pervent use under ACPI.
  - Switch to device properties to allow ACPI usage.
* st_uvis25
  - Drop acpi.h include as no ACPI APIs used.
* ti-ads1015
  - Drop legacy platform data as no one seems to be using it.
  - Use the device property API instead of OF specific.
* ti-ads7950
  - typo fix in error message.

* tag 'iio-for-5.6a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (99 commits)
  iio: accel: bma180: BMA254 support
  iio: pressure: bmp280: Allow device to be enumerated from ACPI
  iio: pressure: bmp280: Drop ACPI support
  dt-bindings: iio: adc: convert sd modulator to json-schema
  iio: buffer: rename 'read_first_n' callback to 'read'
  iio: buffer-dmaengine: Report buffer length requirements
  bindings: iio: pressure: Add documentation for dlh driver
  dt-bindings: Add asc vendor
  iio: pressure: Add driver for DLH pressure sensors
  iio: buffer-dmaengine: Add module information
  iio: accel: bma180: Use explicit member assignment
  iio: accel: bma180: Basic regulator support
  iio: accel: bma180: Add dev helper variable
  iio: imu: st_lsm6dsx: enable sensor-hub support for lsm6dsm
  iio: imu: st_lsm6dsx: rename st_lsm6dsx_shub_read_reg in st_lsm6dsx_shub_read_output
  iio: imu: st_lsm6dsx: check if shub_output reg is located in primary page
  iio: imu: st_lsm6dsx: check if pull_up is located in primary page
  iio: imu: st_lsm6dsx: check if master_enable is located in primary page
  iio: imu: st_lsm6dsx: export max num of slave devices in st_lsm6dsx_shub_settings
  iio: light: remove unneeded semicolon
  ...
2020-01-10 10:44:00 +01:00
Lorenzo Bianconi
e485e2a2cf iio: imu: st_lsm6dsx: enable sensor-hub support for lsm6dsm
Enabled i2c master controller support for LSM6DSM sensor. Enable
ext_sensor0 for lsm6dsm. This series has been tested using LIS2MDL as
slave device connected to the i2c controller of the LSM6DSM

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:07 +00:00
Lorenzo Bianconi
111b087577 iio: imu: st_lsm6dsx: rename st_lsm6dsx_shub_read_reg in st_lsm6dsx_shub_read_output
Rename st_lsm6dsx_shub_read_reg routine in st_lsm6dsx_shub_read_output
since it is used to read from sensorhub channel0 output register

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:07 +00:00
Lorenzo Bianconi
5b8343e067 iio: imu: st_lsm6dsx: check if shub_output reg is located in primary page
Check if the sensor hub output register is located in the primary or in the
secondary memory page. This is a preliminary patch to support i2c master
controller on lsm6dsm devices

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:07 +00:00
Lorenzo Bianconi
3a43195745 iio: imu: st_lsm6dsx: check if pull_up is located in primary page
Check if the pull up register is located in the primary or in the
secondary memory page. This is a preliminary patch to support i2c master
controller on lsm6dsm devices

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:06 +00:00
Lorenzo Bianconi
007f2ebbac iio: imu: st_lsm6dsx: check if master_enable is located in primary page
Check if the master enable register is located in the primary or in the
secondary memory page. This is a preliminary patch to support i2c master
controller on lsm6dsm devices

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:06 +00:00
Lorenzo Bianconi
ee978bb86d iio: imu: st_lsm6dsx: export max num of slave devices in st_lsm6dsx_shub_settings
Export max number of slave devices supported by the i2c master
controller in st_lsm6dsx_shub_settings data structure.
This is a preliminary patch to support i2c master controller
on lsm6dsm sensors

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:06 +00:00
Andy Shevchenko
03d4c566c5 iio: st_lsm6dsx: Make use of device properties
Device property API allows to gather device resources from different sources,
such as ACPI. Convert the drivers to unleash the power of device property API.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:04 +00:00
Andy Shevchenko
e3da430770 iio: st_lsm6dsx: Drop unneeded OF code
There is no need to have OF guard against ID table.
Drop it for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:04 +00:00
Andy Shevchenko
07bf07e2cc iio: st_lsm6dsx: Mark predefined constants with __maybe_unused
Since we put static variable to a header file it's copied to each module
that includes the header. But not all of them are actually used it.

Mark predefined constants with __maybe_unused to calm a compiler down:

In file included from drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c:17:
.../st_lsm6dsx/st_lsm6dsx.h:399:28: warning: ‘st_lsm6dsx_available_scan_masks’ defined but not used [-Wunused-const-variable=]
  399 | static const unsigned long st_lsm6dsx_available_scan_masks[] = {0x7, 0x0};
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../st_lsm6dsx/st_lsm6dsx.h:392:36: warning: ‘st_lsm6dsx_event’ defined but not used [-Wunused-const-variable=]
  392 | static const struct iio_event_spec st_lsm6dsx_event = {
      |                                    ^~~~~~~~~~~~~~~~
...

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:03 +00:00
Lorenzo Bianconi
757b4bcaa0 iio: imu: st_lsm6dsx: fix checkpatch warning
Fix following checkpatch warning:

CHECK: Alignment should match open parenthesis
+static int st_lsm6dsx_read_event(struct iio_dev *iio_dev,
+                                  const struct iio_chan_spec *chan,

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-15 11:42:15 +00:00
Linus Walleij
52241a082d iio: imu: inv_mpu6050: Select I2C_MUX again
commit f7072198f2 ("iio: imu: Fix inv_mpu6050 dependencies")
undid the explicit selection of I2C_MUX previously
done by the driver, because I2C_MUX implicitly depended
on HAS_IOMEM.

However commit 93d710a65e ("i2c: mux: fix up dependencies")
cleared up the situation properly and drivers that need
to select I2C_MUX can now do so again.

It makes a lot of sense for a driver to select the driver
infrastructure it needs so restore the natural order of
things.

Cc: Richard Weinberger <richard@nod.at>
Cc: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-15 11:42:14 +00:00
Greg Kroah-Hartman
7347f09a19 First set of fixes for IIO in the 5.5 cycle.
Mixture of old things people have just hit, and a few late breaking
 issues with things that went in during the merge window.
 
 Being sent promptly to resolve potential DT breakage causing
 issues for binding test builds.
 
 * ad7606
   - Avoid reading extra data from the device over what was intended.
 * ad7124
   - Enable the internal reference when in use.
 * ad7292
   - Fix up license for newly added binding.  Better to not have this go
     out in a release with more limited header than intended.
   - Fix a constraint on number of channels.
 * ad7949
   - Fix an issue which can result in readouts being from the wrong channel.
 * hdc100x
   - Fix wrong ABI usage (units) for relative humidity channel.
 * intel mrfld
   - Allocate right amount of private data (currently allocating too much).
 * ltc2983
   - Avoid a potential issue with machine endianness and wrong length device
     tree read.
 * max1027
   - Clean up leak of an iio_trigger on probe failure.
 * max9611
   - Ensure we sleep long enough to successfully initialize the sensor.
 * mpu6050
   - Fix wrong ABI usage (units) for temperature channel.
 * st_accel
   - Fix an unused variable warning.
 * st_lsm6dsx
   - Fix decimation factor issue that can lead to missaligned datasets
     (and hence garbage)
   - Fix an issue with how we track enabled fifo channels.
   - Avoid powering off the device if wake up events are enabled.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl3tPj0RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohHAA/5AYRHumbbF8AlbK7frPMqRKq7NqcOJOOB
 90WeSbr0rFyieKymrCHjOfW72BnHdNeIMh4IGf+D5nCtZd+HHs5Cs0G/dsTgVn//
 JjnmGXxil0ZyEKBrvlfKmOjkhfEcvnCR83gYR+P/cY7B9oukOJGn86x9vuzGDf/v
 ciDZcHYmbMyB3zuxqy9Xn0CLAdSok5ND1PPwIyQrKXhv8LihcyXOwCBxs5Yu61Iu
 kGmyZ8cru6PXt0aP7lZODyZQ4wexwWxtRRjEkDD3bYjqe+qltgHjmOgSwRr+fZLL
 JxtgaRoArnfIlkuUd2yy7Wbt/NXxiMXKwv6o5pESlKeqrxxCqTOonJi64ZDrPVO5
 ggnL3/HXGfKd+JLjKn4e1MzTSWFkbvNU9zw3IGEAWSX0kPVIJtx7yo8dx3bYszLZ
 1bADUEvL+gDnFsBJ3MhCzF5xUDDnus/3yz2GykNKMxVFhEhjxV4rvNZPWtxtWyIB
 liCwsczeDft+TaQqR0ke0Ki8zbOeG8jxrogHBIJWZvaBu1KHgDhkySLloT+gFthD
 +BDf4EGGsxuItK6rN4X0Q62SUa9gAGnQ/bfyQ8+1ZGaHc/I3rUzUN59WS/7NP9C9
 x9TwrQPYdJCQoJ6M6qzuyQaD2qMqt5B85hD0nK2e6q28C/T2P83xC/wMDEt5Bo88
 5WHDKxQwxhE=
 =vySY
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-5.5a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

Jonathan writes:

First set of fixes for IIO in the 5.5 cycle.

Mixture of old things people have just hit, and a few late breaking
issues with things that went in during the merge window.

Being sent promptly to resolve potential DT breakage causing
issues for binding test builds.

* ad7606
  - Avoid reading extra data from the device over what was intended.
* ad7124
  - Enable the internal reference when in use.
* ad7292
  - Fix up license for newly added binding.  Better to not have this go
    out in a release with more limited header than intended.
  - Fix a constraint on number of channels.
* ad7949
  - Fix an issue which can result in readouts being from the wrong channel.
* hdc100x
  - Fix wrong ABI usage (units) for relative humidity channel.
* intel mrfld
  - Allocate right amount of private data (currently allocating too much).
* ltc2983
  - Avoid a potential issue with machine endianness and wrong length device
    tree read.
* max1027
  - Clean up leak of an iio_trigger on probe failure.
* max9611
  - Ensure we sleep long enough to successfully initialize the sensor.
* mpu6050
  - Fix wrong ABI usage (units) for temperature channel.
* st_accel
  - Fix an unused variable warning.
* st_lsm6dsx
  - Fix decimation factor issue that can lead to missaligned datasets
    (and hence garbage)
  - Fix an issue with how we track enabled fifo channels.
  - Avoid powering off the device if wake up events are enabled.

* tag 'iio-fixes-for-5.5a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: adc: max9611: Fix too short conversion time delay
  iio: ad7949: fix channels mixups
  iio: imu: st_lsm6dsx: do not power-off accel if events are enabled
  iio: imu: st_lsm6dsx: track hw FIFO buffering with fifo_mask
  iio: imu: st_lsm6dsx: fix decimation factor estimation
  iio: imu: inv_mpu6050: fix temperature reporting using bad unit
  iio: humidity: hdc100x: fix IIO_HUMIDITYRELATIVE channel reporting
  iio: adc: max1027: fix not unregistered iio trigger
  iio: adc: intel_mrfld_adc: Allocating too much data in probe()
  iio: adc: ad7124: Enable internal reference
  dt-bindings: iio: adc: ad7292: fix constraint over channel quantity
  dt-bindings: iio: adc: ad7292: Update SPDX identifier
  iio: temperature: ltc2983: fix u32 read into a unsigned long long
  iio: st_accel: Fix unused variable warning
  iio: adc: ad7606: fix reading unnecessary data from device
2019-12-09 09:27:52 +01:00
Lorenzo Bianconi
bd41c445b7 iio: imu: st_lsm6dsx: do not power-off accel if events are enabled
Do not power-off accel unconditionally if wake-up events are enabled
powering off the hw FIFO. At the same time do not power-off the accel
sensor if it is 'batched' in the hw FIFO disabling sensor events

Fixes: b5969abfa8 ("iio: imu: st_lsm6dsx: add motion events")
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-08 18:10:30 +00:00
Lorenzo Bianconi
c2686eb2ae iio: imu: st_lsm6dsx: track hw FIFO buffering with fifo_mask
Track hw FIFO state introducing fifo_mask since now the accel sensor
can be enabled during suspend/resume in order to trigger the wake-up
enabling the FIFO in st_lsm6dsx_resume even if it was disabled before
the suspend.  Hence we must separately track the fifo state.

Fixes: 4c997dfa69 ("iio: imu: st_lsm6dsx: add wakeup-source option")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-08 18:10:30 +00:00
Lorenzo Bianconi
5685b145c1 iio: imu: st_lsm6dsx: fix decimation factor estimation
Fix decimation factor and sip estimation for LSM6DSM series
(max value for decimation factor is 32).
If gyro and accel sensors are enabled at 12.5Hz and 416Hz
respectively, decimation factor lookup will fail, producing
unaligned data.
Remove unused decimator filed in st_lsm6dsx_sensor structure.

Fixes: f8710f0357 ("iio: imu: st_lsm6dsx: express odr in mHZ")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-08 18:10:30 +00:00
Jean-Baptiste Maneyrol
53eaa9c27f iio: imu: inv_mpu6050: fix temperature reporting using bad unit
Temperature should be reported in milli-degrees, not degrees. Fix
scale and offset values to use the correct unit.

This is a fix for an issue that has been present for a long time.
The fixes tag reflects the point at which the code last changed in a
fashion that would make this fix patch no longer apply.  Backports
will be necessary to fix those elements that predate that patch.

Fixes: 1615fe41a1 ("iio: imu: mpu6050: Fix FIFO layout for ICM20602")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-08 18:10:30 +00:00
Linus Torvalds
0dd09bc02c Staging / IIO patches for 5.5-rc1
Here is the big staging and iio set of patches for the 5.5-rc1 release.
 
 It's the usual huge collection of cleanup patches all over the
 drivers/staging/ area, along with a new staging driver, and a bunch of
 new IIO drivers as well.
 
 Full details are in the shortlog, but all of these have been in
 linux-next for a long time with no reported issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCXd6lVQ8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ylFnwCgyvZ62uUyQTRey0zvNTe3I4fY9L4AnAnrz3ZC
 U6ZA2+Uj3O6qhAr5frRu
 =uv8S
 -----END PGP SIGNATURE-----

Merge tag 'staging-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging / iio updates from Greg KH:
 "Here is the big staging and iio set of patches for the 5.5-rc1
  release.

  It's the usual huge collection of cleanup patches all over the
  drivers/staging/ area, along with a new staging driver, and a bunch of
  new IIO drivers as well.

  Full details are in the shortlog, but all of these have been in
  linux-next for a long time with no reported issues"

* tag 'staging-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (548 commits)
  staging: vchiq: Have vchiq_dump_* functions return an error code
  staging: vchiq: Refactor indentation in vchiq_dump_* functions
  staging: fwserial: Fix Kconfig indentation (seven spaces)
  staging: vchiq_dump: Replace min with min_t
  staging: vchiq: Fix block comment format in vchiq_dump()
  staging: octeon: indent with tabs instead of spaces
  staging: comedi: usbduxfast: usbduxfast_ai_cmdtest rounding error
  staging: most: core: remove sysfs attr remove_link
  staging: vc04: Fix Kconfig indentation
  staging: pi433: Fix Kconfig indentation
  staging: nvec: Fix Kconfig indentation
  staging: most: Fix Kconfig indentation
  staging: fwserial: Fix Kconfig indentation
  staging: fbtft: Fix Kconfig indentation
  fbtft: Drop OF dependency
  fbtft: Make use of device property API
  fbtft: Drop useless #ifdef CONFIG_OF and dead code
  fbtft: Describe function parameters in kernel-doc
  fbtft: Make sure string is NULL terminated
  staging: rtl8723bs: remove set but not used variable 'change', 'pos'
  ...
2019-11-27 10:57:52 -08:00
Alexandru Ardelean
d693845da3 iio: imu: adis16480: use state lock for filter freq set
It's the only operation that does 2 operations (a read & a write), so the
unlocked functions can be used under a single state lock.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:17:35 +00:00
Alexandru Ardelean
ce476cd18a iio: imu: adis16400: rework locks using ADIS library's state lock
This change removes the use of indio_dev's mlock in favor using the state
lock from the ADIS library.

The set_freq() & get_freq() hooks are unlocked, so they require specific
locking. That is because in some cases the get_freq() hook is used in
combination with adis16400_set_filter().

In cases where only one read/write is done, the functions that hold the
state lock are used.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:14:59 +00:00
Alexandru Ardelean
c5485a5d6a iio: imu: adis: group single conversion under a single state lock
The single conversion function does a series of reads + writes. This change
extends the use of the state_lock for the entire set of operations.
Previously, indio_dev's mlock was used. This change also removes the use of
this lock.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:13:35 +00:00
Alexandru Ardelean
cb5a07f1f1 iio: imu: adis: protect initial startup routine with state lock
The initial startup routine is called by some ADIS drivers during probe,
and before registering with IIO. Normally, userspace should not be able to
do any access to the device (as there shouldn't be any available).

This change extends the state lock to the entire initial-startup routine.
Behaviourally nothing should change, but this should make the library
function a bit more robust.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:09:54 +00:00
Alexandru Ardelean
762ab093cb iio: imu: adis: create an unlocked version of adis_reset()
The reset routine may also be important to be protected by the state-lock
and grouped with other operations, so create an unlocked version, so that
this can be done.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:05:17 +00:00
Alexandru Ardelean
6a4d6a7d65 iio: imu: adis: create an unlocked version of adis_check_status()
This one also gets re-used in certain operations, so it makes sense to
have an unlocked version of this to group it with other
reads/writes/operations to have a single lock for the whole state change.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:02:05 +00:00
Alexandru Ardelean
100bfa38c8 iio: imu: adis[16480]: group RW into a single lock in adis_enable_irq()
The adis_enable_irq() does a read & a write. This change keeps a lock for
the duration of both operations vs for each op.

The change is also needed in adis16480, since that has it's own
implementation for adis_enable_irq().

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:00:04 +00:00
Alexandru Ardelean
770d465619 iio: imu: adis: add unlocked read/write function versions
This will allow more flexible control to group reads & writes into a single
lock (particularly the state_lock).

The end-goal is to remove the indio_dev->mlock usage, and the simplest fix
would have been to just add another lock, which would not be a good idea on
the long-run.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 11:57:42 +00:00
Alexandru Ardelean
6a9afcb198 iio: imu: adis: rename txrx_lock -> state_lock
The lock can be extended a bit to protect other elements that are not
particular to just TX/RX. Another idea would have been to just add a new
`state_lock`, but that would mean 2 locks which would be redundant, and
probably cause more potential for dead-locks.

What will be done in the next patches, will be to add some unlocked
versions for read/write_reg functions.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 11:53:10 +00:00
Mark Brown
ca4196aa10
Merge branch 'spi-5.5' into spi-next 2019-11-22 19:56:35 +00:00
Jean-Baptiste Maneyrol
a2587eb032 iio: imu: inv_mpu6050: add support of MPU9150 magnetometer
Add support for driving MPU9150 magnetometer (AK8975) from mpu.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-16 17:19:01 +00:00
Jean-Baptiste Maneyrol
b95ed40627 iio: imu: inv_mpu6050: delete not existing MPU9150 spi support
MPU9150 is i2c only.
Update Kconfig to delete in description chips that are i2c or
spi only.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-16 17:15:57 +00:00
Greg Kroah-Hartman
8bde9f3d2a Third set of IIO new device support cleanups and fixes for the 5.5 cycle.
New device support
 * ad5446
   - Support the ad5600 DAC (id only needed).
 * ad7292 ADC DAC etc
   - New driver plus dt-bindings.
 * veml6030 ambient light sensor
   - New driver plus dt-bindings and sysfs docs.
 
 Features
 * mpu6050
   - Explicit VDD control.
 * stm32-adc
   - Allow limiting of max clock frequency from devicetree to ensure it's
     suitable for external circuitry.
 
 yaml binding conversions
 * ltc1660
 * mcp3911
 
 Fixes
 * adis16480
   - Fix wrong scale factors.
   - Fix debugfs reg access by providing the callback.
 * cros_ec_baro
   - Fixing missing mask entry to make available sample frequencies visible
     in sysfs.
 * st_lsm6dsx
   - Explicitly handle different ODR table sizes.
   - Handle restrictions between slave ODR and accel ODR when
     both are enabled.
   - Allow ODR to be expressed more accurately by using miliHz.
 * tools
   - Fix an issue with parallel builds.
 
 Cleanups and warning fixes
 * adis16136, adis16400, adis16460, adis-lib
   - Change some checks on return values to be for 0 rather than strictly
     negative. Avoids some fiddly issues with the compiler concluding some
     variables are initialized due to a mixture of error checks.
   - Assign values only on success of 'read' operations - avoiding any
     chance the compiler will falsly suggest they might be used uninitialized.
   - Whitespace and simlar cleanups.
 * aspeed adc
   - devm_platfom_ioremap_resource to reduce boilerplate.
 * bcm-iproc-adc
   - Stray semicolon removal.
 * cc10001
   - devm_platfom_ioremap_resource to reduce boilerplate.
 * dln2-adc
   - Reorganise the buffered mode setup and tear down. Part of moving towards
     being able to refactor this area of the IIO core.
 * hdc100x
   - Reorganise the buffered mode setup and tear down.
 * ingenic-adc
   - devm_platfom_ioremap_resource to reduce boilerplate.
 * lpc18xx-adc
   - devm_platfom_ioremap_resource to reduce boilerplate.
 * lpc18xx-dac
   - devm_platfom_ioremap_resource to reduce boilerplate.
 * mt6577
   - devm_platfom_ioremap_resource to reduce boilerplate.
 * npcm
   - devm_platfom_ioremap_resource to reduce boilerplate.
 * rcar-gyroadc
   - devm_platfom_ioremap_resource to reduce boilerplate.
 * spear-adc
   - devm_platfom_ioremap_resource to reduce boilerplate.
 * vf610-adc
   - devm_platfom_ioremap_resource to reduce boilerplate.
 * vf610-dac
   - devm_platfom_ioremap_resource to reduce boilerplate.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl3JsAoRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Foiw0w//Qpe9IxW4kdiMZB0vMr0mz74Aa6niS1Rm
 c/vMEv7x/0cHjNBJWZiI4VQqScadVMMk2nD/KHAMt+9ZgZg+/r9d7PkVsrEIydZw
 XBFf8qwFYoxL6jAgWinuCWuWAE3o9aKVqqGj/aosloUwzZDBXUpmCSnRpBFOhEyp
 hbNNYZJo4Sbrg/xOYqyIaGJFTes0u+n8OuiS53dLN71lGW6BbGyJQtPzb/7rkOV/
 z7zL0nbIfXszRrFQc17eBlblZvWl3QtHY08aiem8gcTkQbzTOTVWgLxyg+aZwBB2
 XkCeeI21gLjVh2rxAcqBTs7OWObyGUjVES0+fAGBqIGEslq9nruMPrVrlTqkUHxJ
 +vMPPA2VqvAqLI6cBz8oG9HsO/TUTQaRV3tHMF5WnoX9mDEzu9A8V4Cd7pg15lc1
 aEvDXq5UU+aocKOofvyZJ8LqBi0ZmxJpohMGHHyDPmdtlL/HuWWsn9FyzsSgdBuc
 EiGH+GKlUnG4mNOibr2L+TOBZwyelL+wGu40Xld3+KTyHyaysvQ2puP6wHTVf1da
 ME0e6sFDPk4k+JTmsT9vYljgEfW3IMuTzI0BePlsfsx3/SbMZqdYLkijIHM1mpyE
 yhaP/00u4aDFOlE1Ct0iwakUJ4Myxw0UeOz6deNKdTHcOExy28c8AIG6dqZhAJ9S
 ohWETBDIDzI=
 =ckQz
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.5c' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Third set of IIO new device support cleanups and fixes for the 5.5 cycle.

New device support
* ad5446
  - Support the ad5600 DAC (id only needed).
* ad7292 ADC DAC etc
  - New driver plus dt-bindings.
* veml6030 ambient light sensor
  - New driver plus dt-bindings and sysfs docs.

Features
* mpu6050
  - Explicit VDD control.
* stm32-adc
  - Allow limiting of max clock frequency from devicetree to ensure it's
    suitable for external circuitry.

yaml binding conversions
* ltc1660
* mcp3911

Fixes
* adis16480
  - Fix wrong scale factors.
  - Fix debugfs reg access by providing the callback.
* cros_ec_baro
  - Fixing missing mask entry to make available sample frequencies visible
    in sysfs.
* st_lsm6dsx
  - Explicitly handle different ODR table sizes.
  - Handle restrictions between slave ODR and accel ODR when
    both are enabled.
  - Allow ODR to be expressed more accurately by using miliHz.
* tools
  - Fix an issue with parallel builds.

Cleanups and warning fixes
* adis16136, adis16400, adis16460, adis-lib
  - Change some checks on return values to be for 0 rather than strictly
    negative. Avoids some fiddly issues with the compiler concluding some
    variables are initialized due to a mixture of error checks.
  - Assign values only on success of 'read' operations - avoiding any
    chance the compiler will falsly suggest they might be used uninitialized.
  - Whitespace and simlar cleanups.
* aspeed adc
  - devm_platfom_ioremap_resource to reduce boilerplate.
* bcm-iproc-adc
  - Stray semicolon removal.
* cc10001
  - devm_platfom_ioremap_resource to reduce boilerplate.
* dln2-adc
  - Reorganise the buffered mode setup and tear down. Part of moving towards
    being able to refactor this area of the IIO core.
* hdc100x
  - Reorganise the buffered mode setup and tear down.
* ingenic-adc
  - devm_platfom_ioremap_resource to reduce boilerplate.
* lpc18xx-adc
  - devm_platfom_ioremap_resource to reduce boilerplate.
* lpc18xx-dac
  - devm_platfom_ioremap_resource to reduce boilerplate.
* mt6577
  - devm_platfom_ioremap_resource to reduce boilerplate.
* npcm
  - devm_platfom_ioremap_resource to reduce boilerplate.
* rcar-gyroadc
  - devm_platfom_ioremap_resource to reduce boilerplate.
* spear-adc
  - devm_platfom_ioremap_resource to reduce boilerplate.
* vf610-adc
  - devm_platfom_ioremap_resource to reduce boilerplate.
* vf610-dac
  - devm_platfom_ioremap_resource to reduce boilerplate.

* tag 'iio-for-5.5c' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (43 commits)
  iio: adis16480: Add debugfs_reg_access entry
  iio: adis16480: Fix scales factors
  tools: iio: Correctly add make dependency for iio_utils
  iio: adc: Add driver support for AD7292
  dt-bindings: iio: adc: Add dt-schema for AD7292
  dt-bindings: iio: adc: Migrate MCP3911 documentation to yaml
  iio: imu: mpu6050: Add support for vdd-supply regulator
  dt-bindings: iio: imu: mpu6050: add vdd-supply
  iio: cros_ec_baro: set info_mask_shared_by_all_available field
  iio: dac: ad5446: Add support for new AD5600 DAC
  dt-bindings: iio: dac: Migrate LTC1660 documentation to yaml
  iio: documentation: light: Add veml6030 sysfs documentation
  dt-bindings: iio: light: add veml6030 ALS bindings
  iio: light: add driver for veml6030 ambient light sensor
  iio: imu: st_lsm6dsx: express odr in mHZ
  iio: imu: st_lsm6dsx: fix ODR check in st_lsm6dsx_write_raw
  iio: imu: st_lsm6dsx: explicitly define odr table size
  iio: adc: stm32: allow to tune analog clock
  dt-bindings: iio: stm32-adc: add max clock rate property
  iio: dac: vf610: Use devm_platform_ioremap_resource
  ...
2019-11-13 19:24:42 +08:00
Nuno Sá
4c35b7a51e iio: adis16480: Add debugfs_reg_access entry
The driver is defining debugfs entries by calling
`adis16480_debugfs_init()`. However, those entries are attached to the
iio_dev debugfs entry which won't exist if no debugfs_reg_access
callback is provided.

Fixes: 2f3abe6cbb ("iio:imu: Add support for the ADIS16480 and similar IMUs")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-11 18:38:13 +00:00
Nuno Sá
49549cb23a iio: adis16480: Fix scales factors
This patch fixes the scales for the gyroscope, accelerometer and
barometer. The pressure scale was just wrong. For the others, the scale
factors were not taking into account that a 32bit word is being read
from the device.

Fixes: 7abad1063d ("iio: adis16480: Fix scale factors")
Fixes: 82e7a1b250 ("iio: imu: adis16480: Add support for ADIS1649x family of devices")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-11 18:38:03 +00:00
Greg Kroah-Hartman
f0cb9b5dfd Merge 5.4-rc7 into staging-next
We want the staging fixes in here, and it resolves some merge issues.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-11 06:23:37 +01:00
Stephan Gerhold
26a0ffeed9 iio: imu: mpu6050: Add support for vdd-supply regulator
MPU6050 has two power supply pins: VDD and VLOGIC, but the
mpu6050 driver only supports enabling one of them at the moment.
In some cases, they may need to be enabled separately.

Add an additional "vdd-supply" that stays enabled for as long as
the driver is loaded. We cannot turn off the VDD regulator during
suspend as this would cause register settings (FSR, sampling rate, ...)
to be lost.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-10 16:00:34 +00:00
Lorenzo Bianconi
f8710f0357 iio: imu: st_lsm6dsx: express odr in mHZ
Express available frequencies in mHZ in order to support even
rational ODRs. This patch is need to fix an Android CTS failure

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-09 13:23:17 +00:00
Lorenzo Bianconi
fc3f6ad7f5 iio: imu: st_lsm6dsx: fix ODR check in st_lsm6dsx_write_raw
Since st_lsm6dsx i2c master controller relies on accel device as trigger
and slave devices can run at different ODRs we must select an accel_odr >=
slave_odr. Report real accel ODR in st_lsm6dsx_check_odr() in order to
properly set sensor frequency in st_lsm6dsx_write_raw and avoid to
report unsupported frequency

Fixes: 6ffb55e500 ("iio: imu: st_lsm6dsx: introduce ST_LSM6DSX_ID_EXT sensor ids")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-09 13:17:15 +00:00
Lorenzo Bianconi
59af4e2063 iio: imu: st_lsm6dsx: explicitly define odr table size
Introduce odr_len in st_lsm6dsx_odr_table_entry data structure in order
to explicitly define odr table size and support devices with different
odr table map

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-09 13:10:59 +00:00
Alexandru Ardelean
38262c01ea iio: imu: adis: assign read val in debugfs hook only if op successful
This was also caught by the `-Wmaybe-uninitialized` warning, which
(ironically as-is) it makes quite a lot of sense to do for this.

The code that actually calls this function will fail to copy on
the uninitialized value.   Hence, patch does not need to go into stable.

Fixes: 78026a6fde ("iio:imu:adis: Add debugfs register access support")
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:44:29 +00:00
Alexandru Ardelean
9b742763d9 iio: imu: adis16480: assign bias value only if operation succeeded
This was found only after the whole thing with the inline functions, but
the compiler actually found something. The value of the `bias` (in
adis16480_get_calibbias()) should only be set if the read operation was
successful.

No actual known problem occurs as users of this function all
ultimately check the return value.  Hence probably not stable material.

Fixes: 2f3abe6cbb ("iio:imu: Add support for the ADIS16480 and similar IMUs")
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:40:25 +00:00
Alexandru Ardelean
52c4c732b2 iio: imu: adis16480: prefer unsigned int over unsigned
This is a typical checkpatch warning. The change just renames the type of
the `freq` var to `unsigned int`.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:38:40 +00:00
Alexandru Ardelean
d9bbae304a iio: imu: adis16480: fix indentation of return statement
This is just a minor indentation/alignment fix for the default case of a
switch statement.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:35:21 +00:00
Alexandru Ardelean
6a39ab3b19 iio: imu: adis: check ret val for non-zero vs less-than-zero
The ADIS library functions return zero on success, and negative values for
error. Positive values aren't returned, but we only care about the success
value (which is zero).

This change is mostly needed so that the compiler won't make any inferences
about some about values being potentially un-initialized. This only
triggers after making some functions inline, because the compiler can
better follow return paths.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:29:25 +00:00
Alexandru Ardelean
92c7529fc1 iio: imu: adis16480: check ret val for non-zero vs less-than-zero
The ADIS library functions return zero on success, and negative values for
error. Positive values aren't returned, but we only care about the success
value (which is zero).

This change is mostly needed so that the compiler won't make any inferences
about some about values being potentially un-initialized. This only
triggers after making some functions inline, because the compiler can
better follow return paths.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:25:43 +00:00
Alexandru Ardelean
c754a45455 iio: imu: adis16460: check ret val for non-zero vs less-than-zero
The ADIS library functions return zero on success, and negative values for
error. Positive values aren't returned, but we only care about the success
value (which is zero).

This change is mostly needed so that the compiler won't make any inferences
about some about values being potentially un-initialized. This only
triggers after making some functions inline, because the compiler can
better follow return paths.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:22:39 +00:00
Alexandru Ardelean
fe4b7f917e iio: imu: adis16400: check ret val for non-zero vs less-than-zero
The ADIS library functions return zero on success, and negative values for
error. Positive values aren't returned, but we only care about the success
value (which is zero).

This change is mostly needed so that the compiler won't make any inferences
about some about values being potentially un-initialized. This only
triggers after making some functions inline, because the compiler can
better follow return paths.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:16:54 +00:00
Lorenzo Bianconi
cf9c71b38b iio: imu: st_lsm6dsx: add support to LSM6DSRX
Add support to STM LSM6DSRX 6-axis (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/lsm6dsrx.pdf

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-27 16:38:06 +00:00
Jean-Baptiste Maneyrol
6e82ae6b8d iio: imu: inv_mpu6050: fix no data on MPU6050
Some chips have a fifo overflow bit issue where the bit is always
set. The result is that every data is dropped.

Change fifo overflow management by checking fifo count against
a maximum value.

Add fifo size in chip hardware set of values.

Fixes: f5057e7b2d ("iio: imu: inv_mpu6050: better fifo overflow handling")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-22 12:42:54 +01:00
Robert Jones
84e5ddd5c4 iio: imu: Add support for the FXOS8700 IMU
FXOS8700CQ is a small, low-power, 3-axis linear accelerometer and 3-axis
magnetometer combined into a single package. The device features a
selectable I2C or point-to-point SPI serial interface with 14-bit
accelerometer and 16-bit magnetometer ADC resolution along with
smart-embedded functions.

FXOS8700CQ has dynamically selectable accelerationfull-scale ranges of
±2 g/±4 g/±8 g and a fixed magnetic measurement range of ±1200 μT.
Output data rates (ODR) from 1.563 Hz to 800 Hz are selectable by the user
for each sensor. Interleaved magnetic and acceleration data is available
at ODR rates of up to 400 Hz. FXOS8700CQ is available in a plastic QFN
package and it is guaranteed to operate over the extended temperature
range of –40 °C to +85 °C.

TODO: Trigger and IRQ configuration support

Datasheet:
  http://cache.freescale.com/files/sensors/doc/data_sheet/FXOS8700CQ.pdf

Signed-off-by: Robert Jones <rjones@gateworks.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-22 10:24:50 +01:00
Lorenzo Bianconi
fa060a3d9c iio: imu: st_lsm6dsx: add support to LSM6DS0
Add support to STM LSM6DS0 6-axis (acc + gyro) Mems sensor

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:07 +01:00
Lorenzo Bianconi
1b3751017e iio: imu: st_lsm6dsx: fix gyro gain definitions for LSM9DS1
Fix typos in gyro gain definitions for LSM9DS1 sensor

Fixes: 52f4b1f196 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:07 +01:00
Mario Tesi
cb3b6b8e1b iio: imu: st_lsm6dsx: add odr calibration feature
On LSM6DSO/LSM6DSR/LSM6DSOX/ASM330LHH and ISH330DHCX
devices it is possible to trim the hardware timestamp
resolution through the FREQ_FINE[7:0] bits of the
INTERNAL_FREQ_FINE register, which contains the difference
in percentage of the effective ODR (and timestamp rate)
with respect to the typical value.

The formula for calculating the effective ODR reported
in the application notes has been linearized to the first
order to simplify the calculation (pls. see note on source
code).

This change may be useful in the outcome of CTS
tests regarding the SingleSensorTests and the
SensorTest#testSensorTimeStamps for high ODRs

Signed-off-by: Mario Tesi <mario.tesi@st.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:06 +01:00
Lorenzo Bianconi
960506ed2c iio: imu: st_lsm6dsx: enable drdy-mask if available
Enable drdy mask if available in order to mark invalid samples during
sensor bootstrap phase

Tested-by: Mario Tesi <mario.tesi@st.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:06 +01:00
Lorenzo Bianconi
3ea39d61ee iio: imu: st_lsm6dsx: enable wake-up event for LSM6DSO
Add missing wake-up register info for LSM6DSO/LSM6DSOX sensor

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:06 +01:00
Lorenzo Bianconi
3473b923b3 iio: imu: st_lsm6dsx: add missing kernel documenation
Add missing kernel doc for st_lsm6dsx_hw data structure

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:05 +01:00
Lorenzo Bianconi
b7a73b33bb iio: imu: st_lsm6dsx: add wakeup_source in st_sensors_platform_data
Add the possibility to enable/disable wakeup source through
st_sensors_platform_data and not only through device tree

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:05 +01:00
Lorenzo Bianconi
b307f49546 iio: imu: st_lsm6dsx: fix checkpatch warning
Fix following checkpatch warnings:

CHECK: Alignment should match open parenthesis
+static int st_lsm6dsx_read_event(struct iio_dev *iio_dev,
+				   const struct iio_chan_spec *chan,

CHECK: Alignment should match open parenthesis
+static int st_lsm6dsx_write_event(struct iio_dev *iio_dev,
+				    const struct iio_chan_spec *chan,

CHECK: Alignment should match open parenthesis
+static int st_lsm6dsx_read_event_config(struct iio_dev *iio_dev,
+					  const struct iio_chan_spec *chan,

CHECK: Alignment should match open parenthesis
+static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev,
+					   const struct iio_chan_spec *chan,

WARNING: line over 80 characters
+	if (dev->of_node && of_property_read_bool(dev->of_node, "wakeup-source"))

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:05 +01:00
Lorenzo Bianconi
d278d44794 iio: imu: st_lsm6dsx: grab conf mutex in st_lsm6dsx_write_event_config
Always grub conf mutex in st_lsm6dsx_write_event_config since it can run
concurrently with FIFO configuration

Fixes: b5969abfa8 ("iio: imu: st_lsm6dsx: add motion events")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:05 +01:00
Lorenzo Bianconi
04ca37d5ad iio: imu: st_lsm6dsx: rely on st_lsm6dsx_update_bits_locked configuring events
Rely on st_lsm6dsx_update_bits_locked in st_lsm6dsx_write_event and
st_lsm6dsx_event_setup routines since they can run concurrently with
sensor hub configuration

Fixes: b5969abfa8 ("iio: imu: st_lsm6dsx: add motion events")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:05 +01:00
Lorenzo Bianconi
84b2e7c319 iio: imu: st_lsm6dsx: always check enable_reg in st_lsm6dsx_event_setup
Check if enable_reg of event_settings data structure is defined before
writing on it

Fixes: b5969abfa8 ("iio: imu: st_lsm6dsx: add motion events")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:05 +01:00
Lorenzo Bianconi
66b662a176 iio: imu: st_lsm6dsx: move bdu/boot and reset register info in hw_settings
Move bdu, boot and reset register definitions in hw_settings register
map since not all supported sensors (e.g lsm9ds1) rely on the same
definitions

Fixes: 52f4b1f196 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:04 +01:00
Lorenzo Bianconi
31fe8d4e0f iio: imu: st_lsm6dsx: do not access active-low/open-drain regs if not supported
Move active low and open drain register definitions in hw_settings
register map since not all supported sensors (e.g lsm9ds1) rely on the
same definitions

Fixes: 52f4b1f196 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:04 +01:00
Lorenzo Bianconi
7e9061030d iio: imu: st_lsm6dsx: move irq related definitions in irq_config
Group irq related definition in irq_config structure in
st_lsm6dsx_settings. This is a preliminary patch to move
OpenDrain/Active low registers in st_lsm6dsx_settings.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:04 +01:00
Lorenzo Bianconi
a912ee4c91 iio: imu: st_lsm6dsx: add sanity check for read_fifo pointer
Check read_fifo pointer before using it since we can't assume it
is always set adding new sensors. This patch fixes the following crash:

irq 277: nobody cared (try booting with the "irqpoll" option)
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.3.0-rc5-00322-g792b824-dirty #7
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[<c0112750>] (unwind_backtrace) from [<c010d018>] (show_stack+0x10/0x14)
[<c010d018>] (show_stack) from [<c0c2bfc8>] (dump_stack+0xd8/0x10c)
[<c0c2bfc8>] (dump_stack) from [<c01923fc>] (__report_bad_irq+0x24/0xc0)
[<c01923fc>] (__report_bad_irq) from [<c0192820>] (note_interrupt+0x27c/0x2dc)
[<c0192820>] (note_interrupt) from [<c018f174>] (handle_irq_event_percpu+0x54/0x7c)
[<c018f174>] (handle_irq_event_percpu) from [<c018f1d4>] (handle_irq_event+0x38/0x5c)
[<c018f1d4>] (handle_irq_event) from [<c0193664>] (handle_level_irq+0xc8/0x154)
[<c0193664>] (handle_level_irq) from [<c018df58>] (generic_handle_irq+0x20/0x34)
[<c018df58>] (generic_handle_irq) from [<c053c348>] (mxc_gpio_irq_handler+0xc4/0xf8)
[<c053c348>] (mxc_gpio_irq_handler) from [<c053c3e0>] (mx3_gpio_irq_handler+0x64/0xb8)
[<c053c3e0>] (mx3_gpio_irq_handler) from [<c018df58>] (generic_handle_irq+0x20/0x34)
[<c018df58>] (generic_handle_irq) from [<c018e550>] (__handle_domain_irq+0x64/0xe0)
[<c018e550>] (__handle_domain_irq) from [<c0529610>] (gic_handle_irq+0x4c/0xa0)
[<c0529610>] (gic_handle_irq) from [<c0101a70>] (__irq_svc+0x70/0x98)
Exception stack(0xc1301f10 to 0xc1301f58
1f00: 00000001 00000006 00000000 c130c340
1f20: c1300000 c1308928 00000001 c1308960 00000000 c12b9db0 c1308908 00000000
1f40: 00000000 c1301f60 c0182010 c0109508 20000013 ffffffff
[<c0101a70>] (__irq_svc) from [<c0109508>] (arch_cpu_idle+0x20/0x3c)
[<c0109508>] (arch_cpu_idle) from [<c015ed70>] (do_idle+0x1bc/0x2bc)
[<c015ed70>] (do_idle) from [<c015f204>] (cpu_startup_entry+0x18/0x1c)
[<c015f204>] (cpu_startup_entry) from [<c1200e68>] (start_kernel+0x440/0x504)
[<c1200e68>] (start_kernel) from [<00000000>] (0x0)
handlers:
[<62052c0d>] st_lsm6dsx_handler_irq threaded
[<f2004b92>] st_lsm6dsx_handler_thread

Fixes: 52f4b1f196 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
Tested-by: Bobby Jones <rjones@gateworks.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:04 +01:00
Lorenzo Bianconi
615bd3785b iio: imu: st_lsm6dsx: use st_lsm6dsx_read_locked in st_lsm6dsx_report_motion_event
Rely on st_lsm6dsx_read_locked in st_lsm6dsx_report_motion_event since
it can run concurrently with sensor hub configuration. Move event
related code in st_lsm6dsx_report_motion_event

Fixes: 1aabad1fb5 ("iio: imu: st_lsm6dsx: add motion report function and call from interrupt")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:04 +01:00
Alexandru Ardelean
329f0dac4c
spi: make cs_change_delay the first user of the spi_delay logic
Since the logic for `spi_delay` struct + `spi_delay_exec()` has been copied
from the `cs_change_delay` logic, it's natural to make this delay, the
first user.

The `cs_change_delay` logic requires that the default remain 10 uS, in case
it is unspecified/unconfigured. So, there is some special handling needed
to do that.

The ADIS library is one of the few users of the new `cs_change_delay`
parameter for an spi_transfer.

The introduction of the `spi_delay` struct, requires that the users of of
`cs_change_delay` get an update. This change also updates the ADIS library.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20190926105147.7839-4-alexandru.ardelean@analog.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-15 11:41:47 +01:00
Greg Kroah-Hartman
27d6e47f8e Merge 5.4-rc3 into staging-next
We want the staging driver fixes in here as well to build on and test
with.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-10-14 07:07:36 +02:00
Alexandru Ardelean
24e1eb5c0d iio: imu: adis16480: make sure provided frequency is positive
It could happen that either `val` or `val2` [provided from userspace] is
negative. In that case the computed frequency could get a weird value.

Fix this by checking that neither of the 2 variables is negative, and check
that the computed result is not-zero.

Fixes: e4f9593901 ("iio: imu: adis16480 switch sampling frequency attr to core support")
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-12 14:14:45 +01:00
Lorenzo Bianconi
fdb828e2c7 iio: imu: st_lsm6dsx: fix waitime for st_lsm6dsx i2c controller
i2c controller available in st_lsm6dsx series performs i2c slave
configuration using accel clock as trigger.
st_lsm6dsx_shub_wait_complete routine is used to wait the controller has
carried out the requested configuration. However if the accel sensor is not
enabled we should not use its configured odr to estimate a proper timeout

Fixes: c91c1c844e ("iio: imu: st_lsm6dsx: add i2c embedded controller support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-09 19:11:28 +01:00
Navid Emamdoost
9c0530e898 iio: imu: adis16400: fix memory leak
In adis_update_scan_mode_burst, if adis->buffer allocation fails release
the adis->xfer.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-09 19:11:27 +01:00
Navid Emamdoost
ab612b1daf iio: imu: adis16400: release allocated memory on failure
In adis_update_scan_mode, if allocation for adis->buffer fails,
previously allocated adis->xfer needs to be released.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-09 19:11:27 +01:00
Sean Nyekjaer
1aabad1fb5 iio: imu: st_lsm6dsx: add motion report function and call from interrupt
Report iio motion events to iio subsystem and filter motion events.
Wakeup will still be on all channels as it's not possible to do the filtering
in hw.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:40:26 +01:00
Sean Nyekjaer
a3aa17d4ba iio: imu: st_lsm6dsx: always enter interrupt thread
The interrupt source can come from multiple sources,
fifo and wake interrupts.
Enter interrupt thread to check which interrupt that has fired.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:36:54 +01:00
Sean Nyekjaer
4c997dfa69 iio: imu: st_lsm6dsx: add wakeup-source option
This add ways for the SoC to wake from accelerometer wake events.

In the suspend function we skip disabling the sensor if wakeup-source
and events are activated.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:36:39 +01:00
Sean Nyekjaer
b5969abfa8 iio: imu: st_lsm6dsx: add motion events
Add event channels that controls the creation of motion events.
Tested on ISM330DLC

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:30:56 +01:00
Sean Nyekjaer
6ee6a368ac iio: imu: st_lsm6dsx: move interrupt thread to core
This prepares the interrupt to be used for other stuff than
fifo reading + event readings.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:23:58 +01:00
Jean-Baptiste Maneyrol
e764fb4e20 iio: imu: inv_mpu6050: add fifo support for magnetometer data
Put read magnetometer data by mpu inside the fifo.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:14:31 +01:00
Jean-Baptiste Maneyrol
b1392de061 iio: imu: inv_mpu6050: add MPU925x magnetometer support
Add support of driving MPU9250 magnetometer connected on i2c
auxiliary bus using the MPU i2c master.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:14:20 +01:00
Jean-Baptiste Maneyrol
16ef433769 iio: imu: inv_mpu6050: helpers for using i2c master on auxiliary bus
Add helper functions to use the i2c auxiliary bus with the MPU i2c
master block.

Support only register based chip, reading and 1 byte writing. These
will be useful for initializing magnetometers inside MPU9x50 chips.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:06:16 +01:00
Jean-Baptiste Maneyrol
9d8261dbc4 iio: imu: inv_mpu6050: fix objects syntax in Makefile
Use the correct syntax *-y for declaring object files.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 11:59:59 +01:00