All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Masson <jmasson@baylibre.com>
To: u-boot@lists.denx.de
Cc: Jaehoon Chung <jh80.chung@samsung.com>,
	Peng Fan <peng.fan@nxp.com>,
	Chunfeng Yun <chunfeng.yun@mediatek.com>,
	Weijie Gao <weijie.gao@mediatek.com>,
	Ryder Lee <ryder.lee@mediatek.com>,
	GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>,
	Mattijs Korpershoek <mkorpershoek@baylibre.com>,
	Fabien Parent <fparent@baylibre.com>
Subject: [PATCH] mmc: mtk-sd: implement waiting for DAT0 line state
Date: Fri,  5 Nov 2021 14:34:14 +0100	[thread overview]
Message-ID: <87wnlm90ut.fsf@baylibre.com> (raw)

With the recent changes on mmc driver, we saw that the boot is ~5 secs
longer compared to v2021.07 on mediatek platforms.

This regression is seen during mmc_init and caused by the following
patch [1].

Indeed since we did not support poll dat0, we fulfilled the condition
of [1] and a delay of 500 ms was added for every __mmc_switch call.

By adding the support of wait_dat0(), we now don't need to mdelay
during mmc_init anymore.

[1]: https://patchwork.ozlabs.org/project/uboot/patch/1629192034-64056-1-git-send-email-ye.li@nxp.com/

Signed-off-by: Julien Masson <jmasson@baylibre.com>
---
 drivers/mmc/mtk-sd.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/mmc/mtk-sd.c b/drivers/mmc/mtk-sd.c
index 8599f095bc..97182ffd7f 100644
--- a/drivers/mmc/mtk-sd.c
+++ b/drivers/mmc/mtk-sd.c
@@ -1724,6 +1724,20 @@ static int msdc_drv_bind(struct udevice *dev)
 	return mmc_bind(dev, &plat->mmc, &plat->cfg);
 }
 
+static int msdc_ops_wait_dat0(struct udevice *dev, int state, int timeout_us)
+{
+	struct msdc_host *host = dev_get_priv(dev);
+	int ret;
+	u32 reg;
+
+	ret = readl_poll_sleep_timeout(&host->base->msdc_ps, reg,
+				       !!(reg & MSDC_PS_DAT0) == !!state,
+				       1000, /* 1 ms */
+				       timeout_us);
+
+	return ret;
+}
+
 static const struct dm_mmc_ops msdc_ops = {
 	.send_cmd = msdc_ops_send_cmd,
 	.set_ios = msdc_ops_set_ios,
@@ -1732,6 +1746,7 @@ static const struct dm_mmc_ops msdc_ops = {
 #ifdef MMC_SUPPORTS_TUNING
 	.execute_tuning = msdc_execute_tuning,
 #endif
+	.wait_dat0 = msdc_ops_wait_dat0,
 };
 
 static const struct msdc_compatible mt7620_compat = {
-- 
2.31.1


             reply	other threads:[~2021-11-05 13:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20211105134105epcas1p316549d76f459e83010b1cd77e207d5c2@epcas1p3.samsung.com>
2021-11-05 13:34 ` Julien Masson [this message]
2021-11-09  4:24   ` [PATCH] mmc: mtk-sd: implement waiting for DAT0 line state Jaehoon Chung
2021-11-18 19:16   ` Tom Rini

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=87wnlm90ut.fsf@baylibre.com \
    --to=jmasson@baylibre.com \
    --cc=GSS_MTK_Uboot_upstream@mediatek.com \
    --cc=chunfeng.yun@mediatek.com \
    --cc=fparent@baylibre.com \
    --cc=jh80.chung@samsung.com \
    --cc=mkorpershoek@baylibre.com \
    --cc=peng.fan@nxp.com \
    --cc=ryder.lee@mediatek.com \
    --cc=u-boot@lists.denx.de \
    --cc=weijie.gao@mediatek.com \
    /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.