Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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")
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Link: https://lore.kernel.org/r/20200527105659.142560-1-eugen.hristev@microchip.com
Cc: stable@vger.kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Eugen Hristev and committed by
Ulf Hansson
dbdea70f 16e40e5b

+5 -2
+5 -2
drivers/mmc/host/sdhci-of-at91.c
··· 121 121 || mmc_gpio_get_cd(host->mmc) >= 0) 122 122 sdhci_at91_set_force_card_detect(host); 123 123 124 - if (priv->cal_always_on && (mask & SDHCI_RESET_ALL)) 125 - sdhci_writel(host, SDMMC_CALCR_ALWYSON | SDMMC_CALCR_EN, 124 + if (priv->cal_always_on && (mask & SDHCI_RESET_ALL)) { 125 + u32 calcr = sdhci_readl(host, SDMMC_CALCR); 126 + 127 + sdhci_writel(host, calcr | SDMMC_CALCR_ALWYSON | SDMMC_CALCR_EN, 126 128 SDMMC_CALCR); 129 + } 127 130 } 128 131 129 132 static const struct sdhci_ops sdhci_at91_sama5d2_ops = {