Skip to contentSkip to conversation

sunxi: fix eMMC stability issues on A64

PATCH Superseded Vasily Khoruzhick 3 participants 11 messages May 14, 2018 – May 31, 2018

Subsystems (4)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover sunxi: fix eMMC stability issues on A64

eMMC seems to require new clocking mode and calibration on A64, otherwise it is pretty unstable on some boards (e.g. Pinebook) with some eMMCs.

v2: - improve comment about calibration for eMMC on A64
- simplify ifdef-s around configuring delays

Vasily Khoruzhick (2):
sunxi-mmc: use new mode on A64
mmc: sunxi: run calibration on A64

 arch/arm/include/asm/arch-sunxi/mmc.h |  6 +++++-
 arch/arm/mach-sunxi/Kconfig           |  1 +
 drivers/mmc/sunxi_mmc.c               | 13 ++++++++++++-
 3 files changed, 18 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.0
#1 lore raw

PATCH v2 1/2 sunxi-mmc: use new mode on A64

That is necessary for using automatic calibration on A64 eMMC.

---
 arch/arm/mach-sunxi/Kconfig | 1 +
 drivers/mmc/sunxi_mmc.c     | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-sunxi/Kconfig +1 -0
index f0c9d1b058..376380e977 100644
@@ -256,6 +256,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
drivers/mmc/sunxi_mmc.c +1 -1
index fe6d82c7b4..65d88ee921 100644
@@ -165,7 +165,7 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
 	}
 
 	if (new_mode) {
-#ifdef CONFIG_MMC_SUNXI_HAS_NEW_MODE
+#if defined(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && !defined(CONFIG_MACH_SUN50I)
 		val = CCM_MMC_CTRL_MODE_SEL_NEW;
 		setbits_le32(&priv->reg->ntsr, SUNXI_MMC_NTSR_MODE_SEL_NEW);
 #endif
Signature · 1 line
2.17.0
#2 lore raw

PATCH v2 1/2 sunxi-mmc: use new mode on A64

Quoted 3 lines · Vasily Khoruzhick

That is necessary for using automatic calibration on A64 eMMC.

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180515/647211a7/attachment.sig>
#3 lore raw

PATCH v2 1/2 sunxi-mmc: use new mode on A64

In reply to Vasily Khoruzhick
Quoted 25 lines · Vasily Khoruzhick

That is necessary for using automatic calibration on A64 eMMC.

---
 arch/arm/mach-sunxi/Kconfig | 1 +
 drivers/mmc/sunxi_mmc.c     | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-sunxi/Kconfig +1 -0
index f0c9d1b058..376380e977 100644
@@ -256,6 +256,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
drivers/mmc/sunxi_mmc.c +0 -0
index fe6d82c7b4..65d88ee921 100644

drivers/mmc/sunxi_mmc.c static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz) · line 169

Quoted 6 lines
drivers/mmc/sunxi_mmc.c +1 -1
@@ -165,7 +165,7 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
        }
 
        if (new_mode) {
-#ifdef CONFIG_MMC_SUNXI_HAS_NEW_MODE
+#if defined(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && !defined(CONFIG_MACH_SUN50I)
                val = CCM_MMC_CTRL_MODE_SEL_NEW;

This is breaking eMMC boot on A64

U-Boot SPL 2018.05-00431-gf4fcaa5f15 (May 27 2018 - 23:59:42 +0530)
DRAM: 1024 MiB
Trying to boot from MMC2
unable to select a mode
mmc_load_image_raw_sector: mmc block read error
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

#4 lore raw

PATCH v2 1/2 sunxi-mmc: use new mode on A64

You need both patches in order for it to work.

I tested these patches on Pinebook and Pine64 LTS, both were able to boot from eMMC. What board are you using?

Quoted 42 lines · Jagan Teki
Quoted 25 lines · Vasily Khoruzhick

That is necessary for using automatic calibration on A64 eMMC.

---
 arch/arm/mach-sunxi/Kconfig | 1 +
 drivers/mmc/sunxi_mmc.c     | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-sunxi/Kconfig +1 -0
index f0c9d1b058..376380e977 100644
@@ -256,6 +256,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
drivers/mmc/sunxi_mmc.c +0 -0
index fe6d82c7b4..65d88ee921 100644

drivers/mmc/sunxi_mmc.c static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz) · line 169

