openwrt/staging/blogic.git
4 years agoiio: trigger: stm32-timer: add power management support
Fabrice Gasnier [Tue, 3 Mar 2020 14:59:45 +0000 (15:59 +0100)]
iio: trigger: stm32-timer: add power management support

Add suspend/resume PM sleep ops to stm32-timer-trigger driver.
Register contents may be lost depending on low power modes.
When going to low power, enforce the timer isn't active. Gracefully
restore its state upon resume in case it's been left enabled prior to
suspend.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: trigger: stm32-timer: rename enabled flag
Fabrice Gasnier [Tue, 3 Mar 2020 14:59:44 +0000 (15:59 +0100)]
iio: trigger: stm32-timer: rename enabled flag

"clk_enabled" flag reflects enabled state of the timer, for master mode,
slave mode or trigger (with sampling_frequency). So rename it to "enabled".

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: add a TODO
Rohit Sarkar [Sat, 29 Feb 2020 14:37:21 +0000 (20:07 +0530)]
iio: add a TODO

This patch adds a TODO file with some work items added with reference to
the conversation in [1].
A TODO file is immensely useful while onboarding new contributors who
are looking for some low hanging fruit to get their foot into the door.
Since these items affect all drivers the file has been placed in the
root iio directory instead of augmenting the staging TODO.

Thanks,
Rohit

[1]: https://marc.info/?l=linux-iio&m=158256721009892&w=2
Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agocounter: 104-quad-8: Support Differential Encoder Cable Status
William Breathitt Gray [Sun, 1 Mar 2020 22:07:19 +0000 (17:07 -0500)]
counter: 104-quad-8: Support Differential Encoder Cable Status

The ACCES 104-QUAD-8 series provides status information about the
connection state of the differential encoder cable inputs. This patch
implements support to expose such information from these devices.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agocounter: 104-quad-8: Support Filter Clock Prescaler
William Breathitt Gray [Sat, 22 Feb 2020 16:49:58 +0000 (11:49 -0500)]
counter: 104-quad-8: Support Filter Clock Prescaler

The ACCES 104-QUAD-8 series does active filtering on the quadrature
input signals via the PC/104 bus clock (OSC 14.318 MHz). This patch
exposes the filter clock prescaler available on each channel.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: pressure: icp10100: add driver for InvenSense ICP-101xx
Jean-Baptiste Maneyrol [Fri, 21 Feb 2020 20:11:23 +0000 (21:11 +0100)]
iio: pressure: icp10100: add driver for InvenSense ICP-101xx

InvenSense ICP-101xx sensors are a family of barometric pressure
and temperature sensor.

These devices are I2C only and use a specific protocol of
commands/responses. Data transfer is secured by using crc8.

Driver provides processed pressure and raw temperature data.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: industrialio-core: Fix debugfs read
Alexandru Tachici [Fri, 21 Feb 2020 12:06:55 +0000 (14:06 +0200)]
iio: industrialio-core: Fix debugfs read

Currently iio_debugfs_read_reg calls debugfs_reg_access
every time it is ran. Reading the same hardware register
multiple times during the same reading of a debugfs file
can cause unintended effects.

For example for each: cat iio:device0/direct_reg_access
the file_operations.read function will be called at least
twice. First will return the full length of the string in
bytes  and the second will return 0.

This patch makes iio_debugfs_read_reg to call debugfs_reg_access
only when the user's buffer position (*ppos) is 0. (meaning
it is the beginning of a new reading of the debugfs file).

Fixes: e553f182d55b ("staging: iio: core: Introduce debugfs support, add support for direct register access")
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: imu: adis: add a note better explaining state_lock
Alexandru Ardelean [Tue, 25 Feb 2020 10:33:19 +0000 (12:33 +0200)]
iio: imu: adis: add a note better explaining state_lock

The 'state_lock' mutex was renamed from 'txrx_lock' in a previous patch and
is intended to be used by ADIS drivers to protect the state of devices
during consecutive R/W ops.
The initial patch that introduced this change did not do a good [well, any]
job at explaining this. This patch adds a comment to the 'state_lock'
better explaining it's use.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: imu: adis: update 'adis_data' struct doc-string
Alexandru Ardelean [Tue, 25 Feb 2020 10:33:18 +0000 (12:33 +0200)]
iio: imu: adis: update 'adis_data' struct doc-string

