[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250422-iio-driver-ad4052-v2-0-638af47e9eb3@analog.com>
Date: Tue, 22 Apr 2025 13:34:45 +0200
From: Jorge Marques <jorge.marques@...log.com>
To: Jonathan Cameron <jic23@...nel.org>, Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>,
Rob Herring
<robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley
<conor+dt@...nel.org>, Jonathan Corbet <corbet@....net>,
David Lechner
<dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy
Shevchenko <andy@...nel.org>,
Uwe Kleine-König
<ukleinek@...nel.org>
CC: <linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<devicetree@...r.kernel.org>, <linux-doc@...r.kernel.org>,
<linux-pwm@...r.kernel.org>, Jorge Marques <jorge.marques@...log.com>
Subject: [PATCH v2 0/5] Add support for AD4052 device family
The AD4052/AD4058/AD4050/AD4056 are versatile, 16-bit/12-bit,
successive approximation register (SAR) analog-to-digital converter (ADC).
The series starts with marking iio_dev as const in iio_buffer_enabled,
to not discard the qualifier when calling from get_current_can_type.
This is required since the size of storage bytes varies if the offload
buffer is used or not.
The scan_type also depends if the oversampling feature is enabled, since
the 16-bit device increases the SPI word size from 16-bit to 24-bit.
Also due to this, the spi message optimization is balanced on the buffer ops,
instead of once per probe.
SPI messages related to exiting the ADC mode, and reading raw values are
never optimized.
The device has autonomous monitoring capabilities, that are exposed as IIO
events. Since register access requires leaving the monitoring
state and returning, device access is blocked until the IIO event is disabled.
An auxiliary method ad4052_iio_device_claim_direct manages the IIO claim
direct as well as the required wait_event boolean.
The device has an internal sampling rate for the autonomous modes,
exposed as the sample_rate attribute.
The device contains two required outputs:
* gp0: Threshold event interrupt on the rising edge.
* gp1: ADC conversion ready signal on the falling edge.
The user should either invert the signal or set the IRQ as falling edge.
And one optional input:
* cnv: Triggers a conversion, can be replaced by shortening the CNV and
SPI CS trace.
The devices utilizes PM to enter the low power mode.
The driver can be used with SPI controllers with and without offload support.
A FPGA design is available:
https://analogdevicesinc.github.io/hdl/projects/ad4052_ardz/
The devices datasheet:
https://www.analog.com/media/en/technical-documentation/data-sheets/ad4050-ad4056.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/ad4052-ad4058.pdf
The unique monitoring capabilities and multiple GPIOs where the decision factor
to have a standalone driver for this device family.
Non-implemented features:
* Status word: First byte of the SPI transfer aligned to the register
address.
* Averaging mode: Similar to burst averaging mode used in the
oversampling, but requiring a sequence of CNV triggers for each
conversion.
* Monitor mode: Similar to trigger mode used in the monitoring mode, but
doesn't exit to configuration mode on event, being awkward to expose
to user space.
Signed-off-by: Jorge Marques <jorge.marques@...log.com>
---
Changes in v2:
dt-bindings:
- commit message: describe io, how each device differ, remove driver
specifics.
- add interrupt names, format descriptions
- fix datasheet link
- add vdd/vio supply
documentation (new to series):
- add oversampling_frequency in sysfs-bus-iio
documentation/ad4052:
- rename sample_rate to conversion_frequency
- extend threshold event description
ad4052:
- use oversampling_frequency in burst_averaging_mode
- name the defines with register and label names, not only label
- remove defines that are used once, or may hard to understand, instead, have logic where they are used.
- due to the topology:
- set spi_offload_trigger_config.type from PERIODIC to DATA_READY
- handle the pwm_device on the driver.
- add oversampling_frequency and events_frequency to store distinct conversion_frequency
and to write accordingly when entering monitor_mode or burst_averaging_mode
- set sampling frequency as the pwm_device frequency
- update production IDs values with the ones from the released parts
- use production IDs to obtain device grade.
- set chip info static
- remove ad4052_iio_device_claim_direct, and solve unbalances
- add missing rd_table, wr_table to regmap_config
- replace PTR_ERR_OR_ZERO with if IS_ERR return PTR_ERR
- rename ad4052_set_non_defaults with a ad4052_setup (more usual naming convention)
- reorder pm_runtime autosuspend to after enabling the pm
- Link to v1: https://lore.kernel.org/r/20250306-iio-driver-ad4052-v1-0-2badad30116c@analog.com
---
Jorge Marques (5):
Documentation: ABI: add oversampling frequency in sysfs-bus-iio
iio: code: mark iio_dev as const in iio_buffer_enabled
dt-bindings: iio: adc: Add adi,ad4052
docs: iio: new docs for ad4052 driver
iio: adc: add support for ad4052
Documentation/ABI/testing/sysfs-bus-iio | 17 +
.../devicetree/bindings/iio/adc/adi,ad4052.yaml | 98 ++
Documentation/iio/ad4052.rst | 95 ++
MAINTAINERS | 8 +
drivers/iio/adc/Kconfig | 14 +
drivers/iio/adc/Makefile | 1 +
drivers/iio/adc/ad4052.c | 1425 ++++++++++++++++++++
drivers/iio/industrialio-core.c | 2 +-
include/linux/iio/iio.h | 2 +-
9 files changed, 1660 insertions(+), 2 deletions(-)
---
base-commit: 905d6b57b18fa932b3f05578e82625d22a4dd17f
change-id: 20250306-iio-driver-ad4052-a4acc3bb11b3
Best regards,
--
Jorge Marques <jorge.marques@...log.com>
Powered by blists - more mailing lists