Skip to content

Conversation

machschmitt
Copy link
Contributor

@machschmitt machschmitt commented Jul 24, 2025

This fixes ADAQ4216 data capture

  • Update device tree for ADAQ4216.
  • A couple of minor fixes to ADAQ4216 support.
  • Update to pwm-trigger sources.
  • Extend SPI offload trigger support by adding an end_cycle_offset_ns field to struct spi_offload_trigger_periodic.
  • Add a hacky IIO buffer type.

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly (if there is the case)

@machschmitt machschmitt force-pushed the adaq4216-data-capture-fix branch 2 times, most recently from c9ac8fd to dd952d3 Compare July 25, 2025 14:33
@machschmitt
Copy link
Contributor Author

Change log v1 -> v2

  • Fixed checkpatch warnings:
    • Added commit descriptions where needed
    • Aligned function parameters

No functional change.

@gastmaier
Copy link
Contributor

Can you also fix the ci caught warnings? e.g.,
on ad4630_get_avg_frame_len if regmap fails, it goes to out, and always returns 0; causing *val = temp; to execute, with temp uninitialized (due to the goto + return 0)

@machschmitt machschmitt force-pushed the adaq4216-data-capture-fix branch from dd952d3 to b27cc6d Compare July 30, 2025 21:32
@machschmitt
Copy link
Contributor Author

Change log v2 -> v3

  • Added a comment explaining the need of a special IIO buffer.
  • Add a patch fixing possible use of uninitialized variable due to previous goto + return 0 combination.

@machschmitt machschmitt force-pushed the adaq4216-data-capture-fix branch from cc8e0e0 to 65d4fa4 Compare August 4, 2025 15:07
Switch from old/temporary SPI-Engine compatible to upstream consolidated
SPI-Engine compatible string.

Signed-off-by: Marcelo Schmitt <[email protected]>
The ad4630 driver was updated and is now using the SPI offload trigger
infrastructure which relies on a pwm-trigger being declared in device tree.
Update ADAQ4216 device tree to work with the recent SPI offload trigger
abstraction and infrastructure.

Signed-off-by: Marcelo Schmitt <[email protected]>
… node

The clock properties are no longer used after the update to use
trigger-sources. Drop leftover clock properties in ADC node.

Signed-off-by: Marcelo Schmitt <[email protected]>
Increase the number of pwm-cells to 3, following recent changes made to
zynq-zed-adv7511-ad4630-24.dts.

Signed-off-by: Marcelo Schmitt <[email protected]>
Move properties around and rename PWM phandle (axi_pwm_gen -> adc_trigger)
to make ADAQ4216 dts similar to AD4630-24 as they should be.
No functional change.

Signed-off-by: Marcelo Schmitt <[email protected]>
Remove unneeded num-cs property from SPI-Engine device node.

Signed-off-by: Marcelo Schmitt <[email protected]>
…ord size

Set ADAQ channel storage bit to 32 since that was chosen to be the DMA word
size. While at it, align channel macro arguments to comply with Linux code
style and avoid checkpatch warnings.

Signed-off-by: Marcelo Schmitt <[email protected]>
With SPI-Engine offload module, PWMs, and trigger-sources, the sampling
frequency can be set from a wide range of values that cannot be
displayed as a list of available items. Remove the sampling frequency
available attribute so the user is not constrained when specifying the
desired sampling frequency.

Signed-off-by: Marcelo Schmitt <[email protected]>
ADAQ4216 doesn't use BIT(2) of OUT_DATA_MD field in mode register.

Signed-off-by: Marcelo Schmitt <[email protected]>
This is a hack to discard ADAQ4216 second channel data.

The ad4630_fmc HDL project was designed for ADCs with two channels and
always streams two data channels to DMA (even when the ADC has only one
physical channel). Though, if the ADC has only one physical channel, the
data that would come from the second ADC channel comes in as noise and has
to be discarded. Because of that, only half of data collected by DMA blocks
shall be passed to IIO buffers when using single-channel ADCs such as
ADAQ4216.

Because only half of the data pushed to DMA is used, the filtered dmaengine
buffer variant allocates blocks that are two times the usual size so the
IIO buffer can still be filled with the data from one DMA block. Otherwise,
a data glitch occurs right in the middle of the IIO buffer.

Add a separate dmaengine buffer variant for filtering data from ADAQ4216
and similar single-channel ADCs supported by the ad4630.c driver.

Signed-off-by: Marcelo Schmitt <[email protected]>
Use the new filtered DMA buffer variant to avoid pushing noise to IIO
buffers when single-channel ADCs are used.

Signed-off-by: Marcelo Schmitt <[email protected]>
Previously, due to return 0 after goto jump, '*val = temp;' could execute
with temp uninitialized if regmap_read() failed in
ad4630_get_avg_frame_len(). Prevent that by returning the actual error code
if regmap_read() fails in ad4630_get_avg_frame_len().

Suggested-by: Jorge Marques <[email protected]>
Fixes: 5bc31c5 ("iio: adc: ad4630: Use oversampling iio attribute for average mode")
Signed-off-by: Marcelo Schmitt <[email protected]>
The average mode value is never negative so there is no need to check if it
is lower than zero.

This fixes a 'comparison of unsigned expression in '< 0' is always false'
build warn.

Signed-off-by: Marcelo Schmitt <[email protected]>
The PGA gain value is stored in an unsigned variable so it's value can
never be a negative number. Thus, drop the lower bound check for PGA gain
values as that is not needed.

This fixes a 'comparison of unsigned expression in '< 0' is always false'
build warn.

Signed-off-by: Marcelo Schmitt <[email protected]>
The calibration scale value is stored in an unsigned variable so it's
value can never be a negative number. Thus, drop the lower bound check
for the calibration scale values as that is not needed.

This fixes a 'comparison of unsigned expression in '< 0' is always false'
build warn.

Signed-off-by: Marcelo Schmitt <[email protected]>
The ADC input range value is never negative and so there is no need to use
shift_right() to calculate the scale. Make direct use of right shift
operator for scale calculation.

This fixes 'comparison of unsigned expression in ‘< 0’ is always false'
build warn.

Signed-off-by: Marcelo Schmitt <[email protected]>
@machschmitt machschmitt force-pushed the adaq4216-data-capture-fix branch from 65d4fa4 to f71869b Compare August 6, 2025 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants