platform/kernel/linux-rpi.git
5 years agoiio: imx7d_adc: Add local struct device pointer in imx7d_adc_probe()
Andrey Smirnov [Wed, 3 Apr 2019 07:03:20 +0000 (00:03 -0700)]
iio: imx7d_adc: Add local struct device pointer in imx7d_adc_probe()

Use a local "struct device *dev" in imx7d_adc_probe() for brevity. No
functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Chris Healy <cphealy@gmail.com>
Cc: linux-iio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: iio: adc: Add AD7616 ADC documentation
Beniamin Bia [Tue, 2 Apr 2019 13:18:41 +0000 (16:18 +0300)]
dt-bindings: iio: adc: Add AD7616 ADC documentation

Document support for AD7616 Analog to Digital Converter.

Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: ad7616: Add support for AD7616 ADC
Beniamin Bia [Tue, 2 Apr 2019 13:18:40 +0000 (16:18 +0300)]
iio: adc: ad7616: Add support for AD7616 ADC

The AD7616 is a 12-bit ADC with 16 channels.

The AD7616 can be configured to work in hardware mode by controlling it via
gpio pins and read data via spi. No support for software mode yet, but it
is a work in progress.

This device requires a reset in order to update oversampling, so chip info
has got a new attribute to mark this.

The current assumption that this driver makes for AD7616, is that it's
working in Hardware Mode with Serial, Burst and Sequencer modes activated.
To activate them, following pins must be pulled high:
-SER/PAR
-SEQEN
And following must be pulled low:
-WR/BURST
-DB4/SEQEN

Datasheets:
Link: https://www.analog.com/media/en/technical-documentation/data-sheets/ad7616.pdf
Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: ad7606: Move oversampling options in chip info and rework *_avail attributes
Stefan Popa [Tue, 2 Apr 2019 13:18:39 +0000 (16:18 +0300)]
iio: adc: ad7606: Move oversampling options in chip info and rework *_avail attributes

Available oversampling ratios and scales can be shown by calling a
common ad7606_show_avail function which takes as parameters the array
which stores the values, together with the size of the array.

Oversampling options are now defined in chip info
structure and they are loaded at probe.

Has_Oversampling attribute was removed because oversampling_num was added
and it is not needed anymore.

The purpose of this patch is to deal with the scale_avail and
oversampling_avail arrays in a generic way. This makes it easier to add
support for new devices which will work with different scales and
oversampling ratios. It is also an intermediate step for adding support
for ad7616 which has different oversampling sampling ratios available.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: frequency: ad9834: Remove unnecessary parentheses
Melissa Wen [Tue, 2 Apr 2019 20:18:54 +0000 (17:18 -0300)]
staging: iio: frequency: ad9834: Remove unnecessary parentheses

Remove unneeded parentheses around the arguments of ||. This reduces
clutter and code behave in the same way. Change suggested by
checkpatch.pl.

CHECK: Unnecessary parentheses around 'st->devid == ID_AD9833'
CHECK: Unnecessary parentheses around 'st->devid == ID_AD9837'

Signed-off-by: Melissa Wen <melissa.srw@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: Fix MAX9611 spacing
Fabrizio Castro [Wed, 3 Apr 2019 15:03:51 +0000 (16:03 +0100)]
iio: adc: Fix MAX9611 spacing

Between "config" and "MAX9611" there is a tab, replace it
with a space.

Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: iio: imu: st_lsm6dsx: add lsm6dsr device bindings
Lorenzo Bianconi [Thu, 4 Apr 2019 16:02:35 +0000 (18:02 +0200)]
dt-bindings: iio: imu: st_lsm6dsx: add lsm6dsr device bindings

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: imu: st_lsm6dsx: add support to LSM6DSR
Lorenzo Bianconi [Thu, 4 Apr 2019 16:02:34 +0000 (18:02 +0200)]
iio: imu: st_lsm6dsx: add support to LSM6DSR

