[PATCH 07/10] mmc: spi: Pull out common DMA parts from MXS MMC

2012-08-03 Thread Marek Vasut
These parts will be used by the MXS SPI driver too.

Signed-off-by: Marek Vasut 
Cc: Attila Kinali 
Cc: Chris Ball 
CC: Dong Aisheng 
Cc: Fabio Estevam 
Cc: Grant Likely 
Cc: Linux ARM kernel 
Cc: Mark Brown 
CC: Shawn Guo 
---
 drivers/mmc/host/mxs-mmc.c  |   88 +--
 drivers/spi/spi-mxs.c   |1 -
 include/linux/spi/mxs-spi.h |9 +
 3 files changed, 51 insertions(+), 47 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 0813340..4da9966 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -41,7 +41,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -69,13 +68,6 @@ struct mxs_mmc_host {
struct mmc_command  *cmd;
struct mmc_data *data;
 
-   int dma_channel;
-   struct dma_chan *dmach;
-   struct mxs_dma_data dma_data;
-   unsigned intdma_dir;
-   enum dma_transfer_direction slave_dirn;
-   u32 ssp_pio_words[SSP_PIO_NUM];
-
unsigned char   bus_width;
spinlock_t  lock;
int sdio_irq_en;
@@ -163,7 +155,7 @@ static void mxs_mmc_request_done(struct mxs_mmc_host *host)
 
if (data) {
dma_unmap_sg(mmc_dev(host->mmc), data->sg,
-data->sg_len, host->dma_dir);
+data->sg_len, ssp->dma_dir);
/*
 * If there was an error on any block, we mark all
 * data blocks as being in error.
@@ -232,6 +224,7 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void 
*dev_id)
 static struct dma_async_tx_descriptor *mxs_mmc_prep_dma(
struct mxs_mmc_host *host, unsigned long flags)
 {
+   struct mxs_ssp *ssp = &host->ssp;
struct dma_async_tx_descriptor *desc;
struct mmc_data *data = host->data;
struct scatterlist * sgl;
@@ -240,24 +233,24 @@ static struct dma_async_tx_descriptor *mxs_mmc_prep_dma(
if (data) {
/* data */
dma_map_sg(mmc_dev(host->mmc), data->sg,
-  data->sg_len, host->dma_dir);
+  data->sg_len, ssp->dma_dir);
sgl = data->sg;
sg_len = data->sg_len;
} else {
/* pio */
-   sgl = (struct scatterlist *) host->ssp_pio_words;
+   sgl = (struct scatterlist *) ssp->ssp_pio_words;
sg_len = SSP_PIO_NUM;
}
 
-   desc = dmaengine_prep_slave_sg(host->dmach,
-   sgl, sg_len, host->slave_dirn, flags);
+   desc = dmaengine_prep_slave_sg(ssp->dmach,
+   sgl, sg_len, ssp->slave_dirn, flags);
if (desc) {
desc->callback = mxs_mmc_dma_irq_callback;
desc->callback_param = host;
} else {
if (data)
dma_unmap_sg(mmc_dev(host->mmc), data->sg,
-data->sg_len, host->dma_dir);
+data->sg_len, ssp->dma_dir);
}
 
