107 lines
3.3 KiB
Diff
107 lines
3.3 KiB
Diff
From d25807c04228381ec55b7ee18480345516481e22 Mon Sep 17 00:00:00 2001
|
|
From: Peter Robinson <pbrobinson@gmail.com>
|
|
Date: Fri, 8 Jun 2018 04:24:16 +0100
|
|
Subject: [PATCH] sunxi: fix eMMC stability issues on A64
|
|
|
|
Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
|
|
---
|
|
arch/arm/include/asm/arch-sunxi/mmc.h | 6 +++++-
|
|
arch/arm/mach-sunxi/Kconfig | 2 ++
|
|
drivers/mmc/Kconfig | 4 ++++
|
|
drivers/mmc/sunxi_mmc.c | 13 +++++++++++++
|
|
4 files changed, 24 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/arch/arm/include/asm/arch-sunxi/mmc.h b/arch/arm/include/asm/arch-sunxi/mmc.h
|
|
index 1574b8e8fed..d6664a01f21 100644
|
|
--- a/arch/arm/include/asm/arch-sunxi/mmc.h
|
|
+++ b/arch/arm/include/asm/arch-sunxi/mmc.h
|
|
@@ -46,7 +46,9 @@ struct sunxi_mmc {
|
|
u32 cbda; /* 0x94 */
|
|
u32 res2[26];
|
|
#ifdef CONFIG_SUNXI_GEN_SUN6I
|
|
- u32 res3[64];
|
|
+ u32 res3[17];
|
|
+ u32 samp_dl;
|
|
+ u32 res4[46];
|
|
#endif
|
|
u32 fifo; /* 0x100 / 0x200 FIFO access address */
|
|
};
|
|
@@ -130,5 +132,7 @@ struct sunxi_mmc {
|
|
#define SUNXI_MMC_COMMON_CLK_GATE (1 << 16)
|
|
#define SUNXI_MMC_COMMON_RESET (1 << 18)
|
|
|
|
+#define SUNXI_MMC_CAL_DL_SW_EN (0x1 << 7)
|
|
+
|
|
struct mmc *sunxi_mmc_init(int sdc_no);
|
|
#endif /* _SUNXI_MMC_H */
|
|
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
|
|
index a3f77230286..6e3d7f6d0a2 100644
|
|
--- a/arch/arm/mach-sunxi/Kconfig
|
|
+++ b/arch/arm/mach-sunxi/Kconfig
|
|
@@ -213,6 +213,7 @@ config MACH_SUN8I_A83T
|
|
select PHY_SUN4I_USB
|
|
select SUNXI_GEN_SUN6I
|
|
select MMC_SUNXI_HAS_NEW_MODE
|
|
+ select MMC_SUNXI_HAS_NEW_MODE_SWITCH
|
|
select SUPPORT_SPL
|
|
|
|
config MACH_SUN8I_H3
|
|
@@ -265,6 +266,7 @@ config MACH_SUN50I
|
|
select SUNXI_DE2
|
|
select SUNXI_GEN_SUN6I
|
|
select SUNXI_HIGH_SRAM
|
|
+ select MMC_SUNXI_HAS_NEW_MODE
|
|
select SUPPORT_SPL
|
|
select SUNXI_DRAM_DW
|
|
select SUNXI_DRAM_DW_32BIT
|
|
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
|
|
index 693b3ceaf00..f8e435a2a25 100644
|
|
--- a/drivers/mmc/Kconfig
|
|
+++ b/drivers/mmc/Kconfig
|
|
@@ -536,6 +536,10 @@ config MMC_SUNXI_HAS_NEW_MODE
|
|
bool
|
|
depends on MMC_SUNXI
|
|
|
|
+config MMC_SUNXI_HAS_NEW_MODE_SWITCH
|
|
+ bool
|
|
+ depends on MMC_SUNXI
|
|
+
|
|
config GENERIC_ATMEL_MCI
|
|
bool "Atmel Multimedia Card Interface support"
|
|
depends on DM_MMC && BLK && ARCH_AT91
|
|
diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
|
|
index fe6d82c7b4e..624c9071548 100644
|
|
--- a/drivers/mmc/sunxi_mmc.c
|
|
+++ b/drivers/mmc/sunxi_mmc.c
|
|
@@ -166,7 +166,9 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
|
|
|
|
if (new_mode) {
|
|
#ifdef CONFIG_MMC_SUNXI_HAS_NEW_MODE
|
|
+#ifdef CONFIG_MMC_SUNXI_HAS_NEW_MODE_SWITCH
|
|
val = CCM_MMC_CTRL_MODE_SEL_NEW;
|
|
+#endif
|
|
setbits_le32(&priv->reg->ntsr, SUNXI_MMC_NTSR_MODE_SEL_NEW);
|
|
#endif
|
|
} else {
|
|
@@ -223,6 +225,17 @@ static int mmc_config_clock(struct sunxi_mmc_priv *priv, struct mmc *mmc)
|
|
rval &= ~SUNXI_MMC_CLK_DIVIDER_MASK;
|
|
writel(rval, &priv->reg->clkcr);
|
|
|
|
+#ifdef CONFIG_MACH_SUN50I
|
|
+ /* A64 needs to run calibration on eMMC controller and we
|
|
+ * have to set delay of zero before starting calibration.
|
|
+ * Allwinner BSP driver sets a delay only in the case of
|
|
+ * using HS400 which is not supported by mainline U-Boot or
|
|
+ * Linux at the moment
|
|
+ */
|
|
+ if (priv->mmc_no == 2)
|
|
+ writel(SUNXI_MMC_CAL_DL_SW_EN, &priv->reg->samp_dl);
|
|
+#endif
|
|
+
|
|
/* Re-enable Clock */
|
|
rval |= SUNXI_MMC_CLK_ENABLE;
|
|
writel(rval, &priv->reg->clkcr);
|
|
--
|
|
2.17.1
|
|
|