Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
From: Paul Barker <paul@paulbarker.me.uk>
To: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: linux-omap@vger.kernel.org, Jarkko Nikula <jarkko.nikula@bitmer.com>
Subject: Re: McBSP functions not exported
Date: Tue, 15 Jan 2013 17:43:54 +0000	[thread overview]
Message-ID: <f358e8045003700c83717ce3f7bc1932@localhost> (raw)
In-Reply-To: <50F3C648.60101@ti.com>

Hi,

On 2013-01-14 08:48, Peter Ujfalusi wrote:
> On 01/11/2013 05:27 PM, Paul Barker wrote:
>>
>> <snip>
>>
>> I've just been having a look at the McSPI interface and SPI code in 
>> the kernel.
>> I can see how to wire this up, use the processor as SPI master and 
>> the ADC as
>> SPI slave, get the clock running, etc. I need the transfers to be 
>> synchronised
>> to the data ready signal from the ADC, or I need them to occur at a 
>> guaranteed
>> frequency. I can't see how to do either of these with the SPI 
>> interface provided
>> by <linux/spi/spi.h>, so looks like I'd have to interface directly 
>> with the
>> McSPI hardware. I'll have a bash around, try to get some advice from 
>> the
>> beagleboard@googlegroups.com list and see what I can come up with as 
>> I think
>> that's a bit off topic for this list.
>
> Naturally you would use the data ready line as interrupt source for 
> your
> driver. When you receive the interrupt you would issue a read via SPI 
> to get
> the result from the chip.
>

I've written a quick driver which issues SPI reads in response to 
hrtimer events
to see if this is possible. I'm getting a rough average latency of 
100us between
calling spi_async() and the clock signal changing. This is no use for 
reading a
single sample at a time at a rate of 625kHz. Even ignoring this 
problem, I
imagine there would be at least a few microseconds of latency between a 
GPIO pin
changing and an interrupt handler being executed by the kernel. My 
transfer
takes 1us and I have a new data word every 1.6us. So I think issuing 
single SPI
read requests each time I get an interrupt isn't going to work for me.

With the hrtimer interval set to 1.6us my board completely locks up 
(probably
has no free time to handle anything else). I don't think Linux was 
designed to
respond to these sorts of requests in real-time. I need to offload this 
to the
DMA system, but I can't see any way to do that (with a 600ns gap 
between
transfers) using the Linux SPI API.

>
> I don't see how it could help custom boards. For audio all boards can 
> just
> happily use the McBSP stack + omap-pcm. It could help with boards 
> where the
> McBSP is not used for audio. But I think those users could use McSPI 
> instead
> of McBSP for their needs.
>
> As a sidenote: The support for SPI like protocols in McBSP only 
> existed on
> OMAP1 where we had a stop clocks possibility. In all latest versions 
> of OMAP
> removed this possibility and McBSP officially only supports I2S, PCM, 
> TDM
> protocols. This was another reason to move the McBSP under sound.

The ADS1672 shouldn't care if the clock stops or not, it has the 
ability to
output its own clock signal and that runs continuously.

My understanding of the McBSP using DMA is that a read would be issued 
as soon
as a frame sync pulse is detected, with no processor involvement, and I 
can get
an interrupt from the DMA controller once every few thousand samples or 
so and
so the OS can just get on with running in the meantime. It looks like 
that is
what I need to happen here.

I'm going to go back to using kernel 3.2 and check that this actually 
works
with the McBSP. If it does, how much hassle is it to export the 
required symbols
in more recent kernels? I'll happily write the patch, I just don't want 
to
introduce too much more maintenance overhead going forward.

Thanks,

Paul Barker

  reply	other threads:[~2013-01-15 19:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11 11:48 McBSP functions not exported Paul Barker
2013-01-11 13:17 ` Peter Ujfalusi
2013-01-11 16:27   ` Paul Barker
2013-01-14  8:48     ` Peter Ujfalusi
2013-01-15 17:43       ` Paul Barker [this message]
2013-01-16  7:44         ` Jarkko Nikula
2013-01-16  9:05         ` Peter Ujfalusi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f358e8045003700c83717ce3f7bc1932@localhost \
    --to=paul@paulbarker.me.uk \
    --cc=jarkko.nikula@bitmer.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=peter.ujfalusi@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox