spi: dw-mid: fix FIFO size
[pandora-kernel.git] / drivers / spi / spi-dw-mid.c
index 130e555..e6a1bd3 100644 (file)
@@ -88,7 +88,13 @@ err_exit:
 
 static void mid_spi_dma_exit(struct dw_spi *dws)
 {
+       if (!dws->dma_inited)
+               return;
+
+       dmaengine_terminate_all(dws->txchan);
        dma_release_channel(dws->txchan);
+
+       dmaengine_terminate_all(dws->rxchan);
        dma_release_channel(dws->rxchan);
 }
 
@@ -116,13 +122,13 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
        /* 1. setup DMA related registers */
        if (cs_change) {
                spi_enable_chip(dws, 0);
-               dw_writew(dws, dmardlr, 0xf);
-               dw_writew(dws, dmatdlr, 0x10);
+               dw_writew(dws, DW_SPI_DMARDLR, 0xf);
+               dw_writew(dws, DW_SPI_DMATDLR, 0x10);
                if (dws->tx_dma)
                        dma_ctrl |= 0x2;
                if (dws->rx_dma)
                        dma_ctrl |= 0x1;
-               dw_writew(dws, dmacr, dma_ctrl);
+               dw_writew(dws, DW_SPI_DMACR, dma_ctrl);
                spi_enable_chip(dws, 1);
        }
 
@@ -135,7 +141,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
        txconf.dst_addr = dws->dma_addr;
        txconf.dst_maxburst = LNW_DMA_MSIZE_16;
        txconf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
-       txconf.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
+       txconf.dst_addr_width = dws->dma_width;
 
        txchan->device->device_control(txchan, DMA_SLAVE_CONFIG,
                                       (unsigned long) &txconf);
@@ -157,7 +163,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
        rxconf.src_addr = dws->dma_addr;
        rxconf.src_maxburst = LNW_DMA_MSIZE_16;
        rxconf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
-       rxconf.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
+       rxconf.src_addr_width = dws->dma_width;
 
        rxchan->device->device_control(rxchan, DMA_SLAVE_CONFIG,
                                       (unsigned long) &rxconf);
@@ -200,7 +206,8 @@ static struct dw_spi_dma_ops mid_dma_ops = {
 
 int dw_spi_mid_init(struct dw_spi *dws)
 {
-       u32 *clk_reg, clk_cdiv;
+       void __iomem *clk_reg;
+       u32 clk_cdiv;
 
        clk_reg = ioremap_nocache(MRST_CLK_SPI0_REG, 16);
        if (!clk_reg)
@@ -212,7 +219,6 @@ int dw_spi_mid_init(struct dw_spi *dws)
        iounmap(clk_reg);
 
        dws->num_cs = 16;
-       dws->fifo_len = 40;     /* FIFO has 40 words buffer */
 
 #ifdef CONFIG_SPI_DW_MID_DMA
        dws->dma_priv = kzalloc(sizeof(struct mid_dma), GFP_KERNEL);