History log of /linux-master/drivers/iio/adc/ad7793.c
Revision Date Author Comments
# ef807729 30-Jan-2022 Jonathan Cameron <Jonathan.Cameron@huawei.com>

iio:adc:ad_sigma_delta: Move exports into IIO_AD_SIGMA_DELTA namespace

In order to avoid unnecessary pollution of the global symbol namespace
move the core/library functions into a specific namespace and import
that into the various specific device drivers that use them.

For more information see https://lwn.net/Articles/760045/

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Renato Lui Geh <renatogeh@gmail.com>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220130205701.334592-2-jic23@kernel.org


# 1a913270 06-Sep-2021 Alexandru Tachici <alexandru.tachici@analog.com>

iio: adc: ad7793: Fix IRQ flag

In Sigma-Delta devices the SDO line is also used as an interrupt.
Leaving IRQ on level instead of falling might trigger a sample read
when the IRQ is enabled, as the SDO line is already low. Not sure
if SDO line will always immediately go high in ad_sd_buffer_postenable
before the IRQ is enabled.

Also the datasheet seem to explicitly say the falling edge of the SDO
should be used as an interrupt:
>From the AD7793 datasheet: " The DOUT/RDY falling edge can be
used as an interrupt to a processor"

Fixes: da4d3d6bb9f6 ("iio: adc: ad-sigma-delta: Allow custom IRQ flags")
Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210906065630.16325-4-alexandru.tachici@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 801a80ef 13-May-2021 Alexandru Ardelean <aardelean@deviqon.com>

iio: adc: ad7793: convert to device-managed functions

With the devm_ad_sd_setup_buffer_and_trigger() helper, it's a bit easier
now to convert the probe of the AD7793 driver to use device-managed
functions.

Only the regulator disable requires a devm_add_action_or_reset() callback.

This change does that, cleaning up the driver a bit.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210513120752.90074-7-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 4ed243b1 14-May-2021 YueHaibing <yuehaibing@huawei.com>

iio: adc: ad7793: Add missing error code in ad7793_setup()

Set error code while device ID query failed.

Fixes: 88bc30548aae ("IIO: ADC: New driver for AD7792/AD7793 3 Channel SPI ADC")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 8cb631cc 13-Jun-2020 Lars-Peter Clausen <lars@metafoo.de>

iio: Remove superfluous of_node assignments

If a driver does not assign an of_node to a IIO device to IIO core will
automatically assign the of_node of the parent device. This automatic
assignment is done in the iio_device_register() function.

There is a fair amount of drivers that currently manually assign the
of_node of the IIO device. All but 4 of them can make use of the automatic
assignment though.

The exceptions are:
* mxs-lradc-adc: Which uses the of_node of the parent of the parent.
* stm32-dfsdm-adc, stm32-adc and stm32-dac: Which reference the of_node
assigned to the IIO device before iio_device_register() is called.

All other drivers are updated to use automatic assignment. This reduces
the amount of boilerplate code involved in setting up the IIO device.

The patch has mostly been auto-generated with the following semantic patch

// <smpl>
@exists@
expression indio_dev;
expression parent;
@@
indio_dev = \(devm_iio_device_alloc\|iio_device_alloc\)(&parent, ...)
...
-indio_dev->dev.of_node = parent.of_node;

@exists@
expression indio_dev;
expression parent;
@@
indio_dev = \(devm_iio_device_alloc\|iio_device_alloc\)(parent, ...)
...
-indio_dev->dev.of_node = parent->of_node;
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# d3be8324 22-May-2020 Alexandru Ardelean <alexandru.ardelean@analog.com>

iio: remove explicit IIO device parent assignment

This patch applies the semantic patch:
@@
expression I, P, SP;
@@
I = devm_iio_device_alloc(P, SP);
...
- I->dev.parent = P;

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

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

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

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

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 1cfe38fc 22-Mar-2020 Alexandru Ardelean <alexandru.ardelean@analog.com>

iio: adc: ad7793: use read_avail iio hook for scale available

This change uses the read_avail and '.info_mask_shared_by_type_available'
modifier to set the available scale.
Essentially, nothing changes to the driver's ABI.

The main idea for this patch is to remove the AD7793 driver from
checkpatch's radar. There have been about ~3 attempts to fix/break the
'in_voltage-voltage_scale_available' attribute, because checkpatch assumed
it to be an arithmetic operation and people were trying to change that.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# aebefb44 21-Mar-2020 Alexandru Ardelean <alexandru.ardelean@analog.com>

iio: adc: ad7793: define/use own IIO channel macros

This driver seems to use most of the AD_SD_*_CHANNEL. This change will move
them in the driver. The intent is that if a new part comes along which
would require tweaks per IIO channel, these should be doable in the driver.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 28535877 10-Mar-2020 YueHaibing <yuehaibing@huawei.com>

iio:ad7797: Use correct attribute_group

It should use ad7797_attribute_group in ad7797_info,
according to commit ("iio:ad7793: Add support for the ad7796 and ad7797").

Scale is fixed for the ad7796 and not programmable, hence
should not have the scale_available attribute.

Fixes: fd1a8b912841 ("iio:ad7793: Add support for the ad7796 and ad7797")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# da4d3d6b 12-Jan-2020 Alexandru Tachici <alexandru.tachici@analog.com>

iio: adc: ad-sigma-delta: Allow custom IRQ flags

Before this patch the ad_sigma_delta implementation hardcoded
the irq trigger type to low, assuming that all Sigma-Delta ADCs
have the same interrupt-type.

This patch allows all drivers using the ad_sigma_delta layer to set the
irq trigger type to the one specified in the datasheet.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# fda8d26e 28-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 177

