mbox series

[RFC,0/7] Signal pxa2xx SPI slave readiness via handshake signal [Was: SPI Slave with handshaking]

Message ID 20180917120808.20224-1-lkundrak@v3.sk (mailing list archive)
Headers show
Series Signal pxa2xx SPI slave readiness via handshake signal [Was: SPI Slave with handshaking] | expand

Message

Lubomir Rintel Sept. 17, 2018, 12:08 p.m. UTC
Hello Geert,

thanks for your response.

On Mon, 2018-08-27 at 16:32 +0200, Geert Uytterhoeven wrote:
> Hi Lubo,
> 
> On Tue, Aug 21, 2018 at 10:14 AM Lubomir Rintel <lkundrak@v3.sk> wrote:
> > I'm trying to port the OPLC XO 1.75 Embedded Controler (EC) driver to the SPI
> > slave framework. The EC is a SPI master that uses an extra pair of handshake
> > signals to determine when is it safe to transmit. The original driver [1]
> > included the SPI slave driver.
> > 
> > [1] http://dev.laptop.org/git/olpc-kernel/tree/drivers/misc/olpc-ec-1-75.c?h=arm-3.0-wip
> > 
> > To send the command to the EC, the protocol requires me to [2] signal to the
> > master that the tx FIFO is filled and it can start the transaction. The problem
> > is that I have no idea when that is. I'm wondering what my options are?
> 
> The SPI slave output FIFO has been filled after the SPI slave controller's
> spi_controller.transfer_one() function has written all data to the controller's
> FIFO.  Hence this is SPI controller specific.
> 
> After filling the FIFO, the SPI slave controller should assert the ACK line.

Yes. In fact, the EC detect an edge on the ACK/Ready line, and resets
its state machine when it's held high for too long, thus it just needs
to be strobed.
> 
> > [2] http://wiki.laptop.org/go/XO_1.75_HOST_to_EC_Protocol
> > 
> > 1.) Add a ready() callback to the spi_message, that would fire after the tx
> >     FIFO has been filled?
> > 
> > 2.) Delay the ACK strobe a bit after spi_async() and just hope for the best
> >     (Eek)
> > 
> > 3.) Have the transfer with NULL rx_buf complete just after sending the data to
> >     the controller, not waiting for actual transfer. And then strobe the ACK.
> > 
> > 4.) Keep the SPI slave code in the EC driver. I suppose this wouldn't be
> >     acceptable?
> > 
> > Better ideas, opinions & advice appreciated!
> 
> Is this on a DT-based platform?
> If yes, the GPIO (I assume it's a GPIO) used for the ACK signal will be
> provided by DT, and the SPI slave controller driver can assert it from its
> transfer_one() (or .transfer_one_message()) function after filling the FIFO.

Yes it is. I'm following up with a couple of patches that aim to
implement your suggestion. I'd be very thankful if you could take a look
and let me know if I got that right.

The patches don't include the EC driver, since that one needs some more
infrastructure work. My current working version is here:

https://github.com/hackerspace/olpc-xo175-linux/commits/lr/olpc-xo175-fixes2-spi-ec

The relevant patches are the last two:
https://github.com/hackerspace/olpc-xo175-linux/commit/ae67cbc4d86.patch
https://github.com/hackerspace/olpc-xo175-linux/commit/70bca1bc176.patch

If that looks reasonable, I'll go ahead and submit the whole thing for
review.

Regards,
Lubo