-
Notifications
You must be signed in to change notification settings - Fork 863
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
base: main
Are you sure you want to change the base?
Ad4630 offload update #2725
Conversation
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>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#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>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}; | |
}; |
* so round this setting to the closest available value. | ||
*/ | ||
offload_offset_ns = AD4630_TQUIET_CNV_DELAY_NS; | ||
do { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rx_dma, IIO_BUFFER_DIRECTION_IN); | |
rx_dma, IIO_BUFFER_DIRECTION_IN); |
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
PR Checklist