Add support to STM LSM6DSR 6-axis (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/lsm6dsr.pdf

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoMerge tag 'iio-for-5.2a-2' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23...
Greg Kroah-Hartman [Thu, 4 Apr 2019 20:25:29 +0000 (22:25 +0200)]
Merge tag 'iio-for-5.2a-2' of git://git./linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

First set of new device support, features and fixes for IIO in the 5.2 cycle

Staging graduations
* ad7780
  - Move this ADC driver out of staging.  Included adding some new features
    along the way (see below). Also added DT bindings.

New device support
* adis16480
  - Support the ADIS16495 and ADIS16497 IMU devices making
    heavy use of refactoring of various aspects of the driver in precursor
    patches.
* lsm6dsx
  - Support for the ASM330LHH 6-axis (accelerometer + gyro) sensor.
  - Support for the LSM6DS0X
* matbotix mb1232
  - New driver for this ultrasound ranging device family. Including bindings.
  - Supports mb1202, mb1212, mb1222, mb1232, mb1242, mb7040 and mb7137.
* max31856
  - New driver for this thermocouple temperature sensor.
* meson saradc
  - Support the Meson-G12A (ID addition only).
* stmpe-adc
  - New driver supporting generic ADC alongside touchscreen support which
    previously existed. Includes DT bindings.
* vcnl4000
  - Support for the vcln4040 proximity and light sensor, including adding
    DT bindings for this and parts previously supported.

Features
* core
  - Allow reading of mount matrices from ACPI in addition to DT.
  - Common binding for theromcouple types.
* ad5933
  - Add ABI docs as there are a few 'unsual' elements about this
    device - perhaps because it's our only impedance analyser.
* ad7780
  - Add gain and filter gpio support + readback of current gain and filter.
* adis16480
  - Allow selection fo the dataready pin to be used.
  - Device tree ID table and binding documentation.
  - Support external clock modes, including new bindings.
* bma180
  - Mount matrix support.
* bmc150
  - Mount matrix support.
* bmg160
  - Mount matrix support.
  - DT id table and bindings doc.
* bmp280
  - Put calibration data into the entropy pool.
* hmc5843
  - Mount matrix support.
* itg3200
  - Mount matrix support.
* kxcjk1013
  - Device tree id table, and binding docs.
* lpc32xx
  - Add scale when regulator specified including DT docs for regulator.
* pms7003
  - Add device IDs for all supported parts to driver and binding.
* stm32-dfsdm
  - Enable hw consumer support, scan mode control and a complex set of
    triggered buffer modes.
  - Power management.
* stm32-lptimer-counter
  - power management.
  - Document the pinctrl sleep state binding.
* ti-ads7950
  - GPIO pin support.

Cleanups, minor fixes
* core
  - Use bitmap_zalloc to make it explicit that is what we are doing.
  - Tidy up all the Kconfig files (which had slowly gotten messy)
  - Fix a forwards definition missing issue in iio/driver.h
* ad sigma delta core
  - Improve handling of SPI bus locking vs CS assertion.  This has been
    wrong a long time so not rushing this in.
* ad5064
  - Mlock to local lock.
* ad5933 (staging cleanup)
  - Multiline comment fixes.
  - Include ordering.
  - SPDX.
  - Tidy up Kconfig help which was a bit missleading.
  - Change some non standard attributes to ABI defined ones.
* ad7124
  - White space fix.
* ad7192
  - White space.
  - Use DT clock binding.
  - Improve error reporting.
  - Platform data to DT conversion.
  - Use read_avail callback, mostly to avoid the endless series of
    patches from new contributors trying to falsely put spaces around
    the negative sign.
ad7280a
  - Add brackets to macros to avoid potential precedence isseus.
  - Add temp vars for event codes to reduce indent and improved readability.
  - Clean out som CamelCase notation.
  - White space.
* ad7606
  - Fix broken file naming in MAINTAINERS.
* ad7780
  - Missing switch defaults to supress warnings and harden the code slightly.
  - Set pattern masks more directly.
  - Add ID values and masks for all supported chips.
  - SPDX + add Renato as a copyright holder as he has done a lot of work on
    this driver.
  - Add brackets to macros to avoid potential precedence issues.
* ad7923
  - White space fixes.
  - Use BIT macro to improve readability.
  - Add brackets to macros to avoid potential precedence issues.
  - Tidy up a null comparisom.
* ad9523
  - Fix a typo in naming of variables.
* adis16400
  - Combine trigger file into main code as no advantage in separate files.
    Rename core file to just adis16400.
  - Squash the header into the c file now there is only one file.
  - Generalize burst mode to support new variants.
* ak8975
  - Local variable to improve readability around mount matrix support.
* as3935
  - Avoid potential race by ensuring remove does exact opposite of
    probe rather than a slightly different order.
* cross_ec
  - Drop some unnecessary includes.
  - Fix some warning and the slightly 'unusual' code.
  - Add some docs for non obvious function.
  - SPDX
* hmc5843
  - Potential unhandled error case.
* iio trigger core
  - Print an error if there is no available irq due to max consumers per
    trigger being set to low.
* iio loop trigger
  - Drop an unlikely on IS_ERR as IS_ERR already has the annotation.
* ingenic-adc
  - Drop a redundant dev_err call as devm_ioremap_resource reports the same
    internally.
* lmp91000
  - Drop some unncessary parentheses and white space tidy up.
  - Invert and if statement to improve readability.
  - Fix a wrong error message.
* lpc32xx
  - Header sorting + drop some unused ones.
* mma8542
  - Mark a switch fallthrough.
* mpu6050
  - Add a local variable to improve code readability around mount matrix
    support.
* mxs-lradc-adc
  - Handle devm_iio_trigger_alloc failure.
* sps30
  - Fix up a kernel version in the ABI docs.
* srf04
  - DT binding doc converted to yaml.
* ssp_sensors
  - Supress a clang build warning due to lack of visibility of conditional
    within a iio_push_to_buffers_with_timestamp.  (reasonable false warning!)
* st_accel
  - Drop pointless less than 0 comparisom of unsigned int.
* stm32-dfsdm
  - Improve accuracy of spi_master_frequency calculation.
  - Improve calculation fo sampling frequency.
  - Rework various internals to simplify adding triggered buffer support.
  - Claim direct mode to avoid racing around read_raw and being in buffered
    mode.
* stmpe
  - Fix a clang false positive warning.
* ti-ads7950
  - Use local lock rather than using the core mlock when not locking around
    the device mode.
* vcnl4000
  - Use word writes instead of byte writes.  It seems byte writes are fine
    for some parts (undocument) but not others that the driver will shortly
    support.

Other
* mailmap
  - Add email address change for Sean Nyekjaer.  Update in relevant drivers

* tag 'iio-for-5.2a-2' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (129 commits)
  iio: ad_sigma_delta: Properly handle SPI bus locking vs CS assertion
  iio: adc: stm32-dfsdm: add PM support
  iio: adc: stm32-dfsdm: improve sampling frequency accuracy
  staging: iio: adc: ad7280a: Tab alignment
  MAINTAINERS: Fix the link to ad7606 dt-bindings
  iio:temperature: Add MAX31856 thermocouple support
  iio:temperature:max31856:Add device tree bind info
  dt-bindings: iio/temperature: Add thermocouple types (and doc)
  devantech-srf04.yaml: transform DT binding to YAML
  iio: frequency: ad9523: Fix typo in ad9523_platform_data
  iio: Make possible to include driver.h first
  dt-bindings: iio: add Bosch BMG160 gyroscope sensor
  iio: gyro: bmg160: add device tree compatibility table
  staging: iio: adc: ad7192: Use read_avail for available attributes
  dt-bindings: iio: light: add vcnl4040 devicetree bindings
  iio: light: vcnl4000 add support for the VCNL4040 proximity and light sensor
  dt-bindings: iio: light: add vcnl4000 devicetree bindings
  iio: light: vcnl4000 add devicetree hooks
  iio: light: vcnl4000 use word writes instead of byte writes
  iio: adc: stm32-dfsdm: claim direct mode for raw read and settings
  ...

5 years agoiio: ad_sigma_delta: Properly handle SPI bus locking vs CS assertion
Lars-Peter Clausen [Tue, 19 Mar 2019 11:37:55 +0000 (13:37 +0200)]
iio: ad_sigma_delta: Properly handle SPI bus locking vs CS assertion

For devices from the SigmaDelta family we need to keep CS low when doing a
conversion, since the device will use the MISO line as a interrupt to
indicate that the conversion is complete.

This is why the driver locks the SPI bus and when the SPI bus is locked
keeps as long as a conversion is going on. The current implementation gets
one small detail wrong though. CS is only de-asserted after the SPI bus is
unlocked. This means it is possible for a different SPI device on the same
bus to send a message which would be wrongfully be addressed to the
SigmaDelta device as well. Make sure that the last SPI transfer that is
done while holding the SPI bus lock de-asserts the CS signal.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <Alexandru.Ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: stm32-dfsdm: add PM support
Fabrice Gasnier [Mon, 25 Mar 2019 14:49:28 +0000 (15:49 +0100)]
iio: adc: stm32-dfsdm: add PM support

Add PM and runtime PM support to STM32 DFSDM drivers:
- stm32-dfsdm-core: manage clocks.
- stm32-dfsdm-adc: restore channels configuration upon resume. Also stop
  restart everything in case of buffer mode.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: stm32-dfsdm: improve sampling frequency accuracy
Fabrice Gasnier [Mon, 25 Mar 2019 14:24:01 +0000 (15:24 +0100)]
iio: adc: stm32-dfsdm: improve sampling frequency accuracy

The sample frequency is driven using the oversampling ratio depending
on the SPI bus frequency.
Currently, oversampling ratio is computed by an entire division:
- spi_freq / sample_freq. This may result in inaccurate value.
Using DIV_ROUND_CLOSEST improves resulting sample frequency, which is
useful for audio that requests fixed rates (such as: 8, 16 or 32 kHz).
BTW, introduce new routine to re-factor sample frequency setting, and
move frequency accuracy message from warning to debug level.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: adc: ad7280a: Tab alignment
Cristian Sicilia [Sun, 24 Mar 2019 17:23:09 +0000 (18:23 +0100)]
staging: iio: adc: ad7280a: Tab alignment

Aligned some parameters.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoMAINTAINERS: Fix the link to ad7606 dt-bindings
Stefan Popa [Tue, 26 Mar 2019 10:59:52 +0000 (12:59 +0200)]
MAINTAINERS: Fix the link to ad7606 dt-bindings

The devicetree bindings documentation for ad7606 should also include
the vendor prefix: ad7606.txt -> adi,ad7606.txt

Fixes: 6e33a125df66 ("dt-bindings: iio: adc: Add docs for AD7606 ADC")
Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio:temperature: Add MAX31856 thermocouple support
Paresh Chaudhary [Tue, 26 Mar 2019 11:18:42 +0000 (12:18 +0100)]
iio:temperature: Add MAX31856 thermocouple support

This patch adds support for Maxim MAX31856 thermocouple
temperature sensor support.

More information can be found in:
https://www.maximintegrated.com/en/ds/MAX31856.pdf

NOTE: Driver support only Comparator Mode.

Signed-off-by: Paresh Chaudhary <paresh.chaudhary@rockwellcollins.com>
Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Patrick Havelange <patrick.havelange@essensium.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio:temperature:max31856:Add device tree bind info
Paresh Chaudhary [Tue, 26 Mar 2019 11:18:41 +0000 (12:18 +0100)]
iio:temperature:max31856:Add device tree bind info

This patch added device tree binding info for MAX31856 driver.

Signed-off-by: Paresh Chaudhary <paresh.chaudhary@rockwellcollins.com>
Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Patrick Havelange <patrick.havelange@essensium.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: iio/temperature: Add thermocouple types (and doc)
Patrick Havelange [Tue, 26 Mar 2019 11:18:40 +0000 (12:18 +0100)]
dt-bindings: iio/temperature: Add thermocouple types (and doc)

This patch introduces common thermocouple types used by various
temperature sensors. Also a brief documentation explaining this
"thermocouple-type" property.

Signed-off-by: Patrick Havelange <patrick.havelange@essensium.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodevantech-srf04.yaml: transform DT binding to YAML
Andreas Klinger [Tue, 26 Mar 2019 13:39:40 +0000 (14:39 +0100)]
devantech-srf04.yaml: transform DT binding to YAML

devantech-srf04.yaml: yaml devicetree binding for iio ultrasonic
proximity driver of devantech srf04

use devantech-srf04.txt, transform binding into yaml and remove the
outdated DT documentation

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: frequency: ad9523: Fix typo in ad9523_platform_data
Lars-Peter Clausen [Tue, 26 Mar 2019 13:40:03 +0000 (15:40 +0200)]
iio: frequency: ad9523: Fix typo in ad9523_platform_data

Replace diff_{m1,m2} with div_{m1,m2} since they are dividers and not a
differential settings.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: Make possible to include driver.h first
Andy Shevchenko [Tue, 26 Mar 2019 13:47:00 +0000 (15:47 +0200)]
iio: Make possible to include driver.h first

If we put headers alphabetically sorted in the IIO driver,
the compilation will abort because of unknown type to handle.

Simple add a forward declaration of opaque struct iio_dev.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: iio: add Bosch BMG160 gyroscope sensor
H. Nikolaus Schaller [Mon, 18 Mar 2019 15:14:15 +0000 (16:14 +0100)]
dt-bindings: iio: add Bosch BMG160 gyroscope sensor

Define bindings for "bosch,bmg160" and "bosch,bmi055_gyro".

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: gyro: bmg160: add device tree compatibility table
H. Nikolaus Schaller [Mon, 18 Mar 2019 15:14:14 +0000 (16:14 +0100)]
iio: gyro: bmg160: add device tree compatibility table

Add of_match_table.

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: adc: ad7192: Use read_avail for available attributes
Mircea Caprioru [Tue, 19 Mar 2019 14:25:20 +0000 (16:25 +0200)]
staging: iio: adc: ad7192: Use read_avail for available attributes

This patch removes the in_voltage-voltage_scale_available and
in_voltage_scale_available attributes. These are replaced with available
attributes added in info_mask_shared_by_type_available.

With this modification the iio core will be responsible with naming the
attributes thus removing the checkpatch warning related to
in_voltage-voltage_scale_available naming.

Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: iio: light: add vcnl4040 devicetree bindings
Angus Ainslie (Purism) [Thu, 21 Mar 2019 15:40:47 +0000 (08:40 -0700)]
dt-bindings: iio: light: add vcnl4040 devicetree bindings

Document the vishay VCNL4040 devicetree bindings.

Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: light: vcnl4000 add support for the VCNL4040 proximity and light sensor
Angus Ainslie (Purism) [Thu, 21 Mar 2019 15:40:46 +0000 (08:40 -0700)]
iio: light: vcnl4000 add support for the VCNL4040 proximity and light sensor

The VCNL4040 is almost identical to the VCNL4200 as far as register
layout goes but just need to check a different ID register location.

Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: iio: light: add vcnl4000 devicetree bindings
Angus Ainslie (Purism) [Thu, 21 Mar 2019 15:40:45 +0000 (08:40 -0700)]
dt-bindings: iio: light: add vcnl4000 devicetree bindings

Document the vishay VCNL4000 devicetree bindings.

Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: light: vcnl4000 add devicetree hooks
Angus Ainslie (Purism) [Thu, 21 Mar 2019 15:40:44 +0000 (08:40 -0700)]
iio: light: vcnl4000 add devicetree hooks

Add an of_match table for devicetree probing.

Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: light: vcnl4000 use word writes instead of byte writes
Angus Ainslie (Purism) [Thu, 21 Mar 2019 15:40:43 +0000 (08:40 -0700)]
iio: light: vcnl4000 use word writes instead of byte writes

The VCNL4200 datasheet says that word read and writes should be used
to access the registers.

Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
Tested-by: Tomas Novotny <tomas@novotny.cz>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: stm32-dfsdm: claim direct mode for raw read and settings
Fabrice Gasnier [Thu, 21 Mar 2019 16:47:29 +0000 (17:47 +0100)]
iio: adc: stm32-dfsdm: claim direct mode for raw read and settings

Claim direct mode to ensure no buffer mode is in use for:
- single conversion
- sample rate setting (must be set when filter isn't enabled).
- oversampling ratio (must be set when filter isn't enabled).

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: stm32-dfsdm: add support for buffer modes
Fabrice Gasnier [Thu, 21 Mar 2019 16:47:28 +0000 (17:47 +0100)]
iio: adc: stm32-dfsdm: add support for buffer modes

DFSDM conversions can be launched continuously, or using various
triggers:
- by software
- hardware triggers (e.g. like in stm32-adc: TIM, LPTIM, EXTI)
- synchronously with DFSDM filter 0. e.g. for filters 1, 2

Launching conversions can be done using two methods:
a - injected:
    - scan mode can be used to convert several channels each time a
      trigger occurs.
    - When not is scan mode, channels are converted in sequence, one upon
      each trigger.
b - regular:
    - supports software triggers or synchronous with filter 0
    - single or continuous conversions

This patch finalizes DFSDM operating modes using IIO buffer modes:
- INDIO_BUFFER_SOFTWARE: regular continuous conversions (no trigger)
  but limited to 1 channel. Users must set sampling frequency in this case.
  For filters > 1, conversions can be started synchronously with filter 0.
- INDIO_BUFFER_TRIGGERED: triggered conversions uses injected mode for
  launching conversions. DFSDM can use hardware triggers (e.g. STM32 timer
  or lptimer), so add INDIO_HARDWARE_TRIGGERED to supported modes.
- INDIO_DIRECT_MODE: Only support DMA-based buffer modes. In case no DMA is
  available, only support single conversions.

From userland perspective, to summarize various use cases:
1 - single conversion on any filter:
$ cd iio:deviceX
$ cat in_voltageY_raw
This uses regular a conversion (not continuous)

2 - Using sampling frequency without trigger (single channel, buffer)
$ cd iio:deviceX
$ echo 100 > sampling_frequency
$ echo "" > trigger/current_trigger
$ echo 1 > scan_elements/in_voltageY_en
$ echo 1 > buffer/enable
This uses regular conversion in continuous mode (Frequency is achieved
by tuning filter parameters)

3 - sync mode with filter 0: other filters can be converted when using
"st,filter0-sync" dt property. The conversions will get started at the
same time as filter 0. So for any filters > 1:
$ cd iio:deviceX
$ echo 100 > sampling_frequency
$ echo "" > trigger/current_trigger
$ echo 1 > scan_elements/in_voltageY_en
$ echo 1 > buffer/enable
Then start filter 0 as in 2 above.

4 - Using a hardware trigger (with one channel):
- check trigger, configure it:
$ cat /sys/bus/iio/devices/trigger1/name
tim6_trgo
$ echo 100 > /sys/bus/iio/devices/trigger1/sampling_frequency
- go to any filter:
$ echo 1 > scan_elements/in_voltageY_en
$ echo tim6_trgo > trigger/current_trigger
$ echo 1 > buffer/enable
This uses injected conversion as it uses a hardware trigger (without scan)

5 - Using a hardware trigger (with 2+ channel):
Same as in 4/ above, but enable two or more channels in scan_elements.
This uses injected conversion as it uses a hardware trigger (with scan mode)

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: stm32-dfsdm: add support for scan mode
Fabrice Gasnier [Thu, 21 Mar 2019 16:47:27 +0000 (17:47 +0100)]
iio: adc: stm32-dfsdm: add support for scan mode

In order to support multiple channels in buffer mode, add support for scan
mode. This is precursor patch to ease support of triggered buffer mode.
Currently, only audio uses buffer mode: Regular continuous conversions
with a single channel (per filter).
DFSDM hardware supports scan mode (only) with injected conversions.
Conversions can be launched by software (JSWSTART), trigger or
synchronously with filter 0 (e.g. JSYNC). Continuous conversion mode isn't
available for injected.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: stm32-dfsdm: enable hw consumer
Fabrice Gasnier [Thu, 21 Mar 2019 16:47:26 +0000 (17:47 +0100)]
iio: adc: stm32-dfsdm: enable hw consumer

Optionally enable IIO hw consumer, when provided (e.g. for DFSDM_IIO type).
This is precursor patch to introduce buffer modes.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: stm32-dfsdm: move dma slave config to start routine
Fabrice Gasnier [Thu, 21 Mar 2019 16:47:25 +0000 (17:47 +0100)]
iio: adc: stm32-dfsdm: move dma slave config to start routine

Move DMA slave configuration to start routine: depending on regular or
injected mode is in use, DMA needs to read resp. RDATAR or JDATAR.
This is precursor patch to introduce injected mode (used for scan).

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: stm32-dfsdm: move dma enable from start_conv() to start_dma()
Fabrice Gasnier [Thu, 21 Mar 2019 16:47:24 +0000 (17:47 +0100)]
iio: adc: stm32-dfsdm: move dma enable from start_conv() to start_dma()

Move DMA enable (e.g. set RDMAEN bit) away from start_conv() that is used
for both buffer and single conversions. Thus, single conv rely on
interrupt, not dma.
Note: take care to prepare all DMA stuff and set RDMAEN before starting
filter (can be set only when DFEN=0).

This is precursor patch to ease support of triggered buffer mode.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: stm32-dfsdm: continuous mode depends on current mode
Fabrice Gasnier [Thu, 21 Mar 2019 16:47:23 +0000 (17:47 +0100)]
iio: adc: stm32-dfsdm: continuous mode depends on current mode

DFSDM regular continuous mode usage depends on current mode (not DMA):
- for single conversion, RCONT doesn't need to be set.
- for buffer mode, RCONT has to be set (e.g. INDIO_BUFFER_SOFTWARE
  used by audio currently).
This is related to filter configuration, move it to relevant routine.

This is precursor patch to ease support of triggered buffer mode.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: stm32-dfsdm: make spi_master_freq more accurate
Fabrice Gasnier [Thu, 21 Mar 2019 16:47:22 +0000 (17:47 +0100)]
iio: adc: stm32-dfsdm: make spi_master_freq more accurate

Current ckout divider may be set to a value that makes ckout to exceed
spi-max-frequency. Rather use lower value (e.g. round up divider when
ckout isn't accurate).

Also when the SPI clock isn't accurate, 'spi_master_freq' is filled in
with expected frequency. Use computed value instead to be more accurate:
- e.g. source clock / (CKOUTDIV + 1)

Enforce checks on the divider: ckoutdiv range can be from 1-255 to provide
divider of 2-256.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad5933: change attributes to match ABI
Marcelo Schmitt [Thu, 21 Mar 2019 18:42:13 +0000 (15:42 -0300)]
staging: iio: ad5933: change attributes to match ABI

Change device attributes' names to match ABI documentation. Names were
chosen such that they tend to be similar to existing ABI so it should
be easier to standardize them when necessary.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: ad7780: Add parentheses to macros
Vladimir Petrigo [Thu, 21 Mar 2019 21:15:28 +0000 (00:15 +0300)]
iio: adc: ad7780: Add parentheses to macros

- Fix CHECK Macro argument 'wordsize' may be better as '(wordsize)' to avoid precedence issues

Slightly modified by Jonathan to take into account the staging graduation
and a copy and paste version of the same item on the following line.

Signed-off-by: Vladimir Petrigo <vladimir.petrigo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: imu: adis16400: move adis16400.h into adis16400.c
Alexandru Ardelean [Fri, 22 Mar 2019 20:44:42 +0000 (22:44 +0200)]
iio: imu: adis16400: move adis16400.h into adis16400.c

Final part of the re-organization. Move the `adis16400.h` into
`adis16400.c` since it no longer needs to be shared among other files.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: imu: adis16400: rename adis16400_core.c -> adi16400.c
Alexandru Ardelean [Fri, 22 Mar 2019 20:44:41 +0000 (22:44 +0200)]
iio: imu: adis16400: rename adis16400_core.c -> adi16400.c

This change does a simple 1-to-1 rename of the adis16400_core.c file. Now
that the `adis16400_buffer.c` file was removed, everything can be moved
into a single driver file.
But first, this rename.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: imu: adis16400: move burst logic to ADIS lib
Alexandru Ardelean [Fri, 22 Mar 2019 20:44:40 +0000 (22:44 +0200)]
iio: imu: adis16400: move burst logic to ADIS lib

This change has been done separately, so that it's easier to visualize the
changed logic in the adis_scan_update() function.

Most of the function in this `adis16400_update_scan_mode()` that deals with
burst-mode will be re-used in the ADIS16480, but with different parameters.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: imu: adis: generalize burst mode support
Alexandru Ardelean [Fri, 22 Mar 2019 20:44:39 +0000 (22:44 +0200)]
iio: imu: adis: generalize burst mode support

Some variants in the ADIS16400 family support burst mode. This mechanism is
implemented in the `adis16400_buffer.c` file.

Some variants in ADIS16480 are also adding burst mode, which is
functionally similar to ADIS16400, but with different parameters. To get
there, a `adis_burst` struct is added to parametrize certain bits of the
SPI communication to setup: the register that triggers burst-mode, and the
extra-data-length that needs be accounted for when building the bust-length
buffer.

The trigger handler cannot be made generic, since it's very specific to
each ADIS164XX family.

A future enhancement of this `adis_burst` mode will be the possibility to
enable/disable burst-mode. For the ADIS16400 family it's hard-coded to on
by default. But for ADIS16480 there will be a need to disable this.

When that will be implemented, both ADIS16400 & ADIS16480 will have the
burst-mode enable-able/disable-able.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: imu: adis16400: move trigger handler into adis16400_core
Alexandru Ardelean [Fri, 22 Mar 2019 20:44:38 +0000 (22:44 +0200)]
iio: imu: adis16400: move trigger handler into adis16400_core

The trigger handler for the ADIS16400 is very different from the generic
one in the ADIS library. Keeping it in a separate file won't make much
sense once the update_scan_mode function will be made more generic and
moved into the ADIS library.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: adc: ad7280a: Remove CamelCase notation
Cristian Sicilia [Sat, 23 Mar 2019 19:21:49 +0000 (20:21 +0100)]
staging: iio: adc: ad7280a: Remove CamelCase notation

Fix CamelCase naming.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: adc: ad7280a: Adding temp var to improve readability
Cristian Sicilia [Sat, 23 Mar 2019 19:21:45 +0000 (20:21 +0100)]
staging: iio: adc: ad7280a: Adding temp var to improve readability

Creating a temporary variable to improve readability

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: adc: ad7280a: Avoid precedence issues in macro
Cristian Sicilia [Sat, 23 Mar 2019 19:21:42 +0000 (20:21 +0100)]
staging: iio: adc: ad7280a: Avoid precedence issues in macro

Enclosing parameter with parenthesis due to avoid
possible precedence issue.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoMAINTAINERS: add maintainer for maxbotix ultrasonic driver
Andreas Klinger [Sun, 17 Mar 2019 20:38:29 +0000 (21:38 +0100)]
MAINTAINERS: add maintainer for maxbotix ultrasonic driver

add a maintainer for the newly created ultrasonic driver family of maxbotix

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agomb1232.c: add distance iio sensor with i2c
Andreas Klinger [Sun, 17 Mar 2019 20:38:03 +0000 (21:38 +0100)]
mb1232.c: add distance iio sensor with i2c

Add I2CXL-MaxSonar ultrasonic distance sensors of types mb1202, mb1212,
mb1222, mb1232, mb1242, mb7040, mb7137 using an i2c interface

Implemented functionality:
- reading the distance via in_distance_raw
- buffered mode with trigger
- make use of interrupt to announce completion of ranging

Add mb1232 driver to Kconfig and Makefile

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: maxbotix,mb1232: Add MaxBotix i2c ultrasonic rangers
Andreas Klinger [Sun, 17 Mar 2019 20:35:27 +0000 (21:35 +0100)]
dt-bindings: maxbotix,mb1232: Add MaxBotix i2c ultrasonic rangers

Add doc for dt binding maxbotix,mb1232. This binding is for MaxBotix
I2CXL-MaxSonar ultrasonic rangers which share a common i2c interface.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: Add vendor prefix for MaxBotix
Andreas Klinger [Sun, 17 Mar 2019 20:35:00 +0000 (21:35 +0100)]
dt-bindings: Add vendor prefix for MaxBotix

Add MaxBotix, which is a vendor of ultrasonic rangers in different
varieties and interfaces.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: hmc5843: fix potential NULL pointer dereferences
Kangjie Lu [Sat, 16 Mar 2019 22:08:33 +0000 (17:08 -0500)]
iio: hmc5843: fix potential NULL pointer dereferences

devm_regmap_init_i2c may fail and return NULL. The fix returns
the error when it fails.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad5933: add ABI documentation
Marcelo Schmitt [Sat, 16 Mar 2019 15:07:32 +0000 (12:07 -0300)]
staging: iio: ad5933: add ABI documentation

Add an ABI documentation for the ad5933 driver.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad5933: change help rule message
Marcelo Schmitt [Sat, 16 Mar 2019 15:07:18 +0000 (12:07 -0300)]
staging: iio: ad5933: change help rule message

Remove the previous comment about direct access via sysfs which would
lead one think ad5933 driver has limitations it actually doesn't.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad5933: add SPDX identifier
Marcelo Schmitt [Sat, 16 Mar 2019 15:07:03 +0000 (12:07 -0300)]
staging: iio: ad5933: add SPDX identifier

Add SPDX identifier of GPL-2.0 for the ad5933 driver.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad5933: organize includes
Marcelo Schmitt [Sat, 16 Mar 2019 15:06:50 +0000 (12:06 -0300)]
staging: iio: ad5933: organize includes

Organize includes to list them in lexicographic order.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad5933: change multi-line comment style
Marcelo Schmitt [Sat, 16 Mar 2019 15:06:18 +0000 (12:06 -0300)]
staging: iio: ad5933: change multi-line comment style

Make multi-line comments compliant with the preferred code style.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad7780: add device tree binding
Renato Lui Geh [Sat, 16 Mar 2019 02:16:13 +0000 (23:16 -0300)]
staging: iio: ad7780: add device tree binding

Adds a device tree binding for the ad7780 driver.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad7780: moving ad7780 out of staging
Renato Lui Geh [Sat, 16 Mar 2019 02:15:55 +0000 (23:15 -0300)]
staging: iio: ad7780: moving ad7780 out of staging

Move ad7780 ADC driver out of staging and into the mainline.

The ad7780 is a sigma-delta analog to digital converter. This driver provides
reading voltage values and status bits from both the ad778x and ad717x series.
Its interface also allows writing on the FILTER and GAIN GPIO pins on the
ad778x.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Signed-off-by: Giuliano Belinassi <giuliano.belinassi@usp.br>
Co-developed-by: Giuliano Belinassi <giuliano.belinassi@usp.br>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad7780: add new copyright holder
Renato Lui Geh [Sat, 16 Mar 2019 02:15:26 +0000 (23:15 -0300)]
staging: iio: ad7780: add new copyright holder

This patch adds a new copyright holder to the ad7780 driver.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad7780: add SPDX identifier
Renato Lui Geh [Sat, 16 Mar 2019 02:15:13 +0000 (23:15 -0300)]
staging: iio: ad7780: add SPDX identifier

Add SPDX identifier (GPL-2.0) to the AD7780 driver.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad7780: move regulator to after GPIO init
Renato Lui Geh [Sat, 16 Mar 2019 02:14:59 +0000 (23:14 -0300)]
staging: iio: ad7780: move regulator to after GPIO init

To maintain consistency between ad7780_probe and ad7780_remove orders,
regulator initialization has been moved to after GPIO initializations.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging:iio:ad7780: add chip ID values and mask
Renato Lui Geh [Sat, 16 Mar 2019 02:14:27 +0000 (23:14 -0300)]
staging:iio:ad7780: add chip ID values and mask

The ad7780 supports both the ad778x and ad717x families. Each chip has
a corresponding ID. This patch provides a mask for extracting ID values
from the status bits and also macros for the correct values for the
ad7170, ad7171, ad7780 and ad7781.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad7780: set pattern values and masks directly
Renato Lui Geh [Sat, 16 Mar 2019 02:14:14 +0000 (23:14 -0300)]
staging: iio: ad7780: set pattern values and masks directly

The AD7780 driver contains status pattern bits designed for checking
whether serial transfers have been correctly performed. Pattern macros
were previously generated through bit fields. This patch sets good
pattern values directly and masks through GENMASK.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad7780: add filter reading to ad778x
Renato Lui Geh [Sat, 16 Mar 2019 02:13:42 +0000 (23:13 -0300)]
staging: iio: ad7780: add filter reading to ad778x

This patch adds the new feature of reading the filter odr value for
ad778x chips. This value is stored in the chip's state struct whenever a
read or write call is performed on the chip's driver.

This feature requires sharing SAMP_FREQ. Since the ad717x does not have
a filter option, the driver only shares the relevant info mask for the
ad778x family.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad7780: add gain reading to ad778x
Renato Lui Geh [Sat, 16 Mar 2019 02:13:13 +0000 (23:13 -0300)]
staging: iio: ad7780: add gain reading to ad778x

This patch adds a new functionality of reading gain values from the
ad778x chips. This value is stored in the chip's state struct and is
updated whenever a read or write call is performed on the driver.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad7780: add missing switch default case
Renato Lui Geh [Sat, 16 Mar 2019 02:12:53 +0000 (23:12 -0300)]
staging: iio: ad7780: add missing switch default case

This patch simply adds a missing switch default case in read_raw.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: ad7780: add gain & filter gpio support
Renato Lui Geh [Sat, 16 Mar 2019 02:12:27 +0000 (23:12 -0300)]
staging: iio: ad7780: add gain & filter gpio support

Previously, the AD7780 driver only supported gpio for the 'powerdown'
pin. This commit adds suppport for the 'gain' and 'filter' pin.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Signed-off-by: Giuliano Belinassi <giuliano.belinassi@usp.br>
Co-developed-by: Giuliano Belinassi <giuliano.belinassi@usp.br>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: iio: adc: lpc32xx-adc: Document vref-supply
Gregory CLEMENT [Fri, 15 Mar 2019 09:52:31 +0000 (10:52 +0100)]
dt-bindings: iio: adc: lpc32xx-adc: Document vref-supply

As most of the other ADC the lpc32xx one use a vref-supply property:
document it.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: lpc32xx: Add scale feature
Gregory CLEMENT [Fri, 15 Mar 2019 09:52:30 +0000 (10:52 +0100)]
iio: adc: lpc32xx: Add scale feature

Until now this driver only exposed the raw value of the channels. With
this patch, the scale value is also exposed.

It depends of a regulator supply, and unlike most of the other driver, do
not having this regulator won't prevent to use the driver. The reason for
it is to allow to continue to use this driver with an old device tree. If
there is no regulator supply then the scale won't be exposed.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: lpc32xx: Cleanup headers
Gregory CLEMENT [Fri, 15 Mar 2019 09:52:29 +0000 (10:52 +0100)]
iio: adc: lpc32xx: Cleanup headers

A few headers is useless: remove them.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: lpc32xx: Sort headers
Gregory CLEMENT [Fri, 15 Mar 2019 09:52:28 +0000 (10:52 +0100)]
iio: adc: lpc32xx: Sort headers

Sort the headers in alphabetic order in order to ease the maintenance for
this part.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: adc: ad7192: Convert platform data to DT properties
Mircea Caprioru [Fri, 15 Mar 2019 11:29:03 +0000 (13:29 +0200)]
staging: iio: adc: ad7192: Convert platform data to DT properties

This patch will remove platform data members and replace them with device
tree properties. These properties will be subject to further modifications
and probably replaced with other functionalities at some point in time.

Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: iio: imu: st_lsm6dsx: add lsm6dsox device bindings
Lorenzo Bianconi [Fri, 15 Mar 2019 10:08:25 +0000 (11:08 +0100)]
dt-bindings: iio: imu: st_lsm6dsx: add lsm6dsox device bindings

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: imu: st_lsm6dsx: add support to LSM6DSOX
Lorenzo Bianconi [Fri, 15 Mar 2019 10:08:24 +0000 (11:08 +0100)]
iio: imu: st_lsm6dsx: add support to LSM6DSOX

Add support to STM LSM6DSOX 6-axis (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/lsm6dsox.pdf

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: adc: ad7192: Report error directly in ad7192_setup
Mircea Caprioru [Fri, 15 Mar 2019 11:14:25 +0000 (13:14 +0200)]
staging: iio: adc: ad7192: Report error directly in ad7192_setup

This patch removes the goto out statement and uninformative
print message. This improves readability.

Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: adc: ad7192: Use DT clock binding
Mircea Caprioru [Fri, 15 Mar 2019 11:29:02 +0000 (13:29 +0200)]
staging: iio: adc: ad7192: Use DT clock binding

This patch replaces the platform data clock select member with DT clock
binding. Through the DT the external clock binding is specified. If this is
not provided then the device will use the internal clock source.

With the external clock binding there is the option to use a clock or a
crystal as the clock source. When an external crystal is used it is
connected to MCLK1 and MCLK2 pins. If the external clock is used only MCLK2
pin will be connected.

Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agostaging: iio: adc: ad7192: Fix identation
Mircea Caprioru [Fri, 15 Mar 2019 11:14:24 +0000 (13:14 +0200)]
staging: iio: adc: ad7192: Fix identation

This patch fixes the odd indentation inside function ad7192_calibrate_all.

Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: ad7124 fix indentation issue, remove extra tab
Colin Ian King [Thu, 14 Mar 2019 23:26:03 +0000 (23:26 +0000)]
iio: adc: ad7124 fix indentation issue, remove extra tab

A return statement is indented one level too deeply; clean this
up by removing a tab.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: cros_ec: Switch to SPDX identifier.
Enric Balletbo i Serra [Wed, 13 Mar 2019 11:41:20 +0000 (12:41 +0100)]
iio: cros_ec: Switch to SPDX identifier.

Adopt the SPDX license identifier headers to ease license compliance
management. Also fix MODULE_LICENSE for cros_ec_accel_legacy to match
the SPDX and boiler plate license.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: cros_ec: Add kernel-doc for cros_ec_sensors_read_lpc
Gwendal Grignou [Wed, 13 Mar 2019 11:40:50 +0000 (12:40 +0100)]
iio: cros_ec: Add kernel-doc for cros_ec_sensors_read_lpc

Document cros_ec_sensors_read_lpc, adding an additional note to explain
that this is the safe function for reading the EC data.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: cros_ec: Drop unnecessary include files
Guenter Roeck [Wed, 13 Mar 2019 11:40:32 +0000 (12:40 +0100)]
iio: cros_ec: Drop unnecessary include files

The cros_ec sensors drivers do not call any sysfs functions
or use any sysfs defines, and thus do not need to include
linux/sysfs.h. Also, some cros_ec drivers include linux/delay.h
and is not used.

Signed-off-by: Guenter Roeck <groeck@chromium.org>
[remove linux/delay.h]
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: pressure: bmp280: BMP280 calibration to entropy
Linus Walleij [Tue, 12 Mar 2019 08:40:18 +0000 (09:40 +0100)]
iio: pressure: bmp280: BMP280 calibration to entropy

The BMP280/BME280 calibration data should also go into the
entropy pool, like we do for BMP180.

This just adds the temperature and pressure calibration, the
humidity calibration seems like too much annoying calls to
add.

Cc: Tomasz Duszynski <tduszyns@gmail.com>
Cc: Stefan Tatschner <stefan.tatschner@gmail.com>
Cc: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: iio: imu: adis16480: Document external clock
Stefan Popa [Mon, 11 Mar 2019 09:46:37 +0000 (11:46 +0200)]
dt-bindings: iio: imu: adis16480: Document external clock

Add documentation for optional use of external clock. All devices
supported by this driver can work with an external clock in sync mode.
Another mode, called Pulse Per Second (PPS) is supported only by adis1649x
devices. The mode is selected by using the "clock-names" property.

The pin which is used as external clock input is selected by using a
custom optional property called "adi,ext-clk-pin". If this field is left
empty, DIO2 is assigned as default external clock input pin.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: imu: adis16480: Add support for external clock
Stefan Popa [Mon, 11 Mar 2019 09:45:29 +0000 (11:45 +0200)]
iio: imu: adis16480: Add support for external clock

Inertial sensor data collection and processing can be controlled by
configuring one of the DIOx lines as an external clock input. This
option is available for all devices supported by this driver. However,
only adis1649x devices support different modes for the external clock.

Sync mode is supported by all devices. In this mode, the output data
rate is equal with the clock frequency divided by DEC_RATE + 1. This
mode of calculation is similar with the case when the internal clock is
used.

Pulse Per Second (PPS) Mode, is only supported by adis1649x devices. In
this mode, the output data rate is equal to the product of the external
clock frequency and the scale factor in the SYNC_SCALE register.

This patch uses the "clock-names" property to enable the external clock
in one of the two supported modes: "sync" or "pps". This property is
optional. If it is not specified, the internal clock is used.

This patch also offers the option to select the DIOx line to be used as
an external clock input via the custom "adi,ext-clk-pin" property. If this
field is left empty, DIO2 is assigned as default external clock input pin.
Each DIOx pin supports only one function at a time (data ready line
selection or external clock input).

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio:dac:ad5064 mlock cleanup - move to a local lock.
Jonathan Cameron [Wed, 20 Feb 2019 18:23:44 +0000 (18:23 +0000)]
iio:dac:ad5064 mlock cleanup - move to a local lock.

indio_dev->mlock is intended to protect state transitions in
the core. It's scope is tightly defined. For device specific
uses such as those made here, we should define a local lock
allowing the scope of the lock to be defined near to what it
is protecting.

These mlock changes can be non obvious, but given we don't do
anything other than direct for DACs, these ones are easy to do.

If anyone wants to help with this particular effort it would
be most welcome!

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodrivers: iio: Kconfig: pedantic cleanup
Enrico Weigelt, metux IT consult [Wed, 6 Mar 2019 14:52:23 +0000 (15:52 +0100)]
drivers: iio: Kconfig: pedantic cleanup

Formatting of Kconfig files doesn't look so pretty, so just
take damp cloth and clean it up.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: stmpe-adc: Shuffle an if statement around in stmpe_adc_isr
Nathan Chancellor [Thu, 7 Mar 2019 17:16:04 +0000 (10:16 -0700)]
iio: adc: stmpe-adc: Shuffle an if statement around in stmpe_adc_isr

When building with -Wsometimes-uninitialized, Clang warns:

drivers/iio/adc/stmpe-adc.c:204:13: warning: variable 'data' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

Clang can't tell that data will never be used uninitialized because the
two if statements take care of all cases. Remove the first if statement
and make it the else branch of the second one so that it is apparent to
Clang that all cases are covered.

Link: https://github.com/ClangBuiltLinux/linux/issues/387
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: NIck Desaulniers <ndesaulniers@google.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: common: ssp_sensors: Initialize calculated_time in ssp_common_process_data
Nathan Chancellor [Thu, 7 Mar 2019 21:45:46 +0000 (14:45 -0700)]
iio: common: ssp_sensors: Initialize calculated_time in ssp_common_process_data

When building with -Wsometimes-uninitialized, Clang warns:

drivers/iio/common/ssp_sensors/ssp_iio.c:95:6: warning: variable
'calculated_time' is used uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]

While it isn't wrong, this will never be a problem because
iio_push_to_buffers_with_timestamp only uses calculated_time
on the same condition that it is assigned (when scan_timestamp
is not zero). While iio_push_to_buffers_with_timestamp is marked
as inline, Clang does inlining in the optimization stage, which
happens after the semantic analysis phase (plus inline is merely
a hint to the compiler).

Fix this by just zero initializing calculated_time.

Link: https://github.com/ClangBuiltLinux/linux/issues/394
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: proximity: as3935: fix use-after-free on device remove
Sven Van Asbroeck [Fri, 8 Mar 2019 17:59:35 +0000 (12:59 -0500)]
iio: proximity: as3935: fix use-after-free on device remove

This driver's probe() uses a mix of devm_ and non-devm_ functions. This
means that the remove order will not be the exact opposite of the probe
order.

Remove order:
1. remove() executes:
iio_device_unregister
iio_triggered_buffer_cleanup
iio_trigger_unregister
(A)
2. core frees devm resources in reverse order:
free_irq
iio_trigger_free
iio_device_free

In (A) the trigger has been unregistered, but the irq handler is still
registered and active, so the trigger may still be touched via
interrupt -> as3935_event_work. This is a potential use-after-unregister.

Given that the delayed work is never canceled explicitly, it may run even
after iio_device_free. This is a potential use-after-free.

Solution: convert all probe functions to their devm_ equivalents.
Add a devm callback, called by the core on remove right after irq_free,
which explicitly cancels the delayed work. This will guarantee that all
resources are freed in the correct order.

As an added bonus, some boilerplate code can be removed.

Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio:potentiostat:lmp91000: change dev_err message
Anderson Reis [Fri, 8 Mar 2019 19:46:55 +0000 (16:46 -0300)]
iio:potentiostat:lmp91000: change dev_err message

Change dev_err message on line 215 in order to inform that
tia-gain-ohm is not defined and an external resistor is not
specified.

Signed-off-by: Anderson Reis <andersonreisrosa@gmail.com>
Signed-off-by: Lucas Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio:potentiostat:lmp91000: invert if statement
Anderson Reis [Fri, 8 Mar 2019 19:46:54 +0000 (16:46 -0300)]
iio:potentiostat:lmp91000: invert if statement

Invert if statement arms in line 214, in order to make the code cleaner,
solve these checkpatch.pl CHECKs:

- lmp9100.c:214: CHECK: braces {} should be used on all arms of this statement
- lmp9100.c:216: CHECK: Unbalanced braces around else statement

Signed-off-by: Lucas Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: Anderson Reis <andersonreisrosa@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio:potentiostat:lmp91000: reduce line width and remove blank line
Anderson Reis [Fri, 8 Mar 2019 19:46:53 +0000 (16:46 -0300)]
iio:potentiostat:lmp91000: reduce line width and remove blank line

Break the line 258 in order fit the line width on 80 characters. Remove
the blank line 279, as the line before is also a blank line. Solve these
checkpath.el WARNING and CHECK:

- lmp91000.c:258: WARNING: line over 80 characters
- lmp91000.c:279: CHECK: Please don't use multiple blank lines

Signed-off-by: Lucas Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: Anderson Reis <andersonreisrosa@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio:potentiostat:lmp91000: remove unnecessary parentheses
Lucas Oshiro [Fri, 8 Mar 2019 19:46:52 +0000 (16:46 -0300)]
iio:potentiostat:lmp91000: remove unnecessary parentheses

Remove unnecessary parentheses on line 116.

Signed-off-by: Lucas Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: Anderson Reis <andersonreisrosa@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: ti-ads7950: add GPIO support
Justin Chen [Fri, 8 Mar 2019 22:03:28 +0000 (14:03 -0800)]
iio: adc: ti-ads7950: add GPIO support

The ADS79XX has GPIO pins that can be used. Add support for the GPIO
pins using the GPIO chip framework.

Signed-off-by: Justin Chen <justinpopo6@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: fix a potential NULL pointer dereference
Kangjie Lu [Sat, 9 Mar 2019 04:53:55 +0000 (22:53 -0600)]
iio: adc: fix a potential NULL pointer dereference

devm_iio_trigger_alloc may fail and return NULL. The fix returns
ENOMEM when it fails.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: dac: ti-dac5571: Update the module author email address
Sean Nyekjaer [Tue, 5 Mar 2019 07:36:27 +0000 (08:36 +0100)]
iio: dac: ti-dac5571: Update the module author email address

Update the module author to the current email address

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: adc: ti-ads8688: Update the module author email address
Sean Nyekjaer [Tue, 5 Mar 2019 07:36:26 +0000 (08:36 +0100)]
iio: adc: ti-ads8688: Update the module author email address

Update the module author to the current email address.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agoiio: accel: kxcjk1013: Add device tree support
Robert Yang [Mon, 4 Mar 2019 15:19:12 +0000 (10:19 -0500)]
iio: accel: kxcjk1013: Add device tree support

Add device tree support for kxcjk-1013 accelerometer sensors.

Signed-off-by: Robert Yang <decatf@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: iio: accel: kxcjk1013: Add device tree binding documentation
Robert Yang [Mon, 4 Mar 2019 15:19:11 +0000 (10:19 -0500)]
dt-bindings: iio: accel: kxcjk1013: Add device tree binding documentation

Document device tree bindings for Kionix KXCJK-1013 Accelerometer driver.

Signed-off-by: Robert Yang <decatf@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
5 years agodt-bindings: Add vendor prefix for Kionix, Inc.
Robert Yang [Mon, 4 Mar 2019 15:19:10 +0000 (10:19 -0500)]
dt-bindings: Add vendor prefix for Kionix, Inc.

Kionix manufactured MEMs sensors. There are Kionix acceleromoter sensor
drivers which can be used with device tree.

Signed-off-by: Robert Yang <decatf@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>