aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAddy Ke <addy.ke@rock-chips.com>2014-09-25 02:59:41 -0400
committerMark Brown <broonie@kernel.org>2014-09-25 09:14:44 -0400
commita24e70c0ac146f8bcae3cdb7f514950d5b32219e (patch)
tree5efc415cbd87dc6882e03e39d80ca21d9b327719
parent7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff)
spi/rockchip: fix bug that cause the failure to read data in DMA mode
In my test on RK3288-pinky board, if spi is enabled, it will begin to read data from slave regardless of whether the DMA is ready. So we need prepare DMA before spi is enable. Signed-off-by: Addy Ke <addy.ke@rock-chips.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
-rw-r--r--drivers/spi/spi-rockchip.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index c0743604b906..1fa4eda4b432 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -415,7 +415,7 @@ static void rockchip_spi_dma_txcb(void *data)
415 spin_unlock_irqrestore(&rs->lock, flags); 415 spin_unlock_irqrestore(&rs->lock, flags);
416} 416}
417 417
418static int rockchip_spi_dma_transfer(struct rockchip_spi *rs) 418static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
419{ 419{
420 unsigned long flags; 420 unsigned long flags;
421 struct dma_slave_config rxconf, txconf; 421 struct dma_slave_config rxconf, txconf;
@@ -474,8 +474,6 @@ static int rockchip_spi_dma_transfer(struct rockchip_spi *rs)
474 dmaengine_submit(txdesc); 474 dmaengine_submit(txdesc);
475 dma_async_issue_pending(rs->dma_tx.ch); 475 dma_async_issue_pending(rs->dma_tx.ch);
476 } 476 }
477
478 return 1;
479} 477}
480 478
481static void rockchip_spi_config(struct rockchip_spi *rs) 479static void rockchip_spi_config(struct rockchip_spi *rs)
@@ -556,16 +554,17 @@ static int rockchip_spi_transfer_one(
556 else if (rs->rx) 554 else if (rs->rx)
557 rs->tmode = CR0_XFM_RO; 555 rs->tmode = CR0_XFM_RO;
558 556
559 if (master->can_dma && master->can_dma(master, spi, xfer)) 557 /* we need prepare dma before spi was enabled */
558 if (master->can_dma && master->can_dma(master, spi, xfer)) {
560 rs->use_dma = 1; 559 rs->use_dma = 1;
561 else 560 rockchip_spi_prepare_dma(rs);
561 } else {
562 rs->use_dma = 0; 562 rs->use_dma = 0;
563 }
563 564
564 rockchip_spi_config(rs); 565 rockchip_spi_config(rs);
565 566
566 if (rs->use_dma) 567 if (!rs->use_dma)
567 ret = rockchip_spi_dma_transfer(rs);
568 else
569 ret = rockchip_spi_pio_transfer(rs); 568 ret = rockchip_spi_pio_transfer(rs);
570 569
571 return ret; 570 return ret;