|
@@ -99,11 +99,16 @@ 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;
|
|
unsigned int pll, pll_hz, div, n, oclk_dly, sclk_dly;
|
|
bool new_mode = false;
|
|
bool new_mode = false;
|
|
|
|
+ bool calibrate = false;
|
|
u32 val = 0;
|
|
u32 val = 0;
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
|
|
if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
|
|
new_mode = true;
|
|
new_mode = true;
|
|
|
|
|
|
|
|
+#if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H6)
|
|
|
|
+ calibrate = true;
|
|
|
|
+#endif
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* The MMC clock has an extra /2 post-divider when operating in the new
|
|
* The MMC clock has an extra /2 post-divider when operating in the new
|
|
* mode.
|
|
* mode.
|
|
@@ -174,7 +179,11 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
|
|
val = CCM_MMC_CTRL_MODE_SEL_NEW;
|
|
val = CCM_MMC_CTRL_MODE_SEL_NEW;
|
|
setbits_le32(&priv->reg->ntsr, SUNXI_MMC_NTSR_MODE_SEL_NEW);
|
|
setbits_le32(&priv->reg->ntsr, SUNXI_MMC_NTSR_MODE_SEL_NEW);
|
|
#endif
|
|
#endif
|
|
- } else {
|
|
|
|
|
|
+ } else if (!calibrate) {
|
|
|
|
+ /*
|
|
|
|
+ * Use hardcoded delay values if controller doesn't support
|
|
|
|
+ * calibration
|
|
|
|
+ */
|
|
val = CCM_MMC_CTRL_OCLK_DLY(oclk_dly) |
|
|
val = CCM_MMC_CTRL_OCLK_DLY(oclk_dly) |
|
|
CCM_MMC_CTRL_SCLK_DLY(sclk_dly);
|
|
CCM_MMC_CTRL_SCLK_DLY(sclk_dly);
|
|
}
|
|
}
|
|
@@ -228,6 +237,16 @@ static int mmc_config_clock(struct sunxi_mmc_priv *priv, struct mmc *mmc)
|
|
rval &= ~SUNXI_MMC_CLK_DIVIDER_MASK;
|
|
rval &= ~SUNXI_MMC_CLK_DIVIDER_MASK;
|
|
writel(rval, &priv->reg->clkcr);
|
|
writel(rval, &priv->reg->clkcr);
|
|
|
|
|
|
|
|
+#if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H6)
|
|
|
|
+ /* A64 supports calibration of delays on MMC 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
|
|
|
|
+ */
|
|
|
|
+ writel(SUNXI_MMC_CAL_DL_SW_EN, &priv->reg->samp_dl);
|
|
|
|
+#endif
|
|
|
|
+
|
|
/* Re-enable Clock */
|
|
/* Re-enable Clock */
|
|
rval |= SUNXI_MMC_CLK_ENABLE;
|
|
rval |= SUNXI_MMC_CLK_ENABLE;
|
|
writel(rval, &priv->reg->clkcr);
|
|
writel(rval, &priv->reg->clkcr);
|