-
Notifications
You must be signed in to change notification settings - Fork 908
Add support for AD4052 ADC Family #2642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
gastmaier
wants to merge
13
commits into
mirror/jic23/iio/testing
Choose a base branch
from
staging/ad4052
base: mirror/jic23/iio/testing
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cd27314
iio: adc: spear_adc: mask SPEAR_ADC_STATUS channel and avg sample bef…
losgobbi b12f1e2
Add support for AD4052 device family
gastmaier 14bee97
Documentation: ABI: add oversampling_frequency in sysfs-bus-iio
gastmaier 8aac7b4
dt-bindings: iio: adc: Add adi,ad4052
gastmaier d736905
docs: iio: New docs for ad4052 driver
gastmaier 86adf1c
iio: adc: Add support for ad4052
gastmaier e2cae10
https://lore.kernel.org/all/20250614110812.39af2c41@jic23-huawei/
gastmaier 29efb45
debugfs https://lore.kernel.org/linux-iio/20250621170824.249c6b0c@jic…
gastmaier 1f21a0f
docs: iio: ad4052: Add offload support documentation
gastmaier 084604b
iio: adc: Add offload support for ad4052
gastmaier 66bcf34
docs: iio: ad4052: Add event documentation
gastmaier f373e42
iio: adc: Add events support to ad4052
gastmaier 45bb173
offload: spi_bpw_to_bytes
gastmaier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,6 +139,23 @@ Contact: [email protected] | |
| Description: | ||
| Hardware dependent values supported by the oversampling filter. | ||
|
|
||
| What: /sys/bus/iio/devices/iio:deviceX/oversampling_frequency | ||
| KernelVersion: 6.17 | ||
| Contact: [email protected] | ||
| Description: | ||
| Some devices have internal clocks for oversampling. Sets the | ||
| resulting frequency in Hz to trigger a conversion used by the | ||
| oversampling filter. If the device has a fixed internal clock | ||
| or is computed based on the sampling frequency parameter, the | ||
| parameter is read only. | ||
|
|
||
| What: /sys/bus/iio/devices/iio:deviceX/oversampling_frequency_available | ||
| KernelVersion: 6.17 | ||
| Contact: [email protected] | ||
| Description: | ||
| Hardware dependent values supported by the oversampling | ||
| frequency. | ||
|
|
||
| What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_raw | ||
| What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_raw | ||
| KernelVersion: 2.6.35 | ||
|
|
||
151 changes: 151 additions & 0 deletions
151
Documentation/devicetree/bindings/iio/adc/adi,ad4052.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | ||
| # Copyright 2025 Analog Devices Inc. | ||
| %YAML 1.2 | ||
| --- | ||
| $id: http://devicetree.org/schemas/iio/adc/adi,ad4052.yaml# | ||
| $schema: http://devicetree.org/meta-schemas/core.yaml# | ||
|
|
||
| title: Analog Devices AD4052 ADC family device driver | ||
|
|
||
| maintainers: | ||
| - Jorge Marques <[email protected]> | ||
|
|
||
| description: | | ||
| Analog Devices AD4052 Single Channel Precision SAR ADC family | ||
|
|
||
| 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 | ||
|
|
||
| properties: | ||
| compatible: | ||
| enum: | ||
| - adi,ad4050 | ||
| - adi,ad4052 | ||
| - adi,ad4056 | ||
| - adi,ad4058 | ||
|
|
||
| reg: | ||
| maxItems: 1 | ||
|
|
||
| interrupts: | ||
| minItems: 1 | ||
| maxItems: 2 | ||
|
|
||
| interrupt-names: | ||
| items: | ||
| - const: gp0 | ||
| description: Signal coming from the GP0 pin. | ||
| - const: gp1 | ||
| description: Signal coming from the GP1 pin. | ||
|
|
||
| cnv-gpios: | ||
| description: The Convert Input (CNV). If omitted, CNV is tied to SPI CS. | ||
| maxItems: 1 | ||
|
|
||
| pwms: | ||
| maxItems: 1 | ||
| description: PWM connected to the CNV pin. | ||
|
|
||
| trigger-sources: | ||
| minItems: 1 | ||
| maxItems: 2 | ||
| description: | ||
| Describes the output pin and event associated. | ||
|
|
||
| "#trigger-source-cells": | ||
| const: 2 | ||
| description: | | ||
| Output pins used as trigger source. | ||
|
|
||
| Cell 0 defines the event: | ||
| * 0 = Data ready | ||
| * 1 = Min threshold | ||
| * 2 = Max threshold | ||
| * 3 = Either threshold | ||
| * 4 = CHOP control | ||
| * 5 = Device enable | ||
| * 6 = Device ready (only GP1) | ||
|
|
||
| Cell 1 defines which pin: | ||
| * 0 = GP0 | ||
| * 1 = GP1 | ||
|
|
||
| For convenience, macros for these values are available in | ||
| dt-bindings/iio/adc/adi,ad4052.h. | ||
|
|
||
| spi-max-frequency: | ||
| maximum: 83333333 | ||
|
|
||
| vdd-supply: | ||
| description: Analog power supply. | ||
|
|
||
| vio-supply: | ||
| description: Digital interface logic power supply. | ||
|
|
||
| ref-supply: | ||
| description: | ||
| Reference voltage to set the ADC full-scale range. If not present, | ||
| vdd-supply is used as the reference voltage. | ||
|
|
||
| required: | ||
| - compatible | ||
| - reg | ||
| - vdd-supply | ||
| - vio-supply | ||
|
|
||
| allOf: | ||
| - $ref: /schemas/spi/spi-peripheral-props.yaml# | ||
|
|
||
| unevaluatedProperties: false | ||
gastmaier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| examples: | ||
| - | | ||
| #include <dt-bindings/gpio/gpio.h> | ||
| #include <dt-bindings/interrupt-controller/irq.h> | ||
| #include <dt-bindings/iio/adc/adi,ad4052.h> | ||
|
|
||
| spi { | ||
| #address-cells = <1>; | ||
| #size-cells = <0>; | ||
|
|
||
| adc@0 { | ||
| compatible = "adi,ad4052"; | ||
| reg = <0>; | ||
| vdd-supply = <&vdd>; | ||
| vio-supply = <&vio>; | ||
| ref-supply = <&ref>; | ||
| spi-max-frequency = <83333333>; | ||
|
|
||
| interrupt-parent = <&gpio>; | ||
| interrupts = <0 1 IRQ_TYPE_EDGE_FALLING>; | ||
| interrupt-names = "gp1"; | ||
| cnv-gpios = <&gpio 2 GPIO_ACTIVE_HIGH>; | ||
| }; | ||
| }; | ||
| - | | ||
| #include <dt-bindings/gpio/gpio.h> | ||
| #include <dt-bindings/interrupt-controller/irq.h> | ||
| #include <dt-bindings/iio/adc/adi,ad4052.h> | ||
|
|
||
| spi { | ||
| #address-cells = <1>; | ||
| #size-cells = <0>; | ||
|
|
||
| trigger-sources = <&adc AD4052_TRIGGER_EVENT_DATA_READY | ||
| AD4052_TRIGGER_PIN_GP1>; | ||
|
|
||
| adc@0 { | ||
| compatible = "adi,ad4052"; | ||
| reg = <0>; | ||
| vdd-supply = <&vdd>; | ||
| vio-supply = <&vio>; | ||
| spi-max-frequency = <83333333>; | ||
| pwms = <&adc_trigger 0 10000 0>; | ||
|
|
||
| interrupt-parent = <&gpio>; | ||
| interrupts = <0 0 IRQ_TYPE_EDGE_RISING>, | ||
| <0 1 IRQ_TYPE_EDGE_FALLING>; | ||
| interrupt-names = "gp0", "gp1"; | ||
| cnv-gpios = <&gpio 2 GPIO_ACTIVE_HIGH>; | ||
| }; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| .. SPDX-License-Identifier: GPL-2.0-only | ||
|
|
||
| ============= | ||
| AD4052 driver | ||
| ============= | ||
|
|
||
| ADC driver for Analog Devices Inc. AD4052 and similar devices. The module name | ||
| is ``ad4052``. | ||
|
|
||
| Supported devices | ||
| ================= | ||
|
|
||
| The following chips are supported by this driver: | ||
|
|
||
| * `AD4050 <https://www.analog.com/AD4050>`_ | ||
| * `AD4052 <https://www.analog.com/AD4052>`_ | ||
| * `AD4056 <https://www.analog.com/AD4056>`_ | ||
| * `AD4058 <https://www.analog.com/AD4058>`_ | ||
|
|
||
| Wiring modes | ||
| ============ | ||
|
|
||
| The ADC uses SPI 4-wire mode, and contain two programmable GPIOs and a CNV pin. | ||
|
|
||
| The CNV pin is exposed as the ``cnv-gpios`` and triggers an ADC conversion. GP1 | ||
| is ADC conversion ready signal and GP0 Threshold event interrupt, both exposed | ||
| as interrupts. | ||
|
|
||
| Omit ``cnv-gpios`` and tie CNV and CS together to use the rising edge of the CS | ||
| as the CNV signal. | ||
|
|
||
| Device attributes | ||
| ================= | ||
|
|
||
| The ADC contains only one channel with following attributes: | ||
|
|
||
| .. list-table:: Channel attributes | ||
| :header-rows: 1 | ||
|
|
||
| * - Attribute | ||
| - Description | ||
| * - ``in_voltage_calibscale`` | ||
| - Scale factor to multiply the raw value. | ||
| * - ``in_voltage_raw`` | ||
| - Raw ADC voltage value | ||
| * - ``in_voltage_oversampling_ratio`` | ||
| - Enable the device's burst averaging mode to over sample using the | ||
| internal sample rate. | ||
| * - ``in_voltage_oversampling_ratio_available`` | ||
| - List of available oversampling values. Value 1 disable the burst | ||
| averaging mode. | ||
| * - ``in_voltage_sampling_frequency`` | ||
| - Set the sampling frequency, only present if SPI Offload is being used. | ||
|
|
||
| Also contain the following device attributes: | ||
|
|
||
| .. list-table:: Device attributes | ||
| :header-rows: 1 | ||
|
|
||
| * - Attribute | ||
| - Description | ||
| * - ``oversamling_frequency`` | ||
| - Frequency used in the burst averaging mode, sets the device internal | ||
| sample rate when the mode is activated. | ||
| * - ``oversampling_frequency_available`` | ||
| - List of available sample rates. | ||
|
|
||
| Interrupts | ||
| ========== | ||
|
|
||
| The cell of trigger-sources of the parent node sets which GPIO has the role of | ||
| data ready signal. If not present, defaults as ``gp0``. If not set in the | ||
| ``interrupt-names`` property, the driver will not wait for the data ready | ||
| assertion, and will result in reading a sample before it's ready, particularly | ||
| in oversampling mode. | ||
|
|
||
| A second element in the ``interrupt-names`` property sets which GPIO has the | ||
| role of the threshold event. If not provided, the IIO events attributes are | ||
| still present, but no IIO Event will ever be triggered. This allows to use the | ||
| GPIO output to trigger other resource. | ||
|
|
||
| Low-power mode | ||
| ============== | ||
|
|
||
| The device enters low-power mode on idle to save power. Enabling an event puts | ||
| the device out of the low-power since the ADC autonomously samples to assert | ||
| the event condition. | ||
|
|
||
| SPI offload support | ||
| =================== | ||
|
|
||
| To be able to achieve the maximum sample rate, the driver can be used with the | ||
| `AXI SPI Engine`_ to provide SPI offload support. | ||
|
|
||
| .. _AXI SPI Engine: http://analogdevicesinc.github.io/hdl/projects/ad4052_ardz/index.html | ||
|
|
||
| When SPI offload is being used, additional attributes are present: | ||
|
|
||
| .. list-table:: Additional attributes | ||
| :header-rows: 1 | ||
|
|
||
| * - Attribute | ||
| - Description | ||
| * - ``in_voltage_sampling_frequency`` | ||
| - Set the sampling frequency. | ||
|
|
||
| Threshold events | ||
| ================ | ||
|
|
||
| The ADC supports a monitoring mode to raise threshold events. The driver | ||
| supports a single interrupt for both rising and falling readings. | ||
|
|
||
| The feature is enabled/disabled by setting ``thresh_either_en``. During monitor | ||
| mode, the device continuously operates in autonomous mode until put back in | ||
| configuration mode, due to this, the device returns busy until the feature is | ||
| disabled. | ||
|
|
||
| The following event attributes are available: | ||
|
|
||
| .. list-table:: Event attributes | ||
| :header-rows: 1 | ||
|
|
||
| * - Attribute | ||
| - Description | ||
| * - ``sampling_frequency`` | ||
| - Frequency used in the monitoring mode, sets the device internal sample | ||
| rate when the mode is activated. | ||
| * - ``sampling_frequency_available`` | ||
| - List of available sample rates. | ||
| * - ``thresh_either_en`` | ||
| - Enable monitoring mode. | ||
| * - ``thresh_falling_hysteresis`` | ||
| - Set the hysteresis value for the minimum threshold. | ||
| * - ``thresh_falling_value`` | ||
| - Set the minimum threshold value. | ||
| * - ``thresh_rising_hysteresis`` | ||
| - Set the hysteresis value for the maximum threshold. | ||
| * - ``thresh_rising_value`` | ||
| - Set the maximum threshold value. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ Industrial I/O Kernel Drivers | |
| ad3552r | ||
| ad4000 | ||
| ad4030 | ||
| ad4052 | ||
| ad4695 | ||
| ad7191 | ||
| ad7380 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1374,6 +1374,14 @@ F: Documentation/devicetree/bindings/iio/adc/adi,ad4030.yaml | |
| F: Documentation/iio/ad4030.rst | ||
| F: drivers/iio/adc/ad4030.c | ||
|
|
||
| ANALOG DEVICES INC AD4052 DRIVER | ||
| M: Jorge Marques <[email protected]> | ||
| S: Supported | ||
| W: https://ez.analog.com/linux-software-drivers | ||
| F: Documentation/devicetree/bindings/iio/adc/adi,ad4052.yaml | ||
| F: Documentation/iio/ad4052.rst | ||
| F: drivers/iio/adc/ad4052.c | ||
|
|
||
| ANALOG DEVICES INC AD4080 DRIVER | ||
| M: Antoniu Miclaus <[email protected]> | ||
| L: [email protected] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.