Skip to contentSkip to conversation

mmc: fsl_esdhc: clean up code

PATCH New Yangbo Lu 3 participants 10 messages Aug 19, 2019 – Sep 6, 2019 MMC, SD and SDIO

lore
Share & tools
lore

Yangbo Lu

author
#0 lore raw

cover mmc: fsl_esdhc: clean up code

This patch-set is to clean up fsl_esdhc code.

Yangbo Lu (3):
mmc: fsl_esdhc: make BLK as hard requirement of DM_MMC
mmc: fsl_esdhc: clean up code
mmc: fsl_esdhc: rename fsl_esdhc_init to fsl_esdhc_get_cfg

 drivers/mmc/fsl_esdhc.c | 371 +++++++++++++++++++-----------------------------
 include/fsl_esdhc.h     | 203 ++++++++++++--------------
 2 files changed, 240 insertions(+), 334 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/3 mmc: fsl_esdhc: make BLK as hard requirement of DM_MMC

Current fsl_esdhc driver had support DM_MMC with BLK enabled. Since BLK will be hard requirement of DM_MMC, let's do this now in fsl_esdhc driver. Don't keep BLK conditioanl compiling.

---
 drivers/mmc/fsl_esdhc.c | 35 +----------------------------------
 1 file changed, 1 insertion(+), 34 deletions(-)
drivers/mmc/fsl_esdhc.c +1 -34
index 0731847..ff5565c 100644
@@ -23,10 +23,6 @@
 #include <asm/io.h>
 #include <dm.h>
 
-#if !CONFIG_IS_ENABLED(BLK)
-#include "mmc_private.h"
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #define SDHCI_IRQ_EN_BITS		(IRQSTATEN_CC | IRQSTATEN_TC | \
@@ -35,7 +31,6 @@ DECLARE_GLOBAL_DATA_PTR;
 				IRQSTATEN_CIE | IRQSTATEN_DTOE | IRQSTATEN_DCE | \
 				IRQSTATEN_DEBE | IRQSTATEN_BRR | IRQSTATEN_BWR | \
 				IRQSTATEN_DINT)
-#define ESDHC_DRIVER_STAGE_VALUE 0xffffffff
 
 struct fsl_esdhc {
 	uint    dsaddr;		/* SDMA system address register */
@@ -98,7 +93,7 @@ struct fsl_esdhc_priv {
 	struct clk per_clk;
 	unsigned int clock;
 	unsigned int bus_width;
-#if !CONFIG_IS_ENABLED(BLK)
+#if !CONFIG_IS_ENABLED(DM_MMC)
 	struct mmc *mmc;
 #endif
 	struct udevice *dev;
@@ -961,9 +956,6 @@ static int fsl_esdhc_probe(struct udevice *dev)
 	fdt_addr_t addr;
 	unsigned int val;
 	struct mmc *mmc;
-#if !CONFIG_IS_ENABLED(BLK)
-	struct blk_desc *bdesc;
-#endif
 	int ret;
 
 	addr = dev_read_addr(dev);
@@ -1027,32 +1019,12 @@ static int fsl_esdhc_probe(struct udevice *dev)
 	mmc = &plat->mmc;
 	mmc->cfg = &plat->cfg;
 	mmc->dev = dev;
-#if !CONFIG_IS_ENABLED(BLK)
-	mmc->priv = priv;
-
-	/* Setup dsr related values */
-	mmc->dsr_imp = 0;
-	mmc->dsr = ESDHC_DRIVER_STAGE_VALUE;
-	/* Setup the universal parts of the block interface just once */
-	bdesc = mmc_get_blk_desc(mmc);
-	bdesc->if_type = IF_TYPE_MMC;
-	bdesc->removable = 1;
-	bdesc->devnum = mmc_get_next_devnum();
-	bdesc->block_read = mmc_bread;
-	bdesc->block_write = mmc_bwrite;
-	bdesc->block_erase = mmc_berase;
-
-	/* setup initial part type */
-	bdesc->part_type = mmc->cfg->part_type;
-	mmc_list_add(mmc);
-#endif
 
 	upriv->mmc = mmc;
 
 	return esdhc_init_common(priv, mmc);
 }
 
-#if CONFIG_IS_ENABLED(DM_MMC)
 static int fsl_esdhc_get_cd(struct udevice *dev)
 {
 	struct fsl_esdhc_priv *priv = dev_get_priv(dev);
@@ -1082,30 +1054,25 @@ static const struct dm_mmc_ops fsl_esdhc_ops = {
 	.send_cmd	= fsl_esdhc_send_cmd,
 	.set_ios	= fsl_esdhc_set_ios,
 };
-#endif
 
 static const struct udevice_id fsl_esdhc_ids[] = {
 	{ .compatible = "fsl,esdhc", },
 	{ /* sentinel */ }
 };
 
-#if CONFIG_IS_ENABLED(BLK)
 static int fsl_esdhc_bind(struct udevice *dev)
 {
 	struct fsl_esdhc_plat *plat = dev_get_platdata(dev);
 
 	return mmc_bind(dev, &plat->mmc, &plat->cfg);
 }
-#endif
 
 U_BOOT_DRIVER(fsl_esdhc) = {
 	.name	= "fsl-esdhc-mmc",
 	.id	= UCLASS_MMC,
 	.of_match = fsl_esdhc_ids,
 	.ops	= &fsl_esdhc_ops,
-#if CONFIG_IS_ENABLED(BLK)
 	.bind	= fsl_esdhc_bind,
-#endif
 	.probe	= fsl_esdhc_probe,
 	.platdata_auto_alloc_size = sizeof(struct fsl_esdhc_plat),
 	.priv_auto_alloc_size = sizeof(struct fsl_esdhc_priv),
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 2/3 mmc: fsl_esdhc: clean up code

In reply to Yangbo Lu

This patch is just to clean up code. There were not changes on function.

---
 drivers/mmc/fsl_esdhc.c | 288 ++++++++++++++++++++++++------------------------
 include/fsl_esdhc.h     | 203 ++++++++++++++++------------------
 2 files changed, 238 insertions(+), 253 deletions(-)
drivers/mmc/fsl_esdhc.c +145 -143
index ff5565c..d176bb3 100644
@@ -25,12 +25,13 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define SDHCI_IRQ_EN_BITS		(IRQSTATEN_CC | IRQSTATEN_TC | \
-				IRQSTATEN_CINT | \
-				IRQSTATEN_CTOE | IRQSTATEN_CCE | IRQSTATEN_CEBE | \
-				IRQSTATEN_CIE | IRQSTATEN_DTOE | IRQSTATEN_DCE | \
-				IRQSTATEN_DEBE | IRQSTATEN_BRR | IRQSTATEN_BWR | \
-				IRQSTATEN_DINT)
+#define ESDHC_IRQ_EN_BITS	(IRQSTATEN_CC | IRQSTATEN_TC | \
+				IRQSTATEN_DINT | IRQSTATEN_BWR | \
+				IRQSTATEN_BRR | IRQSTATEN_CINT | \
+				IRQSTATEN_CTOE | IRQSTATEN_CCE | \
+				IRQSTATEN_CEBE | IRQSTATEN_CIE | \
+				IRQSTATEN_DTOE | IRQSTATEN_DCE | \
+				IRQSTATEN_DEBE)
 
 struct fsl_esdhc {
 	uint    dsaddr;		/* SDMA system address register */
@@ -76,16 +77,15 @@ struct fsl_esdhc_plat {
  * struct fsl_esdhc_priv
  *
  * @esdhc_regs: registers of the sdhc controller
- * @sdhc_clk: Current clk of the sdhc controller
+ * @sdhc_clk: reference clk of the sdhc controller
+ * @per_clk: peripheral clock
+ * @clock: target clock
  * @bus_width: bus width, 1bit, 4bit or 8bit
- * @cfg: mmc config
  * @mmc: mmc
  * Following is used when Driver Model is enabled for MMC
  * @dev: pointer for the device
  * @non_removable: 0: removable; 1: non-removable
  * @wp_enable: 1: enable checking wp; 0: no check
- * @cd_gpio: gpio for card detection
- * @wp_gpio: gpio for write protection
  */
 struct fsl_esdhc_priv {
 	struct fsl_esdhc *esdhc_regs;
@@ -102,7 +102,7 @@ struct fsl_esdhc_priv {
 };
 
 /* Return the XFERTYP flags for a given command and data packet */
-static uint esdhc_xfertyp(struct mmc_cmd *cmd, struct mmc_data *data)
+static uint esdhc_setup_xfertyp(struct mmc_cmd *cmd, struct mmc_data *data)
 {
 	uint xfertyp = 0;
 
@@ -310,9 +310,9 @@ static int esdhc_setup_data(struct fsl_esdhc_priv *priv, struct mmc *mmc,
 	return 0;
 }
 
-static void check_and_invalidate_dcache_range
-	(struct mmc_cmd *cmd,
-	 struct mmc_data *data) {
+static void esdhc_invalidate_dcache_range(struct mmc_cmd *cmd,
+					  struct mmc_data *data)
+{
 	unsigned start = 0;
 	unsigned end = 0;
 	unsigned size = roundup(ARCH_DMA_MINALIGN,
@@ -377,11 +377,11 @@ static int esdhc_send_cmd_common(struct fsl_esdhc_priv *priv, struct mmc *mmc,
 			return err;
 
 		if (data->flags & MMC_DATA_READ)
-			check_and_invalidate_dcache_range(cmd, data);
+			esdhc_invalidate_dcache_range(cmd, data);
 	}
 
 	/* Figure out the transfer arguments */
-	xfertyp = esdhc_xfertyp(cmd, data);
+	xfertyp = esdhc_setup_xfertyp(cmd, data);
 
 	/* Mask all irqs */
 	esdhc_write32(&regs->irqsigen, 0);
@@ -479,7 +479,7 @@ static int esdhc_send_cmd_common(struct fsl_esdhc_priv *priv, struct mmc *mmc,
 		 * speculative pre-fetching etc.
 		 */
 		if (data->flags & MMC_DATA_READ) {
-			check_and_invalidate_dcache_range(cmd, data);
+			esdhc_invalidate_dcache_range(cmd, data);
 		}
 #endif
 	}
@@ -506,7 +506,8 @@ out:
 	return err;
 }
 
-static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
+static void esdhc_set_clock(struct fsl_esdhc_priv *priv, struct mmc *mmc,
+			    uint clock)
 {
 	struct fsl_esdhc *regs = priv->esdhc_regs;
 	int div = 1;
@@ -581,7 +582,7 @@ static int esdhc_set_ios_common(struct fsl_esdhc_priv *priv, struct mmc *mmc)
 #endif
 	/* Set the clock speed */
 	if (priv->clock != mmc->clock)
-		set_sysctl(priv, mmc, mmc->clock);
+		esdhc_set_clock(priv, mmc, mmc->clock);
 
 	/* Set the bus width */
 	esdhc_clrbits32(&regs->proctl, PROCTL_DTW_4 | PROCTL_DTW_8);
@@ -669,43 +670,7 @@ static int esdhc_reset(struct fsl_esdhc *regs)
 	return 0;
 }
 
-#if !CONFIG_IS_ENABLED(DM_MMC)
-static int esdhc_getcd(struct mmc *mmc)
-{
-	struct fsl_esdhc_priv *priv = mmc->priv;
-
-	return esdhc_getcd_common(priv);
-}
-
-static int esdhc_init(struct mmc *mmc)
-{
-	struct fsl_esdhc_priv *priv = mmc->priv;
-
-	return esdhc_init_common(priv, mmc);
-}
-
-static int esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
-			  struct mmc_data *data)
-{
-	struct fsl_esdhc_priv *priv = mmc->priv;
-
-	return esdhc_send_cmd_common(priv, mmc, cmd, data);
-}
-
-static int esdhc_set_ios(struct mmc *mmc)
-{
-	struct fsl_esdhc_priv *priv = mmc->priv;
-
-	return esdhc_set_ios_common(priv, mmc);
-}
-
-static const struct mmc_ops esdhc_ops = {
-	.getcd		= esdhc_getcd,
-	.init		= esdhc_init,
-	.send_cmd	= esdhc_send_cmd,
-	.set_ios	= esdhc_set_ios,
-};
-#endif
+static const struct mmc_ops esdhc_ops;
 
 static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
 			  struct fsl_esdhc_plat *plat)
@@ -728,7 +693,7 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
 	esdhc_setbits32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_HCKEN |
 				       SYSCTL_IPGEN | SYSCTL_CKEN);
 
-	writel(SDHCI_IRQ_EN_BITS, &regs->irqstaten);
+	writel(ESDHC_IRQ_EN_BITS, &regs->irqstaten);
 	cfg = &plat->cfg;
 #ifndef CONFIG_DM_MMC
 	memset(cfg, '\0', sizeof(*cfg));
@@ -738,20 +703,19 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
 	caps = esdhc_read32(&regs->hostcapblt);
 
 #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC135
-	caps = caps & ~(ESDHC_HOSTCAPBLT_SRS |
-			ESDHC_HOSTCAPBLT_VS18 | ESDHC_HOSTCAPBLT_VS30);
+	caps = caps & ~(HOSTCAPBLT2_SRS | HOSTCAPBLT2_VS18 | HOSTCAPBLT2_VS30);
 #endif
 
 /* T4240 host controller capabilities register should have VS33 bit */
 #ifdef CONFIG_SYS_FSL_MMC_HAS_CAPBLT_VS33
-	caps = caps | ESDHC_HOSTCAPBLT_VS33;
+	caps = caps | HOSTCAPBLT2_VS33;
 #endif
 
-	if (caps & ESDHC_HOSTCAPBLT_VS18)
+	if (caps & HOSTCAPBLT2_VS18)
 		voltage_caps |= MMC_VDD_165_195;
-	if (caps & ESDHC_HOSTCAPBLT_VS30)
+	if (caps & HOSTCAPBLT2_VS30)
 		voltage_caps |= MMC_VDD_29_30 | MMC_VDD_30_31;
-	if (caps & ESDHC_HOSTCAPBLT_VS33)
+	if (caps & HOSTCAPBLT2_VS33)
 		voltage_caps |= MMC_VDD_32_33 | MMC_VDD_33_34;
 
 	cfg->name = "FSL_SDHC";
@@ -785,7 +749,7 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
 			cfg->host_caps &= ~MMC_MODE_4BIT;
 	}
 
-	if (caps & ESDHC_HOSTCAPBLT_HSS)
+	if (caps & HOSTCAPBLT2_HSS)
 		cfg->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
 
 #ifdef CONFIG_ESDHC_DETECT_8_BIT_QUIRK
@@ -801,76 +765,6 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
 	return 0;
 }
 
-#if !CONFIG_IS_ENABLED(DM_MMC)
-static int fsl_esdhc_cfg_to_priv(struct fsl_esdhc_cfg *cfg,
-				 struct fsl_esdhc_priv *priv)
-{
-	if (!cfg || !priv)
-		return -EINVAL;
-
-	priv->esdhc_regs = (struct fsl_esdhc *)(unsigned long)(cfg->esdhc_base);
-	priv->bus_width = cfg->max_bus_width;
-	priv->sdhc_clk = cfg->sdhc_clk;
-	priv->wp_enable  = cfg->wp_enable;
-
-	return 0;
-};
-
-int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
-{
-	struct fsl_esdhc_plat *plat;
-	struct fsl_esdhc_priv *priv;
-	struct mmc *mmc;
-	int ret;
-
-	if (!cfg)
-		return -EINVAL;
-
-	priv = calloc(sizeof(struct fsl_esdhc_priv), 1);
-	if (!priv)
-		return -ENOMEM;
-	plat = calloc(sizeof(struct fsl_esdhc_plat), 1);
-	if (!plat) {
-		free(priv);
-		return -ENOMEM;
-	}
-
-	ret = fsl_esdhc_cfg_to_priv(cfg, priv);
-	if (ret) {
-		debug("%s xlate failure\n", __func__);
-		free(plat);
-		free(priv);
-		return ret;
-	}
-
-	ret = fsl_esdhc_init(priv, plat);
-	if (ret) {
-		debug("%s init failure\n", __func__);
-		free(plat);
-		free(priv);
-		return ret;
-	}
-
-	mmc = mmc_create(&plat->cfg, priv);
-	if (!mmc)
-		return -EIO;
-
-	priv->mmc = mmc;
-
-	return 0;
-}
-
-int fsl_esdhc_mmc_init(bd_t *bis)
-{
-	struct fsl_esdhc_cfg *cfg;
-
-	cfg = calloc(sizeof(struct fsl_esdhc_cfg), 1);
-	cfg->esdhc_base = CONFIG_SYS_FSL_ESDHC_ADDR;
-	cfg->sdhc_clk = gd->arch.sdhc_clk;
-	return fsl_esdhc_initialize(bis, cfg);
-}
-#endif
-
 #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT
 void mmc_adapter_card_type_ident(void)
 {
@@ -944,7 +838,115 @@ void fdt_fixup_esdhc(void *blob, bd_t *bd)
 }
 #endif
 
-#if CONFIG_IS_ENABLED(DM_MMC)
+#if !CONFIG_IS_ENABLED(DM_MMC)
+static int esdhc_getcd(struct mmc *mmc)
+{
+	struct fsl_esdhc_priv *priv = mmc->priv;
+
+	return esdhc_getcd_common(priv);
+}
+
+static int esdhc_init(struct mmc *mmc)
+{
+	struct fsl_esdhc_priv *priv = mmc->priv;
+
+	return esdhc_init_common(priv, mmc);
+}
+
+static int esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
+			  struct mmc_data *data)
+{
+	struct fsl_esdhc_priv *priv = mmc->priv;
+
+	return esdhc_send_cmd_common(priv, mmc, cmd, data);
+}
+
+static int esdhc_set_ios(struct mmc *mmc)
+{
+	struct fsl_esdhc_priv *priv = mmc->priv;
+
+	return esdhc_set_ios_common(priv, mmc);
+}
+
+static const struct mmc_ops esdhc_ops = {
+	.getcd		= esdhc_getcd,
+	.init		= esdhc_init,
+	.send_cmd	= esdhc_send_cmd,
+	.set_ios	= esdhc_set_ios,
+};
+
+static int fsl_esdhc_cfg_to_priv(struct fsl_esdhc_cfg *cfg,
+				 struct fsl_esdhc_priv *priv)
+{
+	if (!cfg || !priv)
+		return -EINVAL;
+
+	priv->esdhc_regs = (struct fsl_esdhc *)(unsigned long)(cfg->esdhc_base);
+	priv->bus_width = cfg->max_bus_width;
+	priv->sdhc_clk = cfg->sdhc_clk;
+	priv->wp_enable  = cfg->wp_enable;
+
+	return 0;
+};
+
+/* eSDHC initialization requiring cfg */
+int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
+{
+	struct fsl_esdhc_plat *plat;
+	struct fsl_esdhc_priv *priv;
+	struct mmc *mmc;
+	int ret;
+
+	if (!cfg)
+		return -EINVAL;
+
+	priv = calloc(sizeof(struct fsl_esdhc_priv), 1);
+	if (!priv)
+		return -ENOMEM;
+	plat = calloc(sizeof(struct fsl_esdhc_plat), 1);
+	if (!plat) {
+		free(priv);
+		return -ENOMEM;
+	}
+
+	ret = fsl_esdhc_cfg_to_priv(cfg, priv);
+	if (ret) {
+		debug("%s xlate failure\n", __func__);
+		free(plat);
+		free(priv);
+		return ret;
+	}
+
+	ret = fsl_esdhc_init(priv, plat);
+	if (ret) {
+		debug("%s init failure\n", __func__);
+		free(plat);
+		free(priv);
+		return ret;
+	}
+
+	mmc = mmc_create(&plat->cfg, priv);
+	if (!mmc)
+		return -EIO;
+
+	priv->mmc = mmc;
+
+	return 0;
+}
+
+/* eSDHC complete initialization */
+int fsl_esdhc_mmc_init(bd_t *bis)
+{
+	struct fsl_esdhc_cfg *cfg;
+
+	cfg = calloc(sizeof(struct fsl_esdhc_cfg), 1);
+	cfg->esdhc_base = CONFIG_SYS_FSL_ESDHC_ADDR;
+	cfg->sdhc_clk = gd->arch.sdhc_clk;
+	return fsl_esdhc_initialize(bis, cfg);
+}
+
+#else /* DM_MMC */
+
 #ifndef CONFIG_PPC
 #include <asm/arch/clock.h>
 #endif
@@ -1068,13 +1070,13 @@ static int fsl_esdhc_bind(struct udevice *dev)
 }
 
 U_BOOT_DRIVER(fsl_esdhc) = {
-	.name	= "fsl-esdhc-mmc",
-	.id	= UCLASS_MMC,
-	.of_match = fsl_esdhc_ids,
-	.ops	= &fsl_esdhc_ops,
-	.bind	= fsl_esdhc_bind,
-	.probe	= fsl_esdhc_probe,
-	.platdata_auto_alloc_size = sizeof(struct fsl_esdhc_plat),
-	.priv_auto_alloc_size = sizeof(struct fsl_esdhc_priv),
+	.name		= "fsl-esdhc-mmc",
+	.id		= UCLASS_MMC,
+	.of_match	= fsl_esdhc_ids,
+	.ops		= &fsl_esdhc_ops,
+	.bind		= fsl_esdhc_bind,
+	.probe		= fsl_esdhc_probe,
+	.platdata_auto_alloc_size	= sizeof(struct fsl_esdhc_plat),
+	.priv_auto_alloc_size		= sizeof(struct fsl_esdhc_priv),
 };
 #endif
include/fsl_esdhc.h +93 -110

238 lines not on this page · raw message

Signature · 1 line
2.7.4
#3 lore raw

PATCH 2/3 mmc: fsl_esdhc: clean up code

Quoted 7 lines · On Mon, 19 Aug 2019 16:27:49 +0800 Yangbo Lu <[email protected]> wrote:

/* Return the XFERTYP flags for a given command and data packet */

(quoted diff) +1 -1
-static uint esdhc_xfertyp(struct mmc_cmd *cmd, struct mmc_data *data)
+static uint esdhc_setup_xfertyp(struct mmc_cmd *cmd, struct mmc_data

*data) {

drivers/mmc/fsl_esdhc.c +0 -0
 	uint xfertyp = 0;

drivers/mmc/fsl_esdhc.c static int esdhc_setup_data(struct fsl_esdhc_priv · line 314

Quoted 8 lines
drivers/mmc/fsl_esdhc.c +2 -3
@@ -310,9 +310,9 @@ static int esdhc_setup_data(struct fsl_esdhc_priv
 *priv, struct mmc *mmc, return 0;
 }
 
-static void check_and_invalidate_dcache_range
-	(struct mmc_cmd *cmd,
-	 struct mmc_data *data) {
+static void esdhc_invalidate_dcache_range(struct mmc_cmd *cmd,
+					  struct mmc_data *data)

^^^^ - it shall be aligned with the (

Could you double check this patch set with ./tools/checkpatch.py if it is clean?

(You can also test tools/patman - which does automatic checkpatch check)

Review static int esdhc_setup_data(struct fsl_esdhc_priv · line 315

Quoted 1 line
(quoted diff) +1 -0
+{

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190823/5ec66c0b/attachment.sig>

author
#4 lore raw

PATCH 2/3 mmc: fsl_esdhc: clean up code

Hi Lukasz,

Sorry for my late response. Please see my comments inline.

Quoted 20 lines

-----Original Message-----
From: Lukasz Majewski <[email protected]>
Sent: Friday, August 23, 2019 4:45 PM
To: Y.b. Lu <[email protected]>
Cc: u-boot at lists.denx.de; Peng Fan <[email protected]>
Subject: Re: [U-Boot] [PATCH 2/3] mmc: fsl_esdhc: clean up code

Quoted 10 lines · On Mon, 19 Aug 2019 16:27:49 +0800 Yangbo Lu <[email protected]> wrote:

/* Return the XFERTYP flags for a given command and data packet */

(quoted diff) +1 -1
-static uint esdhc_xfertyp(struct mmc_cmd *cmd, struct mmc_data *data)
+static uint esdhc_setup_xfertyp(struct mmc_cmd *cmd, struct mmc_data

*data) {

drivers/mmc/fsl_esdhc.c +0 -0
 	uint xfertyp = 0;
@@ -310,9 +310,9 @@ static int esdhc_setup_data(struct fsl_esdhc_priv
 *priv, struct mmc *mmc, return 0;
 }
 
Quoted 7 lines

drivers/mmc/fsl_esdhc.c static int esdhc_setup_data(struct fsl_esdhc_priv *priv, struct mmc *mmc, · line 314

Quoted 5 lines
drivers/mmc/fsl_esdhc.c +2 -3
-static void check_and_invalidate_dcache_range
-	(struct mmc_cmd *cmd,
-	 struct mmc_data *data) {
+static void esdhc_invalidate_dcache_range(struct mmc_cmd *cmd,
+					  struct mmc_data *data)

^^^^ - it shall be aligned with the (

[Y.b. Lu] Although it's not aligned with the ( in email, it's aligned after applying the patch. I believe there is no issue, and the checkpatch passed before I sent out the patches.

Thanks.

Quoted 20 lines

Could you double check this patch set with ./tools/checkpatch.py if it is clean?

(You can also test tools/patman - which does automatic checkpatch check)

Review static int esdhc_setup_data(struct fsl_esdhc_priv · line 315

Quoted 1 line
(quoted diff) +1 -0
+{

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.de

author
#5 lore raw

PATCH 3/3 mmc: fsl_esdhc: rename fsl_esdhc_init to fsl_esdhc_get_cfg

In reply to Yangbo Lu

For non-DM code, below functions had similar names.
- fsl_esdhc_initialize
- fsl_esdhc_mmc_init
- fsl_esdhc_init

However fsl_esdhc_init was mainly used to get cfg. So rename it to fsl_esdhc_get_cfg. Fix up bus-width capability handling, and drop controller initialization because it will be re-initialized in later esdhc_init_common for DM or esdhc_init for non-DM when use it.

---
 drivers/mmc/fsl_esdhc.c | 68 ++++++++-----------------------------------------
 1 file changed, 11 insertions(+), 57 deletions(-)
drivers/mmc/fsl_esdhc.c +11 -57
index d176bb3..bdf5b14 100644
@@ -25,14 +25,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define ESDHC_IRQ_EN_BITS	(IRQSTATEN_CC | IRQSTATEN_TC | \
-				IRQSTATEN_DINT | IRQSTATEN_BWR | \
-				IRQSTATEN_BRR | IRQSTATEN_CINT | \
-				IRQSTATEN_CTOE | IRQSTATEN_CCE | \
-				IRQSTATEN_CEBE | IRQSTATEN_CIE | \
-				IRQSTATEN_DTOE | IRQSTATEN_DCE | \
-				IRQSTATEN_DEBE)
-
 struct fsl_esdhc {
 	uint    dsaddr;		/* SDMA system address register */
 	uint    blkattr;	/* Block attributes register */
@@ -651,55 +643,23 @@ static int esdhc_getcd_common(struct fsl_esdhc_priv *priv)
 	return timeout > 0;
 }
 
-static int esdhc_reset(struct fsl_esdhc *regs)
-{
-	ulong start;
-
-	/* reset the controller */
-	esdhc_setbits32(&regs->sysctl, SYSCTL_RSTA);
-
-	/* hardware clears the bit when it is done */
-	start = get_timer(0);
-	while ((esdhc_read32(&regs->sysctl) & SYSCTL_RSTA)) {
-		if (get_timer(start) > 100) {
-			printf("MMC/SD: Reset never completed.\n");
-			return -ETIMEDOUT;
-		}
-	}
-
-	return 0;
-}
-
 static const struct mmc_ops esdhc_ops;
 
-static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
-			  struct fsl_esdhc_plat *plat)
+static int fsl_esdhc_get_cfg(struct fsl_esdhc_priv *priv,
+			     struct fsl_esdhc_plat *plat)
 {
+	struct fsl_esdhc *regs = priv->esdhc_regs;
+	u32 caps, voltage_caps = 0;
 	struct mmc_config *cfg;
-	struct fsl_esdhc *regs;
-	u32 caps, voltage_caps;
-	int ret;
 
 	if (!priv)
 		return -EINVAL;
 
-	regs = priv->esdhc_regs;
-
-	/* First reset the eSDHC controller */
-	ret = esdhc_reset(regs);
-	if (ret)
-		return ret;
-
-	esdhc_setbits32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_HCKEN |
-				       SYSCTL_IPGEN | SYSCTL_CKEN);
-
-	writel(ESDHC_IRQ_EN_BITS, &regs->irqstaten);
 	cfg = &plat->cfg;
 #ifndef CONFIG_DM_MMC
 	memset(cfg, '\0', sizeof(*cfg));
 #endif
 
-	voltage_caps = 0;
 	caps = esdhc_read32(&regs->hostcapblt);
 
 #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC135
@@ -737,18 +697,10 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
 	else if (priv->bus_width == 4)
 		cfg->host_caps = MMC_MODE_4BIT;
 
-	cfg->host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT;
 #ifdef CONFIG_SYS_FSL_ESDHC_HAS_DDR_MODE
 	cfg->host_caps |= MMC_MODE_DDR_52MHz;
 #endif
 
-	if (priv->bus_width > 0) {
-		if (priv->bus_width < 8)
-			cfg->host_caps &= ~MMC_MODE_8BIT;
-		if (priv->bus_width < 4)
-			cfg->host_caps &= ~MMC_MODE_4BIT;
-	}
-
 	if (caps & HOSTCAPBLT2_HSS)
 		cfg->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
 
@@ -759,7 +711,6 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
 
 	cfg->f_min = 400000;
 	cfg->f_max = min(priv->sdhc_clk, (u32)200000000);
-
 	cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
 
 	return 0;
@@ -882,7 +833,10 @@ static int fsl_esdhc_cfg_to_priv(struct fsl_esdhc_cfg *cfg,
 		return -EINVAL;
 
 	priv->esdhc_regs = (struct fsl_esdhc *)(unsigned long)(cfg->esdhc_base);
-	priv->bus_width = cfg->max_bus_width;
+	if (cfg->max_bus_width)
+		priv->bus_width = cfg->max_bus_width;
+	else
+		priv->bus_width = 4;
 	priv->sdhc_clk = cfg->sdhc_clk;
 	priv->wp_enable  = cfg->wp_enable;
 
@@ -917,7 +871,7 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
 		return ret;
 	}
 
-	ret = fsl_esdhc_init(priv, plat);
+	ret = fsl_esdhc_get_cfg(priv, plat);
 	if (ret) {
 		debug("%s init failure\n", __func__);
 		free(plat);
@@ -1012,9 +966,9 @@ static int fsl_esdhc_probe(struct udevice *dev)
 		}
 	}
 
-	ret = fsl_esdhc_init(priv, plat);
+	ret = fsl_esdhc_get_cfg(priv, plat);
 	if (ret) {
-		dev_err(dev, "fsl_esdhc_init failure\n");
+		dev_err(dev, "fsl_esdhc_get_cfg failure\n");
 		return ret;
 	}
 
Signature · 1 line
2.7.4
author
#6 lore raw

cover mmc: fsl_esdhc: clean up code

In reply to Yangbo Lu

Any comments?
Thanks:)

Quoted 20 lines

-----Original Message-----
From: Yangbo Lu <[email protected]>
Sent: Monday, August 19, 2019 4:28 PM
To: u-boot at lists.denx.de; Peng Fan <[email protected]>
Cc: Y.b. Lu <[email protected]>
Subject: [PATCH 0/3] mmc: fsl_esdhc: clean up code

This patch-set is to clean up fsl_esdhc code.

Yangbo Lu (3):
mmc: fsl_esdhc: make BLK as hard requirement of DM_MMC
mmc: fsl_esdhc: clean up code
mmc: fsl_esdhc: rename fsl_esdhc_init to fsl_esdhc_get_cfg

 drivers/mmc/fsl_esdhc.c | 371 +++++++++++++++++++-----------------------------
 include/fsl_esdhc.h     | 203 ++++++++++++--------------
 2 files changed, 240 insertions(+), 334 deletions(-)

--
2.7.4

#7 lore raw

cover mmc: fsl_esdhc: clean up code

Quoted 3 lines

Subject: RE: [PATCH 0/3] mmc: fsl_esdhc: clean up code

Any comments?

I'll pick up.

Regards,
Peng.

Quoted 23 lines

Thanks:)

Quoted 7 lines

-----Original Message-----
From: Yangbo Lu <[email protected]>
Sent: Monday, August 19, 2019 4:28 PM
To: u-boot at lists.denx.de; Peng Fan <[email protected]>
Cc: Y.b. Lu <[email protected]>
Subject: [PATCH 0/3] mmc: fsl_esdhc: clean up code

Quoted 8 lines

This patch-set is to clean up fsl_esdhc code.

Yangbo Lu (3):
mmc: fsl_esdhc: make BLK as hard requirement of DM_MMC
mmc: fsl_esdhc: clean up code
mmc: fsl_esdhc: rename fsl_esdhc_init to fsl_esdhc_get_cfg

 drivers/mmc/fsl_esdhc.c | 371

+++++++++++++++++++-----------------------------

Quoted 5 lines
 include/fsl_esdhc.h     | 203 ++++++++++++--------------
 2 files changed, 240 insertions(+), 334 deletions(-)

--
2.7.4

#8 lore raw

cover mmc: fsl_esdhc: clean up code

In reply to Y.b. Lu
Quoted 3 lines

Subject: RE: [PATCH 0/3] mmc: fsl_esdhc: clean up code

Any comments?

Patchset break build https://travis-ci.org/MrVan/u-boot/jobs/581073165

Please take a look.

Regards,
Peng.

Quoted 23 lines

Thanks:)

Quoted 7 lines

-----Original Message-----
From: Yangbo Lu <[email protected]>
Sent: Monday, August 19, 2019 4:28 PM
To: u-boot at lists.denx.de; Peng Fan <[email protected]>
Cc: Y.b. Lu <[email protected]>
Subject: [PATCH 0/3] mmc: fsl_esdhc: clean up code

Quoted 8 lines

This patch-set is to clean up fsl_esdhc code.

Yangbo Lu (3):
mmc: fsl_esdhc: make BLK as hard requirement of DM_MMC
mmc: fsl_esdhc: clean up code
mmc: fsl_esdhc: rename fsl_esdhc_init to fsl_esdhc_get_cfg

 drivers/mmc/fsl_esdhc.c | 371

+++++++++++++++++++-----------------------------

Quoted 5 lines
 include/fsl_esdhc.h     | 203 ++++++++++++--------------
 2 files changed, 240 insertions(+), 334 deletions(-)

--
2.7.4

author
#9 lore raw

cover mmc: fsl_esdhc: clean up code

Hi Peng,

Quoted 6 lines

-----Original Message-----
From: Peng Fan
Sent: Friday, September 6, 2019 10:12 AM
To: Y.b. Lu <[email protected]>; u-boot at lists.denx.de
Subject: RE: [PATCH 0/3] mmc: fsl_esdhc: clean up code

Quoted 7 lines
Quoted 3 lines

Subject: RE: [PATCH 0/3] mmc: fsl_esdhc: clean up code

Any comments?

Patchset break build https://travis-ci.org/MrVan/u-boot/jobs/581073165

Please take a look.

[Y.b. Lu] Sorry. I hadn't seen this issue with my toolchain. I have reproduced with buildman. Let me send out v2 patch-set. The esdhc_ops declaration should be involved in non-DM conditional build.

Thanks.

Quoted 27 lines

Regards,
Peng.

Quoted 23 lines

Thanks:)

Quoted 7 lines

-----Original Message-----
From: Yangbo Lu <[email protected]>
Sent: Monday, August 19, 2019 4:28 PM
To: u-boot at lists.denx.de; Peng Fan <[email protected]>
Cc: Y.b. Lu <[email protected]>
Subject: [PATCH 0/3] mmc: fsl_esdhc: clean up code

Quoted 8 lines

This patch-set is to clean up fsl_esdhc code.

Yangbo Lu (3):
mmc: fsl_esdhc: make BLK as hard requirement of DM_MMC
mmc: fsl_esdhc: clean up code
mmc: fsl_esdhc: rename fsl_esdhc_init to fsl_esdhc_get_cfg

 drivers/mmc/fsl_esdhc.c | 371

+++++++++++++++++++-----------------------------

Quoted 5 lines
 include/fsl_esdhc.h     | 203 ++++++++++++--------------
 2 files changed, 240 insertions(+), 334 deletions(-)

--
2.7.4