spi: rockchip: set tx burst len 16, rx burst len 1.
authorHuibin Hong <huibin.hong@rock-chips.com>
Wed, 15 Jun 2016 09:40:42 +0000 (17:40 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 23 Jun 2016 03:35:59 +0000 (11:35 +0800)
Set ROCKCHIP_SPI_DMATDLR (rs->fifo_len - 16 - 1), which
can keep spi transferring. By the way, rx burst len must be
set 1, because it is hard to deal with the unaligned length.
Such as burst leng 16, ROCKCHIP_SPI_DMARDLR 16, when rx fifo
reaches 16, dma receive 16 bytes. But if the last bytes is less
than 16, dma will miss the bytes left in the rx fifo.

Change-Id: I846db94a87955453e617620ade32f2e68f01c01d
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
drivers/spi/spi-rockchip.c

index c8c1ada0989d36fb99cde4ba2ccd484dd8351e84..9e86ec35c4502d53cfdd59a808e7467dabb783a2 100644 (file)
@@ -446,7 +446,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs)
                rxconf.direction = rs->dma_rx.direction;
                rxconf.src_addr = rs->dma_rx.addr;
                rxconf.src_addr_width = rs->n_bytes;
-               rxconf.src_maxburst = rs->n_bytes;
+               rxconf.src_maxburst = 1;
                dmaengine_slave_config(rs->dma_rx.ch, &rxconf);
 
                rxdesc = dmaengine_prep_slave_sg(
@@ -465,7 +465,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs)
                txconf.direction = rs->dma_tx.direction;
                txconf.dst_addr = rs->dma_tx.addr;
                txconf.dst_addr_width = rs->n_bytes;
-               txconf.dst_maxburst = rs->n_bytes;
+               txconf.dst_maxburst = 16;
                dmaengine_slave_config(rs->dma_tx.ch, &txconf);
 
                txdesc = dmaengine_prep_slave_sg(
@@ -557,7 +557,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs)
        writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_TXFTLR);
        writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_RXFTLR);
 
-       writel_relaxed(0, rs->regs + ROCKCHIP_SPI_DMATDLR);
+       writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_DMATDLR);
        writel_relaxed(0, rs->regs + ROCKCHIP_SPI_DMARDLR);
        writel_relaxed(dmacr, rs->regs + ROCKCHIP_SPI_DMACR);