summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-omap2-mcspi.c
diff options
context:
space:
mode:
authorIllia Smyrnov <illia.smyrnov@globallogic.com>2013-10-09 15:05:08 +0300
committerMark Brown <broonie@linaro.org>2013-10-09 19:00:58 +0100
commit5db542ed85b5e88346675f672dbd2eefa52005f4 (patch)
tree168fb3a17f261cf4822e7f651a29a886d362cc6f /drivers/spi/spi-omap2-mcspi.c
parentd0e639c9e06d44e713170031fe05fb60ebe680af (diff)
downloadlinux-5db542ed85b5e88346675f672dbd2eefa52005f4.tar.bz2
spi: omap2-mcspi: Fix FIFO support for transmit-and-receive mode
This patch fixes MCSPI FIFO buffer support when transmit-and-receive (full duplex) mode is used. In this mode FIFO can be used for RX or for TX or for both directions. If FIFO used for both directions the buffer is split into two 32-byte buffers - one for each direction. Also for full duplex mode both AEL and AFL need to be set in CHCONF0 register. Signed-off-by: Illia Smyrnov <illia.smyrnov@globallogic.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-omap2-mcspi.c')
-rw-r--r--drivers/spi/spi-omap2-mcspi.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index ed4af4708d9a..32dca0c55358 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -276,7 +276,7 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
struct omap2_mcspi_cs *cs = spi->controller_state;
struct omap2_mcspi *mcspi;
unsigned int wcnt;
- int fifo_depth, bytes_per_word;
+ int max_fifo_depth, fifo_depth, bytes_per_word;
u32 chconf, xferlevel;
mcspi = spi_master_get_devdata(master);
@@ -287,7 +287,12 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
if (t->len % bytes_per_word != 0)
goto disable_fifo;
- fifo_depth = gcd(t->len, OMAP2_MCSPI_MAX_FIFODEPTH);
+ if (t->rx_buf != NULL && t->tx_buf != NULL)
+ max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH / 2;
+ else
+ max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH;
+
+ fifo_depth = gcd(t->len, max_fifo_depth);
if (fifo_depth < 2 || fifo_depth % bytes_per_word != 0)
goto disable_fifo;
@@ -299,7 +304,8 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
if (t->rx_buf != NULL) {
chconf |= OMAP2_MCSPI_CHCONF_FFER;
xferlevel |= (fifo_depth - 1) << 8;
- } else {
+ }
+ if (t->tx_buf != NULL) {
chconf |= OMAP2_MCSPI_CHCONF_FFET;
xferlevel |= fifo_depth - 1;
}