Skip to content
Snippets Groups Projects
Commit 4e6d81d1 authored by Marek Vasut's avatar Marek Vasut Committed by Andy Fleming
Browse files

MMC: MXS: Convert MXS MMC driver to generic bounce buffer


Implement necessary code to use the generic bounce buffer routines
inside this driver. This replaces the MMC bounce buffer, which is
to be removed.

Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Andy Fleming <afleming@freescale.com>
Signed-off-by: default avatarAndy Fleming <afleming@freescale.com>
parent b660df3c
Branches
Tags
No related merge requests found
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <asm/arch/imx-regs.h> #include <asm/arch/imx-regs.h>
#include <asm/arch/sys_proto.h> #include <asm/arch/sys_proto.h>
#include <asm/arch/dma.h> #include <asm/arch/dma.h>
#include <bouncebuf.h>
struct mxsmmc_priv { struct mxsmmc_priv {
int id; int id;
...@@ -95,28 +96,33 @@ static int mxsmmc_send_cmd_pio(struct mxsmmc_priv *priv, struct mmc_data *data) ...@@ -95,28 +96,33 @@ static int mxsmmc_send_cmd_pio(struct mxsmmc_priv *priv, struct mmc_data *data)
static int mxsmmc_send_cmd_dma(struct mxsmmc_priv *priv, struct mmc_data *data) static int mxsmmc_send_cmd_dma(struct mxsmmc_priv *priv, struct mmc_data *data)
{ {
uint32_t data_count = data->blocksize * data->blocks; uint32_t data_count = data->blocksize * data->blocks;
uint32_t cache_data_count; uint32_t cache_data_count = roundup(data_count, ARCH_DMA_MINALIGN);
int dmach; int dmach;
struct mxs_dma_desc *desc = priv->desc; struct mxs_dma_desc *desc = priv->desc;
void *addr, *backup;
uint8_t flags;
memset(desc, 0, sizeof(struct mxs_dma_desc)); memset(desc, 0, sizeof(struct mxs_dma_desc));
desc->address = (dma_addr_t)desc; desc->address = (dma_addr_t)desc;
if (data_count % ARCH_DMA_MINALIGN)
cache_data_count = roundup(data_count, ARCH_DMA_MINALIGN);
else
cache_data_count = data_count;
if (data->flags & MMC_DATA_READ) { if (data->flags & MMC_DATA_READ) {
priv->desc->cmd.data = MXS_DMA_DESC_COMMAND_DMA_WRITE; priv->desc->cmd.data = MXS_DMA_DESC_COMMAND_DMA_WRITE;
priv->desc->cmd.address = (dma_addr_t)data->dest; addr = data->dest;
flags = GEN_BB_WRITE;
} else { } else {
priv->desc->cmd.data = MXS_DMA_DESC_COMMAND_DMA_READ; priv->desc->cmd.data = MXS_DMA_DESC_COMMAND_DMA_READ;
priv->desc->cmd.address = (dma_addr_t)data->src; addr = (void *)data->src;
flags = GEN_BB_READ;
}
bounce_buffer_start(&addr, data_count, &backup, flags);
priv->desc->cmd.address = (dma_addr_t)addr;
if (data->flags & MMC_DATA_WRITE) {
/* Flush data to DRAM so DMA can pick them up */ /* Flush data to DRAM so DMA can pick them up */
flush_dcache_range((uint32_t)priv->desc->cmd.address, flush_dcache_range((uint32_t)addr,
(uint32_t)(priv->desc->cmd.address + cache_data_count)); (uint32_t)(addr) + cache_data_count);
} }
/* Invalidate the area, so no writeback into the RAM races with DMA */ /* Invalidate the area, so no writeback into the RAM races with DMA */
...@@ -128,15 +134,19 @@ static int mxsmmc_send_cmd_dma(struct mxsmmc_priv *priv, struct mmc_data *data) ...@@ -128,15 +134,19 @@ static int mxsmmc_send_cmd_dma(struct mxsmmc_priv *priv, struct mmc_data *data)
dmach = MXS_DMA_CHANNEL_AHB_APBH_SSP0 + priv->id; dmach = MXS_DMA_CHANNEL_AHB_APBH_SSP0 + priv->id;
mxs_dma_desc_append(dmach, priv->desc); mxs_dma_desc_append(dmach, priv->desc);
if (mxs_dma_go(dmach)) if (mxs_dma_go(dmach)) {
bounce_buffer_stop(&addr, data_count, &backup, flags);
return COMM_ERR; return COMM_ERR;
}
/* The data arrived into DRAM, invalidate cache over them */ /* The data arrived into DRAM, invalidate cache over them */
if (data->flags & MMC_DATA_READ) { if (data->flags & MMC_DATA_READ) {
invalidate_dcache_range((uint32_t)priv->desc->cmd.address, invalidate_dcache_range((uint32_t)addr,
(uint32_t)(priv->desc->cmd.address + cache_data_count)); (uint32_t)(addr) + cache_data_count);
} }
bounce_buffer_stop(&addr, data_count, &backup, flags);
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment