aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/dw_spi_mid.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/dw_spi_mid.c')
-rw-r--r--drivers/spi/dw_spi_mid.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/drivers/spi/dw_spi_mid.c b/drivers/spi/dw_spi_mid.c
index 465e1cd4142..b53ab22f3cc 100644
--- a/drivers/spi/dw_spi_mid.c
+++ b/drivers/spi/dw_spi_mid.c
@@ -103,13 +103,6 @@ static int mid_spi_dma_init(struct dw_spi *dws)
/* Set the dma done bit to 1 */
dws->dma_inited = 1;
- dws->txdma_done = 1;
- dws->rxdma_done = 1;
-
- dws->tx_param = ((u64)(unsigned long)dws << 32)
- | (unsigned long)(&dws->txdma_done);
- dws->rx_param = ((u64)(unsigned long)dws << 32)
- | (unsigned long)(&dws->rxdma_done);
return 0;
free_rxchan:
@@ -125,20 +118,17 @@ static void mid_spi_dma_exit(struct dw_spi *dws)
dma_release_channel(dws->rxchan);
}
+/*
+ * dws->dma_chan_done is cleared before the dma transfer starts,
+ * callback for rx/tx channel will each increment it by 1.
+ * Reaching 2 means the whole spi transaction is done.
+ */
static void dw_spi_dma_done(void *arg)
{
- u64 *param = arg;
- struct dw_spi *dws;
- int *done;
+ struct dw_spi *dws = arg;
- dws = (struct dw_spi *)(unsigned long)(*param >> 32);
- done = (int *)(unsigned long)(*param & 0xffffffff);
-
- *done = 1;
- /* wait till both tx/rx channels are done */
- if (!dws->txdma_done || !dws->rxdma_done)
+ if (++dws->dma_chan_done != 2)
return;
-
dw_spi_xfer_done(dws);
}
@@ -162,10 +152,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
spi_enable_chip(dws, 1);
}
- if (dws->tx_dma)
- dws->txdma_done = 0;
- if (dws->rx_dma)
- dws->rxdma_done = 0;
+ dws->dma_chan_done = 0;
/* 2. start the TX dma transfer */
txchan = dws->txchan;
@@ -177,7 +164,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
dws->dma_addr, dws->tx_dma,
dws->len, flag);
txdesc->callback = dw_spi_dma_done;
- txdesc->callback_param = &dws->tx_param;
+ txdesc->callback_param = dws;
}
/* 3. start the RX dma transfer */
@@ -186,7 +173,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
dws->rx_dma, dws->dma_addr,
dws->len, flag);
rxdesc->callback = dw_spi_dma_done;
- rxdesc->callback_param = &dws->rx_param;
+ rxdesc->callback_param = dws;
}
/* rx must be started before tx due to spi instinct */