Quoted 6 lines
drivers/mmc/sunxi_mmc.c +1 -1
@@ -165,7 +165,7 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
        }
 
        if (new_mode) {
-#ifdef CONFIG_MMC_SUNXI_HAS_NEW_MODE
+#if defined(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && !defined(CONFIG_MACH_SUN50I)
                val = CCM_MMC_CTRL_MODE_SEL_NEW;

This is breaking eMMC boot on A64

U-Boot SPL 2018.05-00431-gf4fcaa5f15 (May 27 2018 - 23:59:42 +0530)
DRAM: 1024 MiB
Trying to boot from MMC2
unable to select a mode
mmc_load_image_raw_sector: mmc block read error
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

#5 lore raw

PATCH v2 1/2 sunxi-mmc: use new mode on A64

Quoted 4 lines · Vasily Khoruzhick

You need both patches in order for it to work.

I tested these patches on Pinebook and Pine64 LTS, both were able to boot from eMMC. What board are you using?

Did you test BPI-M64? Here is the another board [1] where it failed

[1] https://patchwork.ozlabs.org/patch/921421/

Jagan.

Signature · 4 lines
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.
#6 lore raw

PATCH v2 1/2 sunxi-mmc: use new mode on A64

Quoted 7 lines · Jagan Teki
Quoted 4 lines · Vasily Khoruzhick

You need both patches in order for it to work.

I tested these patches on Pinebook and Pine64 LTS, both were able to boot from eMMC. What board are you using?

Did you test BPI-M64? Here is the another board [1] where it failed

I don't have BPI-M64. Could you enable debug in drivers/mmc/mmc.c to check why it fails to select a mode?

Quoted 9 lines

[1] https://patchwork.ozlabs.org/patch/921421/

Jagan.

--
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.

#7 lore raw

PATCH v2 1/2 sunxi-mmc: use new mode on A64

Quoted 11 lines · Vasily Khoruzhick
Quoted 7 lines · Jagan Teki
Quoted 4 lines · Vasily Khoruzhick

You need both patches in order for it to work.

I tested these patches on Pinebook and Pine64 LTS, both were able to boot from eMMC. What board are you using?

Did you test BPI-M64? Here is the another board [1] where it failed

I don't have BPI-M64. Could you enable debug in drivers/mmc/mmc.c to check why it fails to select a mode?

I found the issue. Will send v3 in a minute.

Quoted 10 lines
Quoted 10 lines

[1] https://patchwork.ozlabs.org/patch/921421/

Jagan.

--
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.

#8 lore raw

PATCH v2 2/2 mmc: sunxi: run calibration on A64

In reply to Vasily Khoruzhick

Along with using new mode it fixes eMMC instability on Pinebook

---
 arch/arm/include/asm/arch-sunxi/mmc.h |  6 +++++-
 drivers/mmc/sunxi_mmc.c               | 11 +++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
arch/arm/include/asm/arch-sunxi/mmc.h +5 -1
index 1574b8e8fe..d6664a01f2 100644
@@ -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 */
drivers/mmc/sunxi_mmc.c +11 -0
index 65d88ee921..542b85b592 100644
@@ -223,6 +223,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);
Signature · 1 line
2.17.0
#9 lore raw

PATCH v2 2/2 mmc: sunxi: run calibration on A64

Quoted 3 lines · Vasily Khoruzhick

Along with using new mode it fixes eMMC instability on Pinebook

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180515/a5577e49/attachment.sig>
#10 lore raw

v2 cover sunxi: fix eMMC stability issues on A64

In reply to Vasily Khoruzhick
Quoted 10 lines · Vasily Khoruzhick

eMMC seems to require new clocking mode and calibration on A64, otherwise it is pretty unstable on some boards (e.g. Pinebook) with some eMMCs.

v2: - improve comment about calibration for eMMC on A64
- simplify ifdef-s around configuring delays

Vasily Khoruzhick (2):
sunxi-mmc: use new mode on A64
mmc: sunxi: run calibration on A64

Applied to u-boot-sunxi/master