All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yangbo Lu <yangbo.lu@nxp.com>
To: u-boot@lists.denx.de
Subject: [PATCH 1/9] mmc: add a reinit() API
Date: Thu, 16 Jul 2020 10:29:46 +0800	[thread overview]
Message-ID: <20200716022954.36774-2-yangbo.lu@nxp.com> (raw)
In-Reply-To: <20200716022954.36774-1-yangbo.lu@nxp.com>

For DM_MMC, the controller re-initialization is needed to
clear old configuration for mmc rescan.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
 drivers/mmc/mmc-uclass.c | 15 +++++++++++++++
 drivers/mmc/mmc.c        |  8 ++++++--
 include/mmc.h            | 10 ++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index c5b7872..b9f0880 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -170,6 +170,21 @@ int mmc_deferred_probe(struct mmc *mmc)
 	return dm_mmc_deferred_probe(mmc->dev);
 }
 
+int dm_mmc_reinit(struct udevice *dev)
+{
+	struct dm_mmc_ops *ops = mmc_get_ops(dev);
+
+	if (ops->reinit)
+		return ops->reinit(dev);
+
+	return 0;
+}
+
+int mmc_reinit(struct mmc *mmc)
+{
+	return dm_mmc_reinit(mmc->dev);
+}
+
 int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg)
 {
 	int val;
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 50f47d4..a53f93a 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2813,13 +2813,17 @@ int mmc_get_op_cond(struct mmc *mmc)
 		return err;
 
 #if CONFIG_IS_ENABLED(DM_MMC)
-	/* The device has already been probed ready for use */
+	/*
+	 * Re-initialization is needed to clear old configuration for
+	 * mmc rescan.
+	 */
+	err = mmc_reinit(mmc);
 #else
 	/* made sure it's not NULL earlier */
 	err = mmc->cfg->ops->init(mmc);
+#endif
 	if (err)
 		return err;
-#endif
 	mmc->ddr_mode = 0;
 
 retry:
diff --git a/include/mmc.h b/include/mmc.h
index 8256219..161b8bc 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -422,6 +422,14 @@ struct dm_mmc_ops {
 	 */
 	int (*deferred_probe)(struct udevice *dev);
 	/**
+	 * reinit() - Re-initialization to clear old configuration for
+	 * mmc rescan.
+	 *
+	 * @dev:	Device to reinit
+	 * @return 0 if Ok, -ve if error
+	 */
+	int (*reinit)(struct udevice *dev);
+	/**
 	 * send_cmd() - Send a command to the MMC device
 	 *
 	 * @dev:	Device to receive the command
@@ -518,6 +526,7 @@ int dm_mmc_execute_tuning(struct udevice *dev, uint opcode);
 int dm_mmc_wait_dat0(struct udevice *dev, int state, int timeout_us);
 int dm_mmc_host_power_cycle(struct udevice *dev);
 int dm_mmc_deferred_probe(struct udevice *dev);
+int dm_mmc_reinit(struct udevice *dev);
 int dm_mmc_get_b_max(struct udevice *dev, void *dst, lbaint_t blkcnt);
 
 /* Transition functions for compatibility */
@@ -529,6 +538,7 @@ int mmc_wait_dat0(struct mmc *mmc, int state, int timeout_us);
 int mmc_set_enhanced_strobe(struct mmc *mmc);
 int mmc_host_power_cycle(struct mmc *mmc);
 int mmc_deferred_probe(struct mmc *mmc);
+int mmc_reinit(struct mmc *mmc);
 int mmc_get_b_max(struct mmc *mmc, void *dst, lbaint_t blkcnt);
 
 #else
-- 
2.7.4

  reply	other threads:[~2020-07-16  2:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200716023643epcas1p475c3faedb3936066fad28809057a79a8@epcas1p4.samsung.com>
2020-07-16  2:29 ` [PATCH 0/9] mmc: fsl_esdhc: support eMMC HS200/HS400 modes Yangbo Lu
2020-07-16  2:29   ` Yangbo Lu [this message]
2020-07-16  2:29   ` [PATCH 2/9] mmc: fsl_esdhc: add a reinit() callback Yangbo Lu
2020-07-16  2:29   ` [PATCH 3/9] mmc: fsl_esdhc: support tuning for eMMC HS200 Yangbo Lu
2020-07-16  2:29   ` [PATCH 4/9] mmc: fsl_esdhc: clean TBCTL[TB_EN] manually during init Yangbo Lu
2020-07-16  2:29   ` [PATCH 5/9] mmc: add a hs400_tuning flag Yangbo Lu
2020-07-16  2:29   ` [PATCH 6/9] mmc: add a mmc_hs400_prepare_ddr() interface Yangbo Lu
2020-07-16  2:29   ` [PATCH 7/9] mmc: fsl_esdhc: support eMMC HS400 mode Yangbo Lu
2020-07-16  2:29   ` [PATCH 8/9] arm: dts: lx2160ardb: " Yangbo Lu
2020-07-16  2:29   ` [PATCH 9/9] configs: lx2160ardb: enable eMMC HS400 mode support Yangbo Lu
2020-07-17  0:31   ` [PATCH 0/9] mmc: fsl_esdhc: support eMMC HS200/HS400 modes Jaehoon Chung
2020-07-17  8:48     ` Y.b. Lu
2020-07-18  1:21       ` Jaehoon Chung

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200716022954.36774-2-yangbo.lu@nxp.com \
    --to=yangbo.lu@nxp.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.