linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-of-at91: fix CALCR register being rewritten
@ 2020-05-27 10:56 Eugen Hristev
  2020-05-28 10:14 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Eugen Hristev @ 2020-05-27 10:56 UTC (permalink / raw)
  To: ludovic.desroches, linux-mmc, adrian.hunter, ulf.hansson
  Cc: linux-arm-kernel, linux-kernel, Eugen Hristev

When enabling calibration at reset, the CALCR register was completely
rewritten. This may cause certain bits being deleted unintentedly.
Fix by issuing a read-modify-write operation.

Fixes: 727d836a375a ("mmc: sdhci-of-at91: add DT property to enable calibration on full reset")
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
 drivers/mmc/host/sdhci-of-at91.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
index 25f4e0f4f53b..1ece2c50042c 100644
--- a/drivers/mmc/host/sdhci-of-at91.c
+++ b/drivers/mmc/host/sdhci-of-at91.c
@@ -121,9 +121,12 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
 	    || mmc_gpio_get_cd(host->mmc) >= 0)
 		sdhci_at91_set_force_card_detect(host);
 
-	if (priv->cal_always_on && (mask & SDHCI_RESET_ALL))
-		sdhci_writel(host, SDMMC_CALCR_ALWYSON | SDMMC_CALCR_EN,
+	if (priv->cal_always_on && (mask & SDHCI_RESET_ALL)) {
+		u32 calcr = sdhci_readl(host, SDMMC_CALCR);
+
+		sdhci_writel(host, calcr | SDMMC_CALCR_ALWYSON | SDMMC_CALCR_EN,
 			     SDMMC_CALCR);
+	}
 }
 
 static const struct sdhci_ops sdhci_at91_sama5d2_ops = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mmc: sdhci-of-at91: fix CALCR register being rewritten
  2020-05-27 10:56 [PATCH] mmc: sdhci-of-at91: fix CALCR register being rewritten Eugen Hristev
@ 2020-05-28 10:14 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2020-05-28 10:14 UTC (permalink / raw)
  To: Eugen Hristev
  Cc: Ludovic Desroches, linux-mmc, Adrian Hunter, Linux ARM,
	Linux Kernel Mailing List

On Wed, 27 May 2020 at 12:57, Eugen Hristev <eugen.hristev@microchip.com> wrote:
>
> When enabling calibration at reset, the CALCR register was completely
> rewritten. This may cause certain bits being deleted unintentedly.
> Fix by issuing a read-modify-write operation.
>
> Fixes: 727d836a375a ("mmc: sdhci-of-at91: add DT property to enable calibration on full reset")
> Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>

Applied for next and by adding a stable tag, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/sdhci-of-at91.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
> index 25f4e0f4f53b..1ece2c50042c 100644
> --- a/drivers/mmc/host/sdhci-of-at91.c
> +++ b/drivers/mmc/host/sdhci-of-at91.c
> @@ -121,9 +121,12 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
>             || mmc_gpio_get_cd(host->mmc) >= 0)
>                 sdhci_at91_set_force_card_detect(host);
>
> -       if (priv->cal_always_on && (mask & SDHCI_RESET_ALL))
> -               sdhci_writel(host, SDMMC_CALCR_ALWYSON | SDMMC_CALCR_EN,
> +       if (priv->cal_always_on && (mask & SDHCI_RESET_ALL)) {
> +               u32 calcr = sdhci_readl(host, SDMMC_CALCR);
> +
> +               sdhci_writel(host, calcr | SDMMC_CALCR_ALWYSON | SDMMC_CALCR_EN,
>                              SDMMC_CALCR);
> +       }
>  }
>
>  static const struct sdhci_ops sdhci_at91_sama5d2_ops = {
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-28 10:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 10:56 [PATCH] mmc: sdhci-of-at91: fix CALCR register being rewritten Eugen Hristev
2020-05-28 10:14 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).