public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Adam Ford <aford173@gmail.com>
To: u-boot@lists.denx.de
Cc: peng.fan@nxp.com, haibo.chen@nxp.com,
	andrey.zhizhikin@leica-geosystems.com, tharvey@gateworks.com,
	estevam@gmail.com, sbabic@denx.de, aford@beaconembedded.com,
	Adam Ford <aford173@gmail.com>
Subject: [PATCH 1/2] mmc: fsl_esdhc_imx: Fix fsl_esdhc_wait_dat0
Date: Wed, 12 Jan 2022 07:53:55 -0600	[thread overview]
Message-ID: <20220112135356.322069-2-aford173@gmail.com> (raw)
In-Reply-To: <20220112135356.322069-1-aford173@gmail.com>

According to Haibo Chen [1] - the current implementation mmc_wait_dat0,
the second mmc_wait_dat0() in mmc_switch_voltage() always return timeout.
This causes UHS cards to not properly initialize to their highest rate,
and default back for high-speed mode.

When reviewing [1] and comparing it to the linux driver, it appears
that this function can be accomplished by turning off the clock,
and waiting for the clock-standby bit to become active.

[1] - https://lists.denx.de/pipermail/u-boot/2021-January/438644.html

Reported-by: Tim Harvey <tharvey@gateworks.com>
Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 4c06361bee..e5814232a2 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -1684,9 +1684,15 @@ static int fsl_esdhc_wait_dat0(struct udevice *dev, int state,
 	struct fsl_esdhc_priv *priv = dev_get_priv(dev);
 	struct fsl_esdhc *regs = priv->esdhc_regs;
 
+	/*
+	 * Clear the clock-enable and wait for the bit indicating it
+	 * is in standby.
+	 */
+	esdhc_clrbits32(&regs->vendorspec, VENDORSPEC_CKEN);
 	ret = readx_poll_timeout(esdhc_read32, &regs->prsstat, tmp,
-				!!(tmp & PRSSTAT_DAT0) == !!state,
+				(tmp & PRSSTAT_SDSTB),
 				timeout_us);
+
 	return ret;
 }
 
-- 
2.32.0


  reply	other threads:[~2022-01-12 13:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12 13:53 [PATCH 0/2] mmc: fsl_esdhc_imx: Auto-detect higher speeds Adam Ford
2022-01-12 13:53 ` Adam Ford [this message]
2022-01-14  3:18   ` [PATCH 1/2] mmc: fsl_esdhc_imx: Fix fsl_esdhc_wait_dat0 Bough Chen
2022-02-19 13:08   ` sbabic
2022-02-19 13:27     ` Fabio Estevam
2022-02-19 13:43       ` Stefano Babic
2022-01-12 13:53 ` [PATCH 2/2] mmc: fsl_esdhc_imx: Use esdhc_soc_data flags to set host caps Adam Ford
2022-02-19 13:07   ` sbabic

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=20220112135356.322069-2-aford173@gmail.com \
    --to=aford173@gmail.com \
    --cc=aford@beaconembedded.com \
    --cc=andrey.zhizhikin@leica-geosystems.com \
    --cc=estevam@gmail.com \
    --cc=haibo.chen@nxp.com \
    --cc=peng.fan@nxp.com \
    --cc=sbabic@denx.de \
    --cc=tharvey@gateworks.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox