From: Adrian Hunter <adrian.hunter@intel.com>
To: "Benoît Thébaudeau" <benoit@wsystem.com>,
linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org
Cc: "Ulf Hansson" <ulf.hansson@linaro.org>,
"Fabio Estevam" <fabio.estevam@nxp.com>,
joancarles <joancarles@fqingenieria.es>,
"Eric Bénard" <eric@eukrea.com>,
"Wolfram Sang" <wsa@the-dreams.de>
Subject: Re: [PATCH 2/4] mmc: sdhci-esdhc-imx: Fix DAT line software reset
Date: Mon, 29 May 2017 11:02:46 +0300 [thread overview]
Message-ID: <e50b673d-e04a-24f9-6790-95803799c1fe@intel.com> (raw)
In-Reply-To: <1493805925-3644-2-git-send-email-benoit@wsystem.com>
On 03/05/17 13:05, Benoît Thébaudeau wrote:
> On i.MX25, the eSDHC DAT line software reset (SYSCTL.RSTD) unexpectedly
> clears at least the data transfer width (PROCTL.DTW), which then results
> in data CRC errors. This behavior is not documented, but it has actually
> been observed. Consequently, the DAT line software resets triggered by
> sdhci.c in case of errors caused unrecoverable errors.
>
> Fix this by making sure that the DAT line software reset does not alter
> the Host Control register. This behavior being undocumented, it may also
> be present on other i.MX SoCs, so apply this fix for the whole i.MX
> family.
>
> Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
I would expect to see Acks from other sdhci-esdhc-imx users. Nevertheless,
for sdhci:
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> drivers/mmc/host/sdhci-esdhc-imx.c | 59 ++++++++++++++++++++++++--------------
> 1 file changed, 38 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 23d8b8a..4ee82e1 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -579,7 +579,7 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
> {
> struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
> - u32 new_val;
> + u32 new_val = 0;
> u32 mask;
>
> switch (reg) {
> @@ -610,29 +610,46 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
>
> esdhc_clrset_le(host, mask, new_val, reg);
> return;
> + case SDHCI_SOFTWARE_RESET:
> + if (val & SDHCI_RESET_DATA)
> + new_val = readl(host->ioaddr + SDHCI_HOST_CONTROL);
> + break;
> }
> esdhc_clrset_le(host, 0xff, val, reg);
>
> - /*
> - * The esdhc has a design violation to SDHC spec which tells
> - * that software reset should not affect card detection circuit.
> - * But esdhc clears its SYSCTL register bits [0..2] during the
> - * software reset. This will stop those clocks that card detection
> - * circuit relies on. To work around it, we turn the clocks on back
> - * to keep card detection circuit functional.
> - */
> - if ((reg == SDHCI_SOFTWARE_RESET) && (val & 1)) {
> - esdhc_clrset_le(host, 0x7, 0x7, ESDHC_SYSTEM_CONTROL);
> - /*
> - * The reset on usdhc fails to clear MIX_CTRL register.
> - * Do it manually here.
> - */
> - if (esdhc_is_usdhc(imx_data)) {
> - /* the tuning bits should be kept during reset */
> - new_val = readl(host->ioaddr + ESDHC_MIX_CTRL);
> - writel(new_val & ESDHC_MIX_CTRL_TUNING_MASK,
> - host->ioaddr + ESDHC_MIX_CTRL);
> - imx_data->is_ddr = 0;
> + if (reg == SDHCI_SOFTWARE_RESET) {
> + if (val & SDHCI_RESET_ALL) {
> + /*
> + * The esdhc has a design violation to SDHC spec which
> + * tells that software reset should not affect card
> + * detection circuit. But esdhc clears its SYSCTL
> + * register bits [0..2] during the software reset. This
> + * will stop those clocks that card detection circuit
> + * relies on. To work around it, we turn the clocks on
> + * back to keep card detection circuit functional.
> + */
> + esdhc_clrset_le(host, 0x7, 0x7, ESDHC_SYSTEM_CONTROL);
> + /*
> + * The reset on usdhc fails to clear MIX_CTRL register.
> + * Do it manually here.
> + */
> + if (esdhc_is_usdhc(imx_data)) {
> + /*
> + * the tuning bits should be kept during reset
> + */
> + new_val = readl(host->ioaddr + ESDHC_MIX_CTRL);
> + writel(new_val & ESDHC_MIX_CTRL_TUNING_MASK,
> + host->ioaddr + ESDHC_MIX_CTRL);
> + imx_data->is_ddr = 0;
> + }
> + } else if (val & SDHCI_RESET_DATA) {
> + /*
> + * The eSDHC DAT line software reset clears at least the
> + * data transfer width on i.MX25, so make sure that the
> + * Host Control register is unaffected.
> + */
> + esdhc_clrset_le(host, 0xff, new_val,
> + SDHCI_HOST_CONTROL);
> }
> }
> }
>
next prev parent reply other threads:[~2017-05-29 8:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-03 10:05 [PATCH 1/4] mmc: sdhci-esdhc: Add SDHCI_QUIRK_32BIT_DMA_ADDR Benoît Thébaudeau
2017-05-03 10:05 ` [PATCH 2/4] mmc: sdhci-esdhc-imx: Fix DAT line software reset Benoît Thébaudeau
2017-05-29 8:02 ` Adrian Hunter [this message]
2017-05-29 11:13 ` Fabio Estevam
2017-05-03 10:05 ` [PATCH 3/4] mmc: sdhci-esdhc-imx: Allow all supported prescaler values Benoît Thébaudeau
2017-05-29 8:03 ` Adrian Hunter
2017-05-29 11:14 ` Fabio Estevam
2017-05-03 10:05 ` [PATCH 4/4] mmc: sdhci-esdhc-imx: Remove the ENGcm07207 workaround Benoît Thébaudeau
2017-05-29 8:07 ` Adrian Hunter
2017-05-29 14:42 ` Ulf Hansson
2017-05-29 16:39 ` Benoît Thébaudeau
2017-05-29 11:14 ` Fabio Estevam
2017-05-04 8:47 ` [PATCH 1/4] mmc: sdhci-esdhc: Add SDHCI_QUIRK_32BIT_DMA_ADDR Arnd Bergmann
2017-05-04 9:00 ` Benoît Thébaudeau
2017-05-04 9:37 ` Arnd Bergmann
2017-05-29 8:02 ` Adrian Hunter
2017-05-29 11:12 ` Fabio Estevam
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=e50b673d-e04a-24f9-6790-95803799c1fe@intel.com \
--to=adrian.hunter@intel.com \
--cc=benoit@wsystem.com \
--cc=eric@eukrea.com \
--cc=fabio.estevam@nxp.com \
--cc=joancarles@fqingenieria.es \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=wsa@the-dreams.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