The doc-string has been neglected over time.
This change updates it with all the missing info.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: imu: adis: add doc-string for 'adis' struct
Alexandru Ardelean [Tue, 25 Feb 2020 10:33:17 +0000 (12:33 +0200)]
iio: imu: adis: add doc-string for 'adis' struct

This change adds a doc-string for the 'adis' struct. It details the fields
and their roles.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: imu: adis_buffer: Use new structure for SPI transfer delays
Sergiu Cuciurean [Thu, 27 Feb 2020 12:38:59 +0000 (14:38 +0200)]
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 bebcfd272df6 ("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>
4 years agoiio: adc: ti-tlc4541: Use new structure for SPI transfer delays
Sergiu Cuciurean [Thu, 27 Feb 2020 12:34:27 +0000 (14:34 +0200)]
iio: adc: ti-tlc4541: 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 bebcfd272df6 ("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>
4 years agoiio: adc: mcp320x: Use new structure for SPI transfer delays
Sergiu Cuciurean [Thu, 27 Feb 2020 12:29:40 +0000 (14:29 +0200)]
iio: adc: mcp320x: 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 bebcfd272df6 ("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>
4 years agoiio: adc: max1118: Use new structure for SPI transfer delays
Sergiu Cuciurean [Thu, 27 Feb 2020 12:25:15 +0000 (14:25 +0200)]
iio: adc: max1118: 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 bebcfd272df6 ("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>
4 years agoiio: adc: ad9292: Use new structure for SPI transfer delays
Sergiu Cuciurean [Thu, 27 Feb 2020 12:18:14 +0000 (14:18 +0200)]
iio: adc: ad9292: 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 bebcfd272df6 ("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>
4 years agoiio: adc: exynos: Silence warning about regulators during deferred probe
Marek Szyprowski [Fri, 28 Feb 2020 09:21:21 +0000 (10:21 +0100)]
iio: adc: exynos: Silence warning about regulators during deferred probe

Don't confuse user with meaningless warning about the failure in getting
regulators in case of deferred probe.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agostaging: iio: update TODO
Rohit Sarkar [Sat, 29 Feb 2020 14:05:45 +0000 (19:35 +0530)]
staging: iio: update TODO

Since there are no uses of the old GPIO API, remove the item from
the TODO.

Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: amplifiers: ad8366: add support for HMC1119 Attenuator
Sergiu Cuciurean [Fri, 21 Feb 2020 16:18:26 +0000 (18:18 +0200)]
iio: amplifiers: ad8366: add support for HMC1119 Attenuator

This change adds support for the HMC1119 Silicon Digial Attenuator. The
HMC1119 is a broadband, highly accurate, 7-bit digital attenuator,
operating from 0.1 GHz to 6.0 GHz with 31.5 dB attenuation control range
in 0.25 dB steps.

Link: https://www.analog.com/media/en/technical-documentation/data-sheets/hmc1119.pdf
Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: si1133: read 24-bit signed integer for measurement
Maxime Roussin-Bélanger [Wed, 19 Feb 2020 17:40:08 +0000 (12:40 -0500)]
iio: si1133: read 24-bit signed integer for measurement

The chip is configured in 24 bit mode. The values read from
it must always be treated as is. This fixes the issue by
replacing the previous 16 bits value by a 24 bits buffer.

This changes affects the value output by previous version of
the driver, since the least significant byte was missing.
The upper half of 16 bit values previously output are now
the upper half of a 24 bit value.

Fixes: e01e7eaf37d8 ("iio: light: introduce si1133")
Reported-by: Simon Goyette <simon.goyette@gmail.com>
Co-authored-by: Guillaume Champagne <champagne.guillaume.c@gmail.com>
Signed-off-by: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com>
Signed-off-by: Guillaume Champagne <champagne.guillaume.c@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: dac: Add docs for AD5770R DAC
Alexandru Tachici [Tue, 18 Feb 2020 12:10:31 +0000 (14:10 +0200)]
dt-bindings: iio: dac: Add docs for AD5770R DAC

Adding dt-bindings documentation for AD5770R DAC.

Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: dac: ad5770r: Add AD5770R support
Alexandru Tachici [Tue, 18 Feb 2020 12:10:30 +0000 (14:10 +0200)]
iio: dac: ad5770r: Add AD5770R support

The AD5770R is a 6-channel, 14-bit resolution, low noise, programmable
current output digital-to-analog converter (DAC) for photonics control
applications.

It contains five 14-bit resolution current sourcing DAC channels and one
14-bit resolution current sourcing/sinking DAC channel.

Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: light: Simplify the current to lux LUT
Gregor Riepl [Thu, 20 Feb 2020 21:20:53 +0000 (22:20 +0100)]
iio: light: Simplify the current to lux LUT

The look-up-table for currens to lux is simply specifying
all currents from 5..47 mA, if we add some values for 0..5
we can just select the index for the lux value in an array
from the mA value. Use clamp() to get the value in the
range of values in the array.

Cc: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Gregor Riepl <onitake@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: adc: ad7923: Add binding documentation for AD7928
Daniel Junho [Tue, 18 Feb 2020 11:06:47 +0000 (08:06 -0300)]
dt-bindings: iio: adc: ad7923: Add binding documentation for AD7928

This patch add device tree binding documentation for AD7923 adc in YAML
format.

Signed-off-by: Daniel Junho <djunho@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: chemical: consolidate atlas-sensor docs
Matt Ranostay [Tue, 18 Feb 2020 03:42:39 +0000 (19:42 -0800)]
dt-bindings: iio: chemical: consolidate atlas-sensor docs

Since Atlas Scientific device support only varies from the compatible
string is ideal all the respective docs are merged into a single doc
named atlas,sensor.yaml

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: chemical: atlas-sensor: add DO-SM module support
Matt Ranostay [Tue, 18 Feb 2020 03:42:38 +0000 (19:42 -0800)]
iio: chemical: atlas-sensor: add DO-SM module support

Atlas Scientific DO-SM OEM sensor reads disolved oxygen in
a solution. This is reported back as mg/L which maps directly
to ppm and so the IIO_CONCENTRATION channel type can be used.

Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: chemical: atlas-sensor: allow probe without interrupt line
Matt Ranostay [Tue, 18 Feb 2020 03:42:37 +0000 (19:42 -0800)]
iio: chemical: atlas-sensor: allow probe without interrupt line

Sensors don't actually need a interrupt line to give valid readings,
and can triggered with CONFIG_IIO_HRTIMER_TRIGGER as well. Remove
the required check for interrupt, and continue along in the probe
function.

Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: imu: inv_mpu6050: temperature only work with accel/gyro
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:58 +0000 (15:39 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: use runtime pm with autosuspend
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:57 +0000 (15:39 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: dynamic sampling rate change
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:56 +0000 (15:39 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: factorize fifo enable/disable
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:55 +0000 (15:39 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: fix data polling interface
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:54 +0000 (15:39 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: rewrite power and engine management
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:53 +0000 (15:39 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: reduce sleep time when turning regulators on
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:52 +0000 (15:39 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: add all signal path resets at init
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:51 +0000 (15:39 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: early init of chip_config for use at setup
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:50 +0000 (15:39 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: simplify polling magnetometer
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:49 +0000 (15:39 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: set power on/off only once during all init
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:48 +0000 (15:39 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: delete useless check
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:47 +0000 (15:39 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: enable i2c aux mux bypass only once
Jean-Baptiste Maneyrol [Wed, 19 Feb 2020 14:39:46 +0000 (15:39 +0100)]
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>
4 years agodt-bindings: iio: adc: max1363 etc i2c ADC binding conversion
Jonathan Cameron [Sat, 8 Feb 2020 17:23:12 +0000 (17:23 +0000)]
dt-bindings: iio: adc: max1363 etc i2c ADC binding conversion

Split the binding in two to reflect the threshold monitor capabilities
and hence interrupts vs the more straight forward parts that
don't have this facility.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
4 years agoiio: trigger: stm32-timer: enable clock when in master mode
Fabrice Gasnier [Fri, 14 Feb 2020 16:23:57 +0000 (17:23 +0100)]
iio: trigger: stm32-timer: enable clock when in master mode

Clock should be enabled as soon as using master modes, even before
enabling timer. Or, this may provoke bad behavior on the other end
(slave timer). Then, introduce 'clk_enabled' flag, instead of relying
on CR1 EN bit, to keep track of clock being enabled (balanced refcount).
Propagate this anywhere else in the driver.

Also add 'remove' routine to stop timer and disable clock in case it
has been left enabled. Enforce the user interface has been unregistered
in the remove routine, before disabling the hardware to avoid possible
race. So, remove use of devm_ variant to register triggers and unregister
them before the hardware gets disabled [1].
[1] https://patchwork.kernel.org/patch/9956247/

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: light: al3320a allow module autoload and polish
David Heidelberg [Tue, 11 Feb 2020 19:12:01 +0000 (20:12 +0100)]
iio: light: al3320a allow module autoload and polish

- allow autoloading when build as module and defined inside DT

Signed-off-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: light: al3320a implement devm_add_action_or_reset
David Heidelberg [Tue, 11 Feb 2020 19:12:00 +0000 (20:12 +0100)]
iio: light: al3320a implement devm_add_action_or_reset

Use devm_add_action_or_reset to automatically disable the device
and allow you to get rid of the remove function entirely.

Signed-off-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: light: al3320a implement suspend support
David Heidelberg [Tue, 11 Feb 2020 19:11:59 +0000 (20:11 +0100)]
iio: light: al3320a implement suspend support

AL3320a is fairly simple chip, so for suspend is enough to disable and
later enable it again.

Signed-off-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: light: add Dyna-Image AL3010 driver
David Heidelberg [Fri, 14 Feb 2020 22:09:17 +0000 (23:09 +0100)]
iio: light: add Dyna-Image AL3010 driver

Based on:
- 3320A in-kernel driver
- https://www.spinics.net/lists/linux-iio/msg25145.html
- https://lore.kernel.org/patchwork/patch/684179/

I decided to keep it aside of AL3320A due to different approach and much
simpler design of 3010.

Tested on Nexus 7 2012 (grouper/tilapia).

Tested-by: David Heidelberg <david@ixit.cz>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: light: al3320a slightly improve code formatting
David Heidelberg [Tue, 11 Feb 2020 19:11:57 +0000 (20:11 +0100)]
iio: light: al3320a slightly improve code formatting

- modified to be in part with al3010 driver
- cleanup using bitfield, no functionality change intended

Signed-off-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: light: add support for Dyna-Image AL3010
David Heidelberg [Tue, 11 Feb 2020 19:11:56 +0000 (20:11 +0100)]
dt-bindings: iio: light: add support for Dyna-Image AL3010

The Dyna-Image AL3010 is a 16-bit digital ambient light sensor which
provides a multiple gain function with linear response over a dynamic
range 1216/4863/19452/77806.

Signed-off-by: David Heidelberg <david@ixit.cz>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: light: add support for Dyna-Image AL3320A
David Heidelberg [Tue, 11 Feb 2020 19:11:55 +0000 (20:11 +0100)]
dt-bindings: iio: light: add support for Dyna-Image AL3320A

This commit add dt-bindings support to al3320a driver and vendor-prefix
dynaimage.
Partly based on unmerged commit:
"iio: Add Dyna-Image AP3223 ambient light and proximity driver"

Signed-off-by: David Heidelberg <david@ixit.cz>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agostaging: iio: adc: ad7192: move out of staging
Alexandru Tachici [Wed, 12 Feb 2020 16:17:21 +0000 (18:17 +0200)]
staging: iio: adc: ad7192: move out of staging

Move ad7192 ADC driver out of staging into mainline.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoDocumentation: ABI: testing: ad7192: update sysfs docs
Alexandru Tachici [Wed, 12 Feb 2020 16:17:20 +0000 (18:17 +0200)]
Documentation: ABI: testing: ad7192: update sysfs docs

Updated mainline documentation on ad7192 userspace sysfs.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agostaging: iio: adc: ad7192: removed spi_device_id
Alexandru Tachici [Wed, 12 Feb 2020 16:17:19 +0000 (18:17 +0200)]
staging: iio: adc: ad7192: removed spi_device_id

This patch removes spi_device_id table and moves the
init data (id of the chip) in the .data field
of of_device_id table.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agostaging: iio: adc: ad7192: modify iio_chan_spec array
Alexandru Tachici [Wed, 12 Feb 2020 16:17:18 +0000 (18:17 +0200)]
staging: iio: adc: ad7192: modify iio_chan_spec array

This patch changes the static const struct iio_chan_spec arrays
in a way that all the necessary attributes are set at
compile time. Now ad7192_channels_config only makes the
channels attribute of iio_dev point to the right array depending
on the chip.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agostaging: iio: adc: ad7192: fail probe on get_voltage
Alexandru Tachici [Wed, 12 Feb 2020 16:17:17 +0000 (18:17 +0200)]
staging: iio: adc: ad7192: fail probe on get_voltage

This patch makes the ad7192_probe fail in case
regulator_get_voltage will return an error or voltage
is set to 0.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adc: ad7124: Add direct reg access
Mircea Caprioru [Tue, 11 Feb 2020 08:44:53 +0000 (10:44 +0200)]
iio: adc: ad7124: Add direct reg access

This patch adds the posibility do read and write registers from userspace
using the kernel debug direct register access option.

Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adis16460: Make use of __adis_initial_startup
Nuno Sá [Mon, 10 Feb 2020 13:26:06 +0000 (15:26 +0200)]
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>
4 years agoiio: adis16480: Make use of __adis_initial_startup
Nuno Sá [Mon, 10 Feb 2020 13:26:05 +0000 (15:26 +0200)]
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>
4 years agoiio: imu: adis: add support product ID check in adis_initial_startup
Alexandru Ardelean [Mon, 10 Feb 2020 13:26:04 +0000 (15:26 +0200)]
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>
4 years agoiio: imu: adis: Refactor adis_initial_startup
Nuno Sá [Mon, 10 Feb 2020 13:26:03 +0000 (15:26 +0200)]
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>
4 years agoiio: imu: adis: Add self_test_reg variable
Nuno Sá [Mon, 10 Feb 2020 13:26:02 +0000 (15:26 +0200)]
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>
4 years agoiio: imu: adis: add unlocked __adis_initial_startup()
Alexandru Ardelean [Mon, 10 Feb 2020 13:26:01 +0000 (15:26 +0200)]
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>
4 years agoiio: gyro: adis16136: initialize adis_data statically
Alexandru Ardelean [Mon, 10 Feb 2020 13:26:00 +0000 (15:26 +0200)]
iio: gyro: adis16136: initialize adis_data statically

This change overrides commit 380b107bbf944 ("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>
4 years agoiio: imu: adis16400: initialize adis_data statically
Alexandru Ardelean [Mon, 10 Feb 2020 13:25:59 +0000 (15:25 +0200)]
iio: imu: adis16400: initialize adis_data statically

This change overrides commit 380b107bbf944 ("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>
4 years agoiio: imu: adis16480: initialize adis_data statically
Alexandru Ardelean [Mon, 10 Feb 2020 13:25:58 +0000 (15:25 +0200)]
iio: imu: adis16480: initialize adis_data statically

This change overrides commit 380b107bbf944 ("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>
4 years agoiio: imu: st_lsm6dsx: check return value from st_lsm6dsx_sensor_set_enable
Lorenzo Bianconi [Fri, 7 Feb 2020 12:37:54 +0000 (13:37 +0100)]
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>
4 years agoMAINTAINERS: add entry for hmc425a driver.
Beniamin Bia [Thu, 6 Feb 2020 15:11:49 +0000 (17:11 +0200)]
MAINTAINERS: add entry for hmc425a driver.

Add Beniamin Bia and Michael Hennerich as maintainers for HMC425A
attenuator.

Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: amplifiers: Add docs for HMC425A Step Attenuator
Michael Hennerich [Thu, 6 Feb 2020 15:11:48 +0000 (17:11 +0200)]
dt-bindings: iio: amplifiers: Add docs for HMC425A Step Attenuator

Document support for Analog Devices MC425A Step Attenuator.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
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>
4 years agoiio: amplifiers: hmc425a: Add support for HMC425A attenuator
Michael Hennerich [Thu, 6 Feb 2020 15:11:47 +0000 (17:11 +0200)]
iio: amplifiers: hmc425a: Add support for HMC425A attenuator

This patch adds support for the HMC425A 0.5 dB LSB GaAs MMIC 6-BIT
DIGITAL POSITIVE CONTROL ATTENUATOR, 2.2 - 8.0 GHz.

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

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: amplifiers: ad8366: Add write_raw_get_fmt function
Beniamin Bia [Thu, 6 Feb 2020 15:11:46 +0000 (17:11 +0200)]
iio: amplifiers: ad8366: Add write_raw_get_fmt function

This patch add write_raw_get_fmt function to specify conversion for
hardware gain.

Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: core: Handle 'dB' suffix in core
Beniamin Bia [Thu, 6 Feb 2020 15:11:45 +0000 (17:11 +0200)]
iio: core: Handle 'dB' suffix in core

This patch handles the db suffix used for writing micro db values.

Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agocounter: stm32-timer-cnt: remove iio headers
Fabrice Gasnier [Tue, 11 Feb 2020 10:56:06 +0000 (11:56 +0100)]
counter: stm32-timer-cnt: remove iio headers

The stm32-timer-cnt driver doesn't use the iio interface. The iio headers
aren't relevant and can be removed as reported by William in [1].
With this change, mod_devicetable.h needs to be added to define the
'of_device_id' struct.

[1] https://lkml.org/lkml/2020/2/10/1516

Reported-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agocounter: stm32-timer-cnt: add power management support
Fabrice Gasnier [Mon, 10 Feb 2020 17:19:58 +0000 (18:19 +0100)]
counter: stm32-timer-cnt: add power management support

Add suspend/resume PM sleep ops. When going to low power, enforce the
counter isn't active. Gracefully restore its state upon resume in case
it's been left enabled prior to suspend.

Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: add description for new supported chips
Jean-Baptiste Maneyrol [Thu, 6 Feb 2020 10:31:05 +0000 (11:31 +0100)]
dt-bindings: add description for new supported chips

Add missing mpu6000 and new icm20609, icm20689, icm20690, and
iam20680.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: imu: inv_mpu6050: update LPF bandwidth settings
Jean-Baptiste Maneyrol [Thu, 6 Feb 2020 10:31:04 +0000 (11:31 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: add support of ICM20690
Jean-Baptiste Maneyrol [Thu, 6 Feb 2020 10:31:03 +0000 (11:31 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: add support of IAM20680
Jean-Baptiste Maneyrol [Thu, 6 Feb 2020 10:31:02 +0000 (11:31 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: add support of ICM20609 & ICM20689
Jean-Baptiste Maneyrol [Thu, 6 Feb 2020 10:31:01 +0000 (11:31 +0100)]
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>
4 years agoiio: imu: inv_mpu6050: cleanup of/acpi support
Jean-Baptiste Maneyrol [Thu, 6 Feb 2020 10:31:00 +0000 (11:31 +0100)]
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>
4 years agoiio: adc: modify NPCM reset support
Tomer Maimon [Mon, 3 Feb 2020 15:09:17 +0000 (17:09 +0200)]
iio: adc: modify NPCM reset support

Modify NPCM ADC reset support from
direct register access to reset controller support.

please make sure to modify NPCM adc device tree
parameters as described at nuvoton,npcm-adc.txt
document for using this change.

Note for anyone noting that this is a breaking change, this is on
a BMC and effectively in a close ecosystem so it is fine to rely
on DT and kernel being updated together.

Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-binding: iio: add NPCM ADC reset support
Tomer Maimon [Mon, 3 Feb 2020 15:09:16 +0000 (17:09 +0200)]
dt-binding: iio: add NPCM ADC reset support

Add NPCM ADC reset binding documentation.

Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: vcnl4000: Enable runtime pm for vcnl4200/4040
Guido Günther [Mon, 3 Feb 2020 09:17:02 +0000 (10:17 +0100)]
iio: vcnl4000: Enable runtime pm for vcnl4200/4040

This is modelled after the vcnl4035 driver. For the vcnl40{0,1,2}0
we don't do anything since they use on demand measurement.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: vcnl4000: Use a single return when getting IIO_CHAN_INFO_RAW
Guido Günther [Mon, 3 Feb 2020 09:17:01 +0000 (10:17 +0100)]
iio: vcnl4000: Use a single return when getting IIO_CHAN_INFO_RAW

This will be useful when introducing runtime pm.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: dac: ltc2632: remove some unused defines
Uwe Kleine-König [Mon, 3 Feb 2020 20:31:26 +0000 (21:31 +0100)]
iio: dac: ltc2632: remove some unused defines

These two defines are unused since the driver was introduced in commit
02b829f9e11f ("iio: dac: Add support for ltc2632 DACs").

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: dac: ltc2632: add support for LTC2636 family
Uwe Kleine-König [Thu, 30 Jan 2020 13:15:49 +0000 (14:15 +0100)]
iio: dac: ltc2632: add support for LTC2636 family

The only difference between LTC2632 and LTC2636 is that the former has
two DAC channels while the latter has eight.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: dac: ltc2632: drop some duplicated data
Uwe Kleine-König [Thu, 30 Jan 2020 13:15:48 +0000 (14:15 +0100)]
iio: dac: ltc2632: drop some duplicated data

The channel data for ltc2632l12 and ltc2632h12 are identical. So there
is no gain in using two different (but identical) channel descriptions.
The only side effect of this change is some memory savings.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: ltc2632: expand for ltc2636 support
Uwe Kleine-König [Thu, 30 Jan 2020 13:15:47 +0000 (14:15 +0100)]
dt-bindings: iio: ltc2632: expand for ltc2636 support

The ltc2636 family of devices is register compatible with the ltc2636
chips, it just features 8 instead of 2 channels.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: srf04: add power management feature
Andreas Klinger [Mon, 20 Jan 2020 16:45:41 +0000 (17:45 +0100)]
iio: srf04: add power management feature

Add suspend and resume operations for being used by optional power
management.

The suspend function is switching off an GPIO which can be used by the
hardware to switch power off. The resume function is switching the GPIO
on and sleeps an adjustable time to give the device a chance to be up
and running.

If activated the driver gets into autosuspend after some time of
inactivity.

Suggested-by: Franz Parzer <rpi-receiver@htl-steyr.ac.at>
Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: devantech-srf04.yaml: add pm feature
Andreas Klinger [Mon, 20 Jan 2020 16:44:55 +0000 (17:44 +0100)]
dt-bindings: devantech-srf04.yaml: add pm feature

Add GPIO line and startup time for usage of power management

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: st_sensors: handle memory allocation failure to fix null pointer dereference
Colin Ian King [Tue, 21 Jan 2020 16:17:57 +0000 (16:17 +0000)]
iio: st_sensors: handle memory allocation failure to fix null pointer dereference

A null pointer deference on pdata can occur if the allocation of
pdata fails.  Fix this by adding a null pointer check and handle
the -ENOMEM failure in the caller.

Addresses-Coverity: ("Dereference null return value")
Fixes: 3ce85cc4fbb7 ("iio: st_sensors: get platform data from device tree")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adc: ad7124: add 3db filter
Alexandru Tachici [Wed, 22 Jan 2020 08:54:14 +0000 (10:54 +0200)]
iio: adc: ad7124: add 3db filter

This patch adds the LOW_PASS_FILTER_3DB_FREQUENCY attribute
in iio_chan_spec for each channel. The used filters are sinc3
or sinc4. The filter type with the highest output data rate
is used when setting a low pass frequency in the channel's sysfs.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: ad5755: fix spelling mistake "to" -> "too" and grammar plus formatting
Colin Ian King [Thu, 23 Jan 2020 09:19:54 +0000 (09:19 +0000)]
iio: ad5755: fix spelling mistake "to" -> "too" and grammar plus formatting

There is a spelling mistake and grammar mistake in a dev_err
message. Fix it.

Also include Joe Perches' additional suggestions around:
* Missing newlines
* Excess braces
* Odd indentation
* Some grammar

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Suggested-by: Joe Perches <joe@perches.com> # Additional cleanups etc.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: light: Add a driver for Sharp GP2AP002x00F
Linus Walleij [Sun, 26 Jan 2020 15:05:48 +0000 (16:05 +0100)]
iio: light: Add a driver for Sharp GP2AP002x00F

This driver handles two different Sharp sensors that have been
proposed for merging to the mainline kernel over the years, and
already has a limited proximity-only driver in the input
subsystem.

These components are completely different from the confusingly
similarly named Sharp GP2AP020A00F, for which we have a driver
in drivers/iio/light/gp2ap020a00f.c

The two components GP2AP002A00F and GP2AP002S00F are
distinctively different but similar: they share the same set of
registers but differ slightly in the I2C protocol.

Instead of the approach by the previous input driver, we create
a combined IIO proximity and light sensor driver.

The plan is to merge this driver and delete the input driver.

The pieces for the driver are picked all over the place after
researching and grepping through a few different vendor trees
and driver submissions.

We merge it under the light sensors because:

- It has similarities with the Capella CM3605 light sensor and
  proximity driver which is there.

- It is related to the GP2AP020A00F driver which is also there.

This driver was tested with the Samsung GT-S7710 mobile phone
which has the GP2AP002S00F proximity sensor mounted.

The suspend/resume cycle will disable the interrupt from the
sensor. If someone would desire to use this interrupt for
wakeup, the driver will need modifications.

Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Minkyu Kang <mk7.kang@samsung.com>
Cc: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Cc: Jonathan Bakker <xc-racer2@live.ca>
Cc: Oskar Andero <oskar.andero@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Tested-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: light: Add DT bindings for GP2AP002
Linus Walleij [Sun, 26 Jan 2020 15:05:47 +0000 (16:05 +0100)]
iio: light: Add DT bindings for GP2AP002

This adds device tree bindings for the GP2AP002 light
and proximity sensor.

As with other early proximity sensors (~2010) the light
sensor and proximity sensors were combined into a single
component.

Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Minkyu Kang <mk7.kang@samsung.com>
Cc: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Cc: Jonathan Bakker <xc-racer2@live.ca>
Cc: Oskar Andero <oskar.andero@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: devicetree@vger.kernel.org
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: imu: st_lsm6dsx: Fix mismatched comments
JieunKim [Mon, 27 Jan 2020 12:03:59 +0000 (21:03 +0900)]
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>
4 years agoiio: accel: st_accel: Use st_sensors_dev_name_probe()
Andy Shevchenko [Mon, 20 Jan 2020 09:25:50 +0000 (11:25 +0200)]
iio: accel: st_accel: Use st_sensors_dev_name_probe()

Use st_sensors_dev_name_probe() instead open coded variant.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: adc: stm32-adc: convert bindings to json-schema
Fabrice Gasnier [Wed, 15 Jan 2020 13:45:41 +0000 (14:45 +0100)]
dt-bindings: iio: adc: stm32-adc: convert bindings to json-schema

Convert the STM32 ADC binding to DT schema format using json-schema

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoRevert "staging/octeon: Mark Ethernet driver as BROKEN"
Chris Packham [Wed, 5 Feb 2020 00:11:16 +0000 (13:11 +1300)]
Revert "staging/octeon: Mark Ethernet driver as BROKEN"

This reverts commit 075a1e87d1e2358d0b0301ac8f8e7f25051decf1. Now that
the build issues have been fixed we can resume build testing.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20200205001116.14096-7-chris.packham@alliedtelesis.co.nz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoMIPS: octeon: remove typedef declaration for cvmx_pko_command_word0
Chris Packham [Wed, 5 Feb 2020 00:11:15 +0000 (13:11 +1300)]
MIPS: octeon: remove typedef declaration for cvmx_pko_command_word0

Remove the typedef and update usage to use the union.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20200205001116.14096-6-chris.packham@alliedtelesis.co.nz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoMIPS: octeon: remove typedef declaration for cvmx_helper_link_info
Chris Packham [Wed, 5 Feb 2020 00:11:14 +0000 (13:11 +1300)]
MIPS: octeon: remove typedef declaration for cvmx_helper_link_info

Remove declaration of union cvmx_helper_link_info as typedef and update
uses to use the union.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20200205001116.14096-5-chris.packham@alliedtelesis.co.nz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoMIPS: octeon: remove typedef declaration for cvmx_wqe
Chris Packham [Wed, 5 Feb 2020 00:11:13 +0000 (13:11 +1300)]
MIPS: octeon: remove typedef declaration for cvmx_wqe

Remove typedef declaration from struct cvmx_wqe and replace its previous
uses with new struct declaration.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20200205001116.14096-4-chris.packham@alliedtelesis.co.nz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoRevert "staging: octeon: delete driver"
Chris Packham [Wed, 5 Feb 2020 00:11:12 +0000 (13:11 +1300)]
Revert "staging: octeon: delete driver"

This reverts commit 710d7fbe21ee2ceab121f1f84a20edf68f9f9742.
Re-instate the code so subsequent commits can clean it up and get it
building properly.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20200205001116.14096-3-chris.packham@alliedtelesis.co.nz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>