mmc: dw_mmc: split out preparation of desc for IDMAC32 and IDMAC64
We intend to add more check for descriptors when preparing desc. Let's spilt out the separate body to make the dw_mci_translate_sglist not so lengthy. After spliting out these two functions, we could remove dw_mci_translate_sglist and call both of them when staring idmac. Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
1712c9373f
commit
ec0baaa6b3
@ -467,14 +467,13 @@ static void dw_mci_dmac_complete_dma(void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dw_mci_translate_sglist(struct dw_mci *host, struct mmc_data *data,
|
static inline void dw_mci_prepare_desc64(struct dw_mci *host,
|
||||||
|
struct mmc_data *data,
|
||||||
unsigned int sg_len)
|
unsigned int sg_len)
|
||||||
{
|
{
|
||||||
unsigned int desc_len;
|
unsigned int desc_len;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (host->dma_64bit_address == 1) {
|
|
||||||
struct idmac_desc_64addr *desc_first, *desc_last, *desc;
|
struct idmac_desc_64addr *desc_first, *desc_last, *desc;
|
||||||
|
int i;
|
||||||
|
|
||||||
desc_first = desc_last = desc = host->sg_cpu;
|
desc_first = desc_last = desc = host->sg_cpu;
|
||||||
|
|
||||||
@ -517,9 +516,16 @@ static void dw_mci_translate_sglist(struct dw_mci *host, struct mmc_data *data,
|
|||||||
/* Set last descriptor */
|
/* Set last descriptor */
|
||||||
desc_last->des0 &= ~(IDMAC_DES0_CH | IDMAC_DES0_DIC);
|
desc_last->des0 &= ~(IDMAC_DES0_CH | IDMAC_DES0_DIC);
|
||||||
desc_last->des0 |= IDMAC_DES0_LD;
|
desc_last->des0 |= IDMAC_DES0_LD;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
|
static inline void dw_mci_prepare_desc32(struct dw_mci *host,
|
||||||
|
struct mmc_data *data,
|
||||||
|
unsigned int sg_len)
|
||||||
|
{
|
||||||
|
unsigned int desc_len;
|
||||||
struct idmac_desc *desc_first, *desc_last, *desc;
|
struct idmac_desc *desc_first, *desc_last, *desc;
|
||||||
|
int i;
|
||||||
|
|
||||||
desc_first = desc_last = desc = host->sg_cpu;
|
desc_first = desc_last = desc = host->sg_cpu;
|
||||||
|
|
||||||
@ -565,14 +571,17 @@ static void dw_mci_translate_sglist(struct dw_mci *host, struct mmc_data *data,
|
|||||||
desc_last->des0 |= cpu_to_le32(IDMAC_DES0_LD);
|
desc_last->des0 |= cpu_to_le32(IDMAC_DES0_LD);
|
||||||
}
|
}
|
||||||
|
|
||||||
wmb(); /* drain writebuffer */
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dw_mci_idmac_start_dma(struct dw_mci *host, unsigned int sg_len)
|
static int dw_mci_idmac_start_dma(struct dw_mci *host, unsigned int sg_len)
|
||||||
{
|
{
|
||||||
u32 temp;
|
u32 temp;
|
||||||
|
|
||||||
dw_mci_translate_sglist(host, host->data, sg_len);
|
if (host->dma_64bit_address == 1)
|
||||||
|
dw_mci_prepare_desc64(host, host->data, sg_len);
|
||||||
|
else
|
||||||
|
dw_mci_prepare_desc32(host, host->data, sg_len);
|
||||||
|
|
||||||
|
/* drain writebuffer */
|
||||||
|
wmb();
|
||||||
|
|
||||||
/* Make sure to reset DMA in case we did PIO before this */
|
/* Make sure to reset DMA in case we did PIO before this */
|
||||||
dw_mci_ctrl_reset(host, SDMMC_CTRL_DMA_RESET);
|
dw_mci_ctrl_reset(host, SDMMC_CTRL_DMA_RESET);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user