[U-Boot] [PATCH v2 1/2] mmc: sunxi: Support new mode

Almost all of the newer Allwinner SoCs have a new operating mode for the eMMC clocks that needs to be enabled in both the clock and the MMC controller.
Details about that mode are sparse, and the name itself (new mode vs old mode) doesn't give much details, but it seems that the it changes the sampling of the MMC clock. One side effect is also that it divides the parent clock rate by 2.
Add support for it through a Kconfig option.
Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com
--- Changes from v1: - Switched to IS_ENABLED when possible - Added some defines - Tried to put more details in the commit log - Added a depends on in the Kconfig option --- arch/arm/include/asm/arch-sunxi/clock_sun8i_a83t.h | 1 + arch/arm/include/asm/arch-sunxi/mmc.h | 11 ++++++--- drivers/mmc/Kconfig | 4 ++++ drivers/mmc/sunxi_mmc.c | 27 +++++++++++++++++++--- 4 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun8i_a83t.h b/arch/arm/include/asm/arch-sunxi/clock_sun8i_a83t.h index 5e1346e5242a..5dfcbf3b017b 100644 --- a/arch/arm/include/asm/arch-sunxi/clock_sun8i_a83t.h +++ b/arch/arm/include/asm/arch-sunxi/clock_sun8i_a83t.h @@ -220,6 +220,7 @@ struct sunxi_ccm_reg { #define CCM_MMC_CTRL_SCLK_DLY(x) ((x) << 20) #define CCM_MMC_CTRL_OSCM24 (0x0 << 24) #define CCM_MMC_CTRL_PLL6 (0x1 << 24) +#define CCM_MMC_CTRL_MODE_SEL_NEW (0x1 << 30) #define CCM_MMC_CTRL_ENABLE (0x1 << 31)
#define CCM_USB_CTRL_PHY0_RST (0x1 << 0) diff --git a/arch/arm/include/asm/arch-sunxi/mmc.h b/arch/arm/include/asm/arch-sunxi/mmc.h index cb52e648731c..69f737f3bffc 100644 --- a/arch/arm/include/asm/arch-sunxi/mmc.h +++ b/arch/arm/include/asm/arch-sunxi/mmc.h @@ -35,16 +35,19 @@ struct sunxi_mmc { u32 cbcr; /* 0x48 CIU byte count */ u32 bbcr; /* 0x4c BIU byte count */ u32 dbgc; /* 0x50 debug enable */ - u32 res0[11]; + u32 res0; /* 0x54 reserved */ + u32 a12a; /* 0x58 Auto command 12 argument */ + u32 ntsr; /* 0x5c New timing set register */ + u32 res1[8]; u32 dmac; /* 0x80 internal DMA control */ u32 dlba; /* 0x84 internal DMA descr list base address */ u32 idst; /* 0x88 internal DMA status */ u32 idie; /* 0x8c internal DMA interrupt enable */ u32 chda; /* 0x90 */ u32 cbda; /* 0x94 */ - u32 res1[26]; + u32 res2[26]; #ifdef CONFIG_SUNXI_GEN_SUN6I - u32 res2[64]; + u32 res3[64]; #endif u32 fifo; /* 0x100 / 0x200 FIFO access address */ }; @@ -116,6 +119,8 @@ struct sunxi_mmc { #define SUNXI_MMC_STATUS_CARD_DATA_BUSY (0x1 << 9) #define SUNXI_MMC_STATUS_DATA_FSM_BUSY (0x1 << 10)
+#define SUNXI_MMC_NTSR_MODE_SEL_NEW (0x1 << 31) + #define SUNXI_MMC_IDMAC_RESET (0x1 << 0) #define SUNXI_MMC_IDMAC_FIXBURST (0x1 << 1) #define SUNXI_MMC_IDMAC_ENABLE (0x1 << 7) diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index 51a87cdd77dc..9075b346036b 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -389,6 +389,10 @@ config MMC_SUNXI This selects support for the SD/MMC Host Controller on Allwinner sunxi SoCs.
+config MMC_SUNXI_HAS_NEW_MODE + bool + depends on MMC_SUNXI + config GENERIC_ATMEL_MCI bool "Atmel Multimedia Card Interface support" depends on DM_MMC && BLK && DM_MMC_OPS && ARCH_AT91 diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c index 588574fab6a9..bc638ae2e64a 100644 --- a/drivers/mmc/sunxi_mmc.c +++ b/drivers/mmc/sunxi_mmc.c @@ -96,6 +96,18 @@ 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; + u32 val = 0; + + if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2)) + new_mode = true; + + /* + * 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; @@ -152,9 +164,18 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz) #endif }
- writel(CCM_MMC_CTRL_ENABLE | pll | CCM_MMC_CTRL_SCLK_DLY(sclk_dly) | - CCM_MMC_CTRL_N(n) | CCM_MMC_CTRL_OCLK_DLY(oclk_dly) | - CCM_MMC_CTRL_M(div), priv->mclkreg); + if (new_mode) { +#ifdef CONFIG_MMC_SUNXI_HAS_NEW_MODE + val = CCM_MMC_CTRL_MODE_SEL_NEW; + writel(SUNXI_MMC_NTSR_MODE_SEL_NEW, &priv->reg->ntsr); +#endif + } else { + val = CCM_MMC_CTRL_OCLK_DLY(oclk_dly) | + CCM_MMC_CTRL_SCLK_DLY(sclk_dly); + } + + writel(CCM_MMC_CTRL_ENABLE| pll | CCM_MMC_CTRL_N(n) | + CCM_MMC_CTRL_M(div) | val, priv->mclkreg);
debug("mmc %u set mod-clk req %u parent %u n %u m %u rate %u\n", priv->mmc_no, hz, pll_hz, 1u << n, div, pll_hz / (1u << n) / div);

The eMMC controller for the A83T uses the new operating mode. Enable it.
Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com --- arch/arm/mach-sunxi/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 94412bac0c1d..8d56d591d97a 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -127,6 +127,7 @@ config MACH_SUN8I_A83T bool "sun8i (Allwinner A83T)" select CPU_V7 select SUNXI_GEN_SUN6I + select MMC_SUNXI_HAS_NEW_MODE select SUPPORT_SPL
config MACH_SUN8I_H3

On Wed, Aug 23, 2017 at 3:33 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
The eMMC controller for the A83T uses the new operating mode. Enable it.
Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com
Reviewed-by: Jagan Teki jagan@openedev.com
thanks!

Hi Jagan,
On Sat, Aug 26, 2017 at 12:11:23PM +0530, Jagan Teki wrote:
On Wed, Aug 23, 2017 at 3:33 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
The eMMC controller for the A83T uses the new operating mode. Enable it.
Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com
Reviewed-by: Jagan Teki jagan@openedev.com
I think both these patches should be merged in the upcoming release. It's a fix for a usecase that already exists (we already enable the eMMC on A83T), and it's unusable on some boards without it.
Maxime

On Mon, Aug 28, 2017 at 12:29 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
Hi Jagan,
On Sat, Aug 26, 2017 at 12:11:23PM +0530, Jagan Teki wrote:
On Wed, Aug 23, 2017 at 3:33 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
The eMMC controller for the A83T uses the new operating mode. Enable it.
Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com
Reviewed-by: Jagan Teki jagan@openedev.com
I think both these patches should be merged in the upcoming release. It's a fix for a usecase that already exists (we already enable the eMMC on A83T), and it's unusable on some boards without it.
But none of A83T boards were not enable eMMC yet? even sun8i-a83t.dtsi still need to add node. May be we can wait once all add?
# grep -R 83T configs/ configs/Sinovoip_BPI_M3_defconfig:CONFIG_MACH_SUN8I_A83T=y configs/h8_homlet_v2_defconfig:CONFIG_MACH_SUN8I_A83T=y configs/Cubietruck_plus_defconfig:CONFIG_MACH_SUN8I_A83T=y
thanks!

On Mon, Aug 28, 2017 at 4:05 PM, Jagan Teki jagannadh.teki@gmail.com wrote:
On Mon, Aug 28, 2017 at 12:29 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
Hi Jagan,
On Sat, Aug 26, 2017 at 12:11:23PM +0530, Jagan Teki wrote:
On Wed, Aug 23, 2017 at 3:33 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
The eMMC controller for the A83T uses the new operating mode. Enable it.
Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com
Reviewed-by: Jagan Teki jagan@openedev.com
I think both these patches should be merged in the upcoming release. It's a fix for a usecase that already exists (we already enable the eMMC on A83T), and it's unusable on some boards without it.
But none of A83T boards were not enable eMMC yet? even sun8i-a83t.dtsi still need to add node. May be we can wait once all add?
The sunxi-mmc driver does not use the device tree.
One only needs to set CONFIG_MMC_SUNXI_SLOT_EXTRA=2 to use the eMMC. And yes, eMMC is broken on some boards unless the new timing mode is used.
ChenYu
# grep -R 83T configs/ configs/Sinovoip_BPI_M3_defconfig:CONFIG_MACH_SUN8I_A83T=y configs/h8_homlet_v2_defconfig:CONFIG_MACH_SUN8I_A83T=y configs/Cubietruck_plus_defconfig:CONFIG_MACH_SUN8I_A83T=y

On Mon, Aug 28, 2017 at 04:12:15PM +0800, Chen-Yu Tsai wrote:
On Mon, Aug 28, 2017 at 4:05 PM, Jagan Teki jagannadh.teki@gmail.com wrote:
On Mon, Aug 28, 2017 at 12:29 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
Hi Jagan,
On Sat, Aug 26, 2017 at 12:11:23PM +0530, Jagan Teki wrote:
On Wed, Aug 23, 2017 at 3:33 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
The eMMC controller for the A83T uses the new operating mode. Enable it.
Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com
Reviewed-by: Jagan Teki jagan@openedev.com
I think both these patches should be merged in the upcoming release. It's a fix for a usecase that already exists (we already enable the eMMC on A83T), and it's unusable on some boards without it.
But none of A83T boards were not enable eMMC yet? even sun8i-a83t.dtsi still need to add node. May be we can wait once all add?
The sunxi-mmc driver does not use the device tree.
One only needs to set CONFIG_MMC_SUNXI_SLOT_EXTRA=2 to use the eMMC. And yes, eMMC is broken on some boards unless the new timing mode is used.
And the support is broken until "mmc: sunxi: fix legacy MMC initialisation" in my other serie is applied.
Maxime

On Mon, Aug 28, 2017 at 2:15 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
On Mon, Aug 28, 2017 at 04:12:15PM +0800, Chen-Yu Tsai wrote:
On Mon, Aug 28, 2017 at 4:05 PM, Jagan Teki jagannadh.teki@gmail.com wrote:
On Mon, Aug 28, 2017 at 12:29 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
Hi Jagan,
On Sat, Aug 26, 2017 at 12:11:23PM +0530, Jagan Teki wrote:
On Wed, Aug 23, 2017 at 3:33 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
The eMMC controller for the A83T uses the new operating mode. Enable it.
Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com
Reviewed-by: Jagan Teki jagan@openedev.com
I think both these patches should be merged in the upcoming release. It's a fix for a usecase that already exists (we already enable the eMMC on A83T), and it's unusable on some boards without it.
But none of A83T boards were not enable eMMC yet? even sun8i-a83t.dtsi still need to add node. May be we can wait once all add?
The sunxi-mmc driver does not use the device tree.
One only needs to set CONFIG_MMC_SUNXI_SLOT_EXTRA=2 to use the eMMC. And yes, eMMC is broken on some boards unless the new timing mode is used.
And the support is broken until "mmc: sunxi: fix legacy MMC initialisation" in my other serie is applied.
With these patches, eMMC detected BPI-M3. But none of A83T boards have CONFIG_MMC_SUNXI_SLOT_EXTRA=2 So it's better to take this once boards added.
thanks!

On Mon, Aug 28, 2017 at 02:30:23PM +0530, Jagan Teki wrote:
On Mon, Aug 28, 2017 at 2:15 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
On Mon, Aug 28, 2017 at 04:12:15PM +0800, Chen-Yu Tsai wrote:
On Mon, Aug 28, 2017 at 4:05 PM, Jagan Teki jagannadh.teki@gmail.com wrote:
On Mon, Aug 28, 2017 at 12:29 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
Hi Jagan,
On Sat, Aug 26, 2017 at 12:11:23PM +0530, Jagan Teki wrote:
On Wed, Aug 23, 2017 at 3:33 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote: > The eMMC controller for the A83T uses the new operating mode. Enable it. > > Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com
Reviewed-by: Jagan Teki jagan@openedev.com
I think both these patches should be merged in the upcoming release. It's a fix for a usecase that already exists (we already enable the eMMC on A83T), and it's unusable on some boards without it.
But none of A83T boards were not enable eMMC yet? even sun8i-a83t.dtsi still need to add node. May be we can wait once all add?
The sunxi-mmc driver does not use the device tree.
One only needs to set CONFIG_MMC_SUNXI_SLOT_EXTRA=2 to use the eMMC. And yes, eMMC is broken on some boards unless the new timing mode is used.
And the support is broken until "mmc: sunxi: fix legacy MMC initialisation" in my other serie is applied.
With these patches, eMMC detected BPI-M3. But none of A83T boards have CONFIG_MMC_SUNXI_SLOT_EXTRA=2 So it's better to take this once boards added.
That argument doesn't really stand, any user is able to modify the configuration themself, and experience that breakage.
The fact that this is not enabled by default just make it less exposed, but it's still a bug that can be encountered today in a real-life situation.
Maxime

On Mon, Aug 28, 2017 at 2:40 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
On Mon, Aug 28, 2017 at 02:30:23PM +0530, Jagan Teki wrote:
On Mon, Aug 28, 2017 at 2:15 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
On Mon, Aug 28, 2017 at 04:12:15PM +0800, Chen-Yu Tsai wrote:
On Mon, Aug 28, 2017 at 4:05 PM, Jagan Teki jagannadh.teki@gmail.com wrote:
On Mon, Aug 28, 2017 at 12:29 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
Hi Jagan,
On Sat, Aug 26, 2017 at 12:11:23PM +0530, Jagan Teki wrote: > On Wed, Aug 23, 2017 at 3:33 PM, Maxime Ripard > maxime.ripard@free-electrons.com wrote: > > The eMMC controller for the A83T uses the new operating mode. Enable it. > > > > Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com > > Reviewed-by: Jagan Teki jagan@openedev.com
I think both these patches should be merged in the upcoming release. It's a fix for a usecase that already exists (we already enable the eMMC on A83T), and it's unusable on some boards without it.
But none of A83T boards were not enable eMMC yet? even sun8i-a83t.dtsi still need to add node. May be we can wait once all add?
The sunxi-mmc driver does not use the device tree.
One only needs to set CONFIG_MMC_SUNXI_SLOT_EXTRA=2 to use the eMMC. And yes, eMMC is broken on some boards unless the new timing mode is used.
And the support is broken until "mmc: sunxi: fix legacy MMC initialisation" in my other serie is applied.
With these patches, eMMC detected BPI-M3. But none of A83T boards have CONFIG_MMC_SUNXI_SLOT_EXTRA=2 So it's better to take this once boards added.
That argument doesn't really stand, any user is able to modify the configuration themself, and experience that breakage.
The fact that this is not enabled by default just make it less exposed, but it's still a bug that can be encountered today in a real-life situation.
OK, will apply these 3 for the release.
thanks!

On Wed, Aug 23, 2017 at 3:33 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
The eMMC controller for the A83T uses the new operating mode. Enable it.
Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com
Applied to u-boot-sunxi/master
thanks!

Hi,
On 08/23/2017 07:03 PM, Maxime Ripard wrote:
Almost all of the newer Allwinner SoCs have a new operating mode for the eMMC clocks that needs to be enabled in both the clock and the MMC controller.
Details about that mode are sparse, and the name itself (new mode vs old mode) doesn't give much details, but it seems that the it changes the sampling of the MMC clock. One side effect is also that it divides the parent clock rate by 2.
Add support for it through a Kconfig option.
Well, i don't know exactly what mode likes your mention.. I think it can be got from dt if it's provided from controller IP or SoC. how about?
Best Regards, Jaehoon Chung
Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com
Changes from v1:
- Switched to IS_ENABLED when possible
- Added some defines
- Tried to put more details in the commit log
- Added a depends on in the Kconfig option
arch/arm/include/asm/arch-sunxi/clock_sun8i_a83t.h | 1 + arch/arm/include/asm/arch-sunxi/mmc.h | 11 ++++++--- drivers/mmc/Kconfig | 4 ++++ drivers/mmc/sunxi_mmc.c | 27 +++++++++++++++++++--- 4 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun8i_a83t.h b/arch/arm/include/asm/arch-sunxi/clock_sun8i_a83t.h index 5e1346e5242a..5dfcbf3b017b 100644 --- a/arch/arm/include/asm/arch-sunxi/clock_sun8i_a83t.h +++ b/arch/arm/include/asm/arch-sunxi/clock_sun8i_a83t.h @@ -220,6 +220,7 @@ struct sunxi_ccm_reg { #define CCM_MMC_CTRL_SCLK_DLY(x) ((x) << 20) #define CCM_MMC_CTRL_OSCM24 (0x0 << 24) #define CCM_MMC_CTRL_PLL6 (0x1 << 24) +#define CCM_MMC_CTRL_MODE_SEL_NEW (0x1 << 30) #define CCM_MMC_CTRL_ENABLE (0x1 << 31)
#define CCM_USB_CTRL_PHY0_RST (0x1 << 0) diff --git a/arch/arm/include/asm/arch-sunxi/mmc.h b/arch/arm/include/asm/arch-sunxi/mmc.h index cb52e648731c..69f737f3bffc 100644 --- a/arch/arm/include/asm/arch-sunxi/mmc.h +++ b/arch/arm/include/asm/arch-sunxi/mmc.h @@ -35,16 +35,19 @@ struct sunxi_mmc { u32 cbcr; /* 0x48 CIU byte count */ u32 bbcr; /* 0x4c BIU byte count */ u32 dbgc; /* 0x50 debug enable */
- u32 res0[11];
- u32 res0; /* 0x54 reserved */
- u32 a12a; /* 0x58 Auto command 12 argument */
- u32 ntsr; /* 0x5c New timing set register */
- u32 res1[8]; u32 dmac; /* 0x80 internal DMA control */ u32 dlba; /* 0x84 internal DMA descr list base address */ u32 idst; /* 0x88 internal DMA status */ u32 idie; /* 0x8c internal DMA interrupt enable */ u32 chda; /* 0x90 */ u32 cbda; /* 0x94 */
- u32 res1[26];
- u32 res2[26];
#ifdef CONFIG_SUNXI_GEN_SUN6I
- u32 res2[64];
- u32 res3[64];
#endif u32 fifo; /* 0x100 / 0x200 FIFO access address */ }; @@ -116,6 +119,8 @@ struct sunxi_mmc { #define SUNXI_MMC_STATUS_CARD_DATA_BUSY (0x1 << 9) #define SUNXI_MMC_STATUS_DATA_FSM_BUSY (0x1 << 10)
+#define SUNXI_MMC_NTSR_MODE_SEL_NEW (0x1 << 31)
#define SUNXI_MMC_IDMAC_RESET (0x1 << 0) #define SUNXI_MMC_IDMAC_FIXBURST (0x1 << 1) #define SUNXI_MMC_IDMAC_ENABLE (0x1 << 7) diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index 51a87cdd77dc..9075b346036b 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -389,6 +389,10 @@ config MMC_SUNXI This selects support for the SD/MMC Host Controller on Allwinner sunxi SoCs.
+config MMC_SUNXI_HAS_NEW_MODE
- bool
- depends on MMC_SUNXI
config GENERIC_ATMEL_MCI bool "Atmel Multimedia Card Interface support" depends on DM_MMC && BLK && DM_MMC_OPS && ARCH_AT91 diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c index 588574fab6a9..bc638ae2e64a 100644 --- a/drivers/mmc/sunxi_mmc.c +++ b/drivers/mmc/sunxi_mmc.c @@ -96,6 +96,18 @@ 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;
u32 val = 0;
if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
new_mode = true;
/*
* 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;
@@ -152,9 +164,18 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz) #endif }
- writel(CCM_MMC_CTRL_ENABLE | pll | CCM_MMC_CTRL_SCLK_DLY(sclk_dly) |
CCM_MMC_CTRL_N(n) | CCM_MMC_CTRL_OCLK_DLY(oclk_dly) |
CCM_MMC_CTRL_M(div), priv->mclkreg);
- if (new_mode) {
+#ifdef CONFIG_MMC_SUNXI_HAS_NEW_MODE
val = CCM_MMC_CTRL_MODE_SEL_NEW;
writel(SUNXI_MMC_NTSR_MODE_SEL_NEW, &priv->reg->ntsr);
+#endif
} else {
val = CCM_MMC_CTRL_OCLK_DLY(oclk_dly) |
CCM_MMC_CTRL_SCLK_DLY(sclk_dly);
}
writel(CCM_MMC_CTRL_ENABLE| pll | CCM_MMC_CTRL_N(n) |
CCM_MMC_CTRL_M(div) | val, priv->mclkreg);
debug("mmc %u set mod-clk req %u parent %u n %u m %u rate %u\n", priv->mmc_no, hz, pll_hz, 1u << n, div, pll_hz / (1u << n) / div);

Hi Jaehoon,
On Wed, Aug 23, 2017 at 08:14:53PM +0900, Jaehoon Chung wrote:
Hi,
On 08/23/2017 07:03 PM, Maxime Ripard wrote:
Almost all of the newer Allwinner SoCs have a new operating mode for the eMMC clocks that needs to be enabled in both the clock and the MMC controller.
Details about that mode are sparse, and the name itself (new mode vs old mode) doesn't give much details, but it seems that the it changes the sampling of the MMC clock. One side effect is also that it divides the parent clock rate by 2.
Add support for it through a Kconfig option.
Well, i don't know exactly what mode likes your mention.. I think it can be got from dt if it's provided from controller IP or SoC. how about?
That's how we do it in Linux, and obviously is our long term goal in U-Boot as well. However, the current driver in U-Boot doesn't use the device model (and the DT), so we cannot use that for now.
Once the switch is over, we'll of course switch to something like you suggested.
Maxime

On Wed, Aug 23, 2017 at 3:33 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
Almost all of the newer Allwinner SoCs have a new operating mode for the eMMC clocks that needs to be enabled in both the clock and the MMC controller.
Details about that mode are sparse, and the name itself (new mode vs old mode) doesn't give much details, but it seems that the it changes the sampling of the MMC clock. One side effect is also that it divides the parent clock rate by 2.
Add support for it through a Kconfig option.
Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com
Reviewed-by: Jagan Teki jagan@openedev.com
thanks!

On Sat, Aug 26, 2017 at 12:10 PM, Jagan Teki jagannadh.teki@gmail.com wrote:
On Wed, Aug 23, 2017 at 3:33 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
Almost all of the newer Allwinner SoCs have a new operating mode for the eMMC clocks that needs to be enabled in both the clock and the MMC controller.
Details about that mode are sparse, and the name itself (new mode vs old mode) doesn't give much details, but it seems that the it changes the sampling of the MMC clock. One side effect is also that it divides the parent clock rate by 2.
Add support for it through a Kconfig option.
Signed-off-by: Maxime Ripard maxime.ripard@free-electrons.com
Reviewed-by: Jagan Teki jagan@openedev.com
Applied to u-boot-sunxi/master
thanks!
participants (4)
-
Chen-Yu Tsai
-
Jaehoon Chung
-
Jagan Teki
-
Maxime Ripard