Skip to content
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

Ad4630 offload update #2725

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Ad4630 offload update #2725

wants to merge 4 commits into from

Conversation

ahaslam2
Copy link
Collaborator

@ahaslam2 ahaslam2 commented Feb 28, 2025

This makes 4630 dirver use the recently backported upstream spi offload implementation.

Main point is to stop using axi-spi-engine-ex so we can remove it.

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)

Add an offset parameter that can be passed in the periodic trigger.
This is useful for example when adc drivers implement a separate periodic
signal to trigger conversion and need offload to read the result with
some delay.

Signed-off-by: Axel Haslam <[email protected]>
Pass the duty offset to the waveform pwm.

Signed-off-by: Axel Haslam <[email protected]>
Update the ad5630 dts to the  upstream SPI offload implementation.

Signed-off-by: Axel Haslam <[email protected]>
Migrate to the recently backported spi offload implementation

Signed-off-by: Axel Haslam <[email protected]>
adc_trigger: pwm@44b00000 {
compatible = "adi,axi-pwmgen-2.00.a";
reg = <0x44b00000 0x1000>;
#pwm-cells = <2>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#pwm-cells = <2>;
#pwm-cells = <3>;

vdd-supply = <&vref>;
vdd_1_8-supply = <&vdd_1_8>;
vio-supply = <&vio>;
vref-supply = <&vref>;
spi-max-frequency = <80000000>;
pwm-names = "cnv";
pwms = <&adc_trigger 1 100000>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pwms = <&adc_trigger 1 100000>;
pwms = <&adc_trigger 1 100000 0>;

if (!st->fetch_trigger)
return 0;

fetch_wf.period_length_ns = conv_wf.period_length_ns;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we should be calling spi_offload_trigger_validate() and saving the result in a new field that replaces st->fetch_wf.


ret = ad4630_update_sample_fetch_trigger(st, avg_len + 1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be replaced with something that also updates the sampling frequency.

Really, this should be the standard oversampling_ratio attribute instead of a custom attribute, but in any case, the conversion trigger rate should be the sampling_frequency (attribute value) times the oversampling ratio (avg_frame_len).

This should be similar to how oversampling ratio and sampling frequency interact in the ad4695 driver.

u64 offload_offset_ns;
struct spi_offload_trigger_config config = {
.type = SPI_OFFLOAD_TRIGGER_PERIODIC,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
};
};

* so round this setting to the closest available value.
*/
offload_offset_ns = AD4630_TQUIET_CNV_DELAY_NS;
do {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be having this loop here. Instead we should be using spi_offload_trigger_validate() in the sysfs callbacks so that we either get a valid value or fail when changing the sampling_frequency attribute. Then here, we can call spi_offload_trigger_enable() directly with a config that has already been validated.

* Receive buffer needs to be non-zero for the SPI engine controller
* to mark the transfer as a read.
*/
st->offload_xfer.speed_hz = AD4630_SPI_SAMPLING_SPEED;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why deleting speed_hz? I think we want to keep that one.

"failed to get offload RX DMA\n");

ret = devm_iio_dmaengine_buffer_setup_with_handle(dev, indio_dev,
rx_dma, IIO_BUFFER_DIRECTION_IN);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rx_dma, IIO_BUFFER_DIRECTION_IN);
rx_dma, IIO_BUFFER_DIRECTION_IN);

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