Based on 1 normalized pattern(s):

licensed under the gpl 2

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 135 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190528170026.071193225@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9920ed25 14-Aug-2018 Michael Hennerich <michael.hennerich@analog.com>

drivers: iio: Update MODULE AUTHOR email address

no functional changes

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 490fba90 09-Mar-2018 Michael Nosthoff <committed@heine.so>

iio: ad7793: implement IIO_CHAN_INFO_SAMP_FREQ

This commit is a follow-up to changes made to ad_sigma_delta.h
in staging: iio: ad7192: implement IIO_CHAN_INFO_SAMP_FREQ
which broke ad7793 as it was not altered to match those changes.

This driver predates the availability of IIO_CHAN_INFO_SAMP_FREQ
attribute wherein usage has some advantages like it can be accessed by
in-kernel consumers as well as reduces the code size.

Therefore, use IIO_CHAN_INFO_SAMP_FREQ to implement the
sampling_frequency attribute instead of using IIO_DEV_ATTR_SAMP_FREQ()
macro.

Move code from the functions associated with IIO_DEV_ATTR_SAMP_FREQ()
into respective read and write hooks with the mask set to
IIO_CHAN_INFO_SAMP_FREQ.

Fixes: a13e831fcaa7 ("staging: iio: ad7192: implement IIO_CHAN_INFO_SAMP_FREQ")

Signed-off-by: Michael Nosthoff <committed@heine.so>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 7ee3b7eb 05-Sep-2017 Dragos Bogdan <dragos.bogdan@analog.com>

iio: ad7793: Fix the serial interface reset

The serial interface can be reset by writing 32 consecutive 1s to the device.
'ret' was initialized correctly but its value was overwritten when
ad7793_check_platform_data() was called. Since a dedicated reset function
is present now, it should be used instead.

Fixes: 2edb769d246e ("iio:ad7793: Add support for the ad7798 and ad7799")
Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 52b31bcc 23-Jul-2017 Jonathan Cameron <jic23@kernel.org>

iio:adc: drop assign iio_info.driver_module and iio_trigger_ops.owner

The equivalent of both of these are now done via macro magic when
the relevant register calls are made. The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>


# b4d46409 18-Jul-2016 Alison Schofield <amsfield22@gmail.com>

iio: adc: ad7793: use iio helper function to guarantee direct mode

Replace the code that guarantees the device stays in direct mode
with iio_device_claim_direct_mode() which does same.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# b541eaff 02-Jul-2016 Matt Ranostay <mranostay@gmail.com>

iio: adc: add missing of_node references to iio_dev

Adding missing indio_dev->dev.of_node references to allow iio consumers
to access the device channels.

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# afa81484 01-Jun-2016 Alison Schofield <amsfield22@gmail.com>

iio: adc: ad7793: claim direct mode when writing frequency

Driver was checking for direct mode and trying to lock it, but
left a gap where mode could change before the desired operation.
Use iio_device_claim_direct_mode() to guarantee device stays in
direct mode.

Refactor function to clarify look-up followed by lock sequence.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 7d173f26 09-Nov-2015 Nizam Haider <nizamhaider786@gmail.com>

iio: adc: ad7793: removed unnecessary else.

Else is not generally useful after a break or return.

Signed-off-by: Nizam Haider <nijamh@cdac.in>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 3821a065 23-Oct-2015 Andrew F. Davis <afd@ti.com>

spi: Drop owner assignment from spi_drivers

An spi_driver does not need to set an owner, it will be populated by the
driver core.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 785171fd 12-Oct-2015 Lars-Peter Clausen <lars@metafoo.de>

iio:ad7793: Fix ad7785 product ID

While the datasheet for the AD7785 lists 0xXB as the product ID the actual
product ID is 0xX3.

Fix the product ID otherwise the driver will reject the device due to non
matching IDs.

Fixes: e786cc26dcc5 ("staging:iio:ad7793: Implement stricter id checking")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 1672d933 03-Mar-2015 Masanari Iida <standby24x7@gmail.com>

iio:adc: Fix typo in MODULE_DESCRIPTION in ad7793.c

This patch fix spelling typo in MODULE_DESCRIPTION

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# a3580132 23-Jul-2013 Sachin Kamat <sachin.kamat@linaro.org>

iio: adc: ad7793: Use devm_* APIs

devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# fd1a8b91 21-Nov-2012 Lars-Peter Clausen <lars@metafoo.de>

iio:ad7793: Add support for the ad7796 and ad7797

The ad7796 and ad7797 are similar to the ad7792 and ad7793 but only have a
single differential input instead of two. Also some other features are missing
like the programmable gain amplifier and also not all sampling frequencies
supported by the ad7792/ad7793 are supported by the ad7796/ad7797. This patch
adds new feature flags for the features not present in the ad7796/ad7797. The
patch also adds a struct iio_info field to the chip_info struct, this becomes
necessary since the ad7796/ad7797 needs a special set of sysfs attributes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 2edb769d 21-Nov-2012 Lars-Peter Clausen <lars@metafoo.de>

iio:ad7793: Add support for the ad7798 and ad7799

The ad7798 and ad7799 are similar to the ad7792 and ad7793 but are missing some
features like the temperature sensor, being able to use an external clocksource
and a few other things. This patch adds a new 'flags' fields to the chip_info
struct which allows to specify which features a certain chip variant supports.
The setup code will then ignore any platform data fields which are related to
non supported features.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# f87f1a23 21-Nov-2012 Lars-Peter Clausen <lars@metafoo.de>

staging:iio: Move ad7793 driver out of staging

The driver does not expose any custom API to userspace and none of the standard
static code checker tools report any issues, so move it out of staging.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>