Skip to contentSkip to conversation

mmc: sdhci-of-at91: fix CALCR register being rewritten

PATCH In review Eugen Hristev 2 participants 2 messages May 27, 2020 – May 28, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci-of-at91: fix CALCR register being rewritten

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")
---
 drivers/mmc/host/sdhci-of-at91.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-of-at91.c +5 -2
index 25f4e0f4f53b..1ece2c50042c 100644
@@ -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 = {
Signature · 1 line
2.25.1
#1 lore raw
Quoted 7 lines · 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")

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

Kind regards
Uffe

Quoted 26 lines
---
 drivers/mmc/host/sdhci-of-at91.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-of-at91.c +5 -3
index 25f4e0f4f53b..1ece2c50042c 100644
@@ -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