From patchwork Fri Feb 14 05:41:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 236327 List-Id: U-Boot discussion From: yamada.masahiro at socionext.com (Masahiro Yamada) Date: Fri, 14 Feb 2020 14:41:39 +0900 Subject: [PATCH v2 06/11] mmc: sdhci: reduce code duplication for aligned buffer In-Reply-To: <20200214054144.18315-1-yamada.masahiro@socionext.com> References: <20200214054144.18315-1-yamada.masahiro@socionext.com> Message-ID: <20200214054144.18315-7-yamada.masahiro@socionext.com> The same code is run for both SDHCI_QUIRK_32BIT_DMA_ADDR and define(CONFIG_FIXED_SDHCI_ALIGNED_BUFFER). Unify the code. Signed-off-by: Masahiro Yamada --- Changes in v2: None drivers/mmc/sdhci.c | 22 ++++++++-------------- include/sdhci.h | 2 ++ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 18fbcb5f1864..b4713e7b9bba 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -140,27 +140,16 @@ static void sdhci_prepare_dma(struct sdhci_host *host, struct mmc_data *data, sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); if (host->flags & USE_SDMA) { - if ((host->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR) && - (host->start_addr & 0x7) != 0x0) { + if (host->force_align_buffer || + (host->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR && + (host->start_addr & 0x7) != 0x0)) { *is_aligned = 0; host->start_addr = (unsigned long)host->align_buffer; if (data->flags != MMC_DATA_READ) memcpy(host->align_buffer, data->src, trans_bytes); } - -#if defined(CONFIG_FIXED_SDHCI_ALIGNED_BUFFER) - /* - * Always use this bounce-buffer when - * CONFIG_FIXED_SDHCI_ALIGNED_BUFFER is defined - */ - *is_aligned = 0; - host->start_addr = (unsigned long)host->align_buffer; - if (data->flags != MMC_DATA_READ) - memcpy(host->align_buffer, data->src, trans_bytes); -#endif sdhci_writel(host, host->start_addr, SDHCI_DMA_ADDRESS); - } else if (host->flags & (USE_ADMA | USE_ADMA64)) { sdhci_prepare_adma_table(host, data); @@ -627,6 +616,11 @@ static int sdhci_init(struct mmc *mmc) #if defined(CONFIG_FIXED_SDHCI_ALIGNED_BUFFER) host->align_buffer = (void *)CONFIG_FIXED_SDHCI_ALIGNED_BUFFER; + /* + * Always use this bounce-buffer when CONFIG_FIXED_SDHCI_ALIGNED_BUFFER + * is defined. + */ + host->force_align_buffer = true; #else if (host->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR) { host->align_buffer = memalign(8, 512 * 1024); diff --git a/include/sdhci.h b/include/sdhci.h index 1358218270b8..7f8feefa450b 100644 --- a/include/sdhci.h +++ b/include/sdhci.h @@ -9,6 +9,7 @@ #ifndef __SDHCI_HW_H #define __SDHCI_HW_H +#include #include #include #include @@ -322,6 +323,7 @@ struct sdhci_host { struct mmc_config cfg; void *align_buffer; + bool force_align_buffer; dma_addr_t start_addr; int flags; #define USE_SDMA (0x1 << 0)