Skip to contentSkip to conversation

sunxi-mmc: enable new clock mode on A64

PATCH Superseded Vasily Khoruzhick 2 participants 10 messages Nov 10, 2018 – Nov 22, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover sunxi-mmc: enable new clock mode on A64

A64 requires new clock mode on SD and eMMC controllers. Not using new clock mode causes stability issues of the driver - SPL may occasionally fail to load u-boot from SD for some particular SD card on some particular devices.

This series depends on "sunxi: add support for automatic delay calibration" from my Pinebook series.

Tested on Pinebook and Pine64-LTS. Fixes eMMC failures on Olinuxino-A64 [1]

[1] https://github.com/armbian/build/commit/03199b3879af24c94029460b8cdf0d41048afc92#commitcomment-31028421

Vasily Khoruzhick (3):
sunxi-mmc: introduce new MMC_SUNXI_HAS_MODE_SWITCH option
sunxi-mmc: don't double clock for new mode unconditionally
sunxi-mmc: use new mode on both controllers on A64

 arch/arm/mach-sunxi/Kconfig |  2 ++
 drivers/mmc/Kconfig         |  4 ++++
 drivers/mmc/sunxi_mmc.c     | 19 +++++++++----------
 3 files changed, 15 insertions(+), 10 deletions(-)
Signature · 1 line
2.19.1
#1 lore raw

PATCH v2 1/3 sunxi-mmc: introduce new MMC_SUNXI_HAS_MODE_SWITCH option

A64 doesn't have a mode switch in CCM, and CCM_MMC_CTRL_MODE_SEL_NEW is not defined, so compilation fails if MMC_SUNXI_HAS_NEW_MODE is enabled

Introduce new MMC_SUNXI_HAS_MODE_SWITCH option to be able to ifdef usage of CCM_MMC_CTRL_MODE_SEL_NEW

---
 arch/arm/mach-sunxi/Kconfig | 1 +
 drivers/mmc/Kconfig         | 4 ++++
 drivers/mmc/sunxi_mmc.c     | 2 ++
 3 files changed, 7 insertions(+)
arch/arm/mach-sunxi/Kconfig +1 -0
index 560dc9b25d..66fff6c6d3 100644
@@ -230,6 +230,7 @@ config MACH_SUN8I_A83T
 	select PHY_SUN4I_USB
 	select SUNXI_GEN_SUN6I
 	select MMC_SUNXI_HAS_NEW_MODE
+	select MMC_SUNXI_HAS_MODE_SWITCH
 	select SUPPORT_SPL
 
 config MACH_SUN8I_H3
drivers/mmc/Kconfig +4 -0
index 27246ee465..3f7458d409 100644
@@ -569,6 +569,10 @@ config MMC_SUNXI_HAS_NEW_MODE
 	bool
 	depends on MMC_SUNXI
 
+config MMC_SUNXI_HAS_MODE_SWITCH
+	bool
+	depends on MMC_SUNXI
+
 config GENERIC_ATMEL_MCI
 	bool "Atmel Multimedia Card Interface support"
 	depends on DM_MMC && BLK && ARCH_AT91
drivers/mmc/sunxi_mmc.c +2 -0
index 147eb9b4d5..b3526f5e3f 100644
@@ -176,7 +176,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_MODE_SWITCH
 		val = CCM_MMC_CTRL_MODE_SEL_NEW;