return desc;
@@ -265,6 +258,7 @@ static struct dma_async_tx_descriptor *mxs_mmc_prep_dma(
 
 static void mxs_mmc_bc(struct mxs_mmc_host *host)
 {
+   struct mxs_ssp *ssp = &host->ssp;
struct mmc_command *cmd = host->cmd;
struct dma_async_tx_descriptor *desc;
u32 ctrl0, cmd0, cmd1;
@@ -278,17 +272,17 @@ static void mxs_mmc_bc(struct mxs_mmc_host *host)
cmd0 |= BM_SSP_CMD0_CONT_CLKING_EN | BM_SSP_CMD0_SLOW_CLKING_EN;
}
 
-   host->ssp_pio_words[0] = ctrl0;
-   host->ssp_pio_words[1] = cmd0;
-   host->ssp_pio_words[2] = cmd1;
-   host->dma_dir = DMA_NONE;
-   host->slave_dirn = DMA_TRANS_NONE;
+   ssp->ssp_pio_words[0] = ctrl0;
+   ssp->ssp_pio_words[1] = cmd0;
+   ssp->ssp_pio_words[2] = cmd1;
+   ssp->dma_dir = DMA_NONE;
+   ssp->slave_dirn = DMA_TRANS_NONE;
desc = mxs_mmc_prep_dma(host, DMA_CTRL_ACK);
if (!desc)
goto out;
 
dmaengine_submit(desc);
-   dma_async_issue_pending(host->dmach);
+   dma_async_issue_pending(ssp->dmach);
return;
 
 out:
@@ -298,6 +292,7 @@ out:
 
 static void mxs_mmc_ac(struct mxs_mmc_host *host)
 {
+   struct mxs_ssp *ssp = &host->ssp;
struct mmc_command *cmd = host->cmd;
struct dma_async_tx_descriptor *desc;
u32 ignore_crc, get_resp, long_resp;
@@ -319,17 +314,17 @@ static void mxs_mmc_ac(struct mxs_mmc_host *host)
cmd0 |= BM_SSP_CMD0_CONT_CLKING_EN | BM_SSP_CMD0_SLOW_CLKING_EN;
}
 
-   host->ssp_pio_words[0] = ctrl0;
-   host->ssp_pio_words[1] = cmd0;
-   host->ssp_pio_words[2] = cmd1;
-   host->dma_dir = DMA_NONE;
-

[PATCH 07/10] mmc: spi: Pull out common DMA parts from MXS MMC

2012-07-16 Thread Marek Vasut
These parts will be used by the MXS SPI driver too.

Signed-off-by: Marek Vasut 
Cc: Chris Ball 
Cc: Detlev Zundel 
CC: Dong Aisheng 
Cc: Fabio Estevam 
Cc: Grant Likely 
Cc: Linux ARM kernel 
Cc: Rob Herring 
CC: Shawn Guo 
Cc: Stefano Babic 
Cc: Wolfgang Denk 
---
 drivers/mmc/host/mxs-mmc.c  |   88 +--
 drivers/spi/spi-mxs.c   |1 -
 include/linux/spi/mxs-spi.h |9 +
 3 files changed, 51 insertions(+), 47 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 3b1c99b..c4be207 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -41,7 +41,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -69,13 +68,6 @@ struct mxs_mmc_host {
struct mmc_command  *cmd;
struct mmc_data *data;
 
-   int dma_channel;
-   struct dma_chan *dmach;
-   struct mxs_dma_data dma_data;
-   unsigned intdma_dir;
-   enum dma_transfer_direction slave_dirn;
-   u32 ssp_pio_words[SSP_PIO_NUM];
-
unsigned char   bus_width;
spinlock_t  lock;
int sdio_irq_en;
@@ -163,7 +155,7 @@ static void mxs_mmc_request_done(struct mxs_mmc_host *host)
 
if (data) {
dma_unmap_sg(mmc_dev(host->mmc), data->sg,
-data->sg_len, host->dma_dir);
+data->sg_len, ssp->dma_dir);
/*
 * If there was an error on any block, we mark all
 * data blocks as being in error.
@@ -232,6 +224,7 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void 
*dev_id)
 static struct dma_async_tx_descriptor *mxs_mmc_prep_dma(
struct mxs_mmc_host *host, unsigned long flags)
 {
+   struct mxs_ssp *ssp = &host->ssp;
struct dma_async_tx_descriptor *desc;
struct mmc_data *data = host->data;
struct scatterlist * sgl;
@@ -240,24 +233,24 @@ static struct dma_async_tx_descriptor *mxs_mmc_prep_dma(
if (data) {
/* data */
dma_map_sg(mmc_dev(host->mmc), data->sg,
-  data->sg_len, host->dma_dir);
+  data->sg_len, ssp->dma_dir);
sgl = data->sg;
sg_len = data->sg_len;
} else {
/* pio */
-   sgl = (struct scatterlist *) host->ssp_pio_words;
+   sgl = (struct scatterlist *) ssp->ssp_pio_words;
sg_len = SSP_PIO_NUM;
}
 
-   desc = dmaengine_prep_slave_sg(host->dmach,
-   sgl, sg_len, host->slave_dirn, flags);
+   desc = dmaengine_prep_slave_sg(ssp->dmach,
+   sgl, sg_len, ssp->slave_dirn, flags);
if (desc) {
desc->callback = mxs_mmc_dma_irq_callback;
desc->callback_param = host;
} else {
if (data)
dma_unmap_sg(mmc_dev(host->mmc), data->sg,
-data->sg_len, host->dma_dir);
+data->sg_len, ssp->dma_dir);
}
 
return desc;
@@ -265,6 +258,7 @@ static struct dma_async_tx_descriptor *mxs_mmc_prep_dma(
 
 static void mxs_mmc_bc(struct mxs_mmc_host *host)
 {
+   struct mxs_ssp *ssp = &host->ssp;
struct mmc_command *cmd = host->cmd;
struct dma_async_tx_descriptor *desc;
u32 ctrl0, cmd0, cmd1;
@@ -278,17 +272,17 @@ static void mxs_mmc_bc(struct mxs_mmc_host *host)
cmd0 |= BM_SSP_CMD0_CONT_CLKING_EN | BM_SSP_CMD0_SLOW_CLKING_EN;
}
 
-   host->ssp_pio_words[0] = ctrl0;
-   host->ssp_pio_words[1] = cmd0;
-   host->ssp_pio_words[2] = cmd1;
-   host->dma_dir = DMA_NONE;
-   host->slave_dirn = DMA_TRANS_NONE;
+   ssp->ssp_pio_words[0] = ctrl0;
+   ssp->ssp_pio_words[1] = cmd0;
+   ssp->ssp_pio_words[2] = cmd1;
+   ssp->dma_dir = DMA_NONE;
+   ssp->slave_dirn = DMA_TRANS_NONE;
desc = mxs_mmc_prep_dma(host, DMA_CTRL_ACK);
if (!desc)
goto out;
 
dmaengine_submit(desc);
-   dma_async_issue_pending(host->dmach);
+   dma_async_issue_pending(ssp->dmach);
return;
 
 out:
@@ -298,6 +292,7 @@ out:
 
 static void mxs_mmc_ac(struct mxs_mmc_host *host)
 {
+   struct mxs_ssp *ssp = &host->ssp;
struct mmc_command *cmd = host->cmd;
struct dma_async_tx_descriptor *desc;
u32 ignore_crc, get_resp, long_resp;
@@ -319,17 +314,17 @@ static void mxs_mmc_ac(struct mxs_mmc_host *host)
cmd0 |= BM_SSP_CMD0_CONT_CLKING_EN | BM_SSP_CMD0_SLOW_CLKING_EN;
}
 
-   host->ssp_pio_words[0] = ctrl0;
-   host->ssp_pio_words[1] = cmd0;
-   host->ssp_pio_words[2] = cmd1;