Re: using dma buffers for SPI adcs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 12 Jun 2021 19:33:32 -0500
Alex Roberts <alex.roberts@xxxxxxxx> wrote:

> Hello,
> 
> I am learning how to use and write iio device drivers for ADCs. It seems
> most of the support is tied to FPGA based SoCs where ADCs can make use of
> Analog Devices SPI Engine and AXI IP. I'm looking at the AD7768-1 driver on
> the Analog Devices fork for example.
> 
> How does one use dma buffers for generic ARM processors for an ADC attached
> to a dma-enabled SPI port.. for example a Beaglebone Black or Raspberry PI?
> Is this even possible or something that makes sense? The goal is of course
> to use DMA to avoid interrupting the processor for every conversion.
> 
> I tried using the ADI driver, but get a ENODEV error when requesting the
> dma channel because there is not a "dmas" entry in the device tree node for
> the ADC, however it's parent SPI node does have dma entries.
> 
> Thanks,
> Alex.

Hi Alex,

I'll take a stab at answering this.

So the key thing here is that it's 'normally' not that easy to get a
DMA enabled SPI port to act like a fully fledged DMA engine suitable for
autonomous use streaming data into RAM.  They tend to be much more focused
on simple transfers needed for SPI itself.  Sometimes they are capable of
simple streaming but not in a remotely generic fashion.

Thus to use a DMA engine to do SPI based ADC transfers you need something
a bit cleverer. The Analog Device SPI Engine is effectively an offload engine
for SPI ADC management.  IIRC you set it up to sample a cyclic set of channels
and it generates all the writes needed to the device to make those happen
+ packs the data in to DMA buffers (large contiguous memory regions in RAM).

It's possible that a generic board might have a smart enough SPI implementation
to do this, but I'm not aware of it being possible on the BBB or RaspberryPi.

I vaguely remember some discussions a long time back about using the PRU on
the BBB to implement this sort of functionality, but can't remember where
or when those happened :(  Possible IRC a long time back.

Jonathan



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux