summaryrefslogtreecommitdiffstats
path: root/drivers/mci
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-03-09 08:32:21 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-03-09 08:32:21 +0100
commit4680b375b9dd32e6558ae2ee8a15b27819c70e73 (patch)
tree945cd90ff3557de600e6e208596c7ef846fb603e /drivers/mci
parent5544581e98d09c7c9008f9cac8cd25dbb6a14d6e (diff)
parent0e06a77f5b93d4479ff1b88bc32003ceaa37d152 (diff)
downloadbarebox-4680b375b9dd32e6558ae2ee8a15b27819c70e73.tar.gz
barebox-4680b375b9dd32e6558ae2ee8a15b27819c70e73.tar.xz
Merge branch 'for-next/streaming-dma'
Conflicts: drivers/mci/dw_mmc.c
Diffstat (limited to 'drivers/mci')
-rw-r--r--drivers/mci/Kconfig2
-rw-r--r--drivers/mci/dw_mmc.c29
-rw-r--r--drivers/mci/imx-esdhc.c28
-rw-r--r--drivers/mci/tegra-sdmmc.c26
4 files changed, 47 insertions, 38 deletions
diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index 17bf0d381c..31f7d2d4ea 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -36,7 +36,7 @@ comment "--- MCI host drivers ---"
config MCI_DW
bool "Synopsys DesignWare Memory Card Interface"
- depends on ARM
+ depends on HAS_DMA
help
This selects support for the Synopsys DesignWare Mobile Storage IP
block, this provides host support for SD and MMC interfaces, in both
diff --git a/drivers/mci/dw_mmc.c b/drivers/mci/dw_mmc.c
index 076f99de0e..c4dfbb88f3 100644
--- a/drivers/mci/dw_mmc.c
+++ b/drivers/mci/dw_mmc.c
@@ -18,6 +18,7 @@
*/
#include <common.h>
+#include <dma.h>
#include <driver.h>
#include <malloc.h>
#include <clock.h>
@@ -28,7 +29,6 @@
#include <linux/clk.h>
#include <linux/err.h>
#include <asm-generic/errno.h>
-#include <asm/mmu.h>
#define DWMCI_CTRL 0x000
#define DWMCI_PWREN 0x004
@@ -417,7 +417,6 @@ dwmci_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
uint64_t start;
int ret;
unsigned int num_bytes = 0;
- const void *writebuf = NULL;
start = get_time_ns();
while (1) {
@@ -435,12 +434,12 @@ dwmci_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
if (data) {
num_bytes = data->blocks * data->blocksize;
- if (data->flags & MMC_DATA_WRITE) {
- dma_flush_range((unsigned long)data->src,
- (unsigned long)(data->src + data->blocks * 512));
-
- writebuf = data->src;
- }
+ if (data->flags & MMC_DATA_WRITE)
+ dma_sync_single_for_device((unsigned long)data->src,
+ num_bytes, DMA_TO_DEVICE);
+ else
+ dma_sync_single_for_device((unsigned long)data->dest,
+ num_bytes, DMA_FROM_DEVICE);
ret = dwmci_prepare_data(host, data);
if (ret)
@@ -541,11 +540,12 @@ dwmci_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
ctrl &= ~(DWMCI_DMA_EN);
dwmci_writel(host, DWMCI_CTRL, ctrl);
- if (data->flags & MMC_DATA_READ) {
- dma_inv_range((unsigned long)data->dest,
- (unsigned long)(data->dest +
- data->blocks * 512));
- }
+ if (data->flags & MMC_DATA_WRITE)
+ dma_sync_single_for_cpu((unsigned long)data->src,
+ num_bytes, DMA_TO_DEVICE);
+ else
+ dma_sync_single_for_cpu((unsigned long)data->dest,
+ num_bytes, DMA_FROM_DEVICE);
}
}
@@ -729,7 +729,8 @@ static int dw_mmc_probe(struct device_d *dev)
/* divider is 0 based in pdata and 1 based in our private struct */
host->ciu_div++;
- host->idmac = dma_alloc_coherent(sizeof(*host->idmac) * DW_MMC_NUM_IDMACS);
+ host->idmac = dma_alloc_coherent(sizeof(*host->idmac) * DW_MMC_NUM_IDMACS,
+ DMA_ADDRESS_BROKEN);
host->mci.send_cmd = dwmci_cmd;
host->mci.set_ios = dwmci_set_ios;
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index 23bdc1fb15..8b45500a09 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -22,6 +22,7 @@
*/
#include <config.h>
#include <common.h>
+#include <dma.h>
#include <driver.h>
#include <init.h>
#include <of.h>
@@ -31,7 +32,6 @@
#include <io.h>
#include <linux/clk.h>
#include <linux/err.h>
-#include <asm/mmu.h>
#include <mach/generic.h>
#include <mach/esdhc.h>
#include <gpio.h>
@@ -211,6 +211,7 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
u32 irqstat;
struct fsl_esdhc_host *host = to_fsl_esdhc(mci);
void __iomem *regs = host->regs;
+ unsigned int num_bytes = 0;
int ret;
esdhc_write32(regs + SDHCI_INT_STATUS, -1);
@@ -225,12 +226,15 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
err = esdhc_setup_data(mci, data);
if(err)
return err;
- if (data->flags & MMC_DATA_WRITE) {
- dma_flush_range((unsigned long)data->src,
- (unsigned long)(data->src + data->blocks * 512));
- } else
- dma_clean_range((unsigned long)data->src,
- (unsigned long)(data->src + data->blocks * 512));
+
+ num_bytes = data->blocks * data->blocksize;
+
+ if (data->flags & MMC_DATA_WRITE)
+ dma_sync_single_for_device((unsigned long)data->src,
+ num_bytes, DMA_TO_DEVICE);
+ else
+ dma_sync_single_for_device((unsigned long)data->dest,
+ num_bytes, DMA_FROM_DEVICE);
}
@@ -313,10 +317,12 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
} while (!(irqstat & IRQSTAT_TC) &&
(esdhc_read32(regs + SDHCI_PRESENT_STATE) & PRSSTAT_DLA));
- if (data->flags & MMC_DATA_READ) {
- dma_inv_range((unsigned long)data->dest,
- (unsigned long)(data->dest + data->blocks * 512));
- }
+ if (data->flags & MMC_DATA_WRITE)
+ dma_sync_single_for_cpu((unsigned long)data->src,
+ num_bytes, DMA_TO_DEVICE);
+ else
+ dma_sync_single_for_cpu((unsigned long)data->dest,
+ num_bytes, DMA_FROM_DEVICE);
#endif
}
diff --git a/drivers/mci/tegra-sdmmc.c b/drivers/mci/tegra-sdmmc.c
index 0e23d6fef1..670c280cb8 100644
--- a/drivers/mci/tegra-sdmmc.c
+++ b/drivers/mci/tegra-sdmmc.c
@@ -17,10 +17,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <asm/mmu.h>
#include <common.h>
#include <clock.h>
#include <driver.h>
+#include <dma.h>
#include <gpio.h>
#include <init.h>
#include <io.h>
@@ -100,6 +100,7 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
struct mci_data *data)
{
struct tegra_sdmmc_host *host = to_tegra_sdmmc_host(mci);
+ unsigned int num_bytes = 0;
u32 val = 0;
int ret;
@@ -109,15 +110,15 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
/* Set up for a data transfer if we have one */
if (data) {
+ num_bytes = data->blocks * data->blocksize;
+
if (data->flags & MMC_DATA_WRITE) {
- dma_flush_range((unsigned long)data->src,
- (unsigned long)(data->src +
- data->blocks * 512));
+ dma_sync_single_for_device((unsigned long)data->src,
+ num_bytes, DMA_TO_DEVICE);
writel((u32)data->src, host->regs + SDHCI_DMA_ADDRESS);
} else {
- dma_clean_range((unsigned long)data->src,
- (unsigned long)(data->src +
- data->blocks * 512));
+ dma_sync_single_for_device((unsigned long)data->dest,
+ num_bytes, DMA_FROM_DEVICE);
writel((u32)data->dest, host->regs + SDHCI_DMA_ADDRESS);
}
@@ -255,11 +256,12 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
}
writel(val, host->regs + SDHCI_INT_STATUS);
- if (data->flags & MMC_DATA_READ) {
- dma_inv_range((unsigned long)data->dest,
- (unsigned long)(data->dest +
- data->blocks * 512));
- }
+ if (data->flags & MMC_DATA_WRITE)
+ dma_sync_single_for_cpu((unsigned long)data->src,
+ num_bytes, DMA_TO_DEVICE);
+ else
+ dma_sync_single_for_cpu((unsigned long)data->dest,
+ num_bytes, DMA_FROM_DEVICE);
}
return 0;