spi: sun4i: Allow transfers larger than FIFO size
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>
Wed, 26 Oct 2016 07:00:31 +0000 (00:00 -0700)
committerMark Brown <broonie@kernel.org>
Sat, 29 Oct 2016 18:11:30 +0000 (12:11 -0600)
commit196737912da5eab055489e0635662a3b7adef6eb
tree3d4c8019d13954ecd45d4a7e4a23edc002c9eb4d
parent1001354ca34179f3db924eb66672442a173147dc
spi: sun4i: Allow transfers larger than FIFO size

SPI transfers were limited to one FIFO depth, which is 64 bytes.
This was an artificial limitation, however, as the hardware can handle
much larger bursts. To accommodate this, we enable the interrupt when
the Rx FIFO is 3/4 full, and drain the FIFO within the interrupt
handler. The 3/4 ratio was chosen arbitrarily, with the intention to
reduce the potential number of interrupts.

Since the SUN4I_CTL_TP bit is set, the hardware will pause
transmission whenever the FIFO is full, so there is no risk of losing
data if we can't service the interrupt in time.

For the Tx side, enable and use the Tx FIFO 3/4 empty interrupt to
replenish the FIFO on large SPI bursts. This requires more care in
when the interrupt is left enabled, as this interrupt will continually
trigger when the FIFO is less than 1/4 full, even though we
acknowledge it.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Olliver Schinagl <o.schinagl@ultimaker.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-sun4i.c