[PATCH v2 2/2] mmc: dw_mmc: support transfer mode auto detection

Johan Jonker jbx6244 at gmail.com
Wed Feb 23 14:07:14 CET 2022


From: Paweł Jarosz <paweljarosz3691 at gmail.com>

dw_mmc supports two transfer modes in u-boot: IDMA and FIFO.
This patch adds auto detection of transfer mode and
eliminates the need to set this in host config struct.
Allow handling for a u-boot,spl-fifo-mode host property in the
logic to not put the MMC controllers into FIFO mode for all time.

Signed-off-by: Paweł Jarosz <paweljarosz3691 at gmail.com>
Signed-off-by: Johan Jonker <jbx6244 at gmail.com>
---

Changed V2:
  use bitfield_extract
  remove use_dma variable
  include fifo_mode from host in logic
---
 drivers/mmc/dw_mmc.c | 6 ++++++
 include/dwmmc.h      | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
index a949dad5..7e2cd5ed 100644
--- a/drivers/mmc/dw_mmc.c
+++ b/drivers/mmc/dw_mmc.c
@@ -536,6 +536,12 @@ static int dwmci_init(struct mmc *mmc)
 		return -EIO;
 	}
 
+	if (!host->fifo_mode &&
+	    SDMMC_GET_TRANS_MODE(dwmci_readl(host, DWMCI_HCON)) == DMA_INTERFACE_IDMA)
+		host->fifo_mode = 0;
+	else
+		host->fifo_mode = 1;
+
 	/* Enumerate at 400KHz */
 	dwmci_setup_bus(host, mmc->cfg->f_min);
 
diff --git a/include/dwmmc.h b/include/dwmmc.h
index 5fc8ed83..d8d9ebe7 100644
--- a/include/dwmmc.h
+++ b/include/dwmmc.h
@@ -9,6 +9,7 @@
 
 #include <asm/cache.h>
 #include <asm/io.h>
+#include <bitfield.h>
 #include <mmc.h>
 #include <linux/bitops.h>
 
@@ -119,6 +120,10 @@
 #define RX_WMARK_SHIFT		16
 #define RX_WMARK_MASK		(0xfff << RX_WMARK_SHIFT)
 
+/* HCON Register */
+#define DMA_INTERFACE_IDMA		(0x0)
+#define SDMMC_GET_TRANS_MODE(x)		bitfield_extract(x, 16, 2)
+
 #define DWMCI_IDMAC_OWN		(1 << 31)
 #define DWMCI_IDMAC_CH		(1 << 4)
 #define DWMCI_IDMAC_FS		(1 << 3)
-- 
2.20.1



More information about the U-Boot mailing list