[PATCH v4 11/13] mmc: Introduce mmc_phys_to_bus()/mmc_bus_to_phys()
Nicolas Saenz Julienne
nsaenzjulienne at suse.de
Tue Dec 22 13:35:46 CET 2020
This will allow us to use DM variants of phys_to_bus()/bus_to_phys()
when relevant.
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne at suse.de>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
Changes since v3
- Don't call phys_to_bus()/bus_to_phys(), we only support DM
drivers/mmc/sdhci.c | 7 ++++---
include/mmc.h | 10 ++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 0628934312..2086d7cdb1 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -19,7 +19,6 @@
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
-#include <phys2bus.h>
static void sdhci_reset(struct sdhci_host *host, u8 mask)
{
@@ -103,7 +102,8 @@ static void sdhci_prepare_dma(struct sdhci_host *host, struct mmc_data *data,
mmc_get_dma_dir(data));
if (host->flags & USE_SDMA) {
- sdhci_writel(host, phys_to_bus((ulong)host->start_addr),
+ sdhci_writel(host,
+ mmc_phys_to_bus(host->mmc, (ulong)host->start_addr),
SDHCI_DMA_ADDRESS);
}
#if CONFIG_IS_ENABLED(MMC_SDHCI_ADMA)
@@ -162,7 +162,8 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data)
start_addr &=
~(SDHCI_DEFAULT_BOUNDARY_SIZE - 1);
start_addr += SDHCI_DEFAULT_BOUNDARY_SIZE;
- sdhci_writel(host, phys_to_bus((ulong)start_addr),
+ sdhci_writel(host,
+ mmc_phys_to_bus(host->mmc, (ulong)start_addr),
SDHCI_DMA_ADDRESS);
}
}
diff --git a/include/mmc.h b/include/mmc.h
index 1d377e0281..393c08d5a9 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -15,6 +15,7 @@
#include <linux/compiler.h>
#include <linux/dma-direction.h>
#include <part.h>
+#include <phys2bus.h>
struct bd_info;
@@ -977,4 +978,13 @@ static inline enum dma_data_direction mmc_get_dma_dir(struct mmc_data *data)
return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
}
+static inline dma_addr_t mmc_phys_to_bus(struct mmc *mmc, phys_addr_t addr)
+{
+#if CONFIG_IS_ENABLED(DM_DMA)
+ return dev_phys_to_bus(mmc->dev, addr);
+#else
+ return (dma_addr_t)addr;
+#endif
+}
+
#endif /* _MMC_H_ */
--
2.29.2
More information about the U-Boot
mailing list