提交 5705973b 编写于 作者: Y Yangbo Lu 提交者: Peng Fan

mmc: fsl_esdhc: convert to use fsl_esdhc_get_cfg_common()

The fsl_esdhc_init() was actually to get configuration of mmc_config.
So rename it to fsl_esdhc_get_cfg_common() and make it common for both
DM_MMC and non-DM_MMC.
Signed-off-by: NYangbo Lu <yangbo.lu@nxp.com>
上级 07bae1de
...@@ -678,23 +678,12 @@ static const struct mmc_ops esdhc_ops = { ...@@ -678,23 +678,12 @@ static const struct mmc_ops esdhc_ops = {
}; };
#endif #endif
static int fsl_esdhc_init(struct fsl_esdhc_priv *priv, static void fsl_esdhc_get_cfg_common(struct fsl_esdhc_priv *priv,
struct fsl_esdhc_plat *plat) struct mmc_config *cfg)
{ {
struct mmc_config *cfg; struct fsl_esdhc *regs = priv->esdhc_regs;
struct fsl_esdhc *regs;
u32 caps; u32 caps;
if (!priv)
return -EINVAL;
regs = priv->esdhc_regs;
cfg = &plat->cfg;
#ifndef CONFIG_DM_MMC
memset(cfg, '\0', sizeof(*cfg));
#endif
caps = esdhc_read32(&regs->hostcapblt); caps = esdhc_read32(&regs->hostcapblt);
#ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC135 #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC135
caps &= ~(HOSTCAPBLT_SRS | HOSTCAPBLT_VS18 | HOSTCAPBLT_VS30); caps &= ~(HOSTCAPBLT_SRS | HOSTCAPBLT_VS18 | HOSTCAPBLT_VS30);
...@@ -710,19 +699,13 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv, ...@@ -710,19 +699,13 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
cfg->voltages |= MMC_VDD_32_33 | MMC_VDD_33_34; cfg->voltages |= MMC_VDD_32_33 | MMC_VDD_33_34;
cfg->name = "FSL_SDHC"; cfg->name = "FSL_SDHC";
#if !CONFIG_IS_ENABLED(DM_MMC)
cfg->ops = &esdhc_ops;
#endif
if (caps & HOSTCAPBLT_HSS) if (caps & HOSTCAPBLT_HSS)
cfg->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS; cfg->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
cfg->f_min = 400000; cfg->f_min = 400000;
cfg->f_max = min(priv->sdhc_clk, (u32)200000000); cfg->f_max = min(priv->sdhc_clk, (u32)200000000);
cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
return 0;
} }
#if !CONFIG_IS_ENABLED(DM_MMC) #if !CONFIG_IS_ENABLED(DM_MMC)
...@@ -732,7 +715,6 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg) ...@@ -732,7 +715,6 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
struct fsl_esdhc_priv *priv; struct fsl_esdhc_priv *priv;
struct mmc_config *mmc_cfg; struct mmc_config *mmc_cfg;
struct mmc *mmc; struct mmc *mmc;
int ret;
if (!cfg) if (!cfg)
return -EINVAL; return -EINVAL;
...@@ -769,20 +751,15 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg) ...@@ -769,20 +751,15 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
if (CONFIG_ESDHC_DETECT_8_BIT_QUIRK) if (CONFIG_ESDHC_DETECT_8_BIT_QUIRK)
mmc_cfg->host_caps &= ~MMC_MODE_8BIT; mmc_cfg->host_caps &= ~MMC_MODE_8BIT;
#endif #endif
ret = fsl_esdhc_init(priv, plat); mmc_cfg->ops = &esdhc_ops;
if (ret) {
debug("%s init failure\n", __func__); fsl_esdhc_get_cfg_common(priv, mmc_cfg);
free(plat);
free(priv);
return ret;
}
mmc = mmc_create(&plat->cfg, priv); mmc = mmc_create(mmc_cfg, priv);
if (!mmc) if (!mmc)
return -EIO; return -EIO;
priv->mmc = mmc; priv->mmc = mmc;
return 0; return 0;
} }
...@@ -927,11 +904,7 @@ static int fsl_esdhc_probe(struct udevice *dev) ...@@ -927,11 +904,7 @@ static int fsl_esdhc_probe(struct udevice *dev)
} }
} }
ret = fsl_esdhc_init(priv, plat); fsl_esdhc_get_cfg_common(priv, &plat->cfg);
if (ret) {
dev_err(dev, "fsl_esdhc_init failure\n");
return ret;
}
mmc_of_parse(dev, &plat->cfg); mmc_of_parse(dev, &plat->cfg);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册