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

Add support for AD7944, AD7985, AD7986 #2280

Merged
merged 4 commits into from
Oct 31, 2023
Merged

Add support for AD7944, AD7985, AD7986 #2280

merged 4 commits into from
Oct 31, 2023

Conversation

dlech
Copy link
Collaborator

@dlech dlech commented Oct 11, 2023

This adds device tree bindings compatible strings, ad_pulsar driver support and ZedBoard device trees for the AD7944, AD7985, and AD7986 chips.

This has not been tested yet since we are waiting on HDL for these.

Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

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

From a code point of view, everything looks good. But I would say, let's wait for real testing before merging

@dlech
Copy link
Collaborator Author

dlech commented Oct 13, 2023

Have the HDL now.

Updated:

  • added gpio for TURBO
  • added spi_clk

Still waiting on a hardware setup to be able to test.

- adi,pulsar,ad7985
- adi,pulsar,ad7944
then:
required:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure this should be required, e.g. the TURBO pin could be hardwired instead of connected to a GPIO.

@dlech dlech force-pushed the dlech/ad7944 branch 2 times, most recently from d606677 to 190b757 Compare October 16, 2023 22:08
@dlech
Copy link
Collaborator Author

dlech commented Oct 16, 2023

update:

  • rebased on master
  • fixed copy/paste mistake for ad7985 in ad_pulsar_of_match
  • fixed turbo gpio number in devicetree

We have hardware to test now, but the driver doesn't seem to be communicating with the ADC chip. The SPI transactions time out (which lead to discovering #2287).

@mhennerich
Copy link
Contributor

Hi David,

I was asked why the dt_binding_check failed on this PR:

CHKDT Documentation/devicetree/bindings/processed-schema.json
/home/vsts/work/1/s/Documentation/devicetree/bindings/iio/adc/adi,pulsar.yaml: allOf:1: 'then' is a dependency of 'if'
hint: Keywords must be a subset of known json-schema keywords
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/home/vsts/work/1/s/Documentation/devicetree/bindings/iio/adc/adi,pulsar.yaml: allOf:1:if: 'if' is a dependency of 'then'
hint: Keywords must be a subset of known json-schema keywords
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#

After fixing the if/then indention this PR runs the failing checks successfully.
Please see here: #2290

dlech added 4 commits October 17, 2023 10:37
This adds compatible strings for the AD7944, AD7985, and AD7986 chips.

Signed-off-by: David Lechner <dlechner@baylibre.com>
This adds support for the AD7944, AD7985, and AD7986 ADCs.

Signed-off-by: David Lechner <dlechner@baylibre.com>
This adds initial support for the TURBO gpio. The TURBO input is
available on some chips (e.g. AD7944) and is used to enable the maximum
sample rate at the expense of increased power consumption.

For now, the TURBO mode is always enabled. In the future, we can add
support to turn it off for lower sample rates.

Signed-off-by: David Lechner <dlechner@baylibre.com>
This adds trees for ZedBoard with AD7944, AD7985, and AD7986 evaluation
boards.

Signed-off-by: David Lechner <dlechner@baylibre.com>
@dlech
Copy link
Collaborator Author

dlech commented Oct 17, 2023

Update:

  • fixed wrong indent in DT bindings

We have the hardware setup working now, so at least superficially this looks like it is working. We can see a sine wave in the IIO oscilloscope.

So the only question left is the desired behavoir of the turbo gpio.

Should we just automatically disable turbo mode if the requested sample rate does not require it? Or do users need more control over this?

@dlech
Copy link
Collaborator Author

dlech commented Oct 17, 2023

I also found an issue where the first sample is always 0, so I will need to fix that. Or is this the expected behavior for the pulsar driver?

@dlech
Copy link
Collaborator Author

dlech commented Oct 17, 2023

Having looked into this more deeply now, I noticed that AD7986/85/44 don't have a config register like AD7682. So should we make the config register optional in ad_pulsar.c or are these chips different enough we should create a separate driver? (I suspect this is what is causing the first sample to be zero as I mentioned in the previous comment.)

@nunojsa
Copy link
Collaborator

nunojsa commented Oct 25, 2023

Should we just automatically disable turbo mode if the requested sample rate does not require it? Or do users need more control over this?

Not know much about the device but if this is something that can be done automatically by the driver I would say it's better. Always better to simplify the ABI. I mean is the turbo meaningful at all for sampling rates not needing it?

I also found an issue where the first sample is always 0, so I will need to fix that. Or is this the expected behavior for the pulsar driver?

Hmm i would be surprised if it's expected :). Those devices have any way to control the interrupt line or are we relying on {enable|disable}_irq()?

@dlech
Copy link
Collaborator Author

dlech commented Oct 25, 2023

Not know much about the device but if this is something that can be done automatically by the driver I would say it's better. Always better to simplify the ABI. I mean is the turbo meaningful at all for sampling rates not needing it?

Not that I know of. Also, there are some configurations, like daisy-chaining multiple chips where turbo mode is not allowed. So keeping it internal to the driver seems like the best option to me.

Hmm i would be surprised if it's expected :). Those devices have any way to control the interrupt line or are we relying on {enable|disable}_irq()?

Having thought about it a bit more, I think it could be a problem with the HDL. The CNV pin is being used as the CS pin but the conversion is triggered on the rising edge. On the first sample there is probably only a falling edge because the CS/CNV line was high since startup.

The HDL needs to make sure there is a low to high transition of the CNV line before each SPI read.

So should we make the config register optional in ad_pulsar.c or are these chips different enough we should create a separate driver?

FYI, I'm looking at making a separate driver for this chips upstream along with the work we have started on getting SPI Engine offload support mainlined.

@dlech
Copy link
Collaborator Author

dlech commented Oct 30, 2023

This has been tested by both BayLibre and ADI now. Do we want to merge as-is and address the outstanding issues separately?

Still TODO:

IMHO, it would be easier to do these if we first split ad_pulsar.c into two drivers as suggested in #2312.

@nunojsa
Copy link
Collaborator

nunojsa commented Oct 31, 2023

This has been tested by both BayLibre and ADI now. Do we want to merge as-is and address the outstanding issues separately?

If you agree, I would just merge this one and add the missing features in future patches... Thoughts?

@dlech
Copy link
Collaborator Author

dlech commented Oct 31, 2023

If you agree, I would just merge this one and add the missing features in future patches... Thoughts?

Yes, I agree.

@dlech dlech merged commit 544a415 into master Oct 31, 2023
12 checks passed
@dlech dlech deleted the dlech/ad7944 branch October 31, 2023 14:40
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.

4 participants