+#endif
 		setbits_le32(&priv->reg->ntsr, SUNXI_MMC_NTSR_MODE_SEL_NEW);
 #endif
 	} else if (!calibrate) {
Signature · 1 line
2.19.1
#2 lore raw

PATCH v2 1/3 sunxi-mmc: introduce new MMC_SUNXI_HAS_MODE_SWITCH option

Quoted 3 lines · Vasily Khoruzhick

A64 doesn't have a mode switch in CCM, and CCM_MMC_CTRL_MODE_SEL_NEW is not defined, so compilation fails if MMC_SUNXI_HAS_NEW_MODE is enabled

Simple update on commit message.

Applied to u-boot-sunxi/master

#3 lore raw

PATCH v2 2/3 sunxi-mmc: don't double clock for new mode unconditionally

In reply to Vasily Khoruzhick

Comment in Linux driver says that clock needs to be doubled only if we use DDR modes, moreover divider has to be set accordingly.

U-boot driver doesn't declare support for any DDR modes and doesn't set internal clock divider in CLKCR, so it doubles clock unconditionally when new mode is used.

Some cards can't handle that and as result SPL fails to load u-boot.

Fixes de9b1771c3b ("mmc: sunxi: Support new mode")
---
 drivers/mmc/sunxi_mmc.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/mmc/sunxi_mmc.c +0 -7
index b3526f5e3f..e50b2c3343 100644
@@ -109,13 +109,6 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
 	calibrate = true;
 #endif
 
-	/*
-	 * The MMC clock has an extra /2 post-divider when operating in the new
-	 * mode.
-	 */
-	if (new_mode)
-		hz = hz * 2;
-
 	if (hz <= 24000000) {
 		pll = CCM_MMC_CTRL_OSCM24;
 		pll_hz = 24000000;
Signature · 1 line
2.19.1
#4 lore raw

PATCH v2 2/3 sunxi-mmc: don't double clock for new mode unconditionally

Quoted 8 lines · Vasily Khoruzhick

Comment in Linux driver says that clock needs to be doubled only if we use DDR modes, moreover divider has to be set accordingly.

U-boot driver doesn't declare support for any DDR modes and doesn't set internal clock divider in CLKCR, so it doubles clock unconditionally when new mode is used.

Quoted 5 lines

Some cards can't handle that and as result SPL fails to load u-boot.

Fixes de9b1771c3b ("mmc: sunxi: Support new mode")

---

Applied to u-boot-sunxi/master

#5 lore raw

PATCH v2 3/3 sunxi-mmc: use new mode on both controllers on A64

In reply to Vasily Khoruzhick

Using new mode improves stability of eMMC and SD cards. Without it SPL fails to load u-boot from SD on Pinebook.

---
 arch/arm/mach-sunxi/Kconfig |  1 +
 drivers/mmc/sunxi_mmc.c     | 10 +++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
arch/arm/mach-sunxi/Kconfig +1 -0
index 66fff6c6d3..3c54f5106d 100644
@@ -282,6 +282,7 @@ config MACH_SUN50I
 	select SUN6I_PRCM
 	select SUNXI_DE2
 	select SUNXI_GEN_SUN6I
+	select MMC_SUNXI_HAS_NEW_MODE
 	select SUPPORT_SPL
 	select SUNXI_DRAM_DW
 	select SUNXI_DRAM_DW_32BIT
drivers/mmc/sunxi_mmc.c +7 -3
index e50b2c3343..2b6f3c2234 100644
@@ -98,12 +98,16 @@ static int mmc_resource_init(int sdc_no)
 static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
 {
 	unsigned int pll, pll_hz, div, n, oclk_dly, sclk_dly;
-	bool new_mode = false;
+	bool new_mode = true;
 	bool calibrate = false;
 	u32 val = 0;
 
-	if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
-		new_mode = true;
+	if (!IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE))
+		new_mode = false;
+
+	/* A83 support new mode only on eMMC */
+	if (IS_ENABLED(CONFIG_MACH_SUN8I_A83T) && priv->mmc_no != 2)
+		new_mode = false;
 
 #if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H6)
 	calibrate = true;
Signature · 1 line
2.19.1
#6 lore raw

PATCH v2 3/3 sunxi-mmc: use new mode on both controllers on A64

Quoted 32 lines · Vasily Khoruzhick

Using new mode improves stability of eMMC and SD cards. Without it SPL fails to load u-boot from SD on Pinebook.

---
 arch/arm/mach-sunxi/Kconfig |  1 +
 drivers/mmc/sunxi_mmc.c     | 10 +++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
arch/arm/mach-sunxi/Kconfig +1 -0
index 66fff6c6d3..3c54f5106d 100644
@@ -282,6 +282,7 @@ config MACH_SUN50I
        select SUN6I_PRCM
        select SUNXI_DE2
        select SUNXI_GEN_SUN6I
+       select MMC_SUNXI_HAS_NEW_MODE
        select SUPPORT_SPL
        select SUNXI_DRAM_DW
        select SUNXI_DRAM_DW_32BIT
drivers/mmc/sunxi_mmc.c +0 -1
index e50b2c3343..2b6f3c2234 100644
@@ -98,12 +98,16 @@ static int mmc_resource_init(int sdc_no)
 static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
 {
        unsigned int pll, pll_hz, div, n, oclk_dly, sclk_dly;
-       bool new_mode = false;

drivers/mmc/sunxi_mmc.c static int mmc_resource_init(int sdc_no) · line 108

Quoted 10 lines
drivers/mmc/sunxi_mmc.c +5 -2
+       bool new_mode = true;
        bool calibrate = false;
        u32 val = 0;
 
-       if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
-               new_mode = true;
+       if (!IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE))
+               new_mode = false;
+
+       /* A83 support new mode only on eMMC */

s/A83/A83T

Applied to u-boot-sunxi/master

#7 lore raw

v2 cover sunxi-mmc: enable new clock mode on A64

In reply to Vasily Khoruzhick
Quoted 10 lines · Vasily Khoruzhick

A64 requires new clock mode on SD and eMMC controllers. Not using new clock mode causes stability issues of the driver - SPL may occasionally fail to load u-boot from SD for some particular SD card on some particular devices.

This series depends on "sunxi: add support for automatic delay calibration" from my Pinebook series.

Tested on Pinebook and Pine64-LTS. Fixes eMMC failures on Olinuxino-A64 [1]

Ping? I've got reports from several users that it fixes issues with different SD cards on Pinebook and Sopine. It would be nice to have it merged.

Quoted 15 lines

[1] https://github.com/armbian/build/commit/03199b3879af24c94029460b8cdf0d41048afc92#commitcomment-31028421

Vasily Khoruzhick (3):
sunxi-mmc: introduce new MMC_SUNXI_HAS_MODE_SWITCH option
sunxi-mmc: don't double clock for new mode unconditionally
sunxi-mmc: use new mode on both controllers on A64

 arch/arm/mach-sunxi/Kconfig |  2 ++
 drivers/mmc/Kconfig         |  4 ++++
 drivers/mmc/sunxi_mmc.c     | 19 +++++++++----------
 3 files changed, 15 insertions(+), 10 deletions(-)

--
2.19.1

#8 lore raw

v2 cover sunxi-mmc: enable new clock mode on A64

Quoted 8 lines · Vasily Khoruzhick
Quoted 6 lines · Vasily Khoruzhick

A64 requires new clock mode on SD and eMMC controllers. Not using new clock mode causes stability issues of the driver - SPL may occasionally fail to load u-boot from SD for some particular SD card on some particular devices.

Quoted 8 lines
Quoted 4 lines

This series depends on "sunxi: add support for automatic delay calibration" from my Pinebook series.

Tested on Pinebook and Pine64-LTS. Fixes eMMC failures on Olinuxino-A64 [1]

Ping? I've got reports from several users that it fixes issues with different SD cards on Pinebook and Sopine. It would be nice to have it merged.

Another gentle reminder - patches has been sitting in ML for almost 2 weeks with no review.

Quoted 15 lines
Quoted 15 lines

[1] https://github.com/armbian/build/commit/03199b3879af24c94029460b8cdf0d41048afc92#commitcomment-31028421

Vasily Khoruzhick (3):
sunxi-mmc: introduce new MMC_SUNXI_HAS_MODE_SWITCH option
sunxi-mmc: don't double clock for new mode unconditionally
sunxi-mmc: use new mode on both controllers on A64

 arch/arm/mach-sunxi/Kconfig |  2 ++
 drivers/mmc/Kconfig         |  4 ++++
 drivers/mmc/sunxi_mmc.c     | 19 +++++++++----------
 3 files changed, 15 insertions(+), 10 deletions(-)

--
2.19.1

#9 lore raw

v2 cover sunxi-mmc: enable new clock mode on A64

Quoted 13 lines · Vasily Khoruzhick
Quoted 11 lines · Vasily Khoruzhick
Quoted 9 lines · Vasily Khoruzhick

A64 requires new clock mode on SD and eMMC controllers. Not using new clock mode causes stability issues of the driver - SPL may occasionally fail to load u-boot from SD for some particular SD card on some particular devices.

This series depends on "sunxi: add support for automatic delay calibration" from my Pinebook series.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Tested on Pinebook and Pine64-LTS. Fixes eMMC failures on Olinuxino-A64 [1]

Ping? I've got reports from several users that it fixes issues with different SD cards on Pinebook and Sopine. It would be nice to have it merged.

Another gentle reminder - patches has been sitting in ML for almost 2 weeks with no review.

Be wait for some time, I understand your concern and I'm working on priority basic (that I mentioned in IRC). will